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

Definition at line 704 of file lwalgorithm.c.

References base32.

Referenced by parse_geohash().

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

Here is the caller graph for this function: