]> granicus.if.org Git - postgis/commitdiff
Pull gserialized_read_gbox_p and gserialized_peek_gbox_p back in favour of a public...
authorPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 11 Jun 2019 18:24:40 +0000 (18:24 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 11 Jun 2019 18:24:40 +0000 (18:24 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@17498 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/g_serialized.c
liblwgeom/liblwgeom.h.in
liblwgeom/liblwgeom_internal.h
postgis/gserialized_gist_2d.c
postgis/lwgeom_out_mvt.c
postgis/mvt.c
postgis/mvt.h

index 2a525620d5e544df366d26de0170d29e1b94d7f8..9e1f8cbabdc5fc8398a6e520a6b6a8e565c40ae4 100644 (file)
@@ -677,6 +677,31 @@ int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *box)
        }
 }
 
+/**
+* Read the bounding box off a serialization and fail if
+* it is not already there.
+*/
+int gserialized_fast_gbox_p(const GSERIALIZED *g, GBOX *box)
+{
+       /* Try to just read the serialized box. */
+       if ( gserialized_read_gbox_p(g, box) == LW_SUCCESS )
+       {
+               return LW_SUCCESS;
+       }
+       /* No box? Try to peek into simpler geometries and */
+       /* derive a box without creating an lwgeom */
+       else if ( gserialized_peek_gbox_p(g, box) == LW_SUCCESS )
+       {
+               return LW_SUCCESS;
+       }
+       else
+       {
+               return LW_FAILURE;
+       }
+}
+
+
+
 
 /***********************************************************************
 * Calculate the GSERIALIZED size for an LWGEOM.
index 9242e8d3f7f20bfab3d925f6a9a8eb13f955ca21..b4e3cd1ec11215f76e87a1e0c7243e79494a1a6d 100644 (file)
@@ -1239,9 +1239,32 @@ extern void interpolate_point4d(const POINT4D *A, const POINT4D *B, POINT4D *I,
 extern int lwgeom_is_clockwise(LWGEOM *lwgeom);
 
 
+/**
+* Simplification
+*/
 extern LWGEOM* lwgeom_simplify(const LWGEOM *igeom, double dist, int preserve_collapsed);
 extern LWGEOM* lwgeom_remove_repeated_points(const LWGEOM *in, double tolerance);
 
+/**
+* Snap-to-grid
+*/
+typedef struct gridspec_t
+{
+    double ipx;
+    double ipy;
+    double ipz;
+    double ipm;
+    double xsize;
+    double ysize;
+    double zsize;
+    double msize;
+}
+gridspec;
+
+extern LWGEOM* lwgeom_grid(const LWGEOM *lwgeom, const gridspec *grid);
+extern void lwgeom_grid_in_place(LWGEOM *lwgeom, const gridspec *grid);
+
+
 /****************************************************************
 * READ/WRITE FUNCTIONS
 *
@@ -1951,7 +1974,13 @@ extern LWGEOM* lwgeom_from_gserialized(const GSERIALIZED *g);
 * it is not, calculate it from the geometry. If that doesn't work (null
 * or empty) return LW_FAILURE.
 */
-extern int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *gbox);
+extern int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *box);
+
+/**
+* Pull a #GBOX from the header of a #GSERIALIZED, if one is available. If
+* it is not, return LW_FAILURE.
+*/
+extern int gserialized_fast_gbox_p(const GSERIALIZED *g, GBOX *box);
 
 
 /**
index 3819fcddcef54f0224997e717a74825bbfd4ab53..ad21114d9a22c9eeb701feb08ddaf7ef7729948e 100644 (file)
@@ -398,25 +398,6 @@ int lwtin_is_closed(const LWTIN *tin);
 /**
 * Snap to grid
 */
-
-/**
-* Snap-to-grid Support
-*/
-typedef struct gridspec_t
-{
-       double ipx;
-       double ipy;
-       double ipz;
-       double ipm;
-       double xsize;
-       double ysize;
-       double zsize;
-       double msize;
-}
-gridspec;
-
-LWGEOM* lwgeom_grid(const LWGEOM *lwgeom, const gridspec *grid);
-void lwgeom_grid_in_place(LWGEOM *lwgeom, const gridspec *grid);
 void ptarray_grid_in_place(POINTARRAY *pa, const gridspec *grid);
 
 /*
index 8cf396d4878f9aa3254d360d4b7d6fbc0772ceaf..65d2c600b8cacea864048a90c6f9b731337b2135 100644 (file)
@@ -571,9 +571,10 @@ gserialized_datum_get_box2df_p(Datum gsdatum, BOX2DF *box2df)
        ** enough to take serious advantage of PG_DETOAST_DATUM_SLICE will have
        ** already been compressed, which means the entire object will be
        ** fetched and decompressed before a slice is taken, thus removing
-       ** any efficiencies gained from slicing. We need to move to
-       ** "storage = external" and implement our own geometry compressor
-       ** before we can take advantage of sliced retrieval.
+       ** any efficiencies gained from slicing.
+       ** As of Pg12 we can partially decompress a toasted object
+       ** (though we still need to fully retrieve it from TOAST)
+       ** which makes slicing worthwhile.
        */
        gpart = (GSERIALIZED*)PG_DETOAST_DATUM(gsdatum);
        flags = gpart->flags;
index 6e992b00e92792f61cbe9810cf4f1edfd621f8a3..f1c72af07097ffcc1171ae00e105f23d7eae8e15 100644 (file)
@@ -89,8 +89,7 @@ Datum ST_AsMVTGeom(PG_FUNCTION_ARGS)
        {
                GBOX gserialized_box;
                /* We only apply the optimization if the bounding box is available */
-               if ((gserialized_read_gbox_p(geom_in, &gserialized_box) == LW_SUCCESS) ||
-                   (gserialized_peek_gbox_p(geom_in, &gserialized_box) == LW_SUCCESS))
+               if (gserialized_fast_gbox_p(geom_in, &gserialized_box) == LW_SUCCESS)
                {
                        /* Shortcut to drop geometries smaller than the resolution */
                        double geom_width = gserialized_box.xmax - gserialized_box.xmin;
index 336c15b7089a9db949f41a6e7d8e7b7dfd48bd3d..7bd1863fac87d0024521673060fdfa3de32f56b3 100644 (file)
@@ -23,6 +23,7 @@
  **********************************************************************/
 
 #include <string.h>
+#include <float.h>
 
 #include "mvt.h"
 #include "lwgeom_geos.h"
@@ -619,7 +620,8 @@ static uint32_t *parse_jsonb(mvt_agg_context *ctx, Jsonb *jb,
                                        PointerGetDatum(v.val.numeric)));
                                d = strtod(str, NULL);
                                l = strtol(str, NULL, 10);
-                               if (FP_NEQUALS(d, (double)l))
+
+                               if (fabs(d - (double)l) > FLT_EPSILON)
                                {
                                        MVT_PARSE_VALUE(d, mvt_kv_double_value, double_values_hash,
                                                double_value, sizeof(double));
index c596437ab6c10ec57f04b9b7dd914d666e227a8b..b2ada4226cf6a2b0d67e35ced6c972de332f4f3f 100644 (file)
@@ -38,7 +38,6 @@
 #include "access/htup.h"
 #include "../postgis_config.h"
 #include "liblwgeom.h"
-#include "liblwgeom_internal.h"
 #include "lwgeom_pg.h"
 #include "lwgeom_log.h"