Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#3355 closed defect (fixed)

ST_Intersects() return no result with ST_Segmentize()

Reported by: sdiz Owned by: robe
Priority: blocker Milestone: PostGIS 2.1.9
Component: postgis Version: 2.1.x
Keywords: Cc:

Description

The same linestring return 't' when intersects directly, but 'f' when mixed with ST_Segmentize()

db=>  select
      ST_Intersects(
        'LINESTRING(124.983539 1.419224,91.181596 29.647798)'::geography
      , 'LINESTRING(124.983539 1.419224,91.181596 29.647798)'::geography);
 st_intersects
---------------
 t
(1 row)
db=>   select
       ST_Intersects(
         'LINESTRING(124.983539 1.419224,91.181596 29.647798)'::geography
       , ST_Segmentize('LINESTRING(124.983539 1.419224,91.181596 29.647798)'::geography, 47487290)::geography);
 st_intersects
---------------
 f
(1 row)

The segmented line should be same as input:

db=> select st_astext(ST_Segmentize('LINESTRING(124.983539 1.419224,91.181596 29.647798)'::geography, 47487290)::geography);
                      st_astext
-----------------------------------------------------
 LINESTRING(124.983539 1.419224,91.181596 29.647798)
(1 row)

Version:

 PostgreSQL 9.4.5 on x86_64-unknown-linux-gnu, compiled by gcc (Debian 5.2.1-21) 5.2.1 20151003, 64-bit POSTGIS="2.1.8 r13780" GEOS="3.5.0-CAPI-1.9.0 r4084" PROJ="Rel. 4.9.2, 08 September 2015" GDAL="GDAL 1.11.3, released 2015/09/16" LIBXML="2.9.1" LIBJSON="UNKNOWN" RASTER


Versions of packages postgis depends on:
ii  postgis          2.1.8+dfsg-4
ii  libc6            2.19-22
ii  libgdal1i        1.11.3+dfsg-2
ii  libgeos-c1v5     3.5.0-1
ii  libglib2.0-0     2.46.1-1
ii  libgtk2.0-0      2.24.28-1
ii  libjson-c2       0.11-4
ii  liblwgeom-2.1.8  2.1.8+dfsg-4
ii  libpq5           9.4.5-1
ii  libproj9         4.9.2-1

Change History (14)

comment:1 Changed 2 years ago by sdiz

The WKB is also the same, but "=" say 'f':

db=> WITH X AS
db->   ( SELECT 'LINESTRING(124.983539 1.419224,91.181596 29.647798)'::geography )
db-> SELECT
db->   (SELECT * from X),
db->   ST_Segmentize((SELECT * from X), 47487290),
db->   (SELECT * from X) = ST_Segmentize((SELECT * from X), 47487290);
-[ RECORD 1 ]-+-------------------------------------------------------------------------------------------
geography     | 0102000020E610000002000000CBD58F4DF23E5F40412C9B3924B5F63F6745D4449FCB56400A6AF816D6A53D40
st_segmentize | 0102000020E610000002000000CBD58F4DF23E5F40412C9B3924B5F63F6745D4449FCB56400A6AF816D6A53D40
?column?      | f

comment:2 Changed 2 years ago by sdiz

Milestone: PostGIS 2.2.1PostGIS 2.1.9
Version: 2.2.x2.1.x

comment:3 Changed 2 years ago by robe

Priority: highblocker

Seems to be something amiss with the boxes. When it comes out of ST_Segmentize, it gets a regular old bounding box instead of a gbox.

I'm tested this on both 2.1.8 and 2.2.0

SELECT  ST_Summary(geog_before) As before,  ST_Summary(geog_after) As after, ST_Intersects(geog_before,geog_after)
       FROM (SELECT 
         'LINESTRING(124.983539 1.419224,91.181596 29.647798)'::geography As geog_before
       , ST_Segmentize('LINESTRING(124.983539 1.419224,91.181596 29.647798)'::geography, 47487290) As geog_after) AS f;

outputs:

            before            |            after            | st_intersects
------------------------------+-----------------------------+---------------
 LineString[GS] with 2 points | LineString[S] with 2 points | f

Trying to recast to geography doesn't help because it's already a geography (so guess it doesn't think updating the box is needed, however double casting works:

SELECT  ST_Summary(geog_before) As before,  ST_Summary(geog_after::geometry::geography) As after,
    ST_Intersects(geog_before,geog_after::geometry::geography)
       FROM (SELECT 
         'LINESTRING(124.983539 1.419224,91.181596 29.647798)'::geography As geog_before
       , ST_Segmentize('LINESTRING(124.983539 1.419224,91.181596 29.647798)'::geography, 47487290) As geog_after) AS f;

outputs:

            before            |             after             | st_intersects
------------------------------+-------------------------------+---------------
 LineString[GS] with 2 points | LineString[BGS] with 2 points | t

comment:4 Changed 2 years ago by robe

Owner: changed from pramsey to robe

comment:5 Changed 2 years ago by robe

I fixed for 2.3 at r14346, sorry didn't comment right. Will close once backported fix to 2.2 and 2.1

comment:6 Changed 2 years ago by robe

(In [14347]) ST_Segmentize does not add geography box ST_Intersects fails as result fix for PostGIS 2.2 references #3355

comment:7 Changed 2 years ago by robe

Resolution: fixed
Status: newclosed

(In [14348]) ST_Segmentize does not add geography box ST_Intersects fails as result fix for PostGIS 2.1 closes #3355

comment:8 Changed 2 years ago by robe

(In [14349]) update release notes (include references #3355)

comment:9 Changed 2 years ago by robe

(In [14350]) Don't add unnecessary boxes during geography casting references #3356 (fix for 2.3 branch) references #3355 redo of fix for 2.3 branch for segmentize

comment:10 Changed 2 years ago by robe

(In [14351]) make sure to drop whatever boxes first references #3356 (fix for 2.3 branch) references #3355 redo of fix for 2.3 branch for segmentize

comment:11 Changed 2 years ago by robe

(In [14352]) cleanup whitespace and comments references #3356 (for 2.3 branch) references #3355 (for 2.3 branch for segmentize)

comment:12 Changed 2 years ago by robe

(In [14353]) revert to prior fix for 2.3 to make travis happy references #3355

comment:13 Changed 2 years ago by robe

(In [14362]) back to using geography_gserialized, but don't add box (gserialized does that) (but we must still set geodetic for some ungodly reason) references #3355 references #3356

comment:14 Changed 2 years ago by robe

(In [14372]) _raster_constraint_info_scale gives invalid input syntax, NEWS update

closes #3360 fix for PostGIS 2.2 NEWS update also references #3355

Note: See TracTickets for help on using tickets.