PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_geohash()

static void test_geohash ( void  )
static

Definition at line 839 of file cu_algorithm.c.

840 {
841  LWPOINT *lwpoint = NULL;
842  LWLINE *lwline = NULL;
843  LWMLINE *lwmline = NULL;
844  char *geohash = NULL;
845 
846  lwpoint = (LWPOINT*)lwgeom_from_wkt("POINT(23.0 25.2)", LW_PARSER_CHECK_NONE);
847  geohash = lwgeom_geohash((LWGEOM*)lwpoint,0);
848  //printf("\ngeohash %s\n",geohash);
849  CU_ASSERT_STRING_EQUAL(geohash, "ss2r77s0du7p2ewb8hmx");
850  lwpoint_free(lwpoint);
851  lwfree(geohash);
852 
853  lwpoint = (LWPOINT*)lwgeom_from_wkt("POINT(23.0 25.2 2.0)", LW_PARSER_CHECK_NONE);
854  geohash = lwgeom_geohash((LWGEOM*)lwpoint,0);
855  //printf("geohash %s\n",geohash);
856  CU_ASSERT_STRING_EQUAL(geohash, "ss2r77s0du7p2ewb8hmx");
857  lwpoint_free(lwpoint);
858  lwfree(geohash);
859 
860  lwline = (LWLINE*)lwgeom_from_wkt("LINESTRING(23.0 23.0,23.1 23.1)", LW_PARSER_CHECK_NONE);
861  geohash = lwgeom_geohash((LWGEOM*)lwline,0);
862  //printf("geohash %s\n",geohash);
863  CU_ASSERT_STRING_EQUAL(geohash, "ss0");
864  lwline_free(lwline);
865  lwfree(geohash);
866 
867  lwline = (LWLINE*)lwgeom_from_wkt("LINESTRING(23.0 23.0,23.001 23.001)", LW_PARSER_CHECK_NONE);
868  geohash = lwgeom_geohash((LWGEOM*)lwline,0);
869  //printf("geohash %s\n",geohash);
870  CU_ASSERT_STRING_EQUAL(geohash, "ss06g7h");
871  lwline_free(lwline);
872  lwfree(geohash);
873 
874  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);
875  geohash = lwgeom_geohash((LWGEOM*)lwmline,0);
876  //printf("geohash %s\n",geohash);
877  CU_ASSERT_STRING_EQUAL(geohash, "ss0");
878  lwmline_free(lwmline);
879  lwfree(geohash);
880 }
void lwpoint_free(LWPOINT *pt)
Definition: lwpoint.c:213
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2005
char * lwgeom_geohash(const LWGEOM *lwgeom, int precision)
Calculate the GeoHash (http://geohash.org) string for a geometry.
Definition: lwalgorithm.c:856
void lwfree(void *mem)
Definition: lwutil.c:244
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
void lwmline_free(LWMLINE *mline)
Definition: lwmline.c:112
void lwline_free(LWLINE *line)
Definition: lwline.c:76

References 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: