]> granicus.if.org Git - postgis/commitdiff
Don't try to do tree caching tricks when the arguments are both points, that's silly.
authorPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 20 Jun 2012 19:29:31 +0000 (19:29 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 20 Jun 2012 19:29:31 +0000 (19:29 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9962 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/geography_measurement_trees.c

index e873f154780c1d12066c46c3338c37fa839ad594..a70e310be1bad7ed929a671c16261c1bd945206a 100644 (file)
@@ -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;