feat(db): add sales points to update-db.sh
This commit is contained in:
parent
dd39773c41
commit
ae443e29d9
|
@ -228,6 +228,10 @@ node,way network text linear
|
|||
node,way park_ride text linear
|
||||
node,way bike_ride text linear
|
||||
|
||||
# consider for ticket office and machine comparison
|
||||
node,way tickets:public_transport text linear
|
||||
node,way vending text linear
|
||||
|
||||
# consider for poi
|
||||
node,way attraction text polygon
|
||||
node,way healthcare text polygon
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
-- colon before variable: for a prepared statement using named placeholders, this will be a parameter name of the form :name
|
||||
CREATE SCHEMA IF NOT EXISTS :schema;
|
||||
SET search_path to :schema, public;
|
||||
|
||||
DROP TABLE IF EXISTS :schema.tbl_sale_points;
|
||||
DROP VIEW IF EXISTS :schema.vw_sale_points;
|
||||
|
||||
CREATE OR REPLACE VIEW :schema.vw_sale_points AS
|
||||
SELECT entity.osm_id, entity.sale_points, entity.name, entity.st_x, entity.st_y
|
||||
FROM (
|
||||
--planet_osm_point/node
|
||||
SELECT osmNode.osm_id, osmNode.sale_points, osmNode.name,
|
||||
st_x(st_transform(osmNode.way, 4326)) AS st_x,
|
||||
st_y(st_transform(osmNode.way, 4326)) AS st_y
|
||||
FROM planet_osm_point AS osmNode
|
||||
WHERE
|
||||
(osmNode.shop = 'ticket'
|
||||
AND osmNode.tickets:public_transport != 'no'
|
||||
AND osmNode.tickets:public_transport IS NOT NULL)
|
||||
OR
|
||||
(osmNode.amenity = 'vending_machine'
|
||||
AND osmNode.vending = 'public_transport_tickets')
|
||||
AND osmNode.proposed IS NULL
|
||||
UNION
|
||||
--planet_osm_polygone/way
|
||||
SELECT osmWay.osm_id, osmWay.sale_points, osmWay.name,
|
||||
st_x(st_centroid(st_transform(osmWay.way, 4326))) AS st_x,
|
||||
st_y(st_centroid(st_transform(osmWay.way, 4326))) AS st_y
|
||||
FROM planet_osm_polygon AS osmWay
|
||||
WHERE
|
||||
(osmWay.shop = 'ticket'
|
||||
AND osmWay.tickets:public_transport != 'no'
|
||||
AND osmWay.tickets:public_transport IS NOT NULL)
|
||||
OR
|
||||
(osmWay.amenity = 'vending_machine'
|
||||
AND osmWay.vending = 'public_transport_tickets')
|
||||
AND osmWay.proposed IS NULL
|
||||
) AS entity
|
||||
--consider coordinates inside rvb only
|
||||
LEFT JOIN vw_counties vwc ON st_contains(vwc.way, st_transform(st_geomfromtext('POINT(' || entity.st_x || ' ' || entity.st_y ||')',4326),3857))
|
||||
--consider coordinates inside rvb only
|
||||
LEFT JOIN vw_municipalities vwm ON st_contains(vwm.way, st_transform(st_geomfromtext('POINT(' || entity.st_x || ' ' || entity.st_y ||')',4326),3857))
|
||||
--consider counties of rvb only
|
||||
WHERE (vwc.name = ANY (ARRAY['Braunschweig','Salzgitter','Wolfsburg','Gifhorn','Landkreis Goslar','Landkreis Helmstedt','Landkreis Peine','Landkreis Wolfenbüttel']))
|
||||
ORDER BY vwc.name, vwm.name, entity.name;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS :schema.tbl_sale_points AS SELECT * FROM :schema.vw_sale_points;
|
|
@ -30,5 +30,7 @@ psql -U $DB_USER -f ./sql/scripts/poi.sql -d $DB_NAME -v schema=$DB_SCHEMA
|
|||
#
|
||||
psql -U $DB_USER -f ./sql/scripts/railway.sql -d $DB_NAME -v schema=$DB_SCHEMA
|
||||
#
|
||||
psql -U $DB_USER -f ./sql/scripts/sales-point.sql -d $DB_NAME -v schema=$DB_SCHEMA
|
||||
#
|
||||
echo "Done."
|
||||
#done.
|
||||
|
|
Loading…
Reference in New Issue