Skip to content

Commit

Permalink
Merge pull request #140 from DataValues/3.0.x-backport
Browse files Browse the repository at this point in the history
Fix parsing of lowercase S/W directions
  • Loading branch information
JeroenDeDauw authored Aug 1, 2018
2 parents 1735bdd + 49cd65d commit f0a4c31
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Parsers/LatLongParserBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] ) ) {
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/Parsers/LatLongParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down

0 comments on commit f0a4c31

Please sign in to comment.