tests for bends vs inflections
This commit is contained in:
parent
3286890f52
commit
b9ffddee71
16
IV/tests.sql
16
IV/tests.sql
@ -25,28 +25,36 @@ insert into bends select unnest(detect_bends((select way from figures where name
|
|||||||
insert into bends select unnest(detect_bends((select way from figures where name='fig5')));
|
insert into bends select unnest(detect_bends((select way from figures where name='fig5')));
|
||||||
insert into bends select unnest(detect_bends((select way from figures where name='inflection-1')));
|
insert into bends select unnest(detect_bends((select way from figures where name='inflection-1')));
|
||||||
|
|
||||||
|
-- DETECT BENDS
|
||||||
do $$
|
do $$
|
||||||
declare
|
declare
|
||||||
vbends geometry[];
|
vbends geometry[];
|
||||||
begin
|
begin
|
||||||
-- DETECT BENDS
|
|
||||||
select detect_bends((select way from figures where name='fig3')) into vbends;
|
select detect_bends((select way from figures where name='fig3')) into vbends;
|
||||||
perform assert_equals(5, array_length(vbends, 1));
|
perform assert_equals(5, array_length(vbends, 1));
|
||||||
perform assert_equals('LINESTRING(0 0,12 0,13 4)', st_astext(vbends[1]));
|
perform assert_equals('LINESTRING(0 0,12 0,13 4)', st_astext(vbends[1]));
|
||||||
perform assert_equals('LINESTRING(12 0,13 4,20 2,20 0)', st_astext(vbends[2]));
|
perform assert_equals('LINESTRING(12 0,13 4,20 2,20 0)', st_astext(vbends[2]));
|
||||||
perform assert_equals('LINESTRING(20 2,20 0,32 0,33 10)', st_astext(vbends[3]));
|
perform assert_equals('LINESTRING(20 2,20 0,32 0,33 10)', st_astext(vbends[3]));
|
||||||
perform assert_equals('LINESTRING(32 0,33 10,38 16,43 15,44 10,44 0)', st_astext(vbends[4]));
|
perform assert_equals('LINESTRING(32 0,33 10,38 16,43 15,44 10,44 0)', st_astext(vbends[4]));
|
||||||
|
|
||||||
perform assert_equals(4, array_length(detect_bends((select way from figures where name='fig3-1')), 1));
|
perform assert_equals(4, array_length(detect_bends((select way from figures where name='fig3-1')), 1));
|
||||||
|
|
||||||
select detect_bends((select way from figures where name='fig5')) into vbends;
|
select detect_bends((select way from figures where name='fig5')) into vbends;
|
||||||
perform assert_equals(3, array_length(vbends, 1));
|
perform assert_equals(3, array_length(vbends, 1));
|
||||||
|
end $$ language plpgsql;
|
||||||
|
|
||||||
-- FIX BEND INFLECTIONS
|
-- FIX BEND INFLECTIONS
|
||||||
|
do $$
|
||||||
|
declare
|
||||||
|
vbends geometry[];
|
||||||
|
vinflections geometry[];
|
||||||
|
begin
|
||||||
select detect_bends((select way from figures where name='inflection-1')) into vbends;
|
select detect_bends((select way from figures where name='inflection-1')) into vbends;
|
||||||
|
select fix_gentle_inflections(vbends) into vinflections;
|
||||||
|
|
||||||
|
perform assert_equals(vbends[1], vinflections[1]); -- unchanged
|
||||||
|
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]));
|
||||||
|
|
||||||
drop table if exists inflections;
|
drop table if exists inflections;
|
||||||
create table inflections (way geometry);
|
create table inflections (way geometry);
|
||||||
insert into inflections select unnest(fix_gentle_inflections(vbends));
|
insert into inflections select unnest(fix_gentle_inflections(vbends));
|
||||||
|
|
||||||
end $$ language plpgsql;
|
end $$ language plpgsql;
|
||||||
|
@ -98,7 +98,7 @@ begin
|
|||||||
-- Then edges (A,B) and (E,F) are shared with the neighboring bends.
|
-- Then edges (A,B) and (E,F) are shared with the neighboring bends.
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- Assume this curve (figure `inflection-1`):
|
-- Assume this curve (figure `inflection-1`), going clockwise from A:
|
||||||
--
|
--
|
||||||
-- \______B
|
-- \______B
|
||||||
-- A `-------. C
|
-- A `-------. C
|
||||||
@ -110,7 +110,9 @@ begin
|
|||||||
-- After processing the curve following the definition of a bend, the bend
|
-- After processing the curve following the definition of a bend, the bend
|
||||||
-- [A-E] would be detected. Assuming inflection point E and F are "small",
|
-- [A-E] would be detected. Assuming inflection point E and F are "small",
|
||||||
-- the bend needs to be extended by two edges to [A,G].
|
-- the bend needs to be extended by two edges to [A,G].
|
||||||
select geom from st_dumppoints(bends[i-1]) order by path[1] asc limit 1 into ptail;
|
select geom from st_dumppoints(bends[i-1])
|
||||||
|
order by path[1] asc limit 1 into ptail;
|
||||||
|
|
||||||
while true loop
|
while true loop
|
||||||
-- copy last 3 points of bends[i-1] (tail) to ptail
|
-- copy last 3 points of bends[i-1] (tail) to ptail
|
||||||
select array(
|
select array(
|
||||||
|
Loading…
Reference in New Issue
Block a user