#4025 closed defect (fixed)
Bugs in the functions ST_ClosestPointOfApproach, ST_DistanceCPA, and ST_CPAWithin
Reported by: | ezimanyi | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 2.3.7 |
Component: | postgis | Version: | 2.4.x |
Keywords: | ST_ClosestPointOfApproach, ST_DistanceCPA, ST_CPAWithin | Cc: |
Description
I have found bugs in the three PostGIS functions providing temporal support, that is ST_ClosestPointOfApproach, ST_DistanceCPA, ST_CPAWithin. In the examples below, the M values of the geometries keep the timestamps encoded in epoch, that is, in seconds since 1970-01-01.
select to_timestamp(ST_ClosestPointOfApproach( geometry 'LINESTRING M ( 3002640.82925984 5833770.09678249 1180471354.482, 3003084.56741608 5833866.22147656 1180471411.791, 3003325.8165722 5833942.66399188 1180471442.914, 3003634.9521919 5834039.57644606 1180471482.436, 3003701.57229565 5833872.50949516 1180471494.55)', geometry 'LINESTRING M ( 2996311.19255982 5844593.73486637 1180471513.163, 2996310.72190852 5844712.60937002 1180471523.37, 2996311.81673704 5844916.90864168 1180471541.171)' )); -- "2007-05-29 20:43:44+00"
The two geometries do not intersect in the time dimension as can be seen next.
select tstzrange(to_timestamp(1180471354.482), to_timestamp(1180471494.55)) as r1, tstzrange(to_timestamp(1180471513.163), to_timestamp(1180471541.171)) as r2, tstzrange(to_timestamp(1180471354.482), to_timestamp(1180471494.55)) * tstzrange(to_timestamp(1180471513.163), to_timestamp(1180471541.171)) as intersection -- "["2007-05-29 20:42:34.482+00","2007-05-29 20:44:54.55+00")"; -- "["2007-05-29 20:45:13.163+00","2007-05-29 20:45:41.171+00")"; -- "empty"
select ST_DistanceCPA ( geometry 'LINESTRING M ( 3002640.82925984 5833770.09678249 1180471354.482, 3003084.56741608 5833866.22147656 1180471411.791, 3003325.8165722 5833942.66399188 1180471442.914, 3003634.9521919 5834039.57644606 1180471482.436, 3003701.57229565 5833872.50949516 1180471494.55)', geometry 'LINESTRING M ( 2996311.19255982 5844593.73486637 1180471513.163, 2996310.72190852 5844712.60937002 1180471523.37, 2996311.81673704 5844916.90864168 1180471541.171)' ); -- 1.84467435239537e+19
Again, the two geometries do not intersect in the time dimension as can be seen next.
select tstzrange(to_timestamp(1180471354.482), to_timestamp(1180471494.55)) as r1, tstzrange(to_timestamp(1180471513.163), to_timestamp(1180471541.171)) as r2, tstzrange(to_timestamp(1180471354.482), to_timestamp(1180471494.55)) * tstzrange(to_timestamp(1180471513.163), to_timestamp(1180471541.171)) as intersection -- "["2007-05-29 20:42:34.482+00","2007-05-29 20:44:54.55+00")"; -- "["2007-05-29 20:45:13.163+00","2007-05-29 20:45:41.171+00")"; -- "empty"
Another example that raises an error
select st_distanceCPA( geometry 'LINESTRING M ( 2997192.88890412 5839689.91506735 1180427687.535, 2985681.00213108 5848959.94022801 1180428894.461, 2985654.50641456 5848965.14626724 1180428897.729)', geometry 'LINESTRING M ( 3010311.09650771 5836055.09743228 1180426478.189, 2997990.4548773 5837170.57877078 1180427568.652, 2997958.79103681 5837131.44898043 1180427572.06)' ) ERROR: Could not find point with M=4.85636e-33 on first geom select tstzrange(to_timestamp(1180427687.535), to_timestamp(1180428897.729)) as r1, tstzrange(to_timestamp(1180426478.189), to_timestamp(1180427572.06)) as r2, tstzrange(to_timestamp(1180427687.535), to_timestamp(1180428897.729)) * tstzrange(to_timestamp(1180426478.189), to_timestamp(1180427572.06)) as intersection -- "["2007-05-29 08:34:47.535+00","2007-05-29 08:54:57.729+00")"; -- "["2007-05-29 08:14:38.189+00","2007-05-29 08:32:52.06+00")"; -- "empty"
Finally, an example where the function raises a warning.
select st_cpawithin( geometry 'LINESTRING M ( 3019128.43134286 5840247.67862383 1180456071.042, 3019119.61305787 5840246.74066617 1180456073.042, 2996737.82023413 5844599.06195388 1180457771.512, 2996737.59384604 5844601.28272594 1180457771.789)', geometry 'LINESTRING M ( 3009712.72081161 5845603.63178027 1180455259.727, 3005699.98574744 5843414.54803783 1180455707.126, 3005620.80433525 5839623.27707574 1180456050.83, 3005625.01275697 5839609.12408978 1180456052.609)', 10); NOTICE: Could not find point with M=4.68292e-310 on first geom
Change History (7)
comment:1 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:5 by , 7 years ago
I just received an e-mail from ezimanyi who reported this bug that he cannot edit this ticket, so I am posting something here to test.
comment:6 by , 7 years ago
Milestone: | PostGIS 2.4.4 → PostGIS 2.3.7 |
---|
In 16419: