PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ test_geohash()

static void test_geohash ( void  )
static

Definition at line 760 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().

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