geocoder-php/Geocoder — pull request #296 by fluxoft (2014-02-26 16:52:15+00:00)
Title: Update MapQuestProvider.php

MapQuest is not returning any useful information for coordinates in London. However, because it does include a locations element in the returned JSON, a results array is returned from the provider, with null values for all fields except the given coordinates.

Because a (bad) result is returned, the next provider in my chain is never queried to get the correct data.

Modified the provider to only return results if there are any non-empty values to be written.

The test file I was using to verify the behavior is below:

```
registerProvider($chain);

$coordinatesArray = array(
array('38.8953003', '-77.0328011'), // Washington, DC
array('48.868865', '2.339355'), // Paris
array('51.507276', '-0.12766') // London
);
foreach ($coordinatesArray as $coordinates) {
$geocoded = $geocoder->reverse($coordinates[0], $coordinates[1]);
echo "reverse geocoding $coordinates[0], $coordinates[1]:\n";
print_r($geocoded->toArray());
}
```

Output before patch:
```
38.8953003, -77.0328011:
Array
(
[latitude] => 38.8953
[longitude] => -77.032801
[bounds] =>
[streetNumber] =>
[streetName] => Pennsylvania Avenue Northwest
[zipcode] => 20004
[city] => Washington
[cityDistrict] =>
[county] => District Of Columbia
[countyCode] =>
[region] =>
[regionCode] =>
[country] => Us
[countryCode] =>
[timezone] =>
)
48.868865, 2.339355:
Array
(
[latitude] => 48.868865
[longitude] => 2.339355
[bounds] =>
[streetNumber] =>
[streetName] => 5 Rue Des Filles Saint-Thomas
[zipcode] => 75002
[city] => Paris
[cityDistrict] =>
[county] => Paris
[countyCode] =>
[region] => Ile-De-France
[regionCode] =>
[country] => Fr
[countryCode] =>
[timezone] =>
)
51.507276, -0.12766:
Array
(
[latitude] => 51.507276
[longitude] => -0.12766
[bounds] =>
[streetNumber] =>
[streetName] =>
[zipcode] =>
[city] =>
[cityDistrict] =>
[county] =>
[countyCode] =>
[region] =>
[regionCode] =>
[country] =>
[countryCode] =>
[timezone] =>
)
```

As you can see, the result for London is all blank except for the given coordinates.

Output after patch:
```
38.8953003, -77.0328011:
Array
(
[latitude] => 38.8953
[longitude] => -77.032801
[bounds] =>
[streetNumber] =>
[streetName] => Pennsylvania Avenue Northwest
[zipcode] => 20004
[city] => Washington
[cityDistrict] =>
[county] => District Of Columbia
[countyCode] =>
[region] =>
[regionCode] =>
[country] => Us
[countryCode] =>
[timezone] =>
)
48.868865, 2.339355:
Array
(
[latitude] => 48.868865
[longitude] => 2.339355
[bounds] =>
[streetNumber] =>
[streetName] => 5 Rue Des Filles Saint-Thomas
[zipcode] => 75002
[city] => Paris
[cityDistrict] =>
[county] => Paris
[countyCode] =>
[region] => Ile-De-France
[regionCode] =>
[country] => Fr
[countryCode] =>
[timezone] =>
)
51.507276, -0.12766:
Array
(
[latitude] => 51.5072997
[longitude] => -0.1275094
[bounds] => Array
(
[south] => 51.5072997
[west] => -0.1275094
[north] => 51.5072997
[east] => -0.1275094
)

[streetNumber] => 3
[streetName] => Whitehall
[zipcode] => SW1A 2EL
[city] => London
[cityDistrict] =>
[county] => Greater London
[countyCode] => GT LON
[region] =>
[regionCode] =>
[country] => United Kingdom
[countryCode] => GB
[timezone] =>
)
```

Here, the MapQuest provider was skipped and the correct result was returned from the GoogleMapsBusinessProvider.