Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
epsg_code = '326' + utm_band
elif lat >= 84:
# epsg_code = '3411'
epsg_code = EPSG_ARCTIC
elif lat <= -80:
# epsg_code = '3412'
epsg_code = EPSG_ANTARCTIC
else:
epsg_code = '327' + utm_band
return epsg_code
elif module == 'mgrs':
import mgrs
if m == None:
m = mgrs.MGRS()
# UTM defined in [-80, 84)
if DEG_ANTARCTIC <= lat < DEG_ARCTIC:
# [-80,84)
mgrs_code = m.toMGRS(lat, lon, MGRSPrecision=5) # 1m precision
UTM_code = m.MGRSToUTM(mgrs_code)
utm_band = str(UTM_code[0]).zfill(2)
hemi = UTM_code[1].decode() # 'N' or 'S'
if not (hemi == 'N' or hemi == 'S'):
# debug check since code is new
print('warning ({}): hemi={} is something other than N or S'.format(module, hemi))
epsg_code = '326' + utm_band # N
if hemi == 'S':
epsg_code = '327' + utm_band
def __init__(self,toplevel,chief):
self._mgrs = mgrs.MGRS()
gui.SimplePanel.__init__(self,toplevel,chief,"Conversions","widgets/icons/convert.png")
def _setup(self,host,port):
""" connect to Nidus for data transfer and pass sensor up event """
try:
# get mgrs converter
self._mgrs = mgrs.MGRS()
# connect to data store
self._nidus = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
self._nidus.connect((host,port))
except socket.error as e:
raise RuntimeError("RTO:Nidus:%s" % e)
except Exception as e:
raise RuntimeError("RTO:Unknown:%s" % e)
def getMGRSVal(self,lat,lon):
m = mgrs.MGRS()
c = m.toMGRS(lat,lon)
ind = 1
for i in range(1,len(c)):
if c[i].isalpha():
ind = i
break
v1 = int(c[:ind])*(ord(c[ind:ind+1])+ord(c[ind+1:ind+2]))
v2 = int(c[ind+3:])
return (v1*v2,c)
epsg_code = '326' + utm_band
elif lat >= 84:
# epsg_code = '3411'
epsg_code = EPSG_ARCTIC
elif lat <= -80:
# epsg_code = '3412'
epsg_code = EPSG_ANTARCTIC
else:
epsg_code = '327' + utm_band
return epsg_code
elif module == 'mgrs':
import mgrs
if m == None:
m = mgrs.MGRS()
# UTM defined in [-80, 84)
if DEG_ANTARCTIC <= lat < DEG_ARCTIC:
# [-80,84)
mgrs_code = m.toMGRS(lat, lon, MGRSPrecision=5) # 1m precision
UTM_code = m.MGRSToUTM(mgrs_code)
utm_band = str(UTM_code[0]).zfill(2)
hemi = UTM_code[1].decode() # 'N' or 'S'
if not (hemi == 'N' or hemi == 'S'):
# debug check since code is new
print('warning ({}): hemi={} is something other than N or S'.format(module, hemi))
epsg_code = '326' + utm_band # N
if hemi == 'S':
epsg_code = '327' + utm_band