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

Definition at line 689 of file lwalgorithm.c.

References base32, and precision.

Referenced by parse_geohash().

690 {
691  int i, j, hashlen;
692  char c, cd, mask, is_even = 1;
693  static char bits[] = {16, 8, 4, 2, 1};
694 
695  lat[0] = -90.0;
696  lat[1] = 90.0;
697  lon[0] = -180.0;
698  lon[1] = 180.0;
699 
700  hashlen = strlen(geohash);
701 
702  if (precision < 0 || precision > hashlen)
703  {
704  precision = hashlen;
705  }
706 
707  for (i = 0; i < precision; i++)
708  {
709  c = tolower(geohash[i]);
710  cd = strchr(base32, c) - base32;
711 
712  for (j = 0; j < 5; j++)
713  {
714  mask = bits[j];
715  if (is_even)
716  {
717  lon[!(cd & mask)] = (lon[0] + lon[1]) / 2;
718  }
719  else
720  {
721  lat[!(cd & mask)] = (lat[0] + lat[1]) / 2;
722  }
723  is_even = !is_even;
724  }
725  }
726 }
uint8_t precision
Definition: cu_in_twkb.c:25
static char * base32
Definition: lwalgorithm.c:560

Here is the caller graph for this function: