-
Notifications
You must be signed in to change notification settings - Fork 5
/
cycleway_merge.sql
35 lines (30 loc) · 1.12 KB
/
cycleway_merge.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
-- remove duplicities
-- etldoc: osm_cycleway_linestring -> osm_cycleway_union_linestring
DROP MATERIALIZED VIEW IF EXISTS osm_cycleway_union_linestring CASCADE;
CREATE MATERIALIZED VIEW osm_cycleway_union_linestring AS
(
SELECT osm_id,
(ST_Dump(ST_LineMerge(ST_Collect(geometry)))).geom AS geometry,
member_name,
network,
surface
FROM osm_cycleway_linestring
GROUP BY osm_id,network, member_name, surface
);
CREATE INDEX IF NOT EXISTS osm_cycleway_union_linestring_gix
ON osm_cycleway_union_linestring USING gist (geometry);
-- merge together by name and surface
-- etldoc: osm_cycleway_union_linestring -> osm_cycleway_merge_linestring
DROP MATERIALIZED VIEW IF EXISTS osm_cycleway_merge_linestring CASCADE;
CREATE MATERIALIZED VIEW osm_cycleway_merge_linestring AS
(
SELECT NULL::bigint AS osm_id,
ST_LineMerge(ST_Collect(geometry)) AS geometry,
member_name,
network,
surface
FROM osm_cycleway_union_linestring
GROUP BY network, member_name, surface
);
CREATE INDEX IF NOT EXISTS osm_cycleway_merge_linestring_gix
ON osm_cycleway_merge_linestring USING gist (geometry);