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
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)
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);
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();
}
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);
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;
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