]> granicus.if.org Git - postgis/commitdiff
Do KNN distance calcs on the spherod
authorPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 26 May 2015 19:05:48 +0000 (19:05 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 26 May 2015 19:05:48 +0000 (19:05 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@13563 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/geography_measurement.c

index 5dcbca3b5b0d86523da97736eccafa9f0829b940..e367a107fea728a4ecad7a07c85467fb80d4f943 100644 (file)
@@ -62,8 +62,8 @@ Datum geography_distance_uncached(PG_FUNCTION_ARGS)
        GSERIALIZED *g1 = NULL;
        GSERIALIZED *g2 = NULL;
        double distance;
-       /* double tolerance; */
-       bool use_spheroid;
+       double tolerance = 0.0;
+       bool use_spheroid = true;
        SPHEROID s;
 
        /* Get our geometry objects loaded into memory. */
@@ -71,10 +71,12 @@ Datum geography_distance_uncached(PG_FUNCTION_ARGS)
        g2 = PG_GETARG_GSERIALIZED_P(1);
 
        /* Read our tolerance value. */
-       /* tolerance = PG_GETARG_FLOAT8(2); */
+       if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
+               tolerance = PG_GETARG_FLOAT8(2);
     
        /* Read our calculation type. */
-       use_spheroid = PG_GETARG_BOOL(3);
+       if ( PG_NARGS() > 3 && ! PG_ARGISNULL(3) )
+               use_spheroid = PG_GETARG_BOOL(3);
 
        /* Initialize spheroid */
        spheroid_init_from_srid(fcinfo, gserialized_get_srid(g1), &s);