Skip to content

Commit d283ebf

Browse files
authored
Merge pull request #141 from DataValues/2.1.x-backport
Fix parsing of lowercase S/W directions
2 parents 8fd8829 + 4725bdd commit d283ebf

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

Geo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
return 1;
1616
}
1717

18-
define( 'DATAVALUES_GEO_VERSION', '2.1.1' );
18+
define( 'DATAVALUES_GEO_VERSION', '2.1.2' );
1919

2020
// Aliases introduced in 1.0
2121
class_alias( DataValues\Geo\Values\LatLongValue::class, 'DataValues\LatLongValue' );

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ It is based upon and contains a lot of code written by [Jeroen De Dauw]
9393

9494
## Release notes
9595

96+
### 2.1.2 (2018-08-01)
97+
98+
* Fixed parsing of coordinates with lowercase S/W directions
99+
96100
### 2.1.1 (2017-08-09)
97101

98102
* Allow use with ~0.4.0 of DataValues/Common

src/Parsers/LatLongParserBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ protected function resolveDirection( $coordinateSegment ) {
213213
$matches
214214
);
215215

216-
if ( $matches[1] === $direction || $matches[3] === $direction ) {
216+
if ( $matches[1] !== '' || $matches[3] !== '' ) {
217217
$coordinateSegment = $matches[2];
218218

219219
if ( in_array( $direction, [ $s, $w ] ) ) {

tests/unit/Parsers/LatLongParserTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ public function validInputProvider() {
9999
'0° 0.3\' S 0° 0.3\' W' => [ -0.005, -0.005 ],
100100
'-55° 30′ -37° 30′' => [ -55.5, -37.5 ],
101101
'S 0° 0.3\' W 0° 0.3\'' => [ -0.005, -0.005 ],
102+
103+
// case insensitive
104+
'55 s, 37.6176330 w' => [ -55, -37.6176330 ],
105+
'5.5s,37w ' => [ -5.5, -37 ],
106+
'5.5s 37w ' => [ -5.5, -37 ],
107+
's5.5 w37 ' => [ -5.5, -37 ],
108+
'5.5S 37w ' => [ -5.5, -37 ],
109+
'5.5s 37W ' => [ -5.5, -37 ],
102110
];
103111

104112
foreach ( $valid as $value => $expected ) {

0 commit comments

Comments
 (0)