From 1cace16013b867810871c46327e917c57087031d Mon Sep 17 00:00:00 2001 From: vv01f Date: Thu, 6 Jun 2019 12:39:15 +0200 Subject: [PATCH] learning python boolean --- create-geojson.sh | 1 + lookup.py | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/create-geojson.sh b/create-geojson.sh index 2368e04..2b8a0f9 100755 --- a/create-geojson.sh +++ b/create-geojson.sh @@ -1,4 +1,5 @@ #!/usr/bin/env sh +echo "this takes some time depending on the amount of addresses in your lists …" for file in $(ls *-csv) ; do out=$(echo ${file}|cut -d- -f1)".geojson" test -e ${out} && { echo "file exists: "${out}", skipping."; continue; } diff --git a/lookup.py b/lookup.py index e647923..8a37770 100755 --- a/lookup.py +++ b/lookup.py @@ -13,12 +13,12 @@ def eprint(*args, **kwargs): # ~ fn="ct-csv" if len(sys.argv) == 2: - fn = sys.argv[1] + fn = sys.argv[1] else: - eprint("in case you do know know what you are doing, better call via e.g. `create-geojson.sh`.\n"); - eprint("expecting one argument: csv-file."); - eprint("received "+str(len(sys.argv))+" argument(s): "+str(sys.argv)); - sys.exit(1) # exit with error + eprint("in case you do know know what you are doing, better call via e.g. `create-geojson.sh`.\n"); + eprint("expecting one argument: csv-file."); + eprint("received "+str(len(sys.argv))+" argument(s): "+str(sys.argv)); + sys.exit(1) # exit with error # for retreiving geo coordinates from addresses geolocator = Nominatim(user_agent="my-mapper") @@ -27,7 +27,7 @@ precision = 2 # convert csv to geojson -firstline = true +firstline = True # start json list print ( "[" ) # get data from file @@ -43,10 +43,10 @@ with open( fn, 'r' ) as fp: # ~ strCoordPlace = '{:s},{:.6f},{:.6f}'.format( arrAddress[3], location.latitude, location.longitude ) 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[1], fn.split("-")[0] ) - if firstline == false: - print (",") - else - firstline = false + if firstline == False : + print (",") + else: + firstline = False print ( strCoordPlace ) # end json list print ( "]" )