Skip to content

Commit

Permalink
Merge pull request #255 from MatTheCat/master
Browse files Browse the repository at this point in the history
Use OpenStreetMap pedestrian tag for street name if road tag is not available
  • Loading branch information
willdurand committed Aug 8, 2013
2 parents 5c71f1b + a32abc8 commit f8ad593
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Geocoder/Provider/OpenStreetMapsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function getGeocodedData($address)
'county' => $this->getNodeValue($place->getElementsByTagName('county')),
'region' => $this->getNodeValue($place->getElementsByTagName('state')),
'streetNumber' => $this->getNodeValue($place->getElementsByTagName('house_number')),
'streetName' => $this->getNodeValue($place->getElementsByTagName('road')),
'streetName' => $this->getNodeValue($place->getElementsByTagName('road')) ?: $this->getNodeValue($place->getElementsByTagName('pedestrian')),
'city' => $this->getNodeValue($place->getElementsByTagName('city')),
'cityDistrict' => $this->getNodeValue($place->getElementsByTagName('suburb')),
'country' => $this->getNodeValue($place->getElementsByTagName('country')),
Expand Down Expand Up @@ -116,7 +116,7 @@ public function getReversedData(array $coordinates)
'county' => $this->getNodeValue($addressParts->getElementsByTagName('county')),
'region' => $this->getNodeValue($addressParts->getElementsByTagName('state')),
'streetNumber' => $this->getNodeValue($addressParts->getElementsByTagName('house_number')),
'streetName' => $this->getNodeValue($addressParts->getElementsByTagName('road')),
'streetName' => $this->getNodeValue($addressParts->getElementsByTagName('road')) ?: $this->getNodeValue($addressParts->getElementsByTagName('pedestrian')),
'city' => $this->getNodeValue($addressParts->getElementsByTagName('city')),
'cityDistrict' => $this->getNodeValue($addressParts->getElementsByTagName('suburb')),
'country' => $this->getNodeValue($addressParts->getElementsByTagName('country')),
Expand Down
8 changes: 8 additions & 0 deletions tests/Geocoder/Tests/Provider/OpenStreetMapsProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,4 +496,12 @@ public function testGetReversedDataWithCoordinatesGetsError()
$provider = new OpenStreetMapsProvider($this->getMockAdapterReturns($errorXml));
$provider->getReversedData(array('-80.000000', '-170.000000'));
}

public function testGetNodeStreetName()
{
$provider = new OpenStreetMapsProvider(new \Geocoder\HttpAdapter\CurlHttpAdapter(), 'fr_FR');
$results = $provider->getReversedData(array(48.86, 2.35));

$this->assertEquals('Rue Quincampoix', $results[0]['streetName']);
}
}

0 comments on commit f8ad593

Please sign in to comment.