def coords_from_query ( query ) : try : coords = json . loads ( query ) except ValueError : vals = re . split ( r'[,\s]+' , query . strip ( ) ) coords = [ float ( v ) for v in vals ] return tuple ( coords [ : 2 ] )
how to get lat and long from string python
Transform a query line into a ( lng lat ) pair of coordinates .
def coords_from_query(query):
    """Transform a query line into a (lng, lat) pair of coordinates."""
    try:
        coords = json.loads(query)
    except ValueError:
        vals = re.split(r'[,\s]+', query.strip())
        coords = [float(v) for v in vals]
    return tuple(coords[:2])