PHPackages                             larryli/eviltransform - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. larryli/eviltransform

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

larryli/eviltransform
=====================

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

v2.0.1(9y ago)6102.3k↓38.3%3proprietaryPHPPHP &gt;=5.4

Since Apr 5Pushed 9y ago4 watchersCompare

[ Source](https://github.com/larryli/eviltransform-php)[ Packagist](https://packagist.org/packages/larryli/eviltransform)[ Docs](https://github.com/googollee/eviltransform)[ RSS](/packages/larryli-eviltransform/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

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

[](#transform-coordinate-between-earthwgs-84-and-mars-in-chinagcj-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
----------------

[](#wgstogcjwgs2gcj)

```
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
----------------

[](#gcjtowgsgcj2wgs)

```
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
----------------------------

[](#gcjtowgsexactgcj2wgs_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
-----------------

[](#distancedistance)

```
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:
--------------

[](#original-from)

-
-

See also:
---------

[](#see-also)

-
-
-

---

地球坐标（WGS-84）与火星坐标（GCJ－2）转换.
===========================

[](#地球坐标wgs-84与火星坐标gcj2转换)

GCJ-02坐标用在谷歌地图，高德地图等中国地图服务。（百度地图要在GCJ-02基础上再加转换）

WGStoGCJ/wgs2gcj
----------------

[](#wgstogcjwgs2gcj-1)

```
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
----------------

[](#gcjtowgsgcj2wgs-1)

```
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
----------------------------

[](#gcjtowgsexactgcj2wgs_exact-1)

```
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
-----------------

[](#distancedistance-1)

```
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)之间的距离，单位为米。

算法来源:
-----

[](#算法来源)

-
-

参考:
---

[](#参考)

-
-
-

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 80% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~398 days

Total

3

Last Release

3630d ago

Major Versions

v1.0.0 → v2.0.02015-12-10

PHP version history (2 changes)v1.0.0PHP &gt;=5.0

v2.0.0PHP &gt;=5.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/96ad7a2df570547276deb3f07f6e604f897c3dcbe495d55c811b9ae7e3b484ae?d=identicon)[larryli](/maintainers/larryli)

---

Top Contributors

[![larryli](https://avatars.githubusercontent.com/u/10723?v=4)](https://github.com/larryli "larryli (4 commits)")[![googollee](https://avatars.githubusercontent.com/u/496526?v=4)](https://github.com/googollee "googollee (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/larryli-eviltransform/health.svg)

```
[![Health](https://phpackages.com/badges/larryli-eviltransform/health.svg)](https://phpackages.com/packages/larryli-eviltransform)
```

###  Alternatives

[aura/payload

A Domain Payload implementation.

56370.4k9](/packages/aura-payload)[barrelstrength/sprout-seo

1133.7k1](/packages/barrelstrength-sprout-seo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
