]> granicus.if.org Git - postgis/commitdiff
Implement canonical text output for GIDX and BOX2DF
authorSandro Santilli <strk@keybit.net>
Tue, 3 Mar 2015 10:26:01 +0000 (10:26 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 3 Mar 2015 10:26:01 +0000 (10:26 +0000)
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
libpgcommon/gserialized_gist.c
libpgcommon/gserialized_gist.h
postgis/gserialized_gist_2d.c
postgis/gserialized_gist_nd.c

diff --git a/NEWS b/NEWS
index 7faa372850ff3ea281830c73d0ef72534cf98b27..98802a9d5c4b1099b528a3221f49910f8d283146 100644 (file)
--- 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)
index 71ccebeceb72057303979b5583cf4c33ec53587e..f5e7df17d381713319196673fefeda2f12b96057 100644 (file)
@@ -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("<NULLPTR>");
 
-       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
index bd26f4b43d5f3b192906f2ae823a324b1f698519..aedd89958d5c1f129c519b1e2af28511231b2d3f 100644 (file)
@@ -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 */
index 6da99f905594f09f329220139742e7c639806bf9..c41119e3e505a147f98c286e8f9040beaa922860 100644 (file)
@@ -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);
 }
index bce01132446dc5a3c497161e947bd4c428337748..e07e13d34ef4f80ff9ddf51f93fb465be87a8973 100644 (file)
@@ -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);
 }