From ea2439195b52dcfde92814b4cb32f59dce93cf33 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Wed, 3 Jun 2015 17:05:12 +0000 Subject: [PATCH] #3132, KNN box-only operator <-> for geography to support PgSQL < 9.5 git-svn-id: http://svn.osgeo.org/postgis/trunk@13605 b70326c6-7e19-0410-871a-916f4a2858ee --- postgis/geography.sql.in | 5 ----- postgis/geography_measurement.c | 2 +- postgis/gserialized_gist_nd.c | 8 ++++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/postgis/geography.sql.in b/postgis/geography.sql.in index 092de843a..b8ac6807f 100644 --- a/postgis/geography.sql.in +++ b/postgis/geography.sql.in @@ -247,8 +247,6 @@ CREATE OPERATOR && ( JOIN = gserialized_gist_joinsel_nd ); -#if POSTGIS_PGSQL_VERSION >= 95 - -- Availability: 2.2.0 CREATE OR REPLACE FUNCTION geography_distance_knn(geography, geography) RETURNS float8 @@ -268,7 +266,6 @@ CREATE OR REPLACE FUNCTION geography_gist_distance(internal, geography, int4) AS 'MODULE_PATHNAME' ,'gserialized_gist_geog_distance' LANGUAGE 'c'; -#endif -- Availability: 1.5.0 CREATE OPERATOR CLASS gist_geography_ops @@ -278,11 +275,9 @@ CREATE OPERATOR CLASS gist_geography_ops -- OPERATOR 6 ~= , -- OPERATOR 7 ~ , -- OPERATOR 8 @ , -#if POSTGIS_PGSQL_VERSION >= 95 -- Availability: 2.2.0 OPERATOR 13 <-> FOR ORDER BY pg_catalog.float_ops, FUNCTION 8 geography_gist_distance (internal, geography, int4), -#endif FUNCTION 1 geography_gist_consistent (internal, geography, int4), FUNCTION 2 geography_gist_union (bytea, internal), FUNCTION 3 geography_gist_compress (internal), diff --git a/postgis/geography_measurement.c b/postgis/geography_measurement.c index d77cd0764..edb240a4d 100644 --- a/postgis/geography_measurement.c +++ b/postgis/geography_measurement.c @@ -61,7 +61,7 @@ Datum geography_distance_knn(PG_FUNCTION_ARGS) GSERIALIZED *g2 = NULL; double distance; double tolerance = FP_TOLERANCE; - bool use_spheroid = false; /**switched back to use sphere, can get index to harmonize with sphoeroid **/ + bool use_spheroid = false; /** switched back to use sphere, can't get index to harmonize with sphoeroid **/ SPHEROID s; /* Get our geometry objects loaded into memory. */ diff --git a/postgis/gserialized_gist_nd.c b/postgis/gserialized_gist_nd.c index c2d7c0575..8be385ee2 100644 --- a/postgis/gserialized_gist_nd.c +++ b/postgis/gserialized_gist_nd.c @@ -78,9 +78,7 @@ Datum gserialized_gist_picksplit(PG_FUNCTION_ARGS); Datum gserialized_gist_union(PG_FUNCTION_ARGS); Datum gserialized_gist_same(PG_FUNCTION_ARGS); Datum gserialized_gist_distance(PG_FUNCTION_ARGS); -#if POSTGIS_PGSQL_VERSION >= 95 Datum gserialized_gist_geog_distance(PG_FUNCTION_ARGS); -#endif /* ** ND Operator prototypes @@ -1048,7 +1046,6 @@ Datum gserialized_gist_same(PG_FUNCTION_ARGS) -#if POSTGIS_PGSQL_VERSION >= 95 PG_FUNCTION_INFO_V1(gserialized_gist_geog_distance); Datum gserialized_gist_geog_distance(PG_FUNCTION_ARGS) @@ -1056,7 +1053,9 @@ Datum gserialized_gist_geog_distance(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY*) PG_GETARG_POINTER(0); Datum query_datum = PG_GETARG_DATUM(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); +#if POSTGIS_PGSQL_VERSION >= 95 bool *recheck = (bool *) PG_GETARG_POINTER(4); +#endif char query_box_mem[GIDX_MAX_SIZE]; GIDX *query_box = (GIDX*)query_box_mem; GIDX *entry_box; @@ -1078,11 +1077,13 @@ Datum gserialized_gist_geog_distance(PG_FUNCTION_ARGS) PG_RETURN_FLOAT8(FLT_MAX); } +#if POSTGIS_PGSQL_VERSION >= 95 /* When we hit leaf nodes, it's time to turn on recheck */ if (GIST_LEAF(entry)) { *recheck = true; } +#endif /* Get the entry box */ entry_box = (GIDX*)DatumGetPointer(entry->key); @@ -1097,7 +1098,6 @@ Datum gserialized_gist_geog_distance(PG_FUNCTION_ARGS) PG_RETURN_FLOAT8(distance); } -#endif /* -- 2.50.1