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
|
#!/usr/bin/env sh
|
||||||
|
echo "this takes some time depending on the amount of addresses in your lists …"
|
||||||
for file in $(ls *-csv) ; do
|
for file in $(ls *-csv) ; do
|
||||||
out=$(echo ${file}|cut -d- -f1)".geojson"
|
out=$(echo ${file}|cut -d- -f1)".geojson"
|
||||||
test -e ${out} && { echo "file exists: "${out}", skipping."; continue; }
|
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"
|
# ~ fn="ct-csv"
|
||||||
if len(sys.argv) == 2:
|
if len(sys.argv) == 2:
|
||||||
fn = sys.argv[1]
|
fn = sys.argv[1]
|
||||||
else:
|
else:
|
||||||
eprint("in case you do know know what you are doing, better call via e.g. `create-geojson.sh`.\n");
|
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("expecting one argument: csv-file.");
|
||||||
eprint("received "+str(len(sys.argv))+" argument(s): "+str(sys.argv));
|
eprint("received "+str(len(sys.argv))+" argument(s): "+str(sys.argv));
|
||||||
sys.exit(1) # exit with error
|
sys.exit(1) # exit with error
|
||||||
|
|
||||||
# for retreiving geo coordinates from addresses
|
# for retreiving geo coordinates from addresses
|
||||||
geolocator = Nominatim(user_agent="my-mapper")
|
geolocator = Nominatim(user_agent="my-mapper")
|
||||||
|
@ -27,7 +27,7 @@ precision = 2
|
||||||
|
|
||||||
# convert csv to geojson
|
# convert csv to geojson
|
||||||
|
|
||||||
firstline = true
|
firstline = True
|
||||||
# start json list
|
# start json list
|
||||||
print ( "[" )
|
print ( "[" )
|
||||||
# get data from file
|
# 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 )
|
# ~ 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}"}}}}';
|
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] )
|
strCoordPlace = geojson.format( location.latitude, location.longitude, arrAddress[1], fn.split("-")[0] )
|
||||||
if firstline == false:
|
if firstline == False :
|
||||||
print (",")
|
print (",")
|
||||||
else
|
else:
|
||||||
firstline = false
|
firstline = False
|
||||||
print ( strCoordPlace )
|
print ( strCoordPlace )
|
||||||
# end json list
|
# end json list
|
||||||
print ( "]" )
|
print ( "]" )
|
||||||
|
|
Loading…
Reference in New Issue