Geohash::binDecode PHP Method

binDecode() private method

decodes binary encoding of number as detailed in http://en.wikipedia.org/wiki/Geohash#Example removing the tail recursion is left an exercise for the reader
private binDecode ( $binary, $min, $max )
    private function binDecode($binary, $min, $max)
    {
        $mid = ($min + $max) / 2;
        if (strlen($binary) == 0) {
            return $mid;
        }
        $bit = substr($binary, 0, 1);
        $binary = substr($binary, 1);
        if ($bit == 1) {
            return $this->binDecode($binary, $mid, $max);
        } else {
            return $this->binDecode($binary, $min, $mid);
        }
    }