diff --git a/README.md b/README.md index b4bad0b..02db1ed 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,10 @@ for the [Maps](https://github.com/JeroenDeDauw/Maps) and ## Release notes +### 3.0.1 (2018-08-01) + +* Fixed parsing of coordinates with lowercase S/W directions + ### 3.0.0 (2018-03-20) * Removed `DATAVALUES_GEO_VERSION` constant diff --git a/src/Parsers/LatLongParserBase.php b/src/Parsers/LatLongParserBase.php index 89255a9..92f742d 100644 --- a/src/Parsers/LatLongParserBase.php +++ b/src/Parsers/LatLongParserBase.php @@ -225,7 +225,7 @@ protected function resolveDirection( $coordinateSegment ) { $matches ); - if ( $matches[1] === $direction || $matches[3] === $direction ) { + if ( $matches[1] !== '' || $matches[3] !== '' ) { $coordinateSegment = $matches[2]; if ( in_array( $direction, [ $s, $w ] ) ) { diff --git a/tests/unit/Parsers/LatLongParserTest.php b/tests/unit/Parsers/LatLongParserTest.php index e3f1743..814efc2 100644 --- a/tests/unit/Parsers/LatLongParserTest.php +++ b/tests/unit/Parsers/LatLongParserTest.php @@ -91,6 +91,14 @@ public function validInputProvider() { '0° 0.3\' S 0° 0.3\' W' => [ -0.005, -0.005 ], '-55° 30′ -37° 30′' => [ -55.5, -37.5 ], 'S 0° 0.3\' W 0° 0.3\'' => [ -0.005, -0.005 ], + + // case insensitive + '55 s, 37.6176330 w' => [ -55, -37.6176330 ], + '5.5s,37w ' => [ -5.5, -37 ], + '5.5s 37w ' => [ -5.5, -37 ], + 's5.5 w37 ' => [ -5.5, -37 ], + '5.5S 37w ' => [ -5.5, -37 ], + '5.5s 37W ' => [ -5.5, -37 ], ]; foreach ( $valid as $value => $expected ) {