ST_LocateBetween and M values

Julien Pilet julien.pilet at invision.ai
Mon Jul 8 07:12:19 PDT 2024


Hi,


There is some strange behavior with ST_LocateBetween: if used with a 0 
offset, it will preserve M values. Otherwise, it will drop them.

Example:


select ST_AsText(ST_LocateBetween(ST_AddMeasure('LINESTRING (20 180, 50 
20, 100 120, 180 20)', 0, 10), 2,5,0 /* no offset */));

returns

MULTILINESTRING M ((34.84090646030401 100.8484988783786 2,50 20 
4.042879736523244,67.23509268015012 54.47018536030024 5))


but

select ST_AsText(ST_LocateBetween(ST_AddMeasure('LINESTRING (20 180, 50 
20, 100 120, 180 20)', 0, 10), 2,5,1 /* non-zero offset */));

returns

MULTILINESTRING((35.823778647238335 101.03278741342879,50.43502803016365 
23.106124037827087,66.3406654891502 54.9173989558002))


The correct behavior is to keep M values. Is that a bug?

What about changing the documentation example on 
https://postgis.net/docs/ST_LocateBetween.html to drop the offset?


Regards,

Julien Pilet




More information about the postgis-users mailing list