From 4a32d2f7ded04b326d59713845a47b2aa10115db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Thu, 15 Apr 2021 15:47:17 +0300 Subject: [PATCH] selfcrossing-1 and selfcrossing-1-rev tests --- IV/tests.sql | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/IV/tests.sql b/IV/tests.sql index 19fac6a..511c1ce 100644 --- a/IV/tests.sql +++ b/IV/tests.sql @@ -135,13 +135,15 @@ end $$ language plpgsql; do $$ declare + fig6 constant text default 'LINESTRING(84 47,91 59,114 64,120 45,125 39,141 39,147 32)'; + selfcrossing1 constant text default 'LINESTRING(-27 180,-20 166,-13 176,-18 184)'; vcrossings geometry[]; mutated boolean; begin select (self_crossing(array((select way from wm_debug where stage='cinflections' and name='fig6')))).* into vcrossings, mutated; perform assert_equals(true, mutated); perform assert_equals( - 'LINESTRING(84 47,91 59,114 64,120 45,125 39,141 39,147 32)', + fig6, (select st_astext( st_linemerge(st_union(way)) ) from (select unnest(vcrossings) way) a) @@ -150,7 +152,7 @@ begin select (self_crossing(array((select way from wm_debug where stage='cinflections' and name='fig6-rev')))).* into vcrossings, mutated; perform assert_equals(true, mutated); perform assert_equals( - 'LINESTRING(84 47,91 59,114 64,120 45,125 39,141 39,147 32)', + fig6, (select st_astext( st_translate(st_reverse(st_linemerge(st_union(way))), -60, 0) ) from (select unnest(vcrossings) way) a) @@ -165,4 +167,23 @@ begin ) from (select unnest(vcrossings) way) a) ); + + select (self_crossing(array((select way from wm_debug where stage='cinflections' and name='selfcrossing-1' and gen=1)))).* into vcrossings, mutated; + perform assert_equals(true, mutated); + perform assert_equals( + selfcrossing1, + (select st_astext( + st_linemerge(st_union(way)) + ) from (select unnest(vcrossings) way) a) + ); + + select (self_crossing(array((select way from wm_debug where stage='cinflections' and name='selfcrossing-1-rev')))).* into vcrossings, mutated; + perform assert_equals(true, mutated); + perform assert_equals( + selfcrossing1, + (select st_astext( + st_translate(st_reverse(st_linemerge(st_union(way))), -60, 0) + ) from (select unnest(vcrossings) way) a) + ); + end $$ language plpgsql;