参见如下python3代码,
import math
def cal_mesh_id(x: float, y: float) -> int:
"""
x表示经度
y表是纬度
返回网格号
"""
intm1m2 = math.floor(y * 1.5)
intj1 = math.floor(x)
dblj2 = x - math.floor(x)
intm3m4 = math.floor(intj1 - 60)
intm5 = math.floor((y - intm1m2 / 1.5) * 12.0)
intm6 = math.floor(dblj2 * 8.0)
if intm1m2<0 or intm1m2>99 or intm3m4<0 or intm3m4>99 or intm5<0 or intm5>7 or intm6<0 or intm6>7:
return 0
ret = int(intm1m2)*10000 + int(intm3m4)*100+int(intm5)*10+int(intm6)
return ret
def coor2mapid(x: float, y: float) -> int:
"""
x表示经度
y表示纬度
返回网格号
"""
m12 = int(y * 60.0 / 40.0)
m34 = int(x - 60.0)
m5 = int((y - m12 * 40.0 / 60.0) * 60.0 / 5.0)
m6 = int((x - m34 - 60.0) * 60.0 / 7.5)
return m12 * 10000 + m34 * 100 + m5 * 10 + m6 #python的 input 坐标 gc02 output 6位 mesh 号