- #1957, ST_Distance to a one-point LineString returns NULL
- #1976, Geography point-in-ring code overhauled for more reliability
- #1981, cleanup of unused variables causing warnings with gcc 4.6+
+ - #2026, improve performance of distance calculations
- #2057, Fixed linking issue for raster2psql to libpq
PostGIS 2.0.1
memset(gbox, 0, sizeof(GBOX));
}
+GBOX* gbox_clone(const GBOX *gbox)
+{
+ GBOX *g = lwalloc(sizeof(GBOX));
+ memcpy(g, gbox, sizeof(GBOX));
+ return g;
+}
/* TODO to be removed */
BOX3D* box3d_from_gbox(const GBOX *gbox)
* NULL if the geometry is empty.
*/
extern void lwgeom_add_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);
/**
* Get a non-empty geometry bounding box, computing and
LWLINE *lwline_clone_deep(const LWLINE *lwgeom);
LWPOLY *lwpoly_clone_deep(const LWPOLY *lwgeom);
LWCOLLECTION *lwcollection_clone_deep(const LWCOLLECTION *lwgeom);
+GBOX *gbox_clone(const GBOX *gbox);
/*
* Startpoint
lwgeom_add_bbox(LWGEOM *lwgeom)
{
/* an empty LWGEOM has no bbox */
- if( lwgeom_is_empty(lwgeom) ) return;
+ if ( lwgeom_is_empty(lwgeom) ) return;
if ( lwgeom->bbox ) return;
FLAGS_SET_BBOX(lwgeom->flags, 1);
lwgeom_calculate_gbox(lwgeom, lwgeom->bbox);
}
+void
+lwgeom_add_bbox_deep(LWGEOM *lwgeom, GBOX *gbox)
+{
+ if ( lwgeom_is_empty(lwgeom) ) return;
+
+ FLAGS_SET_BBOX(lwgeom->flags, 1);
+
+ if ( ! ( gbox || lwgeom->bbox ) )
+ {
+ lwgeom->bbox = gbox_new(lwgeom->flags);
+ lwgeom_calculate_gbox(lwgeom, lwgeom->bbox);
+ }
+ else if ( gbox && ! lwgeom->bbox )
+ {
+ lwgeom->bbox = gbox_clone(gbox);
+ }
+
+ if ( lwgeom_is_collection(lwgeom) )
+ {
+ int i;
+ LWCOLLECTION *lwcol = (LWCOLLECTION*)lwgeom;
+
+ for ( i = 0; i < lwcol->ngeoms; i++ )
+ {
+ lwgeom_add_bbox_deep(lwcol->geoms[i], lwgeom->bbox);
+ }
+ }
+}
+
const GBOX *
lwgeom_get_bbox(const LWGEOM *lwg)
{
PG_RETURN_NULL();
}
+ /* Make sure we have boxes attached */
+ lwgeom_add_bbox_deep(lwgeom1, NULL);
+ lwgeom_add_bbox_deep(lwgeom2, NULL);
+
distance = lwgeom_distance_spheroid(lwgeom1, lwgeom2, &s, FP_TOLERANCE);
/* Clean up */