输入地图图幅编号,例如:j47e008022,输出该图幅对应的经纬度范围:
101.25
38.66666666666664
101.25
38.83333333333336
适用于:1:50万,1:25万,1:10万,1:5万,1:2.5万,1:1万,1:5000比例尺图幅
def getRow(strMapCode):
row = strMapCode[4:7]
return row
def getcol(strMapCode):
col = strMapCode[7:10]
return col
def getLondiff(strMapCode):
str = strMapCode[3]
dlondif=0.0
if str=='B':
dlondif = 3*60*60
elif str=='b':
dlondif = 3 * 60 * 60
elif str == 'C':
dlondif = 1*60*60 + 30*60
elif str == 'c':
dlondif = 1*60*60 + 30*60
elif str == 'D':
dlondif = 30*60
elif str=='d':
dlondif = 30*60
elif str == 'E':
dlondif = 15*60
elif str == 'e':
dlondif = 15*60
elif str == 'F':
dlondif = 7*60 +30
elif str == 'f':
dlondif = 7*60 +30
elif str == 'G':
dlondif = 3*60 + 45
elif str == 'g':
dlondif = 3*60 + 45
elif str == 'H':
dlondif = 1*60 + 52.5
elif str == 'h':
dlondif = 1*60 + 52.5
return dlondif
def getLatdiff(strMapCode):
str = strMapCode[3]
dlatdif=0.0
if str=='B':
dlatdif = 2*60*60
elif str=='b':
dlatdif = 2*60*60
elif str == 'C':
dlatdif = 1*60*60
elif str == 'c':
dlatdif = 1*60*60
elif str == 'D':
dlatdif = 20*60
elif str=='d':
dlatdif = 20*60
elif str == 'E':
dlatdif = 10*60
elif str == 'e':
dlatdif = 10*60
elif str == 'F':
dlatdif = 5*60
elif str == 'f':
dlatdif = 5*60
elif str == 'G':
dlatdif = 2*60 + 30
elif str == 'g':
dlatdif = 2*60 + 30
elif str == 'H':
dlatdif = 1*60 + 15
elif str == 'h':
dlatdif = 1*60 + 15
return dlatdif
def getMapCodeMinLlonlat(strMapCode):
strFirst = strMapCode[0]
a = ord(strFirst)
if a>=65 and a<=86:
a=a-64
elif a>=97 and a<=118:
a=a-96
strSecod = strMapCode[1:3]
b=int(strSecod)
dlong = getLondiff(strMapCode)
dlat = getLatdiff(strMapCode)
col = int(getcol(strMapCode))
row = int(getRow(strMapCode))
wsLong = (b - 31) * 6 * 60 * 60 + (col - 1) * dlong;
wsLat = (a - 1) * 4 * 60 * 60 + (4 * 60 * 60 / dlat - row) * dlat;
enLong = wsLong +dlong;
enLat = wsLat+dlat;
wsLong = wsLong/3600
wsLat = wsLat/3600
enLong = enLong / 3600
enLat = enLat / 3600
print(wsLong)
print(wsLat)
print(enLong)
print(enLat)
return wsLong, wsLat,enLong,enLat
getMapCodeMinLlonlat("F50H071003")