unit tests for self-crossings
This commit is contained in:
parent
26292e9f39
commit
aeb270925e
23
IV/tests.sql
23
IV/tests.sql
@ -46,8 +46,6 @@ create table demo_selfcrossing3 (name text, i bigint, way geometry);
|
|||||||
insert into demo_selfcrossing3 select name, generate_subscripts(ways, 1), unnest(ways) from selfcrossing;
|
insert into demo_selfcrossing3 select name, generate_subscripts(ways, 1), unnest(ways) from selfcrossing;
|
||||||
|
|
||||||
|
|
||||||
\q
|
|
||||||
|
|
||||||
do $$
|
do $$
|
||||||
declare
|
declare
|
||||||
vbends geometry[];
|
vbends geometry[];
|
||||||
@ -81,3 +79,24 @@ begin
|
|||||||
perform assert_equals('LINESTRING(114 20,133 20,145 15,145 0,136 5,123 7,114 7)', st_astext(vinflections[2]));
|
perform assert_equals('LINESTRING(114 20,133 20,145 15,145 0,136 5,123 7,114 7)', st_astext(vinflections[2]));
|
||||||
perform assert_equals('LINESTRING(123 7,114 7,111 2)', st_astext(vinflections[3]));
|
perform assert_equals('LINESTRING(123 7,114 7,111 2)', st_astext(vinflections[3]));
|
||||||
end $$ language plpgsql;
|
end $$ language plpgsql;
|
||||||
|
|
||||||
|
do $$
|
||||||
|
declare
|
||||||
|
vcrossings geometry[];
|
||||||
|
begin
|
||||||
|
select self_crossing((select ways from inflections where name='fig6')) into vcrossings;
|
||||||
|
perform assert_equals(
|
||||||
|
'LINESTRING(84 47,91 59,114 64,120 45,125 39,141 39,147 32)',
|
||||||
|
(select st_astext(
|
||||||
|
st_linemerge(st_union(way))
|
||||||
|
) from (select unnest(vcrossings) way) a)
|
||||||
|
);
|
||||||
|
|
||||||
|
select self_crossing((select ways from inflections where name='fig6-rev')) into vcrossings;
|
||||||
|
perform assert_equals(
|
||||||
|
'LINESTRING(84 47,91 59,114 64,120 45,125 39,141 39,147 32)',
|
||||||
|
(select st_astext(
|
||||||
|
st_translate(st_reverse(st_linemerge(st_union(way))), -80, 0)
|
||||||
|
) from (select unnest(vcrossings) way) a)
|
||||||
|
);
|
||||||
|
end $$ language plpgsql;
|
||||||
|
@ -234,8 +234,10 @@ begin
|
|||||||
-- segment is always duplicated with the i-th bend.
|
-- segment is always duplicated with the i-th bend.
|
||||||
bends[i+1] = st_removepoint(bends[i+1], 0);
|
bends[i+1] = st_removepoint(bends[i+1], 0);
|
||||||
bends[j] = st_geometryn(multi, 1);
|
bends[j] = st_geometryn(multi, 1);
|
||||||
bends[j] = st_setpoint(bends[j], st_npoints(bends[j])-1,
|
bends[j] = st_setpoint(
|
||||||
st_pointn(bends[i], st_npoints(bends[i])));
|
bends[j], st_npoints(bends[j])-1,
|
||||||
|
st_pointn(bends[i], st_npoints(bends[i]))
|
||||||
|
);
|
||||||
bends = bends[1:j] || bends[i+1:prev_length];
|
bends = bends[1:j] || bends[i+1:prev_length];
|
||||||
j = i;
|
j = i;
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user