[postgis-tickets] r17498 - Pull gserialized_read_gbox_p and gserialized_peek_gbox_p back in favour of a public gserialized_fast_gbox_p. Pull liblwgeom_internal out of mvt.c
Paul Ramsey
pramsey at cleverelephant.ca
Tue Jun 11 11:24:40 PDT 2019
Author: pramsey
Date: 2019-06-11 11:24:40 -0700 (Tue, 11 Jun 2019)
New Revision: 17498
Modified:
trunk/liblwgeom/g_serialized.c
trunk/liblwgeom/liblwgeom.h.in
trunk/liblwgeom/liblwgeom_internal.h
trunk/postgis/gserialized_gist_2d.c
trunk/postgis/lwgeom_out_mvt.c
trunk/postgis/mvt.c
trunk/postgis/mvt.h
Log:
Pull gserialized_read_gbox_p and gserialized_peek_gbox_p back in favour of a public gserialized_fast_gbox_p. Pull liblwgeom_internal out of mvt.c
Modified: trunk/liblwgeom/g_serialized.c
===================================================================
--- trunk/liblwgeom/g_serialized.c 2019-06-11 18:09:50 UTC (rev 17497)
+++ trunk/liblwgeom/g_serialized.c 2019-06-11 18:24:40 UTC (rev 17498)
@@ -677,7 +677,32 @@
}
}
+/**
+* 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.
*/
Modified: trunk/liblwgeom/liblwgeom.h.in
===================================================================
--- trunk/liblwgeom/liblwgeom.h.in 2019-06-11 18:09:50 UTC (rev 17497)
+++ trunk/liblwgeom/liblwgeom.h.in 2019-06-11 18:24:40 UTC (rev 17498)
@@ -1239,9 +1239,32 @@
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,9 +1974,15 @@
* 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);
+
/**
* Parser check flags
*
Modified: trunk/liblwgeom/liblwgeom_internal.h
===================================================================
--- trunk/liblwgeom/liblwgeom_internal.h 2019-06-11 18:09:50 UTC (rev 17497)
+++ trunk/liblwgeom/liblwgeom_internal.h 2019-06-11 18:24:40 UTC (rev 17498)
@@ -398,25 +398,6 @@
/**
* 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);
/*
Modified: trunk/postgis/gserialized_gist_2d.c
===================================================================
--- trunk/postgis/gserialized_gist_2d.c 2019-06-11 18:09:50 UTC (rev 17497)
+++ trunk/postgis/gserialized_gist_2d.c 2019-06-11 18:24:40 UTC (rev 17498)
@@ -571,9 +571,10 @@
** 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;
Modified: trunk/postgis/lwgeom_out_mvt.c
===================================================================
--- trunk/postgis/lwgeom_out_mvt.c 2019-06-11 18:09:50 UTC (rev 17497)
+++ trunk/postgis/lwgeom_out_mvt.c 2019-06-11 18:24:40 UTC (rev 17498)
@@ -89,8 +89,7 @@
{
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;
Modified: trunk/postgis/mvt.c
===================================================================
--- trunk/postgis/mvt.c 2019-06-11 18:09:50 UTC (rev 17497)
+++ trunk/postgis/mvt.c 2019-06-11 18:24:40 UTC (rev 17498)
@@ -23,6 +23,7 @@
**********************************************************************/
#include <string.h>
+#include <float.h>
#include "mvt.h"
#include "lwgeom_geos.h"
@@ -619,7 +620,8 @@
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));
Modified: trunk/postgis/mvt.h
===================================================================
--- trunk/postgis/mvt.h 2019-06-11 18:09:50 UTC (rev 17497)
+++ trunk/postgis/mvt.h 2019-06-11 18:24:40 UTC (rev 17498)
@@ -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"
More information about the postgis-tickets
mailing list