]> granicus.if.org Git - postgis/commitdiff
Fix ST_Estimated_Extent by correctly interpret histogram box (#1200)
authorSandro Santilli <strk@keybit.net>
Mon, 19 Sep 2011 14:17:35 +0000 (14:17 +0000)
committerSandro Santilli <strk@keybit.net>
Mon, 19 Sep 2011 14:17:35 +0000 (14:17 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7868 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/geometry_gist_selectivity.c

index 10711b86575c9d5d032b5136feab7b2f5665b15b..75dc2e74b0190a515772e560bb873759a55d0a82 100644 (file)
@@ -1337,6 +1337,7 @@ Datum geometry_estimated_extent(PG_FUNCTION_ARGS)
        bool isnull;
        GBOX *box;
        size_t querysize;
+       GEOM_STATS geomstats;
 
        if ( PG_NARGS() == 3 )
        {
@@ -1481,14 +1482,21 @@ Datum geometry_estimated_extent(PG_FUNCTION_ARGS)
        POSTGIS_DEBUGF(3, " stats array has %d elems", ArrayGetNItems(ARR_NDIM(array), ARR_DIMS(array)));
 
        /*
-        * Construct box2dfloat4.
+        * Construct GBOX.
         * Must allocate this in upper executor context
         * to keep it alive after SPI_finish().
         */
        box = SPI_palloc(sizeof(GBOX));
+       FLAGS_SET_GEODETIC(box->flags, 0);
+       FLAGS_SET_Z(box->flags, 0);
+       FLAGS_SET_M(box->flags, 0);
 
        /* Construct the box */
-       memcpy(box, ARR_DATA_PTR(array), sizeof(GBOX));
+       memcpy(&(geomstats.xmin), ARR_DATA_PTR(array), sizeof(float)*4);
+       box->xmin = geomstats.xmin;
+       box->xmax = geomstats.xmax;
+       box->ymin = geomstats.ymin;
+       box->ymax = geomstats.ymax;
 
        POSTGIS_DEBUGF(3, " histogram extent = %g %g, %g %g", box->xmin,
                       box->ymin, box->xmax, box->ymax);
@@ -1504,4 +1512,4 @@ Datum geometry_estimated_extent(PG_FUNCTION_ARGS)
        PG_RETURN_POINTER(box);
 }
 
-#endif /* GSERIALIZED_ON */
\ No newline at end of file
+#endif /* GSERIALIZED_ON */