Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create or replace function slice_linestring (way geometry, slicepoints int[]) returns geometry[]
- as
- $$
- with
- x as (select (st_dumppoints(way)).geom geom),
- z as (select array_agg(geom) pts_array from x),
- numbers as (select unnest(slicepoints) k),
- slices as (select k, lead(k, 1) over () ll from numbers)
- select array_agg(st_makeline(pts_array[k:ll])) from z, slices
- where ll is not null
- $$
- language sql;
- drop table if exists rd_sliced_roads cascade;
- create table rd_sliced_roads as
- with ways as (
- select b.osm_id, unnest(slice_linestring(way, slices)) way
- from rd_line b, slice_order a
- where a.osm_id = b.osm_id)
- select
- row_number() over () id, osm_id, way
- from ways;
- select st_numpoints(way) from rd_sliced_roads;
- drop view if exists pg cascade;
- drop view if exists nodes cascade;
- create view nodes as
- select row_number() over () id, st_node(way) way
- from rd_sliced_roads;
- drop view if exists pg;
- create view pg as
- with
- polygroup as (select ST_Polygonize(way) initial from nodes),
- dumped as (select (st_dump(initial)).geom result from polygroup)
- select row_number() over () id, result
- from dumped;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement