Opened 6 years ago
Closed 6 years ago
#4314 closed defect (fixed)
ST_AsMVTGeom: IllegalArgumentException
Reported by: | Algunenano | Owned by: | Algunenano |
---|---|---|---|
Priority: | high | Milestone: | PostGIS 2.5.2 |
Component: | postgis | Version: | 2.5.x -- EOL |
Keywords: | Cc: |
Description
# SELECT ST_AsMVTGeom( 'SRID=3857;MULTIPOLYGON(((-8230700.44460474 4970098.60762691,-8230694.76395068 4970080.40480045,-8230692.98226063 4970074.69572152,-8230702.2389602 4970071.78449542,-8230709.99536139 4970096.63875167,-8230700.73864062 4970099.5499925,-8230700.44460474 4970098.60762691)))'::geometry, 'SRID=3857;POLYGON((-8257645.03970416 5009377.08569731,-8257645.03970416 4970241.3272153,-8218509.28122215 4970241.3272153,-8218509.28122215 5009377.08569731,-8257645.03970416 5009377.08569731))'::geometry, 2048, 8, true ) as the_geom_webmercator; ERROR: lwgeom_clip_by_rect: GEOS Error: IllegalArgumentException: Invalid number of points in LinearRing found 3 - must be 0 or >= 4
I think this was introduced in #4289 so it looks like one of the functions that modify the geometry (lwgeom_remove_repeated_points_in_place
, lwgeom_simplify_in_place
, lwgeom_affine
and lwgeom_grid_in_place
) might be producing an invalid ring (or I'm not checking it's output correctly). Note that in the case where the polygon disappeared because of it, MVTGeom should return NULL, not an exception.
Change History (6)
comment:2 by , 6 years ago
According to the manual for ST_ClipByBox2D:
Topologically invalid input geometries do not result in exceptions being thrown.
On the other hand lwgeom_clip_by_rect
might call GEOS_FAIL
and GEOS_FREE_AND_FAIL
, which calls lwerror
throwing an exception.
I think the proper action here would be to call lwdebug
or lwnotice
instead and return NULL.
comment:4 by , 6 years ago
Milestone: | PostGIS 2.4.7 → PostGIS 2.5.2 |
---|---|
Version: | 2.4.x → 2.5.x |
This only affects 2.5, which is when these macros were introduced to simplify the error handling.
I've extracted the geometry and clip box that was used to call clip_by_rect:
` # SELECT ST_ClipByBox2D('POLYGON((1410 2055, 1410 2056, 1410 2057, 1410 2055))'::geometry, ST_MakeEnvelope(-8.000000, -8.000000, 2056.000000, 2056.000000)); ERROR: lwgeom_clip_by_rect: GEOS Error: IllegalArgumentException: Invalid number of points in LinearRing found 3 - must be 0 or >= 4 Time: 0.654 ms
`
The geometry has 4 points but after simplification they've fallen into a Line. I'm not sure yet who is removing one of the points.