This commit is contained in:
苏尹岚
2021-03-09 11:03:23 +08:00
parent defbdb0462
commit f2f46cb867
5 changed files with 91 additions and 21 deletions

View File

@@ -267,6 +267,24 @@ func WalkingDistance(lng1, lat1, lng2, lat2 float64) (distance float64) {
return distance
}
//经纬度坐标转换到平面坐标
func MillierConvertion(lat float64, lon float64) [2]float64 {
var L, H, W, temp, mill, x, y float64
L = 6381372 * math.Pi * 2 //地球周长
W = L // 平面展开后x轴等于周长
H = L / 2 // y轴约等于周长一半
mill = 2.3 // 米勒投影中的一个常数范围大约在正负2.3之间
temp = math.Pi
x = lon * temp / 180 // 将经度从度数转换为弧度
y = lat * temp / 180 // 将纬度从度数转换为弧度
y = 1.25 * math.Log(math.Tan(0.25*temp+0.4*y)) // 米勒投影的转换
// 弧度转为实际距离
x = (W / 2) + (W/(2*math.Pi))*x
y = (H / 2) - (H/(2*mill))*y
var result = [2]float64{x, y}
return result
}
func StandardCoordinate2Int(value float64) int {
return int(math.Round(value * 1000000))
}