diff --git a/liblwgeom/g_serialized.c b/liblwgeom/g_serialized.c index 4e02933e5a7..3001a4ce3fa 100644 --- a/liblwgeom/g_serialized.c +++ b/liblwgeom/g_serialized.c @@ -126,7 +126,7 @@ char* gserialized_to_string(const GSERIALIZED *g) return lwgeom_to_wkt(lwgeom_from_gserialized(g), WKT_ISO, 12, 0); } -int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *gbox) +int gserialized_read_gbox_p(const GSERIALIZED *g, GBOX *gbox) { /* Null input! */ @@ -135,6 +135,7 @@ int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *gbox) /* Initialize the flags on the box */ gbox->flags = g->flags; + /* Has pre-calculated box */ if ( FLAGS_GET_BBOX(g->flags) ) { int i = 0; @@ -164,10 +165,75 @@ int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *gbox) } return LW_SUCCESS; } - else + + /* No pre-calculated box, but for cartesian entries we can do some magic */ + if ( ! FLAGS_GET_GEODETIC(g->flags) ) { - return LW_FAILURE; + uint32_t type = gserialized_get_type(g); + /* Boxes of points are easy peasy */ + if ( type == POINTTYPE ) + { + int i = 1; /* Start past */ + double *dptr = (double*)(g->data); + gbox->xmin = gbox->xmax = dptr[i++]; + gbox->ymin = gbox->ymax = dptr[i++]; + if ( FLAGS_GET_Z(g->flags) ) + { + gbox->zmin = gbox->zmax = dptr[i++]; + } + if ( FLAGS_GET_M(g->flags) ) + { + gbox->mmin = gbox->mmax = dptr[i++]; + } + return LW_SUCCESS; + } + /* We can calculate the box of a two-point cartesian line trivially */ + else if ( type == LINETYPE ) + { + int ndims = FLAGS_NDIMS(g->flags); + int i = 0; /* Start past */ + double *dptr = (double*)(g->data); + int *iptr = (int*)(g->data); + int npoints = iptr[1]; /* Read the npoints */ + + /* This only works with 2-point lines */ + if ( npoints != 2 ) + return LW_FAILURE; + + /* Advance to X */ + i++; + gbox->xmin = FP_MIN(dptr[i], dptr[i+ndims]); + gbox->xmax = FP_MAX(dptr[i], dptr[i+ndims]); + + /* Advance to Y */ + i++; + gbox->ymin = FP_MIN(dptr[i], dptr[i+ndims]); + gbox->ymax = FP_MAX(dptr[i], dptr[i+ndims]); + + if ( FLAGS_GET_Z(g->flags) ) + { + /* Advance to Z */ + i++; + gbox->zmin = FP_MIN(dptr[i], dptr[i+ndims]); + gbox->zmax = FP_MAX(dptr[i], dptr[i+ndims]); + } + if ( FLAGS_GET_M(g->flags) ) + { + /* Advance to M */ + i++; + gbox->zmin = FP_MIN(dptr[i], dptr[i+ndims]); + gbox->zmax = FP_MAX(dptr[i], dptr[i+ndims]); + } + return LW_SUCCESS; + } + /* We could also do single-entry multi-points */ + else if ( type == MULTIPOINTTYPE ) + { + /* TODO: Make this actually happen */ + return LW_FAILURE; + } } + return LW_FAILURE; } @@ -1086,7 +1152,7 @@ LWGEOM* lwgeom_from_gserialized(const GSERIALIZED *g) lwgeom->type = g_type; lwgeom->flags = g_flags; - if ( gserialized_get_gbox_p(g, &bbox) == LW_SUCCESS ) + if ( gserialized_read_gbox_p(g, &bbox) == LW_SUCCESS ) { lwgeom->bbox = gbox_copy(&bbox); } diff --git a/liblwgeom/liblwgeom.h.in b/liblwgeom/liblwgeom.h.in index a9e415c67bb..b53af4609bc 100644 --- a/liblwgeom/liblwgeom.h.in +++ b/liblwgeom/liblwgeom.h.in @@ -1551,7 +1551,7 @@ extern LWGEOM* lwgeom_from_gserialized(const GSERIALIZED *g); * Pull a #GBOX from the header of a #GSERIALIZED, if one is available. If * it is not, return LW_FAILURE. */ -extern int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *gbox); +extern int gserialized_read_gbox_p(const GSERIALIZED *g, GBOX *gbox); /** diff --git a/libpgcommon/lwgeom_pg.c b/libpgcommon/lwgeom_pg.c index 65153bbb648..0438eb2c900 100644 --- a/libpgcommon/lwgeom_pg.c +++ b/libpgcommon/lwgeom_pg.c @@ -230,15 +230,15 @@ GSERIALIZED* geometry_serialize(LWGEOM *lwgeom) return g; } -int pglwgeom_getbox2d_p(const GSERIALIZED *geom, GBOX *box) +int gserialized_get_gbox_p(const GSERIALIZED *geom, GBOX *box) { LWGEOM *lwgeom; - int ret = gserialized_get_gbox_p(geom, box); + int ret = gserialized_read_gbox_p(geom, box); if ( LW_FAILURE == ret ) { /* See http://trac.osgeo.org/postgis/ticket/1023 */ lwgeom = lwgeom_from_gserialized(geom); ret = lwgeom_calculate_gbox(lwgeom, box); - lwgeom_free(lwgeom); + lwgeom_free(lwgeom); } return ret; } diff --git a/libpgcommon/lwgeom_pg.h b/libpgcommon/lwgeom_pg.h index 5ae1065994e..2c99607a5fe 100644 --- a/libpgcommon/lwgeom_pg.h +++ b/libpgcommon/lwgeom_pg.h @@ -108,7 +108,7 @@ GSERIALIZED* geography_serialize(LWGEOM *lwgeom); * Use a cached bbox if available, compute it otherwise. * Return LW_FALSE if the geometry has no bounding box (ie: is empty). */ -extern int pglwgeom_getbox2d_p(const GSERIALIZED *geom, GBOX *box); +extern int gserialized_get_gbox_p(const GSERIALIZED *geom, GBOX *box); /** * Convert cstrings (null-terminated byte array) to textp pointers diff --git a/postgis/geography_measurement.c b/postgis/geography_measurement.c index f46e57a08c6..4f0ac689875 100644 --- a/postgis/geography_measurement.c +++ b/postgis/geography_measurement.c @@ -401,7 +401,7 @@ Datum geography_point_outside(PG_FUNCTION_ARGS) g = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); /* We need the bounding box to get an outside point for area algorithm */ - if ( gserialized_get_gbox_p(g, &gbox) == LW_FAILURE ) + if ( gserialized_read_gbox_p(g, &gbox) == LW_FAILURE ) { LWGEOM *lwgeom = lwgeom_from_gserialized(g); POSTGIS_DEBUGF(4,"unable to read gbox from gserialized, calculating from lwgeom (%p)", lwgeom); diff --git a/postgis/lwgeom_box.c b/postgis/lwgeom_box.c index f6179458dc3..a0aeaba1d27 100644 --- a/postgis/lwgeom_box.c +++ b/postgis/lwgeom_box.c @@ -380,7 +380,7 @@ Datum BOX2DFLOAT4_combine(PG_FUNCTION_ARGS) { lwgeom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1)); /* empty geom would make getbox2d_p return NULL */ - if ( ! pglwgeom_getbox2d_p(lwgeom, &box) ) PG_RETURN_NULL(); + if ( ! gserialized_get_gbox_p(lwgeom, &box) ) PG_RETURN_NULL(); memcpy(result, &box, sizeof(GBOX)); PG_RETURN_POINTER(result); } @@ -395,7 +395,7 @@ Datum BOX2DFLOAT4_combine(PG_FUNCTION_ARGS) /*combine_bbox(BOX3D, geometry) => union(BOX3D, geometry->bvol) */ lwgeom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1)); - if ( ! pglwgeom_getbox2d_p(lwgeom, &box) ) + if ( ! gserialized_get_gbox_p(lwgeom, &box) ) { /* must be the empty geom */ memcpy(result, (char *)PG_GETARG_DATUM(0), sizeof(GBOX)); diff --git a/postgis/lwgeom_btree.c b/postgis/lwgeom_btree.c index a5236916f40..d2994827ba9 100644 --- a/postgis/lwgeom_btree.c +++ b/postgis/lwgeom_btree.c @@ -51,8 +51,8 @@ Datum lwgeom_lt(PG_FUNCTION_ARGS) POSTGIS_DEBUG(3, "lwgeom_lt passed getSRID test"); - pglwgeom_getbox2d_p(geom1, &box1); - pglwgeom_getbox2d_p(geom2, &box2); + gserialized_get_gbox_p(geom1, &box1); + gserialized_get_gbox_p(geom2, &box2); PG_FREE_IF_COPY(geom1, 0); PG_FREE_IF_COPY(geom2, 1); @@ -105,8 +105,8 @@ Datum lwgeom_le(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } - pglwgeom_getbox2d_p(geom1, &box1); - pglwgeom_getbox2d_p(geom2, &box2); + gserialized_get_gbox_p(geom1, &box1); + gserialized_get_gbox_p(geom2, &box2); PG_FREE_IF_COPY(geom1, 0); PG_FREE_IF_COPY(geom2, 1); @@ -170,8 +170,8 @@ Datum lwgeom_eq(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } - pglwgeom_getbox2d_p(geom1, &box1); - pglwgeom_getbox2d_p(geom2, &box2); + gserialized_get_gbox_p(geom1, &box1); + gserialized_get_gbox_p(geom2, &box2); PG_FREE_IF_COPY(geom1, 0); PG_FREE_IF_COPY(geom2, 1); @@ -207,8 +207,8 @@ Datum lwgeom_ge(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } - pglwgeom_getbox2d_p(geom1, &box1); - pglwgeom_getbox2d_p(geom2, &box2); + gserialized_get_gbox_p(geom1, &box1); + gserialized_get_gbox_p(geom2, &box2); PG_FREE_IF_COPY(geom1, 0); PG_FREE_IF_COPY(geom2, 1); @@ -271,8 +271,8 @@ Datum lwgeom_gt(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } - pglwgeom_getbox2d_p(geom1, &box1); - pglwgeom_getbox2d_p(geom2, &box2); + gserialized_get_gbox_p(geom1, &box1); + gserialized_get_gbox_p(geom2, &box2); PG_FREE_IF_COPY(geom1, 0); PG_FREE_IF_COPY(geom2, 1); @@ -331,8 +331,8 @@ Datum lwgeom_cmp(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } - pglwgeom_getbox2d_p(geom1, &box1); - pglwgeom_getbox2d_p(geom2, &box2); + gserialized_get_gbox_p(geom1, &box1); + gserialized_get_gbox_p(geom2, &box2); PG_FREE_IF_COPY(geom1, 0); PG_FREE_IF_COPY(geom2, 1); diff --git a/postgis/lwgeom_functions_basic.c b/postgis/lwgeom_functions_basic.c index 80d8d11f3ad..daef138da57 100644 --- a/postgis/lwgeom_functions_basic.c +++ b/postgis/lwgeom_functions_basic.c @@ -2402,7 +2402,7 @@ Datum optimistic_overlap(PG_FUNCTION_ARGS) } /*bbox check */ - pglwgeom_getbox2d_p(pg_geom1, &g1_bvol ); + gserialized_get_gbox_p(pg_geom1, &g1_bvol ); g1_bvol.xmin = g1_bvol.xmin - dist; g1_bvol.ymin = g1_bvol.ymin - dist; diff --git a/postgis/lwgeom_geos.c b/postgis/lwgeom_geos.c index 35e89b68298..68d1eb542be 100644 --- a/postgis/lwgeom_geos.c +++ b/postgis/lwgeom_geos.c @@ -816,7 +816,7 @@ Datum convexhull(PG_FUNCTION_ARGS) } /* Copy input bbox if any */ - if ( pglwgeom_getbox2d_p(geom1, &bbox) ) + if ( gserialized_get_gbox_p(geom1, &bbox) ) { /* Force the box to have the same dimensionality as the lwgeom */ bbox.flags = lwout->flags; @@ -1524,7 +1524,7 @@ Datum isvalid(PG_FUNCTION_ARGS) #if POSTGIS_GEOS_VERSION < 33 /* Short circuit and return FALSE if we have infinite coordinates */ /* GEOS 3.3+ is supposed to handle this stuff OK */ - if ( pglwgeom_getbox2d_p(geom1, &box1) ) + if ( gserialized_get_gbox_p(geom1, &box1) ) { if ( isinf(box1.xmax) || isinf(box1.ymax) || isinf(box1.xmin) || isinf(box1.ymin) || isnan(box1.xmax) || isnan(box1.ymax) || isnan(box1.xmin) || isnan(box1.ymin) ) @@ -1588,7 +1588,7 @@ Datum isvalidreason(PG_FUNCTION_ARGS) #if POSTGIS_GEOS_VERSION < 33 /* Short circuit and return if we have infinite coordinates */ /* GEOS 3.3+ is supposed to handle this stuff OK */ - if ( pglwgeom_getbox2d_p(geom, &box) ) + if ( gserialized_get_gbox_p(geom, &box) ) { if ( isinf(box.xmax) || isinf(box.ymax) || isinf(box.xmin) || isinf(box.ymin) || isnan(box.xmax) || isnan(box.ymax) || isnan(box.xmin) || isnan(box.ymin) ) @@ -1767,8 +1767,8 @@ Datum overlaps(PG_FUNCTION_ARGS) * geom1 bounding box we can prematurely return FALSE. * Do the test IFF BOUNDING BOX AVAILABLE. */ - if ( pglwgeom_getbox2d_p(geom1, &box1) && - pglwgeom_getbox2d_p(geom2, &box2) ) + if ( gserialized_get_gbox_p(geom1, &box1) && + gserialized_get_gbox_p(geom2, &box2) ) { if ( box2.xmax < box1.xmin ) PG_RETURN_BOOL(FALSE); if ( box2.xmin > box1.xmax ) PG_RETURN_BOOL(FALSE); @@ -1845,8 +1845,8 @@ Datum contains(PG_FUNCTION_ARGS) ** geom1 bounding box we can prematurely return FALSE. ** Do the test IFF BOUNDING BOX AVAILABLE. */ - if ( pglwgeom_getbox2d_p(geom1, &box1) && - pglwgeom_getbox2d_p(geom2, &box2) ) + if ( gserialized_get_gbox_p(geom1, &box1) && + gserialized_get_gbox_p(geom2, &box2) ) { if ( ( box2.xmin < box1.xmin ) || ( box2.xmax > box1.xmax ) || ( box2.ymin < box1.ymin ) || ( box2.ymax > box1.ymax ) ) @@ -1993,8 +1993,8 @@ Datum containsproperly(PG_FUNCTION_ARGS) * geom1 bounding box we can prematurely return FALSE. * Do the test IFF BOUNDING BOX AVAILABLE. */ - if ( pglwgeom_getbox2d_p(geom1, &box1) && - pglwgeom_getbox2d_p(geom2, &box2) ) + if ( gserialized_get_gbox_p(geom1, &box1) && + gserialized_get_gbox_p(geom2, &box2) ) { if (( box2.xmin < box1.xmin ) || ( box2.xmax > box1.xmax ) || ( box2.ymin < box1.ymin ) || ( box2.ymax > box1.ymax )) @@ -2088,8 +2088,8 @@ Datum covers(PG_FUNCTION_ARGS) * geom1 bounding box we can prematurely return FALSE. * Do the test IFF BOUNDING BOX AVAILABLE. */ - if ( pglwgeom_getbox2d_p(geom1, &box1) && - pglwgeom_getbox2d_p(geom2, &box2) ) + if ( gserialized_get_gbox_p(geom1, &box1) && + gserialized_get_gbox_p(geom2, &box2) ) { if (( box2.xmin < box1.xmin ) || ( box2.xmax > box1.xmax ) || ( box2.ymin < box1.ymin ) || ( box2.ymax > box1.ymax )) @@ -2243,8 +2243,8 @@ Datum within(PG_FUNCTION_ARGS) * geom2 bounding box we can prematurely return FALSE. * Do the test IFF BOUNDING BOX AVAILABLE. */ - if ( pglwgeom_getbox2d_p(geom1, &box1) && - pglwgeom_getbox2d_p(geom2, &box2) ) + if ( gserialized_get_gbox_p(geom1, &box1) && + gserialized_get_gbox_p(geom2, &box2) ) { if ( ( box1.xmin < box2.xmin ) || ( box1.xmax > box2.xmax ) || ( box1.ymin < box2.ymin ) || ( box1.ymax > box2.ymax ) ) @@ -2378,8 +2378,8 @@ Datum coveredby(PG_FUNCTION_ARGS) * geom2 bounding box we can prematurely return FALSE. * Do the test IFF BOUNDING BOX AVAILABLE. */ - if ( pglwgeom_getbox2d_p(geom1, &box1) && - pglwgeom_getbox2d_p(geom2, &box2) ) + if ( gserialized_get_gbox_p(geom1, &box1) && + gserialized_get_gbox_p(geom2, &box2) ) { if ( ( box1.xmin < box2.xmin ) || ( box1.xmax > box2.xmax ) || ( box1.ymin < box2.ymin ) || ( box1.ymax > box2.ymax ) ) @@ -2507,8 +2507,8 @@ Datum crosses(PG_FUNCTION_ARGS) * geom1 bounding box we can prematurely return FALSE. * Do the test IFF BOUNDING BOX AVAILABLE. */ - if ( pglwgeom_getbox2d_p(geom1, &box1) && - pglwgeom_getbox2d_p(geom2, &box2) ) + if ( gserialized_get_gbox_p(geom1, &box1) && + gserialized_get_gbox_p(geom2, &box2) ) { if ( ( box2.xmax < box1.xmin ) || ( box2.xmin > box1.xmax ) || ( box2.ymax < box1.ymin ) || ( box2.ymin > box2.ymax ) ) @@ -2584,8 +2584,8 @@ Datum intersects(PG_FUNCTION_ARGS) * geom1 bounding box we can prematurely return FALSE. * Do the test IFF BOUNDING BOX AVAILABLE. */ - if ( pglwgeom_getbox2d_p(geom1, &box1) && - pglwgeom_getbox2d_p(geom2, &box2) ) + if ( gserialized_get_gbox_p(geom1, &box1) && + gserialized_get_gbox_p(geom2, &box2) ) { if ( ( box2.xmax < box1.xmin ) || ( box2.xmin > box1.xmax ) || ( box2.ymax < box1.ymin ) || ( box2.ymin > box1.ymax ) ) @@ -2751,8 +2751,8 @@ Datum touches(PG_FUNCTION_ARGS) * geom1 bounding box we can prematurely return FALSE. * Do the test IFF BOUNDING BOX AVAILABLE. */ - if ( pglwgeom_getbox2d_p(geom1, &box1) && - pglwgeom_getbox2d_p(geom2, &box2) ) + if ( gserialized_get_gbox_p(geom1, &box1) && + gserialized_get_gbox_p(geom2, &box2) ) { if ( ( box2.xmax < box1.xmin ) || ( box2.xmin > box1.xmax ) || ( box2.ymax < box1.ymin ) || ( box2.ymin > box1.ymax ) ) @@ -2820,8 +2820,8 @@ Datum disjoint(PG_FUNCTION_ARGS) * geom1 bounding box we can prematurely return TRUE. * Do the test IFF BOUNDING BOX AVAILABLE. */ - if ( pglwgeom_getbox2d_p(geom1, &box1) && - pglwgeom_getbox2d_p(geom2, &box2) ) + if ( gserialized_get_gbox_p(geom1, &box1) && + gserialized_get_gbox_p(geom2, &box2) ) { if ( ( box2.xmax < box1.xmin ) || ( box2.xmin > box1.xmax ) || ( box2.ymax < box1.ymin ) || ( box2.ymin > box1.ymax ) ) @@ -3044,8 +3044,8 @@ Datum geomequals(PG_FUNCTION_ARGS) * geom1 bounding box we can prematurely return FALSE. * Do the test IFF BOUNDING BOX AVAILABLE. */ - if ( pglwgeom_getbox2d_p(geom1, &box1) && - pglwgeom_getbox2d_p(geom2, &box2) ) + if ( gserialized_get_gbox_p(geom1, &box1) && + gserialized_get_gbox_p(geom2, &box2) ) { if ( box2.xmax != box1.xmax ) PG_RETURN_BOOL(FALSE); if ( box2.xmin != box1.xmin ) PG_RETURN_BOOL(FALSE); diff --git a/postgis/lwgeom_gist.c b/postgis/lwgeom_gist.c index f3fe68b2761..f2a7cfba893 100644 --- a/postgis/lwgeom_gist.c +++ b/postgis/lwgeom_gist.c @@ -107,7 +107,7 @@ Datum LWGEOM_overlap(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } - if ( ! (pglwgeom_getbox2d_p(lwgeom1, &box1) && pglwgeom_getbox2d_p(lwgeom2, &box2)) ) + if ( ! (gserialized_get_gbox_p(lwgeom1, &box1) && gserialized_get_gbox_p(lwgeom2, &box2)) ) { PG_FREE_IF_COPY(lwgeom1, 0); PG_FREE_IF_COPY(lwgeom2, 1); @@ -150,7 +150,7 @@ Datum LWGEOM_overleft(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } - if ( ! (pglwgeom_getbox2d_p(lwgeom1, &box1) && pglwgeom_getbox2d_p(lwgeom2, &box2)) ) + if ( ! (gserialized_get_gbox_p(lwgeom1, &box1) && gserialized_get_gbox_p(lwgeom2, &box2)) ) { PG_FREE_IF_COPY(lwgeom1, 0); PG_FREE_IF_COPY(lwgeom2, 1); @@ -180,7 +180,7 @@ Datum LWGEOM_left(PG_FUNCTION_ARGS) error_if_srid_mismatch(gserialized_get_srid(lwgeom1), gserialized_get_srid(lwgeom2)); - if ( ! (pglwgeom_getbox2d_p(lwgeom1, &box1) && pglwgeom_getbox2d_p(lwgeom2, &box2)) ) + if ( ! (gserialized_get_gbox_p(lwgeom1, &box1) && gserialized_get_gbox_p(lwgeom2, &box2)) ) { PG_FREE_IF_COPY(lwgeom1, 0); PG_FREE_IF_COPY(lwgeom2, 1); @@ -210,7 +210,7 @@ Datum LWGEOM_right(PG_FUNCTION_ARGS) error_if_srid_mismatch(gserialized_get_srid(lwgeom1), gserialized_get_srid(lwgeom2)); - if ( ! (pglwgeom_getbox2d_p(lwgeom1, &box1) && pglwgeom_getbox2d_p(lwgeom2, &box2)) ) + if ( ! (gserialized_get_gbox_p(lwgeom1, &box1) && gserialized_get_gbox_p(lwgeom2, &box2)) ) { PG_FREE_IF_COPY(lwgeom1, 0); PG_FREE_IF_COPY(lwgeom2, 1); @@ -240,7 +240,7 @@ Datum LWGEOM_overright(PG_FUNCTION_ARGS) error_if_srid_mismatch(gserialized_get_srid(lwgeom1), gserialized_get_srid(lwgeom2)); - if ( ! (pglwgeom_getbox2d_p(lwgeom1, &box1) && pglwgeom_getbox2d_p(lwgeom2, &box2)) ) + if ( ! (gserialized_get_gbox_p(lwgeom1, &box1) && gserialized_get_gbox_p(lwgeom2, &box2)) ) { PG_FREE_IF_COPY(lwgeom1, 0); PG_FREE_IF_COPY(lwgeom2, 1); @@ -270,7 +270,7 @@ Datum LWGEOM_overbelow(PG_FUNCTION_ARGS) error_if_srid_mismatch(gserialized_get_srid(lwgeom1), gserialized_get_srid(lwgeom2)); - if ( ! (pglwgeom_getbox2d_p(lwgeom1, &box1) && pglwgeom_getbox2d_p(lwgeom2, &box2)) ) + if ( ! (gserialized_get_gbox_p(lwgeom1, &box1) && gserialized_get_gbox_p(lwgeom2, &box2)) ) { PG_FREE_IF_COPY(lwgeom1, 0); PG_FREE_IF_COPY(lwgeom2, 1); @@ -300,7 +300,7 @@ Datum LWGEOM_below(PG_FUNCTION_ARGS) error_if_srid_mismatch(gserialized_get_srid(lwgeom1), gserialized_get_srid(lwgeom2)); - if ( ! (pglwgeom_getbox2d_p(lwgeom1, &box1) && pglwgeom_getbox2d_p(lwgeom2, &box2)) ) + if ( ! (gserialized_get_gbox_p(lwgeom1, &box1) && gserialized_get_gbox_p(lwgeom2, &box2)) ) { PG_FREE_IF_COPY(lwgeom1, 0); PG_FREE_IF_COPY(lwgeom2, 1); @@ -330,7 +330,7 @@ Datum LWGEOM_above(PG_FUNCTION_ARGS) error_if_srid_mismatch(gserialized_get_srid(lwgeom1), gserialized_get_srid(lwgeom2)); - if ( ! (pglwgeom_getbox2d_p(lwgeom1, &box1) && pglwgeom_getbox2d_p(lwgeom2, &box2)) ) + if ( ! (gserialized_get_gbox_p(lwgeom1, &box1) && gserialized_get_gbox_p(lwgeom2, &box2)) ) { PG_FREE_IF_COPY(lwgeom1, 0); PG_FREE_IF_COPY(lwgeom2, 1); @@ -360,7 +360,7 @@ Datum LWGEOM_overabove(PG_FUNCTION_ARGS) error_if_srid_mismatch(gserialized_get_srid(lwgeom1), gserialized_get_srid(lwgeom2)); - if ( ! (pglwgeom_getbox2d_p(lwgeom1, &box1) && pglwgeom_getbox2d_p(lwgeom2, &box2)) ) + if ( ! (gserialized_get_gbox_p(lwgeom1, &box1) && gserialized_get_gbox_p(lwgeom2, &box2)) ) { PG_FREE_IF_COPY(lwgeom1, 0); PG_FREE_IF_COPY(lwgeom2, 1); @@ -389,7 +389,7 @@ Datum LWGEOM_samebox(PG_FUNCTION_ARGS) error_if_srid_mismatch(gserialized_get_srid(lwgeom1), gserialized_get_srid(lwgeom2)); - if ( ! (pglwgeom_getbox2d_p(lwgeom1, &box1) && pglwgeom_getbox2d_p(lwgeom2, &box2)) ) + if ( ! (gserialized_get_gbox_p(lwgeom1, &box1) && gserialized_get_gbox_p(lwgeom2, &box2)) ) { PG_FREE_IF_COPY(lwgeom1, 0); PG_FREE_IF_COPY(lwgeom2, 1); @@ -418,7 +418,7 @@ Datum LWGEOM_contained(PG_FUNCTION_ARGS) error_if_srid_mismatch(gserialized_get_srid(lwgeom1), gserialized_get_srid(lwgeom2)); - if ( ! (pglwgeom_getbox2d_p(lwgeom1, &box1) && pglwgeom_getbox2d_p(lwgeom2, &box2)) ) + if ( ! (gserialized_get_gbox_p(lwgeom1, &box1) && gserialized_get_gbox_p(lwgeom2, &box2)) ) { PG_FREE_IF_COPY(lwgeom1, 0); PG_FREE_IF_COPY(lwgeom2, 1); @@ -448,7 +448,7 @@ Datum LWGEOM_contain(PG_FUNCTION_ARGS) error_if_srid_mismatch(gserialized_get_srid(lwgeom1), gserialized_get_srid(lwgeom2)); - if ( ! (pglwgeom_getbox2d_p(lwgeom1, &box1) && pglwgeom_getbox2d_p(lwgeom2, &box2)) ) + if ( ! (gserialized_get_gbox_p(lwgeom1, &box1) && gserialized_get_gbox_p(lwgeom2, &box2)) ) { PG_FREE_IF_COPY(lwgeom1, 0); PG_FREE_IF_COPY(lwgeom2, 1); @@ -502,7 +502,7 @@ Datum LWGEOM_gist_compress(PG_FUNCTION_ARGS) rr = (GBOX*) palloc(sizeof(GBOX)); - if ( ! pglwgeom_getbox2d_p(in, rr) || + if ( ! gserialized_get_gbox_p(in, rr) || ! finite(rr->xmin) || ! finite(rr->ymin) || ! finite(rr->xmax) || @@ -602,12 +602,12 @@ Datum LWGEOM_gist_consistent(PG_FUNCTION_ARGS) */ if ( gserialized_has_bbox(query) ) { - pglwgeom_getbox2d_p(query, &box); + gserialized_get_gbox_p(query, &box); } else { query = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(1)); - if ( ! pglwgeom_getbox2d_p(query, &box) ) + if ( ! gserialized_get_gbox_p(query, &box) ) { PG_FREE_IF_COPY(query, 1); PG_RETURN_BOOL(FALSE);