'FeatureCollection', 'features' => array() ); // Ajouter un tronçon au tableau GeoJSON while($edge=pg_fetch_assoc($query)) { $feature = array( 'type' => 'Feature', 'geometry' => json_decode($edge['geojson'], true), 'crs' => array( 'type' => 'EPSG', 'properties' => array('code' => '4326') ), 'properties' => array( 'id' => $edge['id'], 'length' => $edge['length'] ) ); // Ajouter un tableau d'éléments au tableau de collection d'éléments array_push($geojson['features'], $feature); } // Fermeture de la connexion pg_close($dbcon); // Renvoyer le résultat header('Content-type: application/json',true); echo json_encode($geojson); ?>