LatLon.py 文件源码

python
阅读 45 收藏 0 点赞 0 评论 0

项目:qgis-shapetools-plugin 作者: NationalSecurityAgency 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号