Coder Social home page Coder Social logo

ajmdfeipan / eviltransform Goto Github PK

View Code? Open in Web Editor NEW

This project forked from googollee/eviltransform

0.0 2.0 0.0 118 KB

做标准换 Transport coordinate between earth(WGS-84) and mars in china(GCJ-02).

License: Other

C 9.88% C# 10.81% Go 8.09% Haskell 7.59% Java 10.68% JavaScript 10.80% PHP 11.72% Python 8.59% Rust 8.13% Swift 13.70%

eviltransform's Introduction

Transform coordinate between earth(WGS-84) and mars in china(GCJ-02).

GCJ-02 coordiante is used by Google Maps, Autonavi Map and other china map service. (Baidu Map has an extra offset based on GCJ-02)

WGStoGCJ/wgs2gcj

func WGStoGCJ(wgsLat, wgsLng float64) (gcjLat, gcjLng float64) // Go/Golang
void wgs2gcj(double wgsLat, double wgsLng, double *gcjLat, double *gcjLng) // C/C++/Obj-C
eviltransform.wgs2gcj(wgsLat, wgsLng) // JavaScript/Python
\larryli\eviltransform\EvilTransform::WGStoGCJ($wgsLat, $wgsLng) // PHP5.4+
EvilTransform.Transform.WGS2GCJ(wgsLat, wgsLng) // CSharp
wgs2Gcj (gcjLat, gcjLng) // Haskell

Input WGS-84 coordinate(wgsLat, wgsLng) and convert to GCJ-02 coordinate(gcjLat, gcjLng). The output of JavaScript is like:

{"lat": xx.xxxx, "lng": yy.yyyy}

GCJtoWGS/gcj2wgs

func GCJtoWGS(gcjLat, gcjLng float64) (wgsLat, wgsLng float64) // Go/Golang
void gcj2wgs(double gcjLat, double gcjLng, double *wgsLat, double *wgsLnt) // C/C++/Obj-C
eviltransform.gcj2wgs(gcjLat, gcjLng) // JavaScript/Python
\larryli\eviltransform\EvilTransform::GCJtoWGS($gcjLat, $gcjLng) // PHP5.4+
EvilTransform.Transform.GCJ2WGS(gcjLat, gcjLng) //CSharp
gcj2Wgs (gcjLat, gcjLng) // Haskell

Input GCJ-02 coordinate(gcjLat, gcjLng) and convert to WGS-84 coordinate(wgsLat, wgsLng). The output of JavaScript is like:

{"lat": xx.xxxx, "lng": yy.yyyy}

The output WGS-84 coordinate's accuracy is 1m to 2m. If you want more exactly result, use GCJtoWGSExact/gcj2wgs_exact.

GCJtoWGSExact/gcj2wgs_exact

func GCJtoWGSExact(gcjLat, gcjLng float64) (wgsLat, wgsLng float64) // Go/Golang
void gcj2wgs_exact(double gcjLat, double gcjLng, double *wgsLat, double *wgsLnt) // C/C++/Obj-C
eviltransform.gcj2wgs_exact(gcjLat, gcjLng) // JavaScript/Python
\larryli\eviltransform\EvilTransform::GCJtoWGSExact($gcjLat, $gcjLng) // PHP5.4+
EvilTransform.Transform.GCJ2WGSExact(gcjLat, gcjLng) //CSharp
gcj2WgsExact (gcjLat, gcjLng) //Haskell

Input GCJ-02 coordinate(gcjLat, gcjLng) and convert to WGS-84 coordinate(wgsLat, wgsLng). The output of JavaScript is like:

{"lat": xx.xxxx, "lng": yy.yyyy}

The output WGS-84 coordinate's accuracy is less than 0.5m, but much slower than GCJtoWGS/gcj2wgs.

Distance/distance

func Distance(latA, lngA, latB, lngB float64) float64 // Go/Golang
double distance(double latA, double lngA, double latB, double lngB) // C/C++/Obj-C
eviltransform.distance(latA, lngA, latB, lngB) // JavaScript/Python
\larryli\eviltransform\EvilTransform::Distance($latA, $lngA, $latB, $lngB) // PHP5.4+
EvilTransform.Transform.Distance(latA, lngA, latB, lngB) //CSharp
distance (lat, lng)

