PostGIS  2.5.0dev-r@@SVN_REVISION@@
void decode_geohash_bbox ( char *  geohash,
double *  lat,
double *  lon,
int  precision 
)

Definition at line 703 of file lwalgorithm.c.

References base32, and precision.

Referenced by parse_geohash().

704 {
705  int i, j, hashlen;
706  char c, cd, mask, is_even = 1;
707  static char bits[] = {16, 8, 4, 2, 1};
708 
709  lat[0] = -90.0;
710  lat[1] = 90.0;
711  lon[0] = -180.0;
712  lon[1] = 180.0;
713 
714  hashlen = strlen(geohash);
715 
716  if (precision < 0 || precision > hashlen)
717  {
718  precision = hashlen;
719  }
720 
721  for (i = 0; i < precision; i++)
722  {
723  c = tolower(geohash[i]);
724  cd = strchr(base32, c) - base32;
725 
726  for (j = 0; j < 5; j++)
727  {
728  mask = bits[j];
729  if (is_even)
730  {
731  lon[!(cd & mask)] = (lon[0] + lon[1]) / 2;
732  }
733  else
734  {
735  lat[!(cd & mask)] = (lat[0] + lat[1]) / 2;
736  }
737  is_even = !is_even;
738  }
739  }
740 }
uint8_t precision
Definition: cu_in_twkb.c:25
static char * base32
Definition: lwalgorithm.c:574

Here is the caller graph for this function: