From b323b6319d5bf12c8598723fc19982dd1ed8306a Mon Sep 17 00:00:00 2001 From: vv01f Date: Wed, 5 Jun 2019 12:04:07 +0200 Subject: [PATCH] variable precision --- lookup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lookup.py b/lookup.py index ff58945..8729815 100755 --- a/lookup.py +++ b/lookup.py @@ -14,7 +14,7 @@ else: # for retreiving geo coordinates from addresses geolocator = Nominatim(user_agent="my-mapper") - +precision = 2 # get data from file with open( fn, 'r' ) as fp: for place in fp: @@ -26,8 +26,8 @@ with open( fn, 'r' ) as fp: if location is not None: # its a class # todo: ceil coords to hide true location in format string # ~ strCoordPlace = '{:s},{:.6f},{:.6f}'.format( arrAddress[3], location.latitude, location.longitude ) - geojson = '{{"type":"Feature","geometry": {{"type": "Point","coordinates":[{:.6f}, {:.6f}]}},"properties":{{"name":"{:s}","marker":fn.split("-")[0]}}}}'; - strCoordPlace = geojson.format( location.latitude, location.longitude, arrAddress[3] ) + geojson = '{{"type":"Feature","geometry":{{"type":"Point","coordinates":[{:.'+str(precision)+'f},{:.'+str(precision)+'f}]}},"properties":{{"name":"{:s}","marker":{:s}}}}}'; + strCoordPlace = geojson.format( location.latitude, location.longitude, arrAddress[3], fn.split("-")[0] ) # ~ {"type": "Feature","geometry": {"type": "Point","coordinates":[125.6, 10.1]},"properties":{"name":"Dinagat Islands"}} print ( strCoordPlace )