3 // https://github.com/geocoders/geocodejson-spec/
5 $aFilteredPlaces = array();
9 $aFilteredPlaces['error'] = $sError;
10 else $aFilteredPlaces['error'] = 'Unable to geocode';
11 javascript_renderData($aFilteredPlaces);
13 $aFilteredPlaces = array(
15 'properties' => array(
16 'geocoding' => array()
20 if (isset($aPlace['place_id'])) $aFilteredPlaces['properties']['geocoding']['place_id'] = $aPlace['place_id'];
21 $sOSMType = formatOSMType($aPlace['osm_type']);
23 $aFilteredPlaces['properties']['geocoding']['osm_type'] = $sOSMType;
24 $aFilteredPlaces['properties']['geocoding']['osm_id'] = $aPlace['osm_id'];
27 $aFilteredPlaces['properties']['geocoding']['type'] = $aPlace['type'];
29 $aFilteredPlaces['properties']['geocoding']['accuracy'] = (int) $fDistance;
31 $aFilteredPlaces['properties']['geocoding']['label'] = $aPlace['langaddress'];
33 $aFilteredPlaces['properties']['geocoding']['name'] = $aPlace['placename'];
35 $aFieldMappings = array(
36 'house_number' => 'housenumber',
38 'locality' => 'locality',
39 'postcode' => 'postcode',
41 'district' => 'district',
44 'country' => 'country'
47 foreach ($aFieldMappings as $sFrom => $sTo) {
48 if (isset($aPlace['aAddress'][$sFrom])) {
49 $aFilteredPlaces['properties']['geocoding'][$sTo] = $aPlace['aAddress'][$sFrom];
53 $aFilteredPlaces['properties']['geocoding']['admin'] = $aPlace['aAddressAdminLevels'];
55 if (isset($aPlace['asgeojson'])) {
56 $aFilteredPlaces['geometry'] = json_decode($aPlace['asgeojson']);
58 $aFilteredPlaces['geometry'] = array(
60 'coordinates' => array(
61 (float) $aPlace['lon'],
62 (float) $aPlace['lat']
67 javascript_renderData(array(
68 'type' => 'FeatureCollection',
71 'attribution' => 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
75 'features' => $aFilteredPlaces