adjust update-db.sh

This commit is contained in:
dancingCycle 2023-05-03 14:44:32 +02:00
parent 93d7ff3547
commit 8f9cbfc5a1
4 changed files with 25 additions and 18 deletions

View File

@ -1,4 +1,4 @@
DROP VIEW public.vw_counties;
DROP VIEW public.vw_counties CASCADE;
CREATE OR REPLACE VIEW public.vw_counties AS
SELECT planet_osm_polygon.osm_id,

View File

@ -1,22 +1,25 @@
CREATE OR REPLACE VIEW public.vw_export_poi AS
SELECT foo.id, foo.kat, tl.deutsch as kat_de, tl.english as kat_en, foo.kat_sub as kat_sub_de, foo.kat_sub as kat_sub_en, foo.name,
foo.strasse, foo.plz, foo.gemeinde, foo.landkreis,
foo.adr_street AS strasse, foo.plz, foo.gemeinde, foo.landkreis,
foo.stellplaetze, foo.emob, foo.linien,
foo.website, foo.phone, foo.betreiber, foo.oeffnungszeiten, foo.vbn, foo.st_x as x_wgs84, foo.st_y as y_wgs84, foo.haltestelle
foo.website, foo.phone, foo.betreiber, foo.oeffnungszeiten, foo.st_x as x_wgs84, foo.st_y as y_wgs84, foo.haltestelle
FROM
(
--- erstellt die Abfrage für den POI-Export
-- Teil POI
SELECT id, kategorie, kat_sub, name, trim(concat(adr_street, ' ', adr_housenumber)) as adr_street,
SELECT
id, kategorie AS kat, kat_sub, name,
trim(concat(adr_street, ' ', adr_housenumber)) as adr_street,
--- adr_street||' '||adr_housenumber as adr_street,
cast( adr_postcode as integer), landkreis, gemeinde, 0 as stellplaetze, false as emob, NULL as linien, website, phone, operator, '' as opening_hours,
cast( adr_postcode as integer) as plz, landkreis, gemeinde,
0 as stellplaetze, false as emob,NULL as linien, website, phone, operator AS betreiber,
'' as oeffnungszeiten,
--- opening_hours,
st_x, st_y, NULL as haltestelle
FROM tbl_poi
st_x,st_y, NULL as haltestelle
FROM tbl_poi WHERE true
--- dient zum check ob im Feld adr_postcode nur Zahlen stehen
WHERE (adr_postcode ~ '^[0-9]+$' OR adr_postcode IS NULL)
)
as foo, tbl_kat_translate tl
AND (adr_postcode ~ '^[0-9]+$' OR adr_postcode IS NULL))
as foo, tbl_kat_translate tl
WHERE foo.kat = tl.kat
ORDER BY tl.kat, foo.landkreis, foo.gemeinde, foo.name;

View File

@ -1,4 +1,4 @@
DROP VIEW public.vw_municipalitis;
DROP VIEW public.vw_municipalities CASCADE;
CREATE OR REPLACE VIEW public.vw_municipalities AS
SELECT planet_osm_polygon.osm_id,

View File

@ -14,20 +14,24 @@ echo "DB_NAME: $DB_NAME"
DB_USER="$2"
echo "DB_USER: $DB_USER"
#
psql -U $DB_USER -f ../vw_municipalities.sql -d $DB_NAME
psql -U $DB_USER -f ../vw_counties.sql -d $DB_NAME
psql -U $DB_USER -f ../vw_poi.sql -d $DB_NAME
#
psql -U $DB_USER -c 'DROP TABLE IF EXISTS public.tbl_municipalities;' -d $DB_NAME
psql -U $DB_USER -c 'CREATE TABLE tbl_municipalities AS SELECT * FROM vw_municipalities;' -d $DB_NAME
#
psql -U $DB_USER -c 'DROP TABLE IF EXISTS public.tbl_counties;' -d $DB_NAME
psql -U $DB_USER -c 'CREATE TABLE tbl_counties AS SELECT * FROM vw_counties;' -d $DB_NAME
#
psql -U $DB_USER -c 'DROP TABLE IF EXISTS public.tbl_poi;' -d $DB_NAME
psql -U $DB_USER -f ../vw_municipalities.sql -d $DB_NAME
psql -U $DB_USER -c 'DROP TABLE IF EXISTS public.tbl_municipalities;' -d $DB_NAME
psql -U $DB_USER -c 'CREATE TABLE tbl_municipalities AS SELECT * FROM vw_municipalities;' -d $DB_NAME
#
psql -U $DB_USER -c 'DROP TABLE IF EXISTS public.tbl_poi CASCADE;' -d $DB_NAME
psql -U $DB_USER -f ../vw_poi.sql -d $DB_NAME
psql -U $DB_USER -c 'CREATE TABLE tbl_poi AS SELECT * FROM vw_poi;' -d $DB_NAME
#
psql -U $DB_USER -d $DB_NAME -f ../vw_export_poi.sql
#
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/pacs/sib00/users/osm/osm_poi_rvb.csv
#
cp /home/pacs/sib00/users/osm/osm_poi_rvb.csv /home/pacs/sib00/users/osm/doms/osm.swingbe.de/subs-ssl/www/osm/poi_rvb.csv
#
echo "Done."
#done.