private static function parseDecimalMinutesWithCardinalLetters($string, $ellipsoid)
{
// Decimal minutes with cardinal letters, e. g. "52 12.345, 13 23.456",
// "52° 12.345, 13° 23.456", "52° 12.345′, 13° 23.456′", "52 12.345 N, 13 23.456 E",
// "N52° 12.345′ E13° 23.456′"
if (preg_match('/([NS]?\\s*)(\\d{1,2})°?\\s+(\\d{1,2}\\.?\\d*)[\'′]?(\\s*[NS]?)[, ]\\s*([EW]?\\s*)(\\d{1,3})°?\\s+(\\d{1,2}\\.?\\d*)[\'′]?(\\s*[EW]?)/ui', $string, $match)) {
$latitude = $match[2] + $match[3] / 60;
if (trim(strtoupper($match[1])) === 'S' || trim(strtoupper($match[4])) === 'S') {
$latitude = -$latitude;
}
$longitude = $match[6] + $match[7] / 60;
if (trim(strtoupper($match[5])) === 'W' || trim(strtoupper($match[8])) === 'W') {
$longitude = -$longitude;
}
return new Coordinate($latitude, $longitude, $ellipsoid);
}
return null;
}