|
76 | 76 | 'osm_tag_address_state' => isset($_POST['osm_tag_address_state']), |
77 | 77 | 'osm_tag_address_country' => isset($_POST['osm_tag_address_country']), |
78 | 78 | 'osm_tag_address_postcode' => isset($_POST['osm_tag_address_postcode']), |
79 | | - 'osm_tag_address_country_code' => isset($_POST['osm_tag_address_country_code']) |
| 79 | + 'osm_tag_address_country_code' => isset($_POST['osm_tag_address_country_code']), |
| 80 | + 'language' => preg_split("/_/",$_POST['language'])[0] |
80 | 81 | ); |
81 | 82 |
|
82 | 83 | // TODO allow to filter on overwrite |
|
116 | 117 | // As of Sept 2015 require a API KEY |
117 | 118 | //$osm_url = "https://open.mapquestapi.com/nominatim/v1/reverse.php?format=json&addressdetails=1&zoom=12&lat=". $image['latitude'] ."&lon=". $image['longitude']; |
118 | 119 | //$osm_url = "http://localhost:8443/api/". $image['latitude'] ."/". $image['longitude']; |
119 | | - $osm_url = "https://nominatim-xbgmsharp.rhcloud.com/api/". $image['latitude'] ."/". $image['longitude']; |
| 120 | + $osm_url = "https://nominatim-xbgmsharp.rhcloud.com/api/". $image['latitude'] ."/". $image['longitude'] ."/". $sync_options['language']; |
120 | 121 | //print $osm_url ."<br/>"; |
121 | 122 |
|
122 | 123 | // Ensure we do have PHP curl install |
|
170 | 171 | $response['address'] = $response['success'][0]['result']['address']; |
171 | 172 | //print_r($response['address']); |
172 | 173 | //print_r($sync_options); |
173 | | - $tag_ids = array(); |
174 | 174 | $tag_names = array(); |
175 | 175 | if (isset($response['address']['suburb']) and $sync_options['osm_tag_address_suburb']) { |
176 | | - array_push( $tag_ids, tag_id_from_tag_name($sync_options['osm_tag_group'].":".$response['address']['suburb']) ); |
177 | 176 | array_push( $tag_names, $response['address']['suburb'] ); |
178 | 177 | } |
179 | 178 | if (isset($response['address']['city_district']) and $sync_options['osm_tag_address_city_district']) { |
180 | | - array_push( $tag_ids, tag_id_from_tag_name($sync_options['osm_tag_group'].":".$response['address']['city_district']) ); |
181 | 179 | array_push( $tag_names, $response['address']['city_district'] ); |
182 | 180 | } |
183 | 181 | if (isset($response['address']['city']) and $sync_options['osm_tag_address_city']) { |
184 | | - array_push( $tag_ids, tag_id_from_tag_name($sync_options['osm_tag_group'].":".$response['address']['city']) ); |
185 | 182 | array_push( $tag_names, $response['address']['city'] ); |
186 | 183 | } |
187 | 184 | if (isset($response['address']['county']) and $sync_options['osm_tag_address_county']) { |
188 | | - array_push( $tag_ids, tag_id_from_tag_name($sync_options['osm_tag_group'].":".$response['address']['county']) ); |
189 | 185 | array_push( $tag_names, $response['address']['county'] ); |
190 | 186 | } |
191 | 187 | if (isset($response['address']['state']) and $sync_options['osm_tag_address_state']) { |
192 | | - array_push( $tag_ids, tag_id_from_tag_name($sync_options['osm_tag_group'].":".$response['address']['state']) ); |
193 | 188 | array_push( $tag_names, $response['address']['state'] ); |
194 | 189 | } |
195 | 190 | if (isset($response['address']['country']) and $sync_options['osm_tag_address_country']) { |
196 | | - array_push( $tag_ids, tag_id_from_tag_name($sync_options['osm_tag_group'].":".$response['address']['country']) ); |
197 | 191 | array_push( $tag_names, $response['address']['country'] ); |
198 | 192 | } |
199 | 193 | if (isset($response['address']['postcode']) and $sync_options['osm_tag_address_postcode']) { |
200 | | - array_push( $tag_ids, tag_id_from_tag_name($sync_options['osm_tag_group'].":".$response['address']['postcode']) ); |
201 | 194 | array_push( $tag_names, $response['address']['postcode'] ); |
202 | 195 | } |
203 | 196 | if (isset($response['address']['country_code']) and $sync_options['osm_tag_address_country_code']) { |
204 | | - array_push( $tag_ids, tag_id_from_tag_name($sync_options['osm_tag_group'].":".$response['address']['country_code']) ); |
205 | 197 | array_push( $tag_names, $response['address']['country_code'] ); |
206 | 198 | } |
207 | | - //print_r($tag_ids); |
208 | 199 | //print_r($tag_names); |
209 | | - if (!empty($tag_ids) and !empty($tag_names)) |
| 200 | + if (!empty($tag_names)) |
210 | 201 | { |
211 | 202 | if (!$sync_options['simulate']) |
212 | 203 | { |
213 | | - add_tags($tag_ids, [$image['id']]); |
| 204 | + /* Create tag */ |
| 205 | + $tag_ids = array(); |
| 206 | + foreach ($tag_names as $tag_name) |
| 207 | + { |
| 208 | + array_push( $tag_ids, tag_id_from_tag_name($sync_options['osm_tag_group'].":".$tag_name) ); |
| 209 | + } |
| 210 | + /* Assign tags to image */ |
| 211 | + //print_r($tag_ids); |
| 212 | + if (!empty($tag_ids)) |
| 213 | + { |
| 214 | + add_tags($tag_ids, [$image['id']]); |
| 215 | + } |
214 | 216 | } |
215 | 217 | $datas[] = $image['id']; |
216 | 218 | $infos[] = "Set tags '". osm_pprint_r($tag_names) ."' for ". $image['name']; |
|
255 | 257 | 'SUBCATS_INCLUDED_CHECKED' => $sync_options['subcats_included'] ? 'checked="checked"' : '', |
256 | 258 | 'NB_GEOTAGGED' => $nb_geotagged, |
257 | 259 | 'OSM_PATH' => OSM_PATH, |
| 260 | + 'sync_options' => $sync_options, |
| 261 | + 'language_options' => get_languages(), |
| 262 | + 'language_selected' => get_default_language(), |
258 | 263 | ) |
259 | 264 | ); |
260 | 265 |
|
|
0 commit comments