fix for generalization and data query
This commit is contained in:
parent
0c9a86216f
commit
c26652c306
19
lookup.py
19
lookup.py
|
@ -2,12 +2,20 @@
|
|||
|
||||
from geopy import Nominatim
|
||||
# ~ import json
|
||||
import sys
|
||||
|
||||
# ~ fn="ct-csv"
|
||||
if len(sys.argv) == 2:
|
||||
fn = sys.argv[1]
|
||||
else:
|
||||
print("expecting one argument: csv-file.");
|
||||
print("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")
|
||||
|
||||
# first test to retreive geo coordinates
|
||||
|
||||
fn="ct-csv"
|
||||
# get data from file
|
||||
with open( fn, 'r' ) as fp:
|
||||
for place in fp:
|
||||
#error handling: expect
|
||||
|
@ -18,11 +26,14 @@ 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":"ct"}}}}';
|
||||
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] )
|
||||
# ~ {"type": "Feature","geometry": {"type": "Point","coordinates":[125.6, 10.1]},"properties":{"name":"Dinagat Islands"}}
|
||||
print ( strCoordPlace )
|
||||
|
||||
# exit fine
|
||||
sys.exit(0)
|
||||
|
||||
# ~ m = folium.Map( # etc..)
|
||||
# ~ m.save("filename.png")
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ test -e baerer && auth=$(head -1 baerer) || {
|
|||
#~ test -e ct-json && echo "file already exists." || curl -o ct-json "https://"${auth}"doku.ccc.de/Spezial:Semantische_Suche/-5B-5BKategorie:Chaostreffs-5D-5D-20-5B-5BChaostreff-2DIs-2DErfa::falsch-5D-5D-20-5B-5BChaostreff-2DActive::wahr-5D-5D/-3FChaostreff-2DPhysical-2DAddress%3DAdresse/-3FChaostreff-2DPhysical-2DPostcode%3DPLZ/-3FChaostreff-2DPhysical-2DCity%3DStadt/-3FChaostreff-2DCountry%3DLand/mainlabel%3D/limit%3D100/order%3DASC/sort%3DErfa-2DCity/offset%3D0/format%3Djson/headers%3Dshow/searchlabel%3DJSON"
|
||||
#~ test -e erfa-json && echo "file already exists." || curl -o erfa-json "https://"${auth}"doku.ccc.de/Spezial:Semantische_Suche/-5B-5BKategorie:Chaostreffs-5D-5D-20-5B-5BChaostreff-2DIs-2DErfa::wahr-5D-5D-20-5B-5BChaostreff-2DActive::wahr-5D-5D/-3FChaostreff-2DPhysical-2DAddress%3DAdresse/-3FChaostreff-2DPhysical-2DPostcode%3DPLZ/-3FChaostreff-2DPhysical-2DCity%3DStadt/-3FChaostreff-2DCountry%3DLand/mainlabel%3D/limit%3D100/order%3DASC/sort%3DErfa-2DCity/offset%3D0/format%3Djson/headers%3Dshow/searchlabel%3DJSON"
|
||||
test -e ct-csv && echo "file already exists." || curl -o ct-csv "https://"${auth}"doku.ccc.de/Spezial:Semantische_Suche/-5B-5BKategorie:Chaostreffs-5D-5D-20-5B-5BChaostreff-2DIs-2DErfa::falsch-5D-5D-20-5B-5BChaostreff-2DActive::wahr-5D-5D/-3FChaostreff-2DPhysical-2DAddress%3DAdresse/-3FChaostreff-2DPhysical-2DPostcode%3DPLZ/-3FChaostreff-2DPhysical-2DCity%3DStadt/-3FChaostreff-2DCountry%3DLand/mainlabel%3D/limit%3D100/order%3DASC/sort%3DErfa-2DCity/offset%3D0/format%3Dcsv/headers%3Dshow/searchlabel%3DCSV/sep%3D,/filename%3Dct-2Dbesuchsadressen.csv"
|
||||
test -e erfa-csv && echo "file already exists." || curl -o erfa-csv "https://"${auth}"doku.ccc.de/Spezial:Semantische_Suche/-5B-5BKategorie:Chaostreffs-5D-5D-20-5B-5BChaostreff-2DIs-2DErfa::wahr-5D-5D-20-5B-5BChaostreff-2DActive::wahr-5D-5D/-3FChaostreff-2DPhysical-2DAddress%3DAdresse/-3FChaostreff-2DPhysical-2DPostcode%3DPLZ/-3FChaostreff-2DPhysical-2DCity%3DStadt/-3FChaostreff-2DCountry%3DLand/mainlabel%3D/limit%3D100/order%3DASC/sort%3DErfa-2DCity/offset%3D0/format%3Dcsv/headers%3Dshow/searchlabel%3DCSV/sep%3D,/filename%3Derfa-2Dbesuchsadressen.csv"
|
||||
test -e erfa-csv && echo "file already exists." || curl -o erfa-csv "https://"${auth}"doku.ccc.de/Spezial:Semantische_Suche/-5B-5BKategorie:Erfa-2DKreise-5D-5D-20-5B-5BChaostreff-2DActive::wahr-5D-5D/-3FChaostreff-2DPhysical-2DAddress%3DAdresse/-3FChaostreff-2DPhysical-2DPostcode%3DPLZ/-3FChaostreff-2DPhysical-2DCity%3DStadt/-3FChaostreff-2DCountry%3DLand/mainlabel%3D/limit%3D100/order%3DASC/sort%3DErfa-2DCity/offset%3D0/format%3Dcsv/headers%3Dshow/searchlabel%3DCSV/sep%3D,/filename%3Derfa-2Dbesuchsadressen.csv"
|
||||
# preprocess csv data
|
||||
for file in $(echo 'ct-csv\nerfa-csv'); do
|
||||
sed -e 's/"//g' ${file} > tmpfile && mv tmpfile ${file}
|
||||
|
|
Loading…
Reference in New Issue
Block a user