From 63aa79951081d4ab10e5f361531071ad1ea4cb72 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Tue, 3 Mar 2015 10:26:01 +0000 Subject: [PATCH] Implement canonical text output for GIDX and BOX2DF They make spatial indexes inspectable with Gevel: http://www.sai.msu.su/~megera/wiki/Gevel git-svn-id: http://svn.osgeo.org/postgis/trunk@13297 b70326c6-7e19-0410-871a-916f4a2858ee --- NEWS | 1 + libpgcommon/gserialized_gist.c | 4 +--- libpgcommon/gserialized_gist.h | 2 -- postgis/gserialized_gist_2d.c | 9 +++------ postgis/gserialized_gist_nd.c | 6 +++--- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/NEWS b/NEWS index 7faa37285..98802a9d5 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,7 @@ PostGIS 2.2.0 * New Features * + - Canonical output for index key types - ST_SwapOrdinates (Sandro Santilli / Boundless) - #3040, KNN GiST index based centroid (<<->>) and box (<<#>>) n-D distance operators (Sandro Santilli / Boundless) diff --git a/libpgcommon/gserialized_gist.c b/libpgcommon/gserialized_gist.c index 71ccebece..f5e7df17d 100644 --- a/libpgcommon/gserialized_gist.c +++ b/libpgcommon/gserialized_gist.c @@ -29,7 +29,6 @@ /* Generate human readable form for GIDX. */ -#if POSTGIS_DEBUG_LEVEL > 0 char* gidx_to_string(GIDX *a) { char *str, *rv; @@ -38,7 +37,7 @@ char* gidx_to_string(GIDX *a) if ( a == NULL ) return pstrdup(""); - str = (char*)palloc(128); + str = (char*)palloc(128); /* 15*2*4+8==128 */ rv = str; ndims = GIDX_NDIMS(a); @@ -52,7 +51,6 @@ char* gidx_to_string(GIDX *a) return rv; } -#endif static uint8_t diff --git a/libpgcommon/gserialized_gist.h b/libpgcommon/gserialized_gist.h index bd26f4b43..aedd89958 100644 --- a/libpgcommon/gserialized_gist.h +++ b/libpgcommon/gserialized_gist.h @@ -56,9 +56,7 @@ void gidx_expand(GIDX *a, float d); /* Generate human readable form for GIDX. */ -#if POSTGIS_DEBUG_LEVEL > 0 char* gidx_to_string(GIDX *a) ; -#endif /* typedef to correct array-bounds checking for casts to GIDX - do not use this ANYWHERE except in the casts below */ diff --git a/postgis/gserialized_gist_2d.c b/postgis/gserialized_gist_2d.c index 6da99f905..c41119e3e 100644 --- a/postgis/gserialized_gist_2d.c +++ b/postgis/gserialized_gist_2d.c @@ -108,7 +108,6 @@ Datum gserialized_distance_centroid_2d(PG_FUNCTION_ARGS); typedef bool (*box2df_predicate)(const BOX2DF *a, const BOX2DF *b); -#if POSTGIS_DEBUG_LEVEL > 0 static char* box2df_to_string(const BOX2DF *a) { char *rv = NULL; @@ -120,8 +119,6 @@ static char* box2df_to_string(const BOX2DF *a) sprintf(rv, "BOX2DF(%.12g %.12g, %.12g %.12g)", a->xmin, a->ymin, a->xmax, a->ymax); return rv; } -#endif - /* Allocate a new copy of BOX2DF */ static BOX2DF* box2df_copy(BOX2DF *b) @@ -2207,7 +2204,7 @@ Datum box2df_in(PG_FUNCTION_ARGS) PG_FUNCTION_INFO_V1(box2df_out); Datum box2df_out(PG_FUNCTION_ARGS) { - ereport(ERROR,(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("function box2df_out not implemented"))); - PG_RETURN_POINTER(NULL); + BOX2DF *box = (BOX2DF *) PG_GETARG_POINTER(0); + char *result = box2df_to_string(box); + PG_RETURN_CSTRING(result); } diff --git a/postgis/gserialized_gist_nd.c b/postgis/gserialized_gist_nd.c index bce011324..e07e13d34 100644 --- a/postgis/gserialized_gist_nd.c +++ b/postgis/gserialized_gist_nd.c @@ -1496,7 +1496,7 @@ Datum gidx_in(PG_FUNCTION_ARGS) PG_FUNCTION_INFO_V1(gidx_out); Datum gidx_out(PG_FUNCTION_ARGS) { - ereport(ERROR,(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("function gidx_out not implemented"))); - PG_RETURN_POINTER(NULL); + GIDX *box = (GIDX *) PG_GETARG_POINTER(0); + char *result = gidx_to_string(box); + PG_RETURN_CSTRING(result); }