[postgis-tickets] [PostGIS] #5258: Linestring empty when intersecting vertical line with a square
PostGIS
trac at osgeo.org
Thu Oct 13 09:51:00 PDT 2022
#5258: Linestring empty when intersecting vertical line with a square
-----------------------------+---------------------------
Reporter: cactusbone | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 3.3.2
Component: postgis | Version: 3.2.x
Keywords: ST_Intersection |
-----------------------------+---------------------------
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))')
)
)
}}}
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5258>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list