mirror of
https://forge.chapril.org/tykayn/osm-commerces
synced 2025-10-09 17:02:46 +02:00
follow up graphs
This commit is contained in:
parent
4b4a46c3f7
commit
ab1b9a9d3d
11 changed files with 580 additions and 41 deletions
|
@ -556,4 +556,41 @@ out meta;';
|
|||
'counters' => $counters
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Génère la requête Overpass pour les bornes incendie et bornes de recharge
|
||||
*/
|
||||
public function get_followup_query($zone) {
|
||||
return <<<QUERY
|
||||
[out:json][timeout:60];
|
||||
area["ref:INSEE"="$zone"]->.searchArea;
|
||||
(
|
||||
nwr["emergency"="fire_hydrant"](area.searchArea);
|
||||
nwr["amenity"="charging_station"](area.searchArea);
|
||||
);
|
||||
out body;
|
||||
>;
|
||||
out skel qt;
|
||||
QUERY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les objets de suivi pour une ville (bornes incendie et bornes de recharge)
|
||||
*/
|
||||
public function followUpCity($zone) {
|
||||
$query = $this->get_followup_query($zone);
|
||||
try {
|
||||
$response = $this->client->request('POST', 'https://overpass-api.de/api/interpreter', [
|
||||
'body' => ['data' => $query],
|
||||
'timeout' => 60
|
||||
]);
|
||||
if ($response->getStatusCode() !== 200) {
|
||||
throw new \Exception('L\'API Overpass a retourné un code de statut non-200 : ' . $response->getStatusCode());
|
||||
}
|
||||
$data = json_decode($response->getContent(), true);
|
||||
return $data['elements'] ?? [];
|
||||
} catch (\Exception $e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue