def parseDMSStringSingle(str):
'''Parse a single coordinate either DMS or decimal degrees.
It simply returns the value but doesn't maintain any knowledge
as to whether it is latitude or longitude'''
str = str.strip().upper()
try:
if re.search("[NSEW\xb0]", str) == None:
coord = float(str)
else:
m = re.findall('(.+)\s*([NSEW])', str)
if len(m) != 1 or len(m[0]) != 2:
raise ValueError('Invalid DMS Coordinate')
coord = LatLon.parseDMS(m[0][0], m[0][1])
except:
raise ValueError('Invalid Coordinates')
return coord
LatLon.py 文件源码
python
阅读 45
收藏 0
点赞 0
评论 0
评论列表
文章目录