[postgis-tickets] [PostGIS] #4765: ST_ClipByBox2D: Incorrect clipping of lines
PostGIS
trac at osgeo.org
Tue Oct 13 09:54:03 PDT 2020
#4765: ST_ClipByBox2D: Incorrect clipping of lines
------------------------+---------------------------
Reporter: Algunenano | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 3.0.3
Component: postgis | Version: master
Keywords: |
------------------------+---------------------------
It seems there is some kind of bug when clipping lines that are around the
borders of the bbox in ST_ClipByBox2D.
Query:
{{{
WITH geom AS
(
SELECT 'LINESTRING(0 0,0 10, 10 10,1 1)'::geometry as geom
UNION ALL
SELECT 'LINESTRING(0 0, 0 15, 15 15, 1 1)'::geometry as geom
),
box AS
(
SELECT ST_MakeEnvelope(0,0,10,10) AS box
)
SELECT
ST_AsText(geom) as geom,
ST_AsText(box::box2d) as box,
ST_AsText(ST_ClipByBox2D(geom, box)) as clip,
ST_AsText(ST_Intersection(geom, box)) as intersection
FROM geom, box
}}}
Output:
{{{
geom | box |
clip | intersection
--------------------------------+------------------------------------+--------------------------------+------------------------------------------------------
LINESTRING(0 0,0 10,10 10,1 1) | POLYGON((0 0,0 10,10 10,10 0,0 0)) |
LINESTRING(0 0,0 10,10 10,1 1) | MULTILINESTRING((0 0,0 10),(0 10,10
10),(10 10,1 1))
LINESTRING(0 0,0 15,15 15,1 1) | POLYGON((0 0,0 10,10 10,10 0,0 0)) |
LINESTRING(10 10,1 1) | MULTILINESTRING((0 0,0 10),(10 10,1 1))
(2 rows)
}}}
In the first case things look normal, both when you clip using
ST_Intersect or ST_ClipByBox2D, but in the second case the ST_ClipByBox2D
output is clearly wrong as it's missing a whole lien, while
ST_Intersection is returning a valid value.
I haven't reproduced the issue with polygons, just lines.
It's likely a GEOS issue, but I haven't tried to isolate it yet to report
it there if necessary. Tested with Postgis 3.0 and master, GEOS 3.8.2 and
master (with and without overlayNG).
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4765>
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