Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: fix #43: add X_PI constant #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions python/eviltransform/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'distance', 'gcj2bd', 'bd2gcj', 'wgs2bd', 'bd2wgs']

earthR = 6378137.0
X_PI = math.pi * 3000 / 180

def outOfChina(lat, lng):
return not (72.004 <= lng <= 137.8347 and 0.8293 <= lat <= 55.8271)
Expand Down Expand Up @@ -116,8 +117,8 @@ def gcj2bd(gcjLat, gcjLng):

x = gcjLng
y = gcjLat
z = math.hypot(x, y) + 0.00002 * math.sin(y * math.pi)
theta = math.atan2(y, x) + 0.000003 * math.cos(x * math.pi)
z = math.hypot(x, y) + 0.00002 * math.sin(y * X_PI)
theta = math.atan2(y, x) + 0.000003 * math.cos(x * X_PI)
bdLng = z * math.cos(theta) + 0.0065
bdLat = z * math.sin(theta) + 0.006
return bdLat, bdLng
Expand All @@ -129,8 +130,8 @@ def bd2gcj(bdLat, bdLng):

x = bdLng - 0.0065
y = bdLat - 0.006
z = math.hypot(x, y) - 0.00002 * math.sin(y * math.pi)
theta = math.atan2(y, x) - 0.000003 * math.cos(x * math.pi)
z = math.hypot(x, y) - 0.00002 * math.sin(y * X_PI)
theta = math.atan2(y, x) - 0.000003 * math.cos(x * X_PI)
gcjLng = z * math.cos(theta)
gcjLat = z * math.sin(theta)
return gcjLat, gcjLng
Expand Down
6 changes: 3 additions & 3 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
setup(
name = 'eviltransform',
packages = [ 'eviltransform' ],
version = '0.1.0',
description = 'Transform coordinates between earth(WGS-84) and mars in china(GCJ-02).',
author = 'googollee, et. al',
version = '0.1.1',
description = 'Transform coordinates among GPS (WGS-84), Baidu (BD-02) and Mars in China (GCJ-02).',
author = 'googollee, et al.',
url = 'https://github.com/googollee/eviltransform',
keywords = [ 'gis' ]
)
Expand Down