{"id":21089418,"url":"https://github.com/io-sgr/geometry-common","last_synced_at":"2026-05-22T05:06:15.578Z","repository":{"id":57736195,"uuid":"89374765","full_name":"io-sgr/geometry-common","owner":"io-sgr","description":null,"archived":false,"fork":false,"pushed_at":"2019-08-02T03:03:01.000Z","size":145,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-21T00:50:24.207Z","etag":null,"topics":["gcj","gcj-02","gcj02","geometry","java","maven","wgs","wgs-84","wgs84"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/io-sgr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-25T15:09:06.000Z","updated_at":"2025-01-11T10:39:50.000Z","dependencies_parsed_at":"2022-08-23T22:40:40.489Z","dependency_job_id":null,"html_url":"https://github.com/io-sgr/geometry-common","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/io-sgr%2Fgeometry-common","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/io-sgr%2Fgeometry-common/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/io-sgr%2Fgeometry-common/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/io-sgr%2Fgeometry-common/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/io-sgr","download_url":"https://codeload.github.com/io-sgr/geometry-common/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243532564,"owners_count":20306157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gcj","gcj-02","gcj02","geometry","java","maven","wgs","wgs-84","wgs84"],"created_at":"2024-11-19T21:28:50.229Z","updated_at":"2026-05-22T05:06:15.540Z","avatar_url":"https://github.com/io-sgr.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Geometry Utilities\n[![Build Status](https://travis-ci.org/io-sgr/geometry-common.svg?branch=master)](https://travis-ci.org/io-sgr/geometry-common) [![codecov](https://codecov.io/gh/io-sgr/geometry-common/branch/master/graph/badge.svg)](https://codecov.io/gh/io-sgr/geometry-common)\n\nThis library is a simple JAVA / Android library that helps you transform coordinate between earth(WGS-84) and mars in China(GCJ-02).\n\n*Read this in other languages: [English](README.md), [简体中文](README.zh-cn.md).*\n\nGeometry Utilities requires at minimum Java 7 or Android 2.3.\n\n## Usage\nConvert coordinate from earth(WGS-84) to mars(GCJ-02):\n```java\nCoordinate mars = GeometryUtils.wgs2gcj(39.980945, 116.348120);\n```\nConvert coordinate from mars(GCJ-02) to earth(WGS-84):\n```java\nCoordinate earth = GeometryUtils.gcj2wgs(39.982296, 116.354308);\n```\n\n## Advanced\nTo convert coordinates from WGS to GCJ or other way back, you need to know if the coordinate is inside **China mainland** or not.\n\nCommon implementations use a **HUGE** box boundary which covers entire **China Mainland** and several regions like **Taiwan**, **Hong Kong** and **Macau** along with it to check the coordinate, which is not perfect.\n\nTo make sure you have the maximum accuracy and flexibility, Geometry Utilities provided two ways for you to achieve that goal:\n\n### Default Implementation\nBy default, [GeometryUtils](src/main/java/io/sgr/geometry/utils/GeometryUtils.java) uses a [DefaultCoordinateChecker](src/main/java/io/sgr/geometry/utils/DefaultCoordinateChecker.java) to perform the check.\n\nThe **DefaultCoordinateChecker** also uses a box boundary like other implementations but with **Taiwan**, **Hong Kong** and **Macau** excluded, which can cover most of the cases.\n\nNo additional code changes needed.\n\n### Customized Implementation\nIf you are still not satisfied, you can write your own implementation very easily:\n```java\npublic class CustomizedCoordinateChecker implements CoordinateChecker {\n\t@Override\n\tpublic boolean isOutOfChinaMainland(double lat, double lng) {\n\t\t// Add your own logic here\n\t\treturn false;\n\t}\n}\nGeometryUtils.setCoordinateChecker(new CustomizedCoordinateChecker());\n```\nYou're all set!\n\n# License\n\n    Copyright 2017-2019 SgrAlpha\n   \n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n   \n       http://www.apache.org/licenses/LICENSE-2.0\n   \n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fio-sgr%2Fgeometry-common","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fio-sgr%2Fgeometry-common","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fio-sgr%2Fgeometry-common/lists"}