fix bug in final line merging
This commit is contained in:
parent
5b805bde9c
commit
8d4a1c1e60
@ -53,7 +53,7 @@ insert into demo_selfcrossing3 select name, generate_subscripts(ways, 1), unnest
|
|||||||
|
|
||||||
|
|
||||||
-- COMBINED
|
-- COMBINED
|
||||||
insert into figures (name, way) values ('multi-island',ST_GeomFromText('MULTILINESTRING((-15 10,-10 10,-5 11,0 11,5 11,10 10,11 9,13 10,15 9),(-5 11,-1 15,0 16,1 15,5 11))'));
|
insert into figures (name, way) values ('multi-island',ST_GeomFromText('MULTILINESTRING((-15 10,-10 10,-5 11,0 11,5 11,10 10,11 9,13 10,15 9),(-5 11,-2 15,0 16,2 15,5 11))'));
|
||||||
drop table if exists demo_wm;
|
drop table if exists demo_wm;
|
||||||
create table demo_wm (name text, i bigint, way geometry);
|
create table demo_wm (name text, i bigint, way geometry);
|
||||||
insert into demo_wm (name, way) select name, ST_SimplifyWM(way, true) from figures where name='multi-island';
|
insert into demo_wm (name, way) select name, ST_SimplifyWM(way, true) from figures where name='multi-island';
|
||||||
|
40
wm.sql
40
wm.sql
@ -273,6 +273,7 @@ drop function if exists ST_SimplifyWM;
|
|||||||
create function ST_SimplifyWM(geom geometry, dbg boolean default false) returns geometry as $$
|
create function ST_SimplifyWM(geom geometry, dbg boolean default false) returns geometry as $$
|
||||||
declare
|
declare
|
||||||
dbg_stage integer;
|
dbg_stage integer;
|
||||||
|
i integer;
|
||||||
line geometry;
|
line geometry;
|
||||||
lines geometry[];
|
lines geometry[];
|
||||||
bends geometry[];
|
bends geometry[];
|
||||||
@ -290,26 +291,26 @@ begin
|
|||||||
|
|
||||||
if dbg then
|
if dbg then
|
||||||
drop table if exists debug_wm;
|
drop table if exists debug_wm;
|
||||||
create table debug_wm(name text, i bigint, way geometry);
|
create table debug_wm(name text, way geometry);
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
dbg_stage = 1;
|
for i in 1..array_length(lines, 1) loop
|
||||||
foreach line in array lines loop
|
|
||||||
mutated = true;
|
mutated = true;
|
||||||
|
dbg_stage = 1;
|
||||||
while mutated loop
|
while mutated loop
|
||||||
if dbg then
|
if dbg then
|
||||||
insert into debug_wm (name, way) values(
|
insert into debug_wm (name, way) values(
|
||||||
dbg_stage || 'afigures',
|
dbg_stage || 'afigures_' || i,
|
||||||
line
|
lines[i]
|
||||||
);
|
);
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
bends = detect_bends(line);
|
bends = detect_bends(lines[i]);
|
||||||
|
|
||||||
if dbg then
|
if dbg then
|
||||||
insert into debug_wm(name, i, way) values(
|
insert into debug_wm(name, way) values(
|
||||||
dbg_stage || 'bbends',
|
dbg_stage || 'bbends_' || i || '_' || generate_subscripts(bends, 1),
|
||||||
generate_subscripts(bends, 1),
|
|
||||||
unnest(bends)
|
unnest(bends)
|
||||||
);
|
);
|
||||||
end if;
|
end if;
|
||||||
@ -317,9 +318,8 @@ begin
|
|||||||
bends = fix_gentle_inflections(bends);
|
bends = fix_gentle_inflections(bends);
|
||||||
|
|
||||||
if dbg then
|
if dbg then
|
||||||
insert into debug_wm(name, i, way) values(
|
insert into debug_wm(name, way) values(
|
||||||
dbg_stage || 'cinflections',
|
dbg_stage || 'cinflections' || i || '_' || generate_subscripts(bends, 1),
|
||||||
generate_subscripts(bends, 1),
|
|
||||||
unnest(bends)
|
unnest(bends)
|
||||||
);
|
);
|
||||||
end if;
|
end if;
|
||||||
@ -327,22 +327,24 @@ begin
|
|||||||
select * from self_crossing(bends) into bends, mutated;
|
select * from self_crossing(bends) into bends, mutated;
|
||||||
|
|
||||||
if dbg then
|
if dbg then
|
||||||
insert into debug_wm(name, i, way) values(
|
insert into debug_wm(name, way) values(
|
||||||
dbg_stage || 'dcrossings',
|
dbg_stage || 'dcrossings' || i || '_' || generate_subscripts(bends, 1),
|
||||||
generate_subscripts(bends, 1),
|
|
||||||
unnest(bends)
|
unnest(bends)
|
||||||
);
|
);
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
line = st_linemerge(st_union(bends));
|
lines[i] = st_linemerge(st_union(bends));
|
||||||
end loop;
|
|
||||||
|
raise notice 'lines[i]: %', st_summary(lines[i]);
|
||||||
|
|
||||||
dbg_stage = dbg_stage + 1;
|
dbg_stage = dbg_stage + 1;
|
||||||
end loop;
|
end loop;
|
||||||
|
end loop;
|
||||||
|
|
||||||
if l_type = 'ST_LineString' then
|
if l_type = 'ST_LineString' then
|
||||||
return st_linemerge(st_union(bends));
|
return st_linemerge(st_union(lines));
|
||||||
elseif l_type = 'ST_MultiLineString' then
|
elseif l_type = 'ST_MultiLineString' then
|
||||||
return st_union(bends);
|
return st_union(lines);
|
||||||
end if;
|
end if;
|
||||||
end
|
end
|
||||||
$$ language plpgsql;
|
$$ language plpgsql;
|
||||||
|
Loading…
Reference in New Issue
Block a user