]> granicus.if.org Git - postgis/commitdiff
Expose gbox_float_round to liblwgeom API
authorSandro Santilli <strk@keybit.net>
Thu, 12 Jan 2012 08:51:53 +0000 (08:51 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 12 Jan 2012 08:51:53 +0000 (08:51 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@8783 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/g_box.c
liblwgeom/g_serialized.c
liblwgeom/liblwgeom.h.in

index fb6bcf521a03b1a77ea0e2a80f93d75ce3452ff6..61cb1d6dbcc2187305bf6f9509d0b6aaea91379f 100644 (file)
@@ -568,3 +568,22 @@ int lwgeom_calculate_gbox_cartesian(const LWGEOM *lwgeom, GBOX *gbox)
        lwerror("unsupported type (%d) - %s", lwgeom->type, lwtype_name(lwgeom->type));
        return LW_FAILURE;
 }
+
+void gbox_float_round(GBOX *gbox)
+{
+       gbox->xmin = next_float_down(gbox->xmin);
+       gbox->xmax = next_float_up(gbox->xmax);
+
+       gbox->ymin = next_float_down(gbox->ymin);
+       gbox->ymax = next_float_up(gbox->ymax);
+
+       gbox->mmin = next_float_down(gbox->mmin);
+       gbox->mmax = next_float_up(gbox->mmax);
+
+       if ( FLAGS_GET_Z(gbox->flags) )
+       {
+               gbox->zmin = next_float_down(gbox->zmin);
+               gbox->zmax = next_float_up(gbox->zmax);
+       }
+}
+
index e706c977f2de922fa10a6da5dc489b9d70992876..9006cbf44b48b8c102b406b1319d25ee97e0d45a 100644 (file)
@@ -126,25 +126,6 @@ char* gserialized_to_string(const GSERIALIZED *g)
        return lwgeom_to_wkt(lwgeom_from_gserialized(g), WKT_ISO, 12, 0);
 }
 
-/* TODO: expose to internal API ? */
-static void gbox_float_round(GBOX *gbox)
-{
-       gbox->xmin = next_float_down(gbox->xmin);
-       gbox->xmax = next_float_up(gbox->xmax);
-
-       gbox->ymin = next_float_down(gbox->ymin);
-       gbox->ymax = next_float_up(gbox->ymax);
-
-       gbox->mmin = next_float_down(gbox->mmin);
-       gbox->mmax = next_float_up(gbox->mmax);
-
-       if ( FLAGS_GET_Z(gbox->flags) )
-       {
-               gbox->zmin = next_float_down(gbox->zmin);
-               gbox->zmax = next_float_up(gbox->zmax);
-       }
-}
-
 int gserialized_read_gbox_p(const GSERIALIZED *g, GBOX *gbox)
 {
 
index 3c20e6872de67c5bcaab9b17c04493328435b841..b4f340d7b7084e1f5f55e1b1072cc171e1f7f6ab 100644 (file)
@@ -1547,6 +1547,14 @@ extern size_t gbox_serialized_size(uint8_t flags);
 */
 extern int gbox_same(const GBOX *g1, const GBOX *g2);
 
+/**
+ * Round given GBOX to float boundaries
+ *
+ * This turns a GBOX into the version it would become
+ * after a serialize/deserialize round trip.
+ */
+extern void gbox_float_round(GBOX *gbox);
+
 /**
 * Utility function to get type number from string. For example, a string 'POINTZ' 
 * would return type of 1 and z of 1 and m of 0. Valid