eviltransform icon indicating copy to clipboard operation
eviltransform copied to clipboard

wgs2gcj 代码注释上的建议

Open Artoria2e5 opened this issue 9 years ago • 1 comments

今天重新看了一下 wgs→gcj 里面对于 transform() 一滩浑水之后的两个数值的处理:

	d.lat = (d.lat * 180.0) / ((earthR * (1 - ee)) / (magic * sqrtMagic) * Math.PI);
	d.lng = (d.lng * 180.0) / (earthR / sqrtMagic * Math.cos(radLat) * Math.PI);

这边实际上是进行了这样的操作

// https://en.wikipedia.org/wiki/Latitude#Length_of_a_degree_of_latitude
d.lat /= 椭球体纬线1°弧长({纬度: lat})
// https://en.wikipedia.org/wiki/Longitude#Length_of_a_degree_of_longitude
d.lon /= 椭球体经线1°弧长({纬度: lat})

如果感兴趣的话可以加上注释说明。能得到的一个比较有意思的结论是可以从 GCJ 的 transform 函数中直接得到经纬方向上加偏的距离,以及 transform 这个步骤的返回变量可以尝试说明单位是米。

Artoria2e5 avatar Dec 19 '16 06:12 Artoria2e5

OK

googollee avatar Dec 24 '16 10:12 googollee