Skip to content

Commit

Permalink
Merge pull request #141 from DataValues/2.1.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 8fd8829 + 4725bdd commit d283ebf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Geo.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
return 1;
}

define( 'DATAVALUES_GEO_VERSION', '2.1.1' );
define( 'DATAVALUES_GEO_VERSION', '2.1.2' );

// Aliases introduced in 1.0
class_alias( DataValues\Geo\Values\LatLongValue::class, 'DataValues\LatLongValue' );
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ It is based upon and contains a lot of code written by [Jeroen De Dauw]

## Release notes

### 2.1.2 (2018-08-01)

* Fixed parsing of coordinates with lowercase S/W directions

### 2.1.1 (2017-08-09)

* Allow use with ~0.4.0 of DataValues/Common
Expand Down
2 changes: 1 addition & 1 deletion src/Parsers/LatLongParserBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,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 @@ -99,6 +99,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 d283ebf

Please sign in to comment.