# HG changeset patch # User Tom Gottfried # Date 1551797045 -3600 # Node ID 79f4a20e31c2f263edcd0b24b29f45aef46a3e83 # Parent e958104be9a9bfaeea29800fd2e5cddfab4366ac Introduce distance limit up to which axis linestrings are connected Before, e.g. a linestring representing a tributary with its mouth in the middle of another linestring, had been connected to the end of the latter. diff -r e958104be9a9 -r 79f4a20e31c2 schema/isrs_functions.sql --- a/schema/isrs_functions.sql Tue Mar 05 09:59:06 2019 +0100 +++ b/schema/isrs_functions.sql Tue Mar 05 15:44:05 2019 +0100 @@ -25,7 +25,11 @@ -- Uses the table waterway.distance_marks_virtual to map ISRS location codes -- to their geo-location. -- Distance marks are assumed to be near the axis. -CREATE OR REPLACE FUNCTION ISRSrange_axis(stretch isrsrange) RETURNS geometry +CREATE OR REPLACE FUNCTION ISRSrange_axis( + stretch isrsrange, + tolerance float + -- in m, up to which linestrings will be connected at their boundary +) RETURNS geometry AS $$ WITH RECURSIVE -- Get coordinates of location codes @@ -76,6 +80,8 @@ (SELECT ST_Collect(points.geom) AS pts FROM points) AS points WHERE id <> ALL(refids) + AND ST_DWithin( + ST_Boundary(refgeom), ST_Boundary(geom), tolerance) AND NOT ST_Covers(ST_Buffer(refgeom, 0.0001), points.pts) ORDER BY ST_Distance(ST_Boundary(refgeom), ST_Boundary(geom)) FETCH FIRST ROW ONLY)), @@ -118,7 +124,7 @@ AS $$ WITH axis_substring AS ( - SELECT ISRSrange_axis(stretch) AS line), + SELECT ISRSrange_axis(stretch, 5) AS line), utm_zone AS ( SELECT best_utm(stretch) AS z), area_subset AS ( diff -r e958104be9a9 -r 79f4a20e31c2 schema/tap_tests_data.sql --- a/schema/tap_tests_data.sql Tue Mar 05 09:59:06 2019 +0100 +++ b/schema/tap_tests_data.sql Tue Mar 05 15:44:05 2019 +0100 @@ -94,7 +94,7 @@ ST_SetSRID('LINESTRING(0.5 0.5, 1 1)'::geometry, 4326), 'testriver' ), ( - ST_SetSRID('LINESTRING(1.5 0.1, 2 0)'::geometry, 4326), + ST_SetSRID('LINESTRING(1.5 0.00001, 2 0)'::geometry, 4326), 'testriver' );