diff --git a/script/create-entities-table.sh b/script/create-entities-table.sh index 1dc393b..c5a1e21 100755 --- a/script/create-entities-table.sh +++ b/script/create-entities-table.sh @@ -2,33 +2,10 @@ # echo "Started..." #Started... -DB_NAME="osm_poi" -DB_USER="osm_poi" -HIS_HOST="zvbn-his.de" -HIS_USER="zvbn_steckbrief" -HIS_DB="his" +DB_NAME="todo" +DB_USER="todo" # -#import P+R and B+R data from HIS into tabelle infra.brpr -psql -d $DB_NAME -U $DB_USER -c "DELETE FROM infra.brpr;" -psql -h $HIS_HOST -U $HIS_USER -d $HIS_DB -f /home/${DB_USER}/sql/poi/export_pr_br_02.sql| psql -U $DB_USER -d $DB_NAME -c "COPY infra.brpr(id,kat,name,strasse,plz,gemeinde_his,gemeinde,landkreis,x_gk3,y_gk3,anlage_erkennbar,stellplaetze,emob,betreiber,linien) FROM STDIN WITH DELIMITER AS '|' CSV ;" -# -psql -U $DB_USER -f /home/${DB_USER}/sql/poi/vw_poi_fahrplaner_17.sql -d $DB_NAME -psql -U $DB_USER -c 'DROP VIEW IF EXISTS public.vw_export_poi;' -d $DB_NAME -psql -U $DB_USER -c 'DROP TABLE IF EXISTS public.tbl_poi_fahrplaner;' -d $DB_NAME -psql -U $DB_USER -c 'CREATE TABLE tbl_poi_fahrplaner AS SELECT * FROM vw_poi_fahrplaner;' -d $DB_NAME -#TODO What is the reason for the following instruction? -psql -U $DB_USER -c 'CREATE INDEX ind_gemeinde ON public.tbl_poi_fahrplaner USING btree (gemeinde)' -d $DB_NAME -# -#create VIEW public.vw_export_poi for the POI export(OSM, BR, PR, VVK) -psql -U $DB_USER -d $DB_NAME -f /home/${DB_USER}/sql/poi/gesamtexport_poi_br_pr_vv_10.sql -# -#create exports (second call is for Leaflet map view which uses different separators) -psql -U $DB_USER -d $DB_NAME -c "COPY (SELECT * FROM public.vw_export_poi) TO STDOUT WITH DELIMITER AS ';' CSV HEADER NULL '' QUOTE '\"';" -o /home/${DB_USER}/osm_poi/osm_poi.csv -#TODO Required? psql -U $DB_USER -d $DB_NAME -c "COPY (SELECT * FROM public.vw_export_poi) TO STDOUT WITH DELIMITER AS '^' CSV HEADER NULL '' QUOTE '\"' FORCE QUOTE website,oeffnungszeiten;" -o /home/${DB_USER}/osm_poi/osm_poi_ll.csv -# -#copy files from tmp folder to server main folger -cp /home/${DB_USER}/osm_poi/osm_poi.csv /var/www/poi_utf8_demo.csv -#TODO Required? cp /home/${DB_USER}/osm_poi/osm_poi_ll.csv /var/www/osm_poi_ll_utf8.csv +psql -h localhost -p 5432 -U $DB_USER -f ./sql/create-entities-table.sql -d $DB_NAME # echo "Done." -#done. +#Done. diff --git a/sql/create-entities-table.sql b/sql/create-entities-table.sql index 2491848..d15f0f5 100644 --- a/sql/create-entities-table.sql +++ b/sql/create-entities-table.sql @@ -2,18 +2,17 @@ DROP TABLE IF EXISTS entities; --- CREATE TABLE IF NOT EXISTS entities( - id BIGSERIAL PRIMARY KEY, - name TEXT NOT NULL); + entity_id BIGSERIAL PRIMARY KEY, + entity_name TEXT NOT NULL, + entity_lat DOUBLE PRECISION NULL, + entity_lon DOUBLE PRECISION NULL); --- DELETE FROM entities; INSERT INTO entities (name) VALUES -('AfB gemeinnützige GmbH'), -('Green Planet Energy eG'), -('Hostsharing eG'), -('kleiner Heide Laden'), -('Regionale Energie- und KlimaschutzAgentur e. V.'), -('Software Ingenieur Begerad'), -('WEtell GmbH'), -('WTF Kooperative eG') +('AfB gGmbH',50.8320953,6.4719321), +('Green Planet Energy eG',53.5416469,10.0013917), +('Hostsharing eG',53.6388387,10.0148720), +('WEtell GmbH',48.0143619,7.8450213), +('WTF Kooperative eG', 53.5836365,10.0153690) RETURNING *;