From: Paul Ramsey Date: Wed, 20 Jun 2012 19:29:31 +0000 (+0000) Subject: Don't try to do tree caching tricks when the arguments are both points, that's silly. X-Git-Tag: 2.1.0beta2~869 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=21bbf61a4783f66e163766447decb2e44bcb5a67;p=postgis Don't try to do tree caching tricks when the arguments are both points, that's silly. git-svn-id: http://svn.osgeo.org/postgis/trunk@9962 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/geography_measurement_trees.c b/postgis/geography_measurement_trees.c index e873f1547..a70e310be 100644 --- a/postgis/geography_measurement_trees.c +++ b/postgis/geography_measurement_trees.c @@ -133,10 +133,17 @@ CircTreePIP(const CircTreeGeomCache* tree_cache, const GSERIALIZED* g, const LWG int geography_distance_cache(FunctionCallInfoData* fcinfo, const GSERIALIZED* g1, const GSERIALIZED* g2, const SPHEROID* s, double* distance) { - CircTreeGeomCache* tree_cache = GetCircTreeGeomCache(fcinfo, g1, g2); + CircTreeGeomCache* tree_cache = NULL; Assert(distance); + /* Two points? Get outa here... */ + if ( gserialized_get_type(g1) == POINT && gserialized_get_type(g2) == POINT ) + return LW_FAILURE; + + /* Fetch/build our cache, if appropriate, etc... */ + tree_cache = GetCircTreeGeomCache(fcinfo, g1, g2); + if ( tree_cache && tree_cache->argnum && tree_cache->index ) { CIRC_NODE* circ_tree = NULL; @@ -181,11 +188,18 @@ geography_distance_cache(FunctionCallInfoData* fcinfo, const GSERIALIZED* g1, co int geography_dwithin_cache(FunctionCallInfoData* fcinfo, const GSERIALIZED* g1, const GSERIALIZED* g2, const SPHEROID* s, double tolerance, int* dwithin) { - CircTreeGeomCache* tree_cache = GetCircTreeGeomCache(fcinfo, g1, g2); + CircTreeGeomCache* tree_cache = NULL; double distance; - + Assert(dwithin); + /* Two points? Get outa here... */ + if ( gserialized_get_type(g1) == POINT && gserialized_get_type(g2) == POINT ) + return LW_FAILURE; + + /* Fetch/build our cache, if appropriate, etc... */ + tree_cache = GetCircTreeGeomCache(fcinfo, g1, g2); + if ( tree_cache && tree_cache->argnum && tree_cache->index ) { CIRC_NODE* circ_tree = NULL;