Commit aa09c3ea authored by Regina Obe's avatar Regina Obe

Get rid of assert causing ST_3DMakeBox to crash

Change ST_3DMakeBox to throw an error when fed empty points instead of returning a philosophical answer to a stupid question
Change ST_MakeBox2D to return a more meaningful error instead waiting to fail when asking what is x of an empty point?
Closes #4331 for PostGIS 3.0

git-svn-id: http://svn.osgeo.org/postgis/trunk@17281 b70326c6-7e19-0410-871a-916f4a2858ee
parent 5d73dc5a
Pipeline #49183841 failed with stage
in 5 minutes and 10 seconds
......@@ -19,6 +19,7 @@ PostGIS 3.0.0
and postgis.backend switch (Darafei Praliaskouski)
- #4267, Enable Proj 6 deprecated APIs (Darafei Praliaskouski, Raúl Marín)
- #4268, Bump minimum SFCGAL version to 1.3.1 (Darafei Praliaskouski)
- #4331, ST_3DMakeBox now returns error instead of a miniscule box (Regina Obe)
* New Features *
- #2902, postgis_geos_noop (Sandro Santilli)
......
......@@ -219,7 +219,7 @@ getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *op)
return 0;
}
assert(n < pa->npoints);
//assert(n < pa->npoints); --causes point emtpy/point empty to crash
if ( n>=pa->npoints )
{
lwnotice("%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->npoints);
......
......@@ -543,7 +543,12 @@ Datum BOX2D_construct(PG_FUNCTION_ARGS)
if ( (minpoint->type != POINTTYPE) || (maxpoint->type != POINTTYPE) )
{
elog(ERROR, "GBOX_construct: arguments must be points");
elog(ERROR, "BOX2D_construct: arguments must be points");
PG_RETURN_NULL();
}
if (lwgeom_is_empty(minpoint) || lwgeom_is_empty(maxpoint) ){
elog(ERROR, "BOX2D_construct: args can not be empty points");
PG_RETURN_NULL();
}
......
......@@ -565,6 +565,11 @@ Datum BOX3D_construct(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
if (lwgeom_is_empty(minpoint) || lwgeom_is_empty(maxpoint) ){
elog(ERROR, "BOX3D_construct: args can not be empty points");
PG_RETURN_NULL();
}
error_if_srid_mismatch(minpoint->srid, maxpoint->srid);
getPoint3dz_p(((LWPOINT *)minpoint)->point, 0, &minp);
......
......@@ -1125,6 +1125,10 @@ ST_Disjoint(ST_GeneratePoints(g, 1000, 12345), ST_GeneratePoints(g, 1000)),
ST_Distance(ST_GeometryN(ST_GeneratePoints(g, 1000, 12345), 1000), 'POINT(0.801167838758 0.345281131175)'::geometry) < 1e-11
FROM (SELECT 'POLYGON((0 0,1 0,1 1,0 1,0 0))'::geometry AS g) AS f;
-- #4331
SELECT '#4304a', ST_3DMakeBox(ST_GeomFromText('POINT EMPTY',4326), ST_GeomFromText('POINT EMPTY',4326)) IS NULL;
SELECT '#4304b', ST_MakeBox2D(ST_GeomFromText('POINT EMPTY',4326), ST_GeomFromText('POINT EMPTY',4326)) IS NULL;
-- Clean up
DELETE FROM spatial_ref_sys;
......
......@@ -340,4 +340,6 @@ ERROR: lwgeom_union: GEOS Error: TopologyException: Input geom 0 is invalid: Se
NOTICE: table "bug_4144_table" does not exist, skipping
#4299|t
#4304|t|t|t|t
ERROR: BOX3D_construct: args can not be empty points
ERROR: BOX2D_construct: args can not be empty points
#4176|t
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment