Opened 2 years ago
Closed 2 years ago
#5258 closed defect (duplicate)
Linestring empty when intersecting vertical line with a square
Reported by: | cactusbone | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 3.3.2 |
Component: | postgis | Version: | 3.2.x |
Keywords: | ST_Intersection | Cc: | cactusbone |
Description
Hello, I've stumbled on something weird :
Using
SELECT ST_Astext( ST_Intersection( ST_GeomFromText('LINESTRING(1 1, 1 2)'), ST_GeomFromText('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))') ) )
returns LINESTRING EMPTY
on PostGIS 3.2 ("POSTGIS=""3.2.3 2f97b6c"" [EXTENSION] PGSQL=""140"" GEOS=""3.9.0-CAPI-1.16.2"" SFCGAL=""1.3.8"" PROJ=""7.2.1"" GDAL=""GDAL 3.2.2, released 2021/03/05"" LIBXML=""2.9.10"" LIBJSON=""0.15"" LIBPROTOBUF=""1.3.3"" WAGYU=""0.5.0 (Internal)"" RASTER"
or "POSTGIS=""3.2.1 5fae8e5"" [EXTENSION] PGSQL=""140"" GEOS=""3.9.0-CAPI-1.16.2"" SFCGAL=""1.3.8"" PROJ=""7.2.1"" GDAL=""GDAL 3.2.2, released 2021/03/05"" LIBXML=""2.9.10"" LIBJSON=""0.15"" LIBPROTOBUF=""1.3.3"" WAGYU=""0.5.0 (Internal)"" TOPOLOGY RASTER"
)
It works on PostGIS 2.5 ("POSTGIS=""2.5.1 r17027"" [EXTENSION] PGSQL=""110"" GEOS=""3.7.1-CAPI-1.11.1 27a5e771"" SFCGAL=""1.3.6"" PROJ=""Rel. 5.2.0, September 15th, 2018"" GDAL=""GDAL 2.4.0, released 2018/12/14"" LIBXML=""2.9.4"" LIBJSON=""0.12.1"" LIBPROTOBUF=""1.2.1"" TOPOLOGY RASTER"
)
It's the same with horizontal lines
SELECT ST_Astext( ST_Intersection( ST_GeomFromText('LINESTRING(1 1, 2 1)'), ST_GeomFromText('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))') ) )
However it works when the line is neither horizontal nor vertical or when it touches the intersection
Queries that work:
SELECT ST_Astext(ST_Intersection( ST_GeomFromText('LINESTRING(1 1, 2 2)'), ST_GeomFromText('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))') ))
SELECT ST_Astext(ST_Intersection( ST_GeomFromText('LINESTRING(1 1, 2 1.000000000001)'), ST_GeomFromText('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))') ))
SELECT ST_Astext( ST_Intersection( ST_GeomFromText('LINESTRING(0 0, 0 1)'), ST_GeomFromText('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))') ) )
Change History (2)
comment:1 by , 2 years ago
comment:2 by , 2 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
This is a GEOS bug that was fixed in recent versions (3.9.1, etc).