src/Helper/HaversineSphericalDistance.php
public static function getFormulaAsQueryPart(
        $firstLatitude,
        $firstLongitude,
        $secondLatitude,
        $secondLongitude,
        $digits = 0,
        $earthRadius = self::EARTH_RADIUS_IN_KM
    ): string {
        return \sprintf(
            'ROUND(
                SQRT(
                    POWER(2 * PI() / 360 * (CAST(%1$s AS DECIMAL(9,6)) - CAST(%3$s AS DECIMAL(9,6))) * %6$s, 2) 
                    + POWER(2 * PI() / 360 * (CAST(%2$s AS DECIMAL(9,6)) - CAST(%4$s AS DECIMAL(9,6))) * %6$s 
                        * COS(2 * PI() / 360 * (CAST(%1$s AS DECIMAL(9,6)) + CAST(%3$s AS DECIMAL(9,6))) * 0.5), 2)
                ), %5$s
            )',
            $firstLatitude,
            $firstLongitude,
            $secondLatitude,
            $secondLongitude,
            $digits,
            $earthRadius
        );
    }
public static function getFormulaAsQueryPart(
        $firstLatitude,
        $firstLongitude,
        $secondLatitude,
        $secondLongitude,
        $digits = 0,
        $earthRadius = self::EARTH_RADIUS_IN_KM
    ): string {
        return \sprintf(
            'ROUND(
                SQRT(
                    POWER(2 * PI() / 360 * (CAST(%1$s AS DECIMAL(9,6)) - CAST(%3$s AS DECIMAL(9,6))) * %6$s, 2) 
                    + POWER(2 * PI() / 360 * (CAST(%2$s AS DECIMAL(9,6)) - CAST(%4$s AS DECIMAL(9,6))) * %6$s 
                        * COS(2 * PI() / 360 * (CAST(%1$s AS DECIMAL(9,6)) + CAST(%3$s AS DECIMAL(9,6))) * 0.5), 2)
                ), %5$s
            )',
            $firstLatitude,
            $firstLongitude,
            $secondLatitude,
            $secondLongitude,
            $digits,
            $earthRadius
        );
    }
public static function getFormulaAsQueryPart ( $ firstLatitude , $ firstLongitude , $ secondLatitude , $ secondLongitude , $ digits = 0 , $ earthRadius = self :: EARTH_RADIUS_IN_KM ) : string { return \ sprintf ( 'ROUND(
                SQRT(
                    POWER(2 * PI() / 360 * (CAST(%1$s AS DECIMAL(9,6)) - CAST(%3$s AS DECIMAL(9,6))) * %6$s, 2) 
                    + POWER(2 * PI() / 360 * (CAST(%2$s AS DECIMAL(9,6)) - CAST(%4$s AS DECIMAL(9,6))) * %6$s 
                        * COS(2 * PI() / 360 * (CAST(%1$s AS DECIMAL(9,6)) + CAST(%3$s AS DECIMAL(9,6))) * 0.5), 2)
                ), %5$s
            )' , $ firstLatitude , $ firstLongitude , $ secondLatitude , $ secondLongitude , $ digits , $ earthRadius ) ; }
Get the spherical distance haversine formula for the database query part.

@param string|float $firstLatitude   The first latitude coordinate. You can a coordinate or a database field.
@param string|float $firstLongitude  The first longitude coordinate. You can a coordinate or a database field.
@param string|float $secondLatitude  The second latitude coordinate. You can a coordinate or a database field.
@param string|float $secondLongitude The second longitude coordinate. You can a coordinate or a database field.
@param int          $digits          The number of digits after the decimal point.
@param int          $earthRadius     The earth radius.

@return string
Get the spherical distance haversine formula for the database query part .