From 973c78b0cf1dd618717acedd4191639dee49e0f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Thu, 18 Feb 2021 13:45:53 +0200 Subject: [PATCH] more elaborate test cases --- IV/db | 7 +------ IV/tests.sql | 15 +++++++++++---- IV/wm.sql | 6 +++--- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/IV/db b/IV/db index 0bfccfd..238a0d5 100755 --- a/IV/db +++ b/IV/db @@ -40,12 +40,7 @@ case ${1:-} in stop) docker stop "$name" ;; - "" | --) - [[ $# -gt 1 ]] && shift + *) _psql "$@" ;; - *) - >&2 echo "Unknown command: '$*'" - exit 1 - ;; esac diff --git a/IV/tests.sql b/IV/tests.sql index 6cbad3b..2ccac64 100644 --- a/IV/tests.sql +++ b/IV/tests.sql @@ -13,15 +13,22 @@ end $$ LANGUAGE plpgsql; drop table if exists figures; create table figures (name text, way geometry); -insert into figures (name, way) values ('fig3', ST_GeomFromText('LINESTRING(0 0, 12 0, 13 4, 20 2, 20 0, 32 0, 33 10, 38 16, 43 15, 44 10, 44 0, 60 0)')); -insert into figures (name, way) values ('fig3-1', ST_GeomFromText('LINESTRING(0 0, 12 0, 13 4, 20 2, 20 0, 32 0, 33 10, 38 16, 43 15, 44 10, 44 0)')); -insert into figures (name, way) values ('fig5', ST_GeomFromText('LINESTRING(0 39,19 52,27 77,26 104,41 115,49 115,65 103,65 75,53 45,63 15,91 0,91 0)')); +insert into figures (name, way) values ('fig3',ST_GeomFromText('LINESTRING(0 0,12 0,13 4,20 2,20 0,32 0,33 10,38 16,43 15,44 10,44 0,60 0)')); +insert into figures (name, way) values ('fig3-1',ST_GeomFromText('LINESTRING(0 0,12 0,13 4,20 2,20 0,32 0,33 10,38 16,43 15,44 10,44 0)')); +insert into figures (name, way) values ('fig5',ST_GeomFromText('LINESTRING(0 39,19 52,27 77,26 104,41 115,49 115,65 103,65 75,53 45,63 15,91 0,91 0)')); do $$ declare bends geometry[]; begin - perform assert_equals(3, array_length(detect_bends((select way from figures where name='fig3')), 1)); + select detect_bends((select way from figures where name='fig3')) into bends; + perform assert_equals(3, array_length(bends, 1)); + perform assert_equals(4::bigint, (select count(1) from (select (st_dumppoints(detect_bends[1])).path from bends) a)); + perform assert_equals('LINESTRING(12 0,13 4,20 2,20 0)', st_astext(bends[1])); + perform assert_equals('LINESTRING(20 2,20 0,32 0,33 10)', st_astext(bends[2])); + perform assert_equals('LINESTRING(32 0,33 10,38 16,43 15,44 10,44 0)',st_astext(bends[3])); + + perform assert_equals(3, array_length(detect_bends((select way from figures where name='fig3-1')), 1)); select detect_bends((select way from figures where name='fig5')) into bends; diff --git a/IV/wm.sql b/IV/wm.sql index 92f8be1..374fe97 100644 --- a/IV/wm.sql +++ b/IV/wm.sql @@ -45,9 +45,9 @@ begin end $$ language plpgsql; - --- fix_gentle_inflections moves bend endpoints in case of gentle inflections -create or replace function fix_gentle_inflections(line geometry) returns table(bend geometry) as $$ +-- fix_gentle_inflections moves bend endpoints following "Gentle Inflection at +-- End of a Bend" section. +create or replace function fix_gentle_inflections(INOUT bends geometry[]) as $$ begin end $$ language plpgsql;