unit tests
This commit is contained in:
parent
a63a6c51a9
commit
395d8a87f6
11
tests.sql
11
tests.sql
@ -15,7 +15,7 @@ drop table if exists figures;
|
|||||||
create table figures (name text, way geometry);
|
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',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 ('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 ('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)'));
|
||||||
insert into figures (name, way) values ('inflection-1',ST_GeomFromText('LINESTRING(110 24,114 20,133 20,145 15,145 0,136 5,123 7,114 7,111 2)'));
|
insert into figures (name, way) values ('inflection-1',ST_GeomFromText('LINESTRING(110 24,114 20,133 20,145 15,145 0,136 5,123 7,114 7,111 2)'));
|
||||||
|
|
||||||
-- tables are for manual inspection using, say, qgis
|
-- tables are for manual inspection using, say, qgis
|
||||||
@ -53,9 +53,16 @@ declare
|
|||||||
vbends geometry[];
|
vbends geometry[];
|
||||||
vinflections geometry[];
|
vinflections geometry[];
|
||||||
begin
|
begin
|
||||||
|
-- fig5
|
||||||
|
select detect_bends((select way from figures where name='fig5')) into vbends;
|
||||||
|
select fix_gentle_inflections(vbends) into vinflections;
|
||||||
|
perform assert_equals('LINESTRING(0 39,19 52,27 77)', st_astext(vinflections[1]));
|
||||||
|
perform assert_equals('LINESTRING(19 52,27 77,26 104,41 115,49 115,65 103,65 75,53 45)', st_astext(vinflections[2]));
|
||||||
|
perform assert_equals('LINESTRING(65 75,53 45,63 15,91 0)', st_astext(vinflections[3]));
|
||||||
|
|
||||||
|
-- inflections-1, the example in fix_gentle_inflections docstring
|
||||||
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;
|
select fix_gentle_inflections(vbends) into vinflections;
|
||||||
|
|
||||||
perform assert_equals(vbends[1], vinflections[1]); -- unchanged
|
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(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]));
|
||||||
|
Loading…
Reference in New Issue
Block a user