Calculate the distance between point(latA, lngA) and point(latB, lngB), unit in meter.

Original from:

See also:


地球坐标(WGS-84)与火星坐标(GCJ-2)转换.

GCJ-02坐标用在谷歌地图,高德地图等**地图服务。(百度地图要在GCJ-02基础上再加转换)

WGStoGCJ/wgs2gcj

func WGStoGCJ(wgsLat, wgsLng float64) (gcjLat, gcjLng float64) // Go/Golang
void wgs2gcj(double wgsLat, double wgsLng, double *gcjLat, double *gcjLng) // C/C++/Obj-C
eviltransform.wgs2gcj(wgsLat, wgsLng) // JavaScript/Python
\larryli\eviltransform\EvilTransform::WGStoGCJ($wgsLat, $wgsLng) // PHP5.4+
EvilTransform.Transform.WGS2GCJ(wgsLat, wgsLng) // CSharp
wgs2Gcj (gcjLat, gcjLng) // Haskell

输入WGS-84地球坐标(wgsLat, wgsLng),转换为GCJ-02火星坐标(gcjLat, gcjLng)。JavaScript输出格式如下:

{"lat": xx.xxxx, "lng": yy.yyyy}

GCJtoWGS/gcj2wgs

func GCJtoWGS(gcjLat, gcjLng float64) (wgsLat, wgsLng float64) // Go/Golang
void gcj2wgs(double gcjLat, double gcjLng, double *wgsLat, double *wgsLnt) // C/C++/Obj-C
eviltransform.gcj2wgs(gcjLat, gcjLng) // JavaScript/Python
\larryli\eviltransform\EvilTransform::GCJtoWGS($gcjLat, $gcjLng) // PHP5.4+
EvilTransform.Transform.GCJ2WGS(gcjLat, gcjLng) //CSharp
gcj2Wgs (gcjLat, gcjLng) // Haskell

输入GCJ-02火星坐标(gcjLat, gcjLng),转换为WGS-84地球坐标(wgsLat, wgsLng)。JavaScript输出格式如下:

{"lat": xx.xxxx, "lng": yy.yyyy}

输出的WGS-84坐标精度为1米到2米之间。如果要更精确的结果,使用GCJtoWGSExact/gcj2wgs_exact。

GCJtoWGSExact/gcj2wgs_exact

func GCJtoWGSExact(gcjLat, gcjLng float64) (wgsLat, wgsLng float64) // Go/Golang
void gcj2wgs_exact(double gcjLat, double gcjLng, double *wgsLat, double *wgsLnt) // C/C++/Obj-C
eviltransform.gcj2wgs_exact(gcjLat, gcjLng) // JavaScript/Python
\larryli\eviltransform\EvilTransform::GCJtoWGSExact($gcjLat, $gcjLng) // PHP5.4+
EvilTransform.Transform.GCJ2WGSExact(gcjLat, gcjLng) //CSharp
gcj2WgsExact (gcjLat, gcjLng) //Haskell

输入GCJ-02火星坐标(gcjLat, gcjLng),转换为WGS-84地球坐标(wgsLat, wgsLng)。JavaScript 输出格式如下:

{"lat": xx.xxxx, "lng": yy.yyyy}

输出的WGS-84坐标精度为0.5米内,但是计算速度慢于GCJtoWGS/gcj2wgs。

Distance/distance

func Distance(latA, lngA, latB, lngB float64) float64 // Go/Golang
double distance(double latA, double lngA, double latB, double lngB) // C/C++/Obj-C
eviltransform.distance(latA, lngA, latB, lngB) // JavaScript/Python
\larryli\eviltransform\EvilTransform::Distance($latA, $lngA, $latB, $lngB) // PHP5.4+
EvilTransform.Transform.Distance(latA, lngA, latB, lngB) //CSharp
distance (lat, lng)

计算点(latA, lngA)和点(latB, lngB)之间的距离,单位为米。

算法来源:

参考:

eviltransform's People

Contributors

aokizen avatar artoria2e5 avatar bewantbe avatar chenweiyj avatar ghostflying avatar googollee avatar gumblex avatar gutenye avatar jeremypenner avatar josh-taylr avatar larryli avatar lbt05 avatar lennonshawn avatar xingxing avatar y-x-c avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.