From: Paul Ramsey Date: Thu, 22 Nov 2012 17:39:21 +0000 (+0000) Subject: #1828, fix mistake to geography calculation routine X-Git-Tag: 2.1.0beta2~366 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=deedf87abcf57c9bccb0da6a75f29412e5a314a7;p=postgis #1828, fix mistake to geography calculation routine git-svn-id: http://svn.osgeo.org/postgis/trunk@10729 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/liblwgeom.h.in b/liblwgeom/liblwgeom.h.in index 35b3d38fb..97dde8670 100644 --- a/liblwgeom/liblwgeom.h.in +++ b/liblwgeom/liblwgeom.h.in @@ -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); diff --git a/postgis/geography_estimate.c b/postgis/geography_estimate.c index f97dad118..1031e88be 100644 --- a/postgis/geography_estimate.c +++ b/postgis/geography_estimate.c @@ -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);