Location\Factory\CoordinateFactory::parseDecimalDegreesWithCardinalLetters PHP Method

parseDecimalDegreesWithCardinalLetters() private static method

private static parseDecimalDegreesWithCardinalLetters ( $string, $ellipsoid ) : Coordinate | null
$string
$ellipsoid
return Location\Coordinate | null
    private static function parseDecimalDegreesWithCardinalLetters($string, $ellipsoid)
    {
        // Decimal degrees with cardinal letters, e. g. "N52.5, E13.5",
        // "40.2S, 135.3485W", or "56.234°N, 157.245°W"
        if (preg_match('/([NS]?\\s*)(\\d{1,2}\\.?\\d*)°?(\\s*[NS]?)[, ]\\s*([EW]?\\s*)(\\d{1,3}\\.?\\d*)°?(\\s*[EW]?)/ui', $string, $match)) {
            $latitude = $match[2];
            if (trim(strtoupper($match[1])) === 'S' || trim(strtoupper($match[3])) === 'S') {
                $latitude = -$latitude;
            }
            $longitude = $match[5];
            if (trim(strtoupper($match[4])) === 'W' || trim(strtoupper($match[6])) === 'W') {
                $longitude = -$longitude;
            }
            return new Coordinate($latitude, $longitude, $ellipsoid);
        }
        return null;
    }