]> granicus.if.org Git - postgis/commitdiff
#1828, fix mistake to geography calculation routine
authorPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 22 Nov 2012 17:39:21 +0000 (17:39 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 22 Nov 2012 17:39:21 +0000 (17:39 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@10729 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/liblwgeom.h.in
postgis/geography_estimate.c

index 35b3d38fb3ca27e55dd85edf769d3dbd7aca9b10..97dde86706abcd579cb44b47377736a413b4ae46 100644 (file)
@@ -1656,7 +1656,8 @@ extern LWGEOM* lwgeom_from_gserialized(const GSERIALIZED *g);
 
 /**
 * Pull a #GBOX from the header of a #GSERIALIZED, if one is available. If
-* it is not, return LW_FAILURE.
+* 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);
 
index f97dad118f74d3458892e19053d67e129d9fd471..1031e88be84509b0303a1edd8069f4b156a6ef8b 100644 (file)
@@ -849,16 +849,17 @@ compute_geography_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
        {
                Datum datum;
                GSERIALIZED *serialized;
-
+        
                /* Fetch the datum and cast it into a geography */
                datum = fetchfunc(stats, i, &isnull);
+               serialized = (GSERIALIZED*)PG_DETOAST_DATUM(datum);
 
                /* Skip nulls */
                if (isnull)
                        continue;
 
                /* Convert coordinates to 3D geodesic */
-               if ( ! gserialized_datum_get_gbox_p(datum, &gbox) )
+               if ( ! gserialized_get_gbox_p(serialized, &gbox) )
                {
                        /* Unable to obtain or calculate a bounding box */
                        POSTGIS_DEBUGF(3, "skipping geometry at position %d", i);