src/GeoHash.php
public function getGeoHashPrecision(array $geoBoundBox, int $squares)
    {
        $remainder = $squares % 2;
        $xQuotient = $squares / 2;
        $yQuotient = $xQuotient / 2;

        if (0 !== $remainder) {
            throw new \InvalidArgumentException('geoHash divisions must be multiple of 2');
        }

        // get x distance
        $xDist = $this->distance($geoBoundBox['top_left']['lat'], $geoBoundBox['top_left']['lon'], $geoBoundBox['bottom_right']['lat'], $geoBoundBox['top_left']['lon']);
        $xDist = $xDist * 1000;
        // get y distance
        $yDist = $this->distance($geoBoundBox['top_left']['lat'], $geoBoundBox['top_left']['lon'], $geoBoundBox['top_left']['lat'], $geoBoundBox['bottom_right']['lon']);
        $yDist = $yDist * 1000;

        // geohash distances
        $xGeohashDist = $xDist / $xQuotient;
        $yGeohashDist = $yDist / $yQuotient;

        return $this->getPrecisionFromArea($xGeohashDist, $yGeohashDist);

    }
public function getGeoHashPrecision(array $geoBoundBox, int $squares)
    {
        $remainder = $squares % 2;
        $xQuotient = $squares / 2;
        $yQuotient = $xQuotient / 2;

        if (0 !== $remainder) {
            throw new \InvalidArgumentException('geoHash divisions must be multiple of 2');
        }

        // get x distance
        $xDist = $this->distance($geoBoundBox['top_left']['lat'], $geoBoundBox['top_left']['lon'], $geoBoundBox['bottom_right']['lat'], $geoBoundBox['top_left']['lon']);
        $xDist = $xDist * 1000;
        // get y distance
        $yDist = $this->distance($geoBoundBox['top_left']['lat'], $geoBoundBox['top_left']['lon'], $geoBoundBox['top_left']['lat'], $geoBoundBox['bottom_right']['lon']);
        $yDist = $yDist * 1000;

        // geohash distances
        $xGeohashDist = $xDist / $xQuotient;
        $yGeohashDist = $yDist / $yQuotient;

        return $this->getPrecisionFromArea($xGeohashDist, $yGeohashDist);

    }
public function getGeoHashPrecision ( array $ geoBoundBox , int $ squares ) { $ remainder = $ squares % 2 ; $ xQuotient = $ squares / 2 ; $ yQuotient = $ xQuotient / 2 ; if ( 0 !== $ remainder ) { throw new \ InvalidArgumentException ( 'geoHash divisions must be multiple of 2' ) ; } // get x distance $ xDist = $ this -> distance ( $ geoBoundBox [ 'top_left' ] [ 'lat' ] , $ geoBoundBox [ 'top_left' ] [ 'lon' ] , $ geoBoundBox [ 'bottom_right' ] [ 'lat' ] , $ geoBoundBox [ 'top_left' ] [ 'lon' ] ) ; $ xDist = $ xDist * 1000 ; // get y distance $ yDist = $ this -> distance ( $ geoBoundBox [ 'top_left' ] [ 'lat' ] , $ geoBoundBox [ 'top_left' ] [ 'lon' ] , $ geoBoundBox [ 'top_left' ] [ 'lat' ] , $ geoBoundBox [ 'bottom_right' ] [ 'lon' ] ) ; $ yDist = $ yDist * 1000 ; // geohash distances $ xGeohashDist = $ xDist / $ xQuotient ; $ yGeohashDist = $ yDist / $ yQuotient ; return $ this -> getPrecisionFromArea ( $ xGeohashDist , $ yGeohashDist ) ; }
geoBoundBox: [ top_left => [ lat => x, lon => y ], bottom_right => [ lat => x, lon => y ]

@param  array      $geoBoundBox
@param  int        $squares
@return mixed
@throws \Exception
geoBoundBox : [ top_left = > [ lat = > x lon = > y ] bottom_right = > [ lat = > x lon = > y ]