1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| <?php
$original_json_string = file_get_contents('http://data.nantes.fr/api/publication/24440040400129_NM_NM_00019/LOC_EQUIPUB_CULTURE_NM_STBL/content/?format=json');
//$original_data = json_decode($original_json_string, true);
$json_decode=json_decode($original_json_string, true);
foreach($json_decode as $key => $value) {
$features[] = array(
'type' => 'Feature',
'properties' => array('name' => $value['data'][0]['geo']['name'] /*,
'label' => $value['label'],
'Capacite' => $value['capacity'],
'availableBikes' => $value['availableBikes'],
'availablePlaces' => $value['availablePlaces'],
'status' => $value['status'],
'address' => $value['address']*/),
'geometry' => array(
'type' => 'Point',
'coordinates' => array(
$value['data'][0] ['_l'][0],
$value['data'][0] ['_l'][1]
),
),
);
}
$new_data = array(
'type' => 'FeatureCollection',
'features' => $features,
);
$final_data = json_encode($new_data, JSON_PRETTY_PRINT);
print_r($final_data);
?> |
Partager