View Ticket
Not logged in
Ticket Hash: aab7451665c2eb5db3dad24ddcd9fed1314a2ee4
Title: ST_Line_Substring bring unexpected results
Status: Fixed Type: Code_Defect
Severity: Critical Priority: Immediate
Subsystem: Resolution: Fixed
Last Modified: 2016-05-10 04:34:42
Version Found In: 4.4.0-RC0
User Comments:
anonymous added on 2016-05-03 04:18:27:

After updating the fossil version yesterday, together with the latest git version of librttopo,
but without updating GEOS (3.5.0-CAPI-1.9.0 r4084),
my first task of the day failed:

Goal was to split a LINESTRING of 9 points (from the first to the 6th and the 6th to the 9th).
The expected result of ST_Line_Substring was therefore 6 points.
The returned result was 2 points (the first and 6th).
The returned percentage looks correct (0.167243)
Replacing '6' with '9' (thus the whole LINESTRING)
also returns 2 points (first and last) showing (as percentage) 1.0

A few days ago, this worked as expected, so I assume that something in the the updates has effected this GEOS function.


Sample sql:
----
SELECT DateTime('now'),'expected result: first 6 points of 9';
----
SELECT
 GeomFromEWKT('SRID=3068;LINESTRING(25411.96409290977 18594.30407870813,25417.48376372321 18611.01284083039,25422.12080434181 18617.71853584805,25427.29711753031 18623.90508847908,25434.07615000556 18629.32802607159,25445.61804479478 18634.84155566448,25613.85104781448 18671.17029177012,25676.10779529453 18670.55343019976,25716.7955875752 18674.99558137356)') AS input_geom,
 ST_Line_Locate_Point
 (
  GeomFromEWKT('SRID=3068;LINESTRING(25411.96409290977 18594.30407870813,25417.48376372321 18611.01284083039,25422.12080434181 18617.71853584805,25427.29711753031 18623.90508847908,25434.07615000556 18629.32802607159,25445.61804479478 18634.84155566448,25613.85104781448 18671.17029177012,25676.10779529453 18670.55343019976,25716.7955875752 18674.99558137356)') ,
  ST_PointN(GeomFromEWKT('SRID=3068;LINESTRING(25411.96409290977 18594.30407870813,25417.48376372321 18611.01284083039,25422.12080434181 18617.71853584805,25427.29711753031 18623.90508847908,25434.07615000556 18629.32802607159,25445.61804479478 18634.84155566448,25613.85104781448 18671.17029177012,25676.10779529453 18670.55343019976,25716.7955875752 18674.99558137356)') ,6) 
  ) AS procent_to,
 SanitizeGeometry
 (
  ST_Line_Substring
  (
   GeomFromEWKT('SRID=3068;LINESTRING(25411.96409290977 18594.30407870813,25417.48376372321 18611.01284083039,25422.12080434181 18617.71853584805,25427.29711753031 18623.90508847908,25434.07615000556 18629.32802607159,25445.61804479478 18634.84155566448,25613.85104781448 18671.17029177012,25676.10779529453 18670.55343019976,25716.7955875752 18674.99558137356)'),
   0,
   ST_Line_Locate_Point
   (
    GeomFromEWKT('SRID=3068;LINESTRING(25411.96409290977 18594.30407870813,25417.48376372321 18611.01284083039,25422.12080434181 18617.71853584805,25427.29711753031 18623.90508847908,25434.07615000556 18629.32802607159,25445.61804479478 18634.84155566448,25613.85104781448 18671.17029177012,25676.10779529453 18670.55343019976,25716.7955875752 18674.99558137356)') ,
    ST_PointN(GeomFromEWKT('SRID=3068;LINESTRING(25411.96409290977 18594.30407870813,25417.48376372321 18611.01284083039,25422.12080434181 18617.71853584805,25427.29711753031 18623.90508847908,25434.07615000556 18629.32802607159,25445.61804479478 18634.84155566448,25613.85104781448 18671.17029177012,25676.10779529453 18670.55343019976,25716.7955875752 18674.99558137356)') ,6) 
   )
  )
 ) AS output_geom
;
---
SELECT DateTime('now'),'returned result: 2 points, (1st and 6th) ';
---
-- LINESTRING(25411.964093 18594.304079, 25445.618045 18634.841556)
--> from 1 to 9:
-- LINESTRING(25411.964093 18594.304079, 25716.795588 18674.995581)

Could you create an account with the same user-name and password as for the RasterLite2 project?
Mark


anonymous added on 2016-05-03 04:44:31:

Adding a version number for librttopo, after GEOS, might be useful:

PROJ.4 version ......: Rel. 4.8.0, 6 March 2012
GEOS version ........: 3.5.0-CAPI-1.9.0 r4084
ttopo version
TARGET CPU ..........: x86_64-linux-gnu


sandro added on 2016-05-09 10:23:25:
sorry, my fault: there was a really stupid bug (misplaced variable declarations) inadvertently introduced on 2016-04-17 by commit 7031382b2b.
this caused incorrect distance calculations and completely messed up the function as a whole.

thanks for noticing and reporting,
Sandro

mj10777 added on 2016-05-10 04:34:42:
Test show this now working properly.

The question remains about adding a version number for librttopo.