*/
extern void lwgeom_add_bbox(LWGEOM *lwgeom);
/**
+* Drop current bbox and calculate a fresh one.
+*/
+extern void lwgeom_refresh_bbox(LWGEOM *lwgeom);
+/**
* Compute a box for geom and all sub-geometries, if not already computed
*/
extern void lwgeom_add_bbox_deep(LWGEOM *lwgeom, GBOX *gbox);
lwgeom_calculate_gbox(lwgeom, lwgeom->bbox);
}
+void
+lwgeom_refresh_bbox(LWGEOM *lwgeom)
+{
+ lwgeom_drop_bbox(lwgeom);
+ lwgeom_add_bbox(lwgeom);
+}
+
void
lwgeom_add_bbox_deep(LWGEOM *lwgeom, GBOX *gbox)
{
/* only refresh bbox if X or Y changed */
if ( in->bbox && (o1 < 2 || o2 < 2) )
{
- lwgeom_drop_bbox(in);
- lwgeom_add_bbox(in);
+ lwgeom_refresh_bbox(in);
}
}
/* Update the bounding box */
if ( line->bbox )
{
- lwgeom_drop_bbox(lwline_as_lwgeom(line));
- lwgeom_add_bbox(lwline_as_lwgeom(line));
+ lwgeom_refresh_bbox((LWGEOM*)line);
}
return LW_SUCCESS;
/* Update the box, if there is one to update */
if ( line->bbox )
{
- lwgeom_drop_bbox((LWGEOM*)line);
- lwgeom_add_bbox((LWGEOM*)line);
+ lwgeom_refresh_bbox((LWGEOM*)line);
}
}
/* Set the bbox, if necessary */
if ( lwgeom_out->bbox )
{
- lwgeom_drop_bbox((LWGEOM*)lwgeom_out);
- lwgeom_add_bbox((LWGEOM*)lwgeom_out);
+ lwgeom_refresh_bbox((LWGEOM*)lwgeom_out);
}
return lwgeom_out;
/* Set the bbox, if necessary */
if ( lwgeom_out->bbox )
{
- lwgeom_drop_bbox((LWGEOM*)lwgeom_out);
- lwgeom_add_bbox((LWGEOM*)lwgeom_out);
+ lwgeom_refresh_bbox((LWGEOM*)lwgeom_out);
}
return lwgeom_out;
}
if ( lwgeom_out->bbox )
{
- lwgeom_drop_bbox((LWGEOM*)lwgeom_out);
- lwgeom_add_bbox((LWGEOM*)lwgeom_out);
+ lwgeom_refresh_bbox((LWGEOM*)lwgeom_out);
}
if ( ! homogeneous )
if ( lwgeom_out->bbox && lwgeom_out->ngeoms > 0 )
{
- lwgeom_drop_bbox((LWGEOM*)lwgeom_out);
- lwgeom_add_bbox((LWGEOM*)lwgeom_out);
+ lwgeom_refresh_bbox((LWGEOM*)lwgeom_out);
}
return lwgeom_out;
/* Recalculate the boxes after re-setting the geodetic bit */
lwgeom_set_geodetic(lwgeom, false);
- lwgeom_drop_bbox(lwgeom);
- lwgeom_add_bbox(lwgeom);
+ lwgeom_refresh_bbox(lwgeom);
/* We want "geometry" to think all our "geography" has an SRID, and the
implied SRID is the default, so we fill that in if our SRID is actually unknown. */
/* COMPUTE_BBOX TAINTING */
if ( lwgeom->bbox )
{
- lwgeom_drop_bbox(lwgeom);
- lwgeom_add_bbox(lwgeom);
+ lwgeom_refresh_bbox(lwgeom);
}
ret = geometry_serialize(lwgeom);
output_srid = PG_GETARG_INT32(1);
if (output_srid == SRID_UNKNOWN)
{
- elog(ERROR,"%d is an invalid target SRID",SRID_UNKNOWN);
+ elog(ERROR, "%d is an invalid target SRID", SRID_UNKNOWN);
PG_RETURN_NULL();
}
+ /* Input SRID and output SRID are equal, noop */
+ if ( input_srid == output_srid )
+ PG_RETURN_POINTER(PG_GETARG_DATUM(0));
+
geom = PG_GETARG_GSERIALIZED_P_COPY(0);
input_srid = gserialized_get_srid(geom);
if ( input_srid == SRID_UNKNOWN )
{
PG_FREE_IF_COPY(geom, 0);
- elog(ERROR,"Input geometry has unknown (%d) SRID",SRID_UNKNOWN);
+ elog(ERROR, "Input geometry has unknown (%d) SRID", SRID_UNKNOWN);
PG_RETURN_NULL();
}
- /*
- * If input SRID and output SRID are equal, return geometry
- * without transform it
- */
- if ( input_srid == output_srid )
- PG_RETURN_POINTER(PG_GETARG_DATUM(0));
-
if ( GetProjectionsUsingFCInfo(fcinfo, input_srid, output_srid, &input_pj, &output_pj) == LW_FAILURE )
{
PG_FREE_IF_COPY(geom, 0);
- elog(ERROR,"Failure reading projections from spatial_ref_sys.");
+ elog(ERROR, "Failure reading projections from spatial_ref_sys.");
PG_RETURN_NULL();
}
/* Re-compute bbox if input had one (COMPUTE_BBOX TAINTING) */
if ( lwgeom->bbox )
{
- lwgeom_drop_bbox(lwgeom);
- lwgeom_add_bbox(lwgeom);
+ lwgeom_refresh_bbox(lwgeom);
}
result = geometry_serialize(lwgeom);
/* Re-compute bbox if input had one (COMPUTE_BBOX TAINTING) */
if ( lwgeom->bbox )
{
- lwgeom_drop_bbox(lwgeom);
- lwgeom_add_bbox(lwgeom);
+ lwgeom_refresh_bbox(lwgeom);
}
result = geometry_serialize(lwgeom);