Skip to content

Open Infrastructure Map, a view of infrastructure data in OpenStreetMap

Add view

Russ Garrettffe9cb354ef0
diff --git a/schema/views.sql b/schema/views.sql
index 3a673cb..94a8a5b 100644
--- a/schema/views.sql
+++ b/schema/views.sql
@@ -44,6 +44,13 @@ CREATE OR REPLACE VIEW power_plant AS
FROM power_plant_relation;
+CREATE OR REPLACE VIEW power_plant_relation_by_geom_type AS
+ SELECT rel.osm_id, ST_Collect(mem.geometry) AS geometry,
+ (rel.tags -> 'name') AS name, rel.output, rel.source, rel.tags, rel.construction
+ FROM osm_power_plant_relation AS rel, osm_power_plant_relation_member AS mem
+ WHERE mem.osm_id = rel.osm_id
+ GROUP BY rel.osm_id, ST_GeometryType(mem.geometry), rel.tags -> 'name', rel.output, rel.source, rel.tags, rel.construction;
+
/* Dispatch power line query to the appropriate generalised table based on zoom. */
CREATE OR REPLACE FUNCTION power_lines(zoom INT, search_geom geometry) RETURNS