PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ test_geohash()

static void test_geohash ( void  )
static

Definition at line 973 of file cu_algorithm.c.

974 {
975  LWPOINT *lwpoint = NULL;
976  LWLINE *lwline = NULL;
977  LWMLINE *lwmline = NULL;
978  char *geohash = NULL;
979 
980  lwpoint = (LWPOINT*)lwgeom_from_wkt("POINT(23.0 25.2)", LW_PARSER_CHECK_NONE);
981  geohash = lwgeom_geohash((LWGEOM*)lwpoint,0);
982  //printf("\ngeohash %s\n",geohash);
983  ASSERT_STRING_EQUAL(geohash, "ss2r77s0du7p2ewb8hmx");
984  lwpoint_free(lwpoint);
985  lwfree(geohash);
986 
987  lwpoint = (LWPOINT*)lwgeom_from_wkt("POINT(23.0 25.2 2.0)", LW_PARSER_CHECK_NONE);
988  geohash = lwgeom_geohash((LWGEOM*)lwpoint,0);
989  //printf("geohash %s\n",geohash);
990  ASSERT_STRING_EQUAL(geohash, "ss2r77s0du7p2ewb8hmx");
991  lwpoint_free(lwpoint);
992  lwfree(geohash);
993 
994  lwline = (LWLINE*)lwgeom_from_wkt("LINESTRING(23.0 23.0,23.1 23.1)", LW_PARSER_CHECK_NONE);
995  geohash = lwgeom_geohash((LWGEOM*)lwline,0);
996  //printf("geohash %s\n",geohash);
997  ASSERT_STRING_EQUAL(geohash, "ss0");
998  lwline_free(lwline);
999  lwfree(geohash);
1000 
1001  lwline = (LWLINE*)lwgeom_from_wkt("LINESTRING(23.0 23.0,23.001 23.001)", LW_PARSER_CHECK_NONE);
1002  geohash = lwgeom_geohash((LWGEOM*)lwline,0);
1003  //printf("geohash %s\n",geohash);
1004  ASSERT_STRING_EQUAL(geohash, "ss06g7h");
1005  lwline_free(lwline);
1006  lwfree(geohash);
1007 
1008  lwmline = (LWMLINE*)lwgeom_from_wkt("MULTILINESTRING((23.0 23.0,23.1 23.1),(23.0 23.0,23.1 23.1))", LW_PARSER_CHECK_NONE);
1009  geohash = lwgeom_geohash((LWGEOM*)lwmline,0);
1010  //printf("geohash %s\n",geohash);
1011  ASSERT_STRING_EQUAL(geohash, "ss0");
1012  lwmline_free(lwmline);
1013  lwfree(geohash);
1014 }
#define ASSERT_STRING_EQUAL(o, e)
void lwpoint_free(LWPOINT *pt)
Definition: lwpoint.c:213
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2060
char * lwgeom_geohash(const LWGEOM *lwgeom, int precision)
Calculate the GeoHash (http://geohash.org) string for a geometry.
Definition: lwalgorithm.c:861
void lwfree(void *mem)
Definition: lwutil.c:242
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:905
void lwmline_free(LWMLINE *mline)
Definition: lwmline.c:112
void lwline_free(LWLINE *line)
Definition: lwline.c:67

References ASSERT_STRING_EQUAL, LW_PARSER_CHECK_NONE, lwfree(), lwgeom_from_wkt(), lwgeom_geohash(), lwline_free(), lwmline_free(), and lwpoint_free().

Referenced by algorithms_suite_setup().

Here is the call graph for this function:
Here is the caller graph for this function: