forked from vv01f/ccc-map
learning python boolean
This commit is contained in:
parent
40fd4a8ce0
commit
1cace16013
|
@ -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; }
|
||||
|
|
20
lookup.py
20
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 ( "]" )
|
||||
|
|
Loading…
Reference in New Issue