Skip to content

Commit

Permalink
use pedestrian tag for street name if road tag is not available
Browse files Browse the repository at this point in the history
add some spaces

use pedestrian tag for street name if road tag is not available
  • Loading branch information
MatTheCat authored and MatTheCat committed Aug 8, 2013
1 parent 99b9646 commit a32abc8
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 @@ -498,4 +498,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 a32abc8

Please sign in to comment.