PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void test_geohash ( void  )
static

Definition at line 757 of file cu_algorithm.c.

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

Referenced by algorithms_suite_setup().

758 {
759  LWPOINT *lwpoint = NULL;
760  LWLINE *lwline = NULL;
761  LWMLINE *lwmline = NULL;
762  char *geohash = NULL;
763 
764  lwpoint = (LWPOINT*)lwgeom_from_wkt("POINT(23.0 25.2)", LW_PARSER_CHECK_NONE);
765  geohash = lwgeom_geohash((LWGEOM*)lwpoint,0);
766  //printf("\ngeohash %s\n",geohash);
767  CU_ASSERT_STRING_EQUAL(geohash, "ss2r77s0du7p2ewb8hmx");
768  lwpoint_free(lwpoint);
769  lwfree(geohash);
770 
771  lwpoint = (LWPOINT*)lwgeom_from_wkt("POINT(23.0 25.2 2.0)", LW_PARSER_CHECK_NONE);
772  geohash = lwgeom_geohash((LWGEOM*)lwpoint,0);
773  //printf("geohash %s\n",geohash);
774  CU_ASSERT_STRING_EQUAL(geohash, "ss2r77s0du7p2ewb8hmx");
775  lwpoint_free(lwpoint);
776  lwfree(geohash);
777 
778  lwline = (LWLINE*)lwgeom_from_wkt("LINESTRING(23.0 23.0,23.1 23.1)", LW_PARSER_CHECK_NONE);
779  geohash = lwgeom_geohash((LWGEOM*)lwline,0);
780  //printf("geohash %s\n",geohash);
781  CU_ASSERT_STRING_EQUAL(geohash, "ss0");
782  lwline_free(lwline);
783  lwfree(geohash);
784 
785  lwline = (LWLINE*)lwgeom_from_wkt("LINESTRING(23.0 23.0,23.001 23.001)", LW_PARSER_CHECK_NONE);
786  geohash = lwgeom_geohash((LWGEOM*)lwline,0);
787  //printf("geohash %s\n",geohash);
788  CU_ASSERT_STRING_EQUAL(geohash, "ss06g7");
789  lwline_free(lwline);
790  lwfree(geohash);
791 
792  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);
793  geohash = lwgeom_geohash((LWGEOM*)lwmline,0);
794  //printf("geohash %s\n",geohash);
795  CU_ASSERT_STRING_EQUAL(geohash, "ss0");
796  lwmline_free(lwmline);
797  lwfree(geohash);
798 }
void lwmline_free(LWMLINE *mline)
Definition: lwmline.c:99
void lwfree(void *mem)
Definition: lwutil.c:190
void lwpoint_free(LWPOINT *pt)
Definition: lwpoint.c:180
void lwline_free(LWLINE *line)
Definition: lwline.c:63
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:844
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1706
char * lwgeom_geohash(const LWGEOM *lwgeom, int precision)
Calculate the GeoHash (http://geohash.org) string for a geometry.
Definition: lwalgorithm.c:828

Here is the call graph for this function:

Here is the caller graph for this function: