From df3810cb1e3a7a67a9ab214eb8c7d20a91afb340 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Tue, 19 Jun 2012 16:46:22 +0000 Subject: [PATCH] Fix mistaken error trap in st_dwithincached git-svn-id: http://svn.osgeo.org/postgis/trunk@9950 b70326c6-7e19-0410-871a-916f4a2858ee --- postgis/geography_measurement.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/postgis/geography_measurement.c b/postgis/geography_measurement.c index 9d66a7fcd..dc843ac2b 100644 --- a/postgis/geography_measurement.c +++ b/postgis/geography_measurement.c @@ -158,7 +158,10 @@ Datum geography_distance_cached(PG_FUNCTION_ARGS) /* Something went wrong, negative return... should already be eloged, return NULL */ if ( distance < 0.0 ) + { + elog(ERROR, "distance returned negative!"); PG_RETURN_NULL(); + } PG_RETURN_FLOAT8(distance); } @@ -171,8 +174,6 @@ Datum geography_distance_cached(PG_FUNCTION_ARGS) PG_FUNCTION_INFO_V1(geography_dwithin_cached); Datum geography_dwithin_cached(PG_FUNCTION_ARGS) { - LWGEOM *lwgeom1 = NULL; - LWGEOM *lwgeom2 = NULL; GSERIALIZED *g1 = NULL; GSERIALIZED *g2 = NULL; double tolerance; @@ -206,33 +207,24 @@ Datum geography_dwithin_cached(PG_FUNCTION_ARGS) PG_RETURN_BOOL(FALSE); } - lwgeom1 = lwgeom_from_gserialized(g1); - lwgeom2 = lwgeom_from_gserialized(g2); - /* Do the brute force calculation if the cached calculation doesn't tick over */ if ( LW_FAILURE == geography_dwithin_cache(fcinfo, g1, g2, &s, tolerance, &dwithin) ) { LWGEOM* lwgeom1 = lwgeom_from_gserialized(g1); LWGEOM* lwgeom2 = lwgeom_from_gserialized(g2); distance = lwgeom_distance_spheroid(lwgeom1, lwgeom2, &s, tolerance); + /* Something went wrong... */ + if ( distance < 0.0 ) + elog(ERROR, "lwgeom_distance_spheroid returned negative!"); dwithin = (distance <= tolerance); lwgeom_free(lwgeom1); lwgeom_free(lwgeom2); } /* Clean up */ - lwgeom_free(lwgeom1); - lwgeom_free(lwgeom2); PG_FREE_IF_COPY(g1, 0); PG_FREE_IF_COPY(g2, 1); - /* Something went wrong... should already be eloged, return FALSE */ - if ( distance < 0.0 ) - { - elog(ERROR, "lwgeom_distance_spheroid returned negative!"); - PG_RETURN_BOOL(FALSE); - } - PG_RETURN_BOOL(dwithin); } -- 2.50.1