Skip to content

Commit ef4bb41

Browse files
committed
fix reverse geocoding service (#164)
1 parent b455c79 commit ef4bb41

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

admin/admin_tag.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@
110110
$infos = array();
111111
foreach ($images as $image)
112112
{
113-
// Fech reverse location from API
113+
// Fetch reverse location from API
114114
// http://wiki.openstreetmap.org/wiki/Nominatim
115115
// https://nominatim.openstreetmap.org/reverse?format=xml&lat=51.082333&lon=10.366229&zoom=12
116116
// https://open.mapquestapi.com/nominatim/v1/reverse.php?format=xml&lat=48.858366666667&lon=2.2942166666667&zoom=12
117-
//$osm_url = "https://nominatim.openstreetmap.org/reverse?format=json&addressdetails=1&zoom=12&lat=". $image['latitude'] ."&lon=". $image['longitude'];
117+
$osm_url = "https://nominatim.openstreetmap.org/reverse?format=json&addressdetails=1&zoom=12&lat=". $image['latitude'] ."&lon=". $image['longitude'] ."&accept-language=". $sync_options['language'];
118118
// As of Sept 2015 require a API KEY
119119
//$osm_url = "https://open.mapquestapi.com/nominatim/v1/reverse.php?format=json&addressdetails=1&zoom=12&lat=". $image['latitude'] ."&lon=". $image['longitude'];
120120
//$osm_url = "http://localhost:8443/api/". $image['latitude'] ."/". $image['longitude'];
121-
$osm_url = "https://nominatim-xbgmsharp.rhcloud.com/api/". $image['latitude'] ."/". $image['longitude'] ."/". $sync_options['language'];
121+
//$osm_url = "https://nominatim-xbgmsharp.rhcloud.com/api/". $image['latitude'] ."/". $image['longitude'] ."/". $sync_options['language'];
122122
//print $osm_url ."<br/>";
123123

124124
// Ensure we do have PHP curl install
@@ -149,11 +149,11 @@
149149
);
150150
$context = stream_context_create($opts);
151151
if (false !== ($json = @file_get_contents($osm_url, flase, $context))) {
152-
// all good
152+
// all good
153153
//return $json;
154154
} else {
155155
// error happened
156-
//return false;
156+
//return false;
157157
$errors[] = "Error fetching reverse data";
158158
}
159159
}
@@ -166,10 +166,8 @@
166166
//print_r($response);
167167

168168
// If reponse include [address]
169-
if (isset($response) and isset($response['success']) and isset($response['success'][0]) and isset($response['success'][0]['result'])
170-
and isset($response['success'][0]['result']['address']) and is_array($response['success'][0]['result']['address']))
169+
if (isset($response) and isset($response['address']) and is_array($response['address']))
171170
{
172-
$response['address'] = $response['success'][0]['result']['address'];
173171
//print_r($response['address']);
174172
//print_r($sync_options);
175173
$tag_names = array();

0 commit comments

Comments
 (0)