#if POSTGIS_PGSQL_VERSION >= 95
-- Availability: 2.2.0
-CREATE OR REPLACE FUNCTION geography_knn_distance(geography, geography)
+CREATE OR REPLACE FUNCTION geography_distance_knn(geography, geography)
RETURNS float8
- AS 'MODULE_PATHNAME','geography_distance_uncached'
+ AS 'MODULE_PATHNAME','geography_distance_knn'
LANGUAGE 'c' IMMUTABLE STRICT
COST 100;
-- Availability: 2.2.0
CREATE OPERATOR <-> (
- LEFTARG = geography, RIGHTARG = geography, PROCEDURE = geography_knn_distance,
+ LEFTARG = geography, RIGHTARG = geography, PROCEDURE = geography_distance_knn,
COMMUTATOR = '<->'
);
Datum geography_distance(PG_FUNCTION_ARGS);
Datum geography_distance_uncached(PG_FUNCTION_ARGS);
+Datum geography_distance_knn(PG_FUNCTION_ARGS);
Datum geography_distance_tree(PG_FUNCTION_ARGS);
Datum geography_dwithin(PG_FUNCTION_ARGS);
Datum geography_dwithin_uncached(PG_FUNCTION_ARGS);
Datum geography_azimuth(PG_FUNCTION_ARGS);
Datum geography_segmentize(PG_FUNCTION_ARGS);
+
+PG_FUNCTION_INFO_V1(geography_distance_knn);
+Datum geography_distance_knn(PG_FUNCTION_ARGS)
+{
+ return DirectFunctionCall3(geography_distance_uncached,
+ PG_GETARG_DATUM(0),
+ PG_GETARG_DATUM(1),
+ BoolGetDatum(false));
+}
+
/*
** geography_distance_uncached(GSERIALIZED *g1, GSERIALIZED *g2, double tolerance, boolean use_spheroid)
** returns double distance in meters
GSERIALIZED *g2 = NULL;
double distance;
double tolerance = FP_TOLERANCE;
- bool use_spheroid = true;
+ bool use_spheroid = false; /* XXX WARNING< CHANGE THIS DO NOT COMMIT */
SPHEROID s;
/* Get our geometry objects loaded into memory. */
distance = lwgeom_distance_spheroid(lwgeom1, lwgeom2, &s, tolerance);
+ POSTGIS_DEBUGF(2, "[GIST] '%s' got distance %g", __func__, distance);
+
/* Clean up */
lwgeom_free(lwgeom1);
lwgeom_free(lwgeom2);
GIDX *entry_box;
double distance;
- POSTGIS_DEBUGF(4, "[GIST] '%s' function called", __func__);
+ POSTGIS_DEBUGF(3, "[GIST] '%s' function called", __func__);
/* We are using '13' as the gist geography distance <-> strategy number */
if ( strategy != 13 )
/* Null box should never make this far. */
if ( gserialized_datum_get_gidx_p(query_datum, query_box) == LW_FAILURE )
{
- POSTGIS_DEBUG(4, "[GIST] null query_gbox_index!");
+ POSTGIS_DEBUG(2, "[GIST] null query_gbox_index!");
PG_RETURN_FLOAT8(FLT_MAX);
}
+ /* When we hit leaf nodes, it's time to turn on recheck */
+ if (GIST_LEAF(entry))
+ {
+ *recheck = true;
+ }
+
/* Get the entry box */
entry_box = (GIDX*)DatumGetPointer(entry->key);
/* compare reasonably with the over-the-spheroid distances that */
/* the recheck process will turn up */
distance = WGS84_RADIUS * gidx_distance(entry_box, query_box);
+ POSTGIS_DEBUGF(2, "[GIST] '%s' got distance %g", __func__, distance);
- /* When we hit leaf nodes, it's time to turn on recheck */
- if (GIST_LEAF(entry))
- {
- *recheck = true;
- }
-
PG_RETURN_FLOAT8(distance);
}
#endif