Opened 4 years ago

Closed 4 years ago

#4696 closed defect (wontfix)

ST_LocateAlong returns EMPTY geom for certain terminal measures

Reported by: pauldzy Owned by: pramsey
Priority: medium Milestone: PostGIS 2.5.5
Component: postgis Version: 2.5.x -- EOL
Keywords: ST_LocateAlong LRS Cc:

Description

POSTGIS="2.5.2 r17328" [EXTENSION] PGSQL="110" GEOS="3.7.0-CAPI-1.11.0 673b9939" PROJ="Rel. 5.2.0, September 15th, 2018" GDAL="GDAL 2.3.1, released 2018/06/22" LIBXML="2.9.1" LIBJSON="0.12" LIBPROTOBUF="1.3.0" RASTER

I suspect this is related to floats within the measure code as it just goes away if the geometry is "rinsed" by casting it to text and back.

SELECT
 ST_IsValid(a.rawewkb) AS raw_valid
,ST_M(ST_StartPoint(a.rawewkb)) AS raw_startM
,ST_M(ST_Endpoint(a.rawewkb)) AS raw_endM
,ST_AsEWKT(ST_LocateAlong(a.rawewkb,30.46338)) AS raw_locatealong
,ST_IsValid(a.rawewkb) AS rinsed_valid
,ST_M(ST_StartPoint(a.rawewkb)) AS rinsed_startM
,ST_M(ST_Endpoint(a.rawewkb)) AS rinsed_endM
,ST_AsEWKT(ST_LocateAlong(a.rinsed,30.46338)) AS rinsed_locate
FROM (
   SELECT
	aa.rawewkb
   ,ST_AsEWKT(aa.rawewkb) AS txted
   ,ST_GeomFromEWKT(ST_AsEWKT(aa.rawewkb)) AS rinsed
   FROM (
      SELECT
	  ST_GeomFromEWKB(decode('AQIAAGDOEwAAAwAAAEei4br9RCdBbmmOozvgLEHXnlkSoHY+QBCLlwkIRSdBIlcDZybgLEE6r7FLVO86QBDucKJ2RSdBsmULZJjfLEEAAAAAAAAAAA==','base64')) AS rawewkb
   ) aa
) a;

On my 2.5.2 instance I receive

  • true, 30.46338, 0, SRID=5070;MULTIPOINTM EMPTY,
  • true, 30.46338, 0, SRID=5070;MULTIPOINTM(762494.8650027 946205.819445891 30.46338)

with of course the rinsed results being the desired output.

Thanks,

Paul

Change History (1)

comment:1 by robe, 4 years ago

Milestone: PostGIS 2.5.5
Resolution: wontfix
Status: newclosed

You have a mistake in your query you are not outputting rinsed but calling it rinsed.

It should be

SELECT
 ST_IsValid(a.rawewkb) AS raw_valid
,ST_M(ST_StartPoint(a.rawewkb)) AS raw_startM
,ST_M(ST_Endpoint(a.rawewkb)) AS raw_endM
,ST_AsEWKT(ST_LocateAlong(a.rawewkb,30.46338)) AS raw_locatealong
,ST_IsValid(a.rawewkb) AS rinsed_valid
,ST_M(ST_StartPoint(a.rinsed)) AS rinsed_startM
,ST_M(ST_Endpoint(a.rinsed)) AS rinsed_endM
,ST_AsEWKT(ST_LocateAlong(a.rinsed,30.46338)) AS rinsed_locate
FROM (
   SELECT
	aa.rawewkb
   ,ST_AsEWKT(aa.rawewkb) AS txted
   ,ST_GeomFromEWKT(ST_AsEWKT(aa.rawewkb)) AS rinsed
   FROM (
      SELECT
	  ST_GeomFromEWKB(decode('AQIAAGDOEwAAAwAAAEei4br9RCdBbmmOozvgLEHXnlkSoHY+QBCLlwkIRSdBIlcDZybgLEE6r7FLVO86QBDucKJ2RSdBsmULZJjfLEEAAAAAAAAAAA==','base64')) AS rawewkb
   ) aa
) a;

When I run these I get

Original: true, 30.463379999999997, 0, SRID=5070;MULTIPOINTM EMPTY
Rinsed: true, 30.46338, 0, SRID=5070;MULTIPOINTM(762494.8650027 946205.819445891 30.46338)

The ST_AsText is causing your geometry to be rounded, so it's not the same geometry as you had to start with. Sadly this is just the reality of not having a tolerance in our system. That might come in the future.

So I'm going to mark this as a won't fix.

Note: See TracTickets for help on using tickets.