Commit d987747
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:
<?php
require_once dirname(dirname(__FILE__)).'/vendor/autoload.php';
header('Content-type: text/plain');
$geocoder = new \Geocoder\Geocoder();
$buzz = new \Buzz\Browser(new \Buzz\Client\Curl());
$adapter = new \Geocoder\HttpAdapter\BuzzHttpAdapter($buzz);
$chain = new \Geocoder\Provider\ChainProvider(
array(
new \Geocoder\Provider\MapQuestProvider($adapter, 'mapquest_api_key'),
new \Geocoder\Provider\GoogleMapsBusinessProvider($adapter, 'google_client_id', 'google_private_key')
)
);
$geocoder->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);
}1 parent 0271825 commit d987747
1 file changed
+17
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
157 | 159 | | |
158 | 160 | | |
159 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
160 | 166 | | |
161 | 167 | | |
0 commit comments