/**
  * Tests for geohash::encode_digit() and geohash::decode_digit().
  * These functions provide raw conversion digit by digit.
  * 
  * @dataProvider digitProvider
  * @param int $number
  * @param string $digit
  */
 public function testGeocodeEncodeDigitAndDecodeDigit($number, $digit)
 {
     $this->assertEquals($digit, geohash::encode_digit($number));
     $this->assertEquals($number, geohash::decode_digit($digit));
 }
 /**
  * Return the quadrant of an ancestor containing this geohash.
  * If no precision is given, the immediant parent will be assumed.
  * We can find out which quadrant of any ancestor up to and including the first character.
  * To determine the global quadrant, choose precision 0.
  * 
  * Examples:
  *      '00' is in the southwest quadrant of '0'
  *      'drt2zm8h1t3v' is in the northeast quadrant of 'drt2zm8h1t3'
  *      '9345' is northwest on the globe
  * 
  * @param string $hash geohash
  * @param int $precision
  * @return string geohash::northwest, geohash::northeast, geohash::southwest or geohash::southeast
  */
 public static function quadrant($hash, $precision = null)
 {
     if ($precision >= strlen($hash)) {
         return null;
     }
     $odd = $precision % 2;
     $quadrant = (int) (geohash::decode_digit($hash[$precision]) / 8);
     switch ($quadrant) {
         case 0:
             return geohash::southwest;
         case 1:
             return $odd ? geohash::southeast : geohash::northwest;
         case 2:
             return $odd ? geohash::northwest : geohash::southeast;
         case 3:
             return geohash::northeast;
     }
 }