Skip to content
Snippets Groups Projects
Commit cbc050e5 authored by Riccardo Boero's avatar Riccardo Boero :innocent:
Browse files

fix FACT_ports queries to include state-country codes and indexes.

parent 870bddcb
No related branches found
No related tags found
No related merge requests found
......@@ -27,9 +27,11 @@ function eu_ports(conn_dict::Dict, selection::Dict)
dftemp = DataFrame()
# iterate over geo objects
for (id, shape) in zip(geo_id, shape_obj)
# Extract the first two characters of id in Julia
id_short = id[1:2]
# prepare query
query = "SELECT COUNT(*) as ports FROM eu_ports_2013_geo WHERE ST_Intersects(ST_GeomFromText('"*shape*"'), SHAPE);"
query2 = "SELECT SUM(Q1+Q2+Q3+Q4) AS tonnage FROM eu_tonnage et JOIN eu_ports_2013_geo ep ON ep.port_id=et.PORT_ID WHERE ST_Intersects(ST_GeomFromText('"*shape*"'), SHAPE);"
query = "SELECT COUNT(*) as ports FROM eu_ports_2013_geo WHERE eu_country = '"*id_short*"' AND ST_Intersects(ST_GeomFromText('"*shape*"'), SHAPE);"
query2 = "SELECT SUM(Q1+Q2+Q3+Q4) AS tonnage FROM eu_tonnage et JOIN eu_ports_2013_geo ep ON ep.port_id=et.PORT_ID WHERE ep.eu_country = '"*id_short*"' AND ST_Intersects(ST_GeomFromText('"*shape*"'), SHAPE);"
# create connection
conn = establish_connection(conn_dict["host"], conn_dict["user"], conn_dict["password"], conn_dict["database"]; port=conn_dict["port"])
# execute
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment