mirror of
https://forge.chapril.org/tykayn/osm-commerces
synced 2025-06-20 01:44:42 +02:00
up stats page
This commit is contained in:
parent
a412cb977a
commit
e4bf3753b0
9 changed files with 357 additions and 124 deletions
|
@ -13,6 +13,10 @@ body {
|
||||||
background-color: #dfe5eb;
|
background-color: #dfe5eb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.filled {
|
||||||
|
background-color: #b0dfa0;
|
||||||
|
}
|
||||||
|
|
||||||
.no-name {
|
.no-name {
|
||||||
color: #df5a0d;
|
color: #df5a0d;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ final class AdminController extends AbstractController
|
||||||
return $this->render('admin/stats.html.twig', [
|
return $this->render('admin/stats.html.twig', [
|
||||||
'stats' => $stats,
|
'stats' => $stats,
|
||||||
'zip_code' => $zip_code,
|
'zip_code' => $zip_code,
|
||||||
|
'query_places' => $this->motocultrice->get_query_places($zip_code),
|
||||||
'counters' => $calculatedStats['counters'],
|
'counters' => $calculatedStats['counters'],
|
||||||
'maptiler_token' => $_ENV['MAPTILER_TOKEN'],
|
'maptiler_token' => $_ENV['MAPTILER_TOKEN'],
|
||||||
'mapbox_token' => $_ENV['MAPBOX_TOKEN'],
|
'mapbox_token' => $_ENV['MAPBOX_TOKEN'],
|
||||||
|
@ -117,8 +118,7 @@ final class AdminController extends AbstractController
|
||||||
#[Route('/admin/labourer/{zip_code}', name: 'app_admin_labourer')]
|
#[Route('/admin/labourer/{zip_code}', name: 'app_admin_labourer')]
|
||||||
public function labourer_zone(string $zip_code): Response
|
public function labourer_zone(string $zip_code): Response
|
||||||
{
|
{
|
||||||
$results = [];
|
$results = [];
|
||||||
// $zone = 'Briis sous forges';
|
|
||||||
$results = $this->motocultrice->labourer($zip_code);
|
$results = $this->motocultrice->labourer($zip_code);
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,6 +145,16 @@ final class AdminController extends AbstractController
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Si le nom de la zone n'est pas défini, le récupérer via OSM
|
||||||
|
if (!$stats->getName()) {
|
||||||
|
$city_name = $this->motocultrice->get_city_osm_from_zip_code($zip_code);
|
||||||
|
if ($city_name) {
|
||||||
|
$stats->setName($city_name);
|
||||||
|
$this->entityManager->persist($stats);
|
||||||
|
$this->entityManager->flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$commerces = $this->entityManager->getRepository(Place::class)->findBy(['zip_code' => $zip_code]);
|
$commerces = $this->entityManager->getRepository(Place::class)->findBy(['zip_code' => $zip_code]);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,9 @@ class Stats
|
||||||
#[ORM\Column(type: Types::SMALLINT, nullable: true)]
|
#[ORM\Column(type: Types::SMALLINT, nullable: true)]
|
||||||
private ?int $avec_note = null;
|
private ?int $avec_note = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $name = null;
|
||||||
|
|
||||||
// calcule le pourcentage de complétion de la zone
|
// calcule le pourcentage de complétion de la zone
|
||||||
public function computeCompletionPercent(): ?int
|
public function computeCompletionPercent(): ?int
|
||||||
{
|
{
|
||||||
|
@ -211,6 +214,18 @@ class Stats
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getName(): ?string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName(?string $name): static
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,25 @@ class Motocultrice
|
||||||
"alt_name" => "was:alt_name"
|
"alt_name" => "was:alt_name"
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function get_query_places($zone) {
|
||||||
|
return <<<QUERY
|
||||||
|
[out:json][timeout:25];
|
||||||
|
area["ISO3166-1"="FR"]->.france;
|
||||||
|
area["postal_code"="{$zone}"](area.france)->.searchArea;
|
||||||
|
(
|
||||||
|
|
||||||
|
nw["amenity"~"^(cafe|bar|restaurant|library|cinema|fast_food|post_office|marketplace|community_centre|theatre|bank|townhall)$"](area.searchArea);
|
||||||
|
nw["shop"](area.searchArea);
|
||||||
|
nw["healthcare"](area.searchArea);
|
||||||
|
nw["office"](area.searchArea);
|
||||||
|
);
|
||||||
|
out body;
|
||||||
|
>;
|
||||||
|
out skel qt;
|
||||||
|
QUERY;
|
||||||
|
}
|
||||||
|
|
||||||
private $more_tags = ['image', 'ref:FR:SIRET'];
|
private $more_tags = ['image', 'ref:FR:SIRET'];
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private HttpClientInterface $client,
|
private HttpClientInterface $client,
|
||||||
|
@ -72,12 +90,7 @@ class Motocultrice
|
||||||
|
|
||||||
$has_ask_angela = false;
|
$has_ask_angela = false;
|
||||||
$remove_ask_angela = false;
|
$remove_ask_angela = false;
|
||||||
$has_opening_hours = false;
|
$has_opening_hours = false;
|
||||||
// $has_phone = false;
|
|
||||||
// $has_contact_phone = false;
|
|
||||||
|
|
||||||
// $has_email = false;
|
|
||||||
// $has_contact_email = false;
|
|
||||||
|
|
||||||
|
|
||||||
$modified_request_post = [];
|
$modified_request_post = [];
|
||||||
|
@ -123,47 +136,12 @@ class Motocultrice
|
||||||
// Nettoyer et échapper la zone pour la requête
|
// Nettoyer et échapper la zone pour la requête
|
||||||
$zone = addslashes(trim($zone));
|
$zone = addslashes(trim($zone));
|
||||||
// //area["postal_code"="{$zone}"]->.searchArea;
|
// //area["postal_code"="{$zone}"]->.searchArea;
|
||||||
$query = <<<QUERY
|
$query = $this->get_query_places($zone);
|
||||||
[out:json][timeout:25];
|
|
||||||
{{geocodeArea:{$zone}}}->.searchArea;
|
|
||||||
(
|
|
||||||
// Recherche des commerces et services avec email
|
|
||||||
nw["amenity"]["contact:email"][name](area.searchArea);
|
|
||||||
nw["amenity"]["email"][name](area.searchArea);
|
|
||||||
nw["shop"]["contact:email"][name](area.searchArea);
|
|
||||||
nw["shop"]["email"][name](area.searchArea);
|
|
||||||
nw["office"]["contact:email"][name](area.searchArea);
|
|
||||||
nw["office"]["email"][name](area.searchArea);
|
|
||||||
|
|
||||||
// Recherche des commerces et services sans email pour référence
|
|
||||||
nw["amenity"][name](area.searchArea);
|
|
||||||
nw["shop"][name](area.searchArea);
|
|
||||||
nw["office"][name](area.searchArea);
|
|
||||||
);
|
|
||||||
out body;
|
|
||||||
>;
|
|
||||||
out skel qt;
|
|
||||||
QUERY;
|
|
||||||
|
|
||||||
if($use_places_without_email_to_reference) {
|
if($use_places_without_email_to_reference) {
|
||||||
$query = <<<QUERY
|
$query = $this->get_query_places($zone);
|
||||||
[out:json][timeout:25];
|
|
||||||
area(id:3610571698)->.searchArea;
|
|
||||||
(
|
|
||||||
nw["amenity"~"^(cafe|bar|restaurant|library|cinema|fast_food|post_office|marketplace|community_centre|theatre|bank|townhall)$"](area.searchArea);
|
|
||||||
nw["healthcare"](area.searchArea);
|
|
||||||
nw["shop"](area.searchArea);
|
|
||||||
nw["tourism"~"^(museum|hotel|chalet|apartment)$"](area.searchArea);
|
|
||||||
nw["office"](area.searchArea);
|
|
||||||
);
|
|
||||||
out body;
|
|
||||||
>;
|
|
||||||
out skel qt;
|
|
||||||
QUERY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$essai_query = "%5Bout%3Ajson%5D%5Btimeout%3A25%5D%3B%0A%0A(%0Aarea(id%3A3610571698)-%3E.searchArea%3B%0A++++nw%5B%22amenity%22~%22%5E(cafe%7Cbar%7Crestaurant%7Clibrary%7Ccinema%7Cfast_food%7Cpost_office%7Cmarketplace%7Ccommunity_centre%7Ctheatre%7Cbank%7Ctownhall)%24%22%5D(area.searchArea)%3B%0A++++nw%5B%22healthcare%22%5D(area.searchArea)%3B%0A++++nw%5B%22shop%22%5D(area.searchArea)%3B%0A++++nw%5B%22tourism%22~%22%5E(museum%7Chotel%7Cchalet%7Capartment)%24%22%5D(area.searchArea)%3B%0A++++nw%5B%22office%22%5D(area.searchArea)%3B%0A)%3B%0Aout+body%3B%0A%3E%3B%0Aout+center%3B";
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$response = $this->client->request('POST', $this->overpassApiUrl, [
|
$response = $this->client->request('POST', $this->overpassApiUrl, [
|
||||||
'body' => ['data' => $query]
|
'body' => ['data' => $query]
|
||||||
|
@ -208,6 +186,29 @@ QUERY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_city_osm_from_zip_code($zip_code) {
|
||||||
|
// Requête Overpass pour obtenir la zone administrative de niveau 8 avec un nom
|
||||||
|
$query = "[out:json][timeout:25];
|
||||||
|
area[\"postal_code\"=\"{$zip_code}\"]->.searchArea;
|
||||||
|
(
|
||||||
|
relation[\"admin_level\"=\"8\"][\"name\"][\"type\"=\"boundary\"][\"boundary\"=\"administrative\"](area.searchArea);
|
||||||
|
);
|
||||||
|
out body;
|
||||||
|
>;
|
||||||
|
out skel qt;";
|
||||||
|
// $query = "area[\"postal_code\"=\"{$zip_code}\"]->.searchArea;";
|
||||||
|
$response = $this->client->request('POST', $this->overpassApiUrl, [
|
||||||
|
'body' => ['data' => $query]
|
||||||
|
]);
|
||||||
|
$data = json_decode($response->getContent(), true);
|
||||||
|
if (isset($data['elements']) && !empty($data['elements'])) {
|
||||||
|
$city = $data['elements'][0]['tags']['name'];
|
||||||
|
return $city;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function get_osm_object_data($osm_kind = 'node', $osm_object_id = 12855459190)
|
public function get_osm_object_data($osm_kind = 'node', $osm_object_id = 12855459190)
|
||||||
{
|
{
|
||||||
$object_id = "https://www.openstreetmap.org/api/0.6/".$osm_kind."/".$osm_object_id;
|
$object_id = "https://www.openstreetmap.org/api/0.6/".$osm_kind."/".$osm_object_id;
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
<div class="example-wrapper">
|
<div class="example-wrapper">
|
||||||
<h1>Labourage fait sur la zone "{{ zone }}" ✅</h1>
|
<h1>Labourage fait sur la zone "{{ zone }}" ✅</h1>
|
||||||
|
<a href="{{ path('app_admin_labourer', {'zip_code': stats.zone}) }}" class="btn btn-primary" id="labourer">Labourer les mises à jour</a>
|
||||||
|
<a href="{{ path('app_admin_stats', {'zip_code': stats.zone}) }}" class="btn btn-primary" id="labourer">Voir les résultats</a>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
lieux trouvés en plus: {{ results|length }}
|
lieux trouvés en plus: {{ results|length }}
|
||||||
|
|
|
@ -13,26 +13,45 @@
|
||||||
<h1 class="title">{{ 'display.stats'|trans }}</h1>
|
<h1 class="title">{{ 'display.stats'|trans }}</h1>
|
||||||
<p>
|
<p>
|
||||||
{{ stats.zone }}
|
{{ stats.zone }}
|
||||||
|
{{ stats.name }}
|
||||||
</p>
|
</p>
|
||||||
{{ stats.getCompletionPercent() }} % complété sur les critères donnés.
|
<a href="{{ path('app_admin_labourer', {'zip_code': stats.zone}) }}" class="btn btn-primary" id="labourer">Labourer les mises à jour</a>
|
||||||
<br>
|
<div class="row">
|
||||||
<i class="bi bi-building"></i> {{ stats.getPlacesCount() }} commerces dans la zone.
|
<div class="col-md-3 col-12">
|
||||||
<br>
|
{{ stats.getCompletionPercent() }} % complété sur les critères donnés.
|
||||||
<i class="bi bi-clock"></i> {{ stats.getAvecHoraires() }} commerces avec horaires.
|
</div>
|
||||||
<br>
|
<div class="col-md-3 col-12">
|
||||||
<i class="bi bi-map"></i> {{ stats.getAvecAdresse() }} commerces avec adresse.
|
<i class="bi bi-building"></i> {{ stats.getPlacesCount() }} commerces dans la zone.
|
||||||
<br>
|
</div>
|
||||||
<i class="bi bi-globe"></i> {{ stats.getAvecSite() }} commerces avec site web renseigné.
|
<div class="col-md-3 col-12">
|
||||||
<br>
|
<i class="bi bi-clock"></i> {{ stats.getAvecHoraires() }} commerces avec horaires.
|
||||||
<i class="bi bi-wheelchair"></i> {{ stats.getAvecAccessibilite() }} commerces avec accessibilité renseignée.
|
</div>
|
||||||
<br>
|
<div class="col-md-3 col-12">
|
||||||
<i class="bi bi-chat-dots"></i> {{ stats.getAvecNote() }} commerces avec note renseignée.
|
<i class="bi bi-map"></i> {{ stats.getAvecAdresse() }} commerces avec adresse.
|
||||||
<br>
|
</div>
|
||||||
</div>
|
<div class="col-md-3 col-12">
|
||||||
|
<i class="bi bi-globe"></i> {{ stats.getAvecSite() }} commerces avec site web renseigné.
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 col-12">
|
||||||
|
<i class="bi bi-arrow-up-right"></i>
|
||||||
|
{{ stats.getAvecAccessibilite() }} commerces avec accessibilité PMR renseignée.
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 col-12">
|
||||||
|
<i class="bi bi-chat-dots"></i> {{ stats.getAvecNote() }} commerces avec note renseignée.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="map" style="height: 400px;"></div>
|
<div id="map" style="height: 400px;"></div>
|
||||||
|
|
||||||
|
{# <div id="query" style="height: 400px;"> #}
|
||||||
|
{# <pre>
|
||||||
|
{{query_places|raw}}
|
||||||
|
</pre> #}
|
||||||
|
</div>
|
||||||
<div class="card mt-4">
|
<div class="card mt-4">
|
||||||
<h1 class="card-title">Tableau des lieux</h1>
|
<h1 class="card-title">Tableau des {{ stats.getPlacesCount() }} lieux</h1>
|
||||||
<table class="table table-bordered">
|
<a href="{{ path('app_admin_export_csv', {'zip_code': stats.zone}) }}" class="btn btn-primary">Exporter en CSV</a>
|
||||||
|
<table class="table table-bordered table-striped table-hover table-responsive">
|
||||||
{% include 'admin/stats/table-head.html.twig' %}
|
{% include 'admin/stats/table-head.html.twig' %}
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for commerce in stats.places %}
|
{% for commerce in stats.places %}
|
||||||
|
@ -41,24 +60,34 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<h2>requête overpass</h2>
|
||||||
|
<pre>
|
||||||
|
{{query_places|raw}}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src='https://cdn.jsdelivr.net/npm/maplibre-gl@3.6.2/dist/maplibre-gl.js'></script>
|
<script src='https://cdn.jsdelivr.net/npm/maplibre-gl@3.6.2/dist/maplibre-gl.js'></script>
|
||||||
<script>
|
<script>
|
||||||
const request = `[out:json][timeout:25];
|
const request = `{{query_places|raw}}`;
|
||||||
area["postal_code"="{{ zip_code }}"]->.searchArea;
|
const zip_code = `{{stats.zone}}`;
|
||||||
(
|
|
||||||
nw["amenity"]["cafe|bar|restaurant|library|cinema|fast_food"]["name"~"."](area.searchArea);
|
|
||||||
nw["shop"]["name"~"."](area.searchArea);
|
|
||||||
nw["tourism"="museum|hotel|chalet|apartment"]["name"~"."](area.searchArea);
|
|
||||||
nw["office"]["name"~"."](area.searchArea);
|
|
||||||
);
|
|
||||||
out center;
|
|
||||||
>;
|
|
||||||
out skel qt;
|
|
||||||
`;
|
|
||||||
|
|
||||||
async function fetchland() {
|
async function fetchland() {
|
||||||
|
// Requête pour obtenir le contour administratif
|
||||||
|
const boundaryQuery = `[out:json][timeout:25];
|
||||||
|
area["postal_code"="${zip_code}"]->.searchArea;
|
||||||
|
(
|
||||||
|
relation["boundary"="postal_code"]["postal_code"="${zip_code}"](area.searchArea);
|
||||||
|
);
|
||||||
|
out body;
|
||||||
|
>;
|
||||||
|
out skel qt;`;
|
||||||
|
|
||||||
|
const encodedBoundaryRequest = encodeURIComponent(boundaryQuery);
|
||||||
|
const boundaryResponse = await fetch(`https://overpass-api.de/api/interpreter?data=${encodedBoundaryRequest}`);
|
||||||
|
const boundaryData = await boundaryResponse.json();
|
||||||
|
|
||||||
const encodedRequest = encodeURIComponent(request);
|
const encodedRequest = encodeURIComponent(request);
|
||||||
const overpassUrl = `https://overpass-api.de/api/interpreter?data=${encodedRequest}`;
|
const overpassUrl = `https://overpass-api.de/api/interpreter?data=${encodedRequest}`;
|
||||||
const response = await fetch(overpassUrl);
|
const response = await fetch(overpassUrl);
|
||||||
|
@ -72,6 +101,40 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('load', () => {
|
map.on('load', () => {
|
||||||
|
// Ajouter le contour administratif
|
||||||
|
if (boundaryData.elements && boundaryData.elements.length > 0) {
|
||||||
|
const boundary = boundaryData.elements[0];
|
||||||
|
if (boundary.members) {
|
||||||
|
const coordinates = boundary.members.map(member => {
|
||||||
|
if (member.type === 'node') {
|
||||||
|
return [member.lon, member.lat];
|
||||||
|
}
|
||||||
|
}).filter(coord => coord);
|
||||||
|
|
||||||
|
map.addSource('boundary', {
|
||||||
|
'type': 'geojson',
|
||||||
|
'data': {
|
||||||
|
'type': 'Feature',
|
||||||
|
'geometry': {
|
||||||
|
'type': 'Polygon',
|
||||||
|
'coordinates': [coordinates]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
map.addLayer({
|
||||||
|
'id': 'boundary-layer',
|
||||||
|
'type': 'fill',
|
||||||
|
'source': 'boundary',
|
||||||
|
'paint': {
|
||||||
|
'fill-color': '#088',
|
||||||
|
'fill-opacity': 0.1,
|
||||||
|
'fill-outline-color': '#000'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log('map chargé',data.elements);
|
console.log('map chargé',data.elements);
|
||||||
data.elements.forEach(element => {
|
data.elements.forEach(element => {
|
||||||
if(element.tags){
|
if(element.tags){
|
||||||
|
@ -83,10 +146,6 @@
|
||||||
|
|
||||||
const el = document.createElement('div');
|
const el = document.createElement('div');
|
||||||
el.className = 'marker';
|
el.className = 'marker';
|
||||||
el.style.width = '20px';
|
|
||||||
el.style.height = '20px';
|
|
||||||
el.style.borderRadius = '50%';
|
|
||||||
el.style.backgroundColor = '#ff0000';
|
|
||||||
let tagstable = '<table class="table table-bordered"><tr><th>Clé</th><th>Valeur</th></tr>';
|
let tagstable = '<table class="table table-bordered"><tr><th>Clé</th><th>Valeur</th></tr>';
|
||||||
if (element.tags) {
|
if (element.tags) {
|
||||||
for (const tag in element.tags) {
|
for (const tag in element.tags) {
|
||||||
|
@ -98,23 +157,20 @@
|
||||||
// Créer un élément div pour le texte du nom
|
// Créer un élément div pour le texte du nom
|
||||||
const nameDiv = document.createElement('div');
|
const nameDiv = document.createElement('div');
|
||||||
nameDiv.className = 'marker-name';
|
nameDiv.className = 'marker-name';
|
||||||
nameDiv.style.position = 'absolute';
|
nameDiv.textContent = element.tags?.name || '(Sans nom)';
|
||||||
nameDiv.style.backgroundColor = 'white';
|
|
||||||
nameDiv.style.padding = '2px 5px';
|
|
||||||
nameDiv.style.borderRadius = '3px';
|
|
||||||
nameDiv.style.fontSize = '12px';
|
|
||||||
nameDiv.style.whiteSpace = 'nowrap';
|
|
||||||
nameDiv.style.transform = 'translate(-50%, -150%)';
|
|
||||||
nameDiv.textContent = element.tags?.name || 'Sans nom';
|
|
||||||
el.appendChild(nameDiv);
|
el.appendChild(nameDiv);
|
||||||
|
|
||||||
|
|
||||||
new maplibregl.Marker(el)
|
new maplibregl.Marker(el)
|
||||||
.setLngLat([element.lon, element.lat])
|
.setLngLat([element.lon, element.lat])
|
||||||
.setPopup(new maplibregl.Popup({ offset: 25 })
|
.setPopup(new maplibregl.Popup({
|
||||||
|
offset: 25,
|
||||||
|
anchor: 'bottom'
|
||||||
|
})
|
||||||
.setHTML(
|
.setHTML(
|
||||||
`<a href="/admin/placeType/${element.type}/${element.id}" ><h3>${element.tags?.name || 'Sans nom'}</h3></a> <br><a href="https://openstreetmap.org/${element.type}/${element.id}" target="_blank">OSM</a> ${tagstable}`
|
`<a href="/admin/placeType/${element.type}/${element.id}" ><h3>${element.tags?.name || 'Sans nom'}</h3></a> <br><a href="https://openstreetmap.org/${element.type}/${element.id}" target="_blank">OSM</a> ${tagstable}`
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.addTo(map);
|
.addTo(map);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,53 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td style="background-color: {{ commerce.hasAddress() ? 'yellowgreen' : 'transparent' }};">
|
<td class="{{ commerce.hasAddress() ? 'filled' : '' }}">
|
||||||
<a href="{{ path('app_admin_commerce', {'id': commerce.id}) }}">{{ commerce.name }}</a>
|
<a href="{{ path('app_admin_commerce', {'id': commerce.id}) }}">
|
||||||
|
{% if commerce.name is empty %}
|
||||||
|
<span class="no-name">
|
||||||
|
(sans nom)
|
||||||
|
</span>
|
||||||
|
{% else %}
|
||||||
|
{{ commerce.name }}
|
||||||
|
{% endif %}
|
||||||
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td style="background-color: {{ commerce.mainTag ? 'yellowgreen' : 'transparent' }};">{{ commerce.mainTag }}</td>
|
<td class="{{ commerce.mainTag ? 'filled' : '' }}">
|
||||||
<td style="background-color: {{ commerce.hasAddress() ? 'yellowgreen' : 'transparent' }};">{{ commerce.address }}</td>
|
|
||||||
<td style="background-color: {{ commerce.hasWebsite() ? 'yellowgreen' : 'transparent' }};">{{ commerce.website }}</td>
|
{% if commerce.mainTag == 'amenity=restaurant' or commerce.mainTag == 'amenity=bar' or commerce.mainTag == 'amenity=cafe' %}
|
||||||
<td style="background-color: {{ commerce.hasWheelchair() ? 'yellowgreen' : 'transparent' }};">{{ commerce.wheelchair }}</td>
|
<i class="bi bi-fork-knife"></i>
|
||||||
<td style="background-color: {{ commerce.hasNote() ? 'yellowgreen' : 'transparent' }};">{{ commerce.note }}</td>
|
|
||||||
<td style="background-color: {{ commerce.hasNote() ? 'yellowgreen' : 'transparent' }};">{{ commerce.noteContent }}</td>
|
{% elseif commerce.mainTag == 'amenity=townhall' or commerce.mainTag == 'amenity=community_centre' %}
|
||||||
|
<i class="bi bi-building"></i>
|
||||||
|
{% elseif commerce.mainTag == 'amenity=bank' or commerce.mainTag == 'amenity=atm' %}
|
||||||
|
<i class="bi bi-bank"></i>
|
||||||
|
{% elseif commerce.mainTag == 'amenity=pharmacy' or commerce.mainTag == 'amenity=hospital' or commerce.mainTag == 'amenity=clinic' %}
|
||||||
|
<i class="bi bi-hospital"></i>
|
||||||
|
{% elseif commerce.mainTag == 'amenity=school' or commerce.mainTag == 'amenity=kindergarten' or commerce.mainTag == 'amenity=university' %}
|
||||||
|
<i class="bi bi-school"></i>
|
||||||
|
{% elseif commerce.mainTag == 'amenity=library' or commerce.mainTag == 'amenity=museum' or commerce.mainTag == 'amenity=artwork' %}
|
||||||
|
<i class="bi bi-book"></i>
|
||||||
|
{% elseif commerce.mainTag == 'shop=car_repair' or commerce.mainTag == 'shop=car_parts' or commerce.mainTag == 'shop=car_wash' %}
|
||||||
|
<i class="bi bi-car-front"></i>
|
||||||
|
|
||||||
|
{% elseif commerce.mainTag == 'amenity=post_office' %}
|
||||||
|
<i class="bi bi-envelope"></i>
|
||||||
|
{% elseif commerce.mainTag == 'shop=convenience' %}
|
||||||
|
<i class="bi bi-shop"></i>
|
||||||
|
{% elseif commerce.mainTag == 'shop=supermarket' %}
|
||||||
|
<i class="bi bi-shop"></i>
|
||||||
|
{% elseif commerce.mainTag == 'shop=clothes' %}
|
||||||
|
<i class="bi bi-shop"></i>
|
||||||
|
{% else %}
|
||||||
|
<i class="bi bi-tag"></i>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{{ commerce.mainTag }}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td class="{{ commerce.hasAddress() ? 'filled' : '' }}">{{ commerce.address }}</td>
|
||||||
|
<td class="{{ commerce.hasWebsite() ? 'filled' : '' }}">{{ commerce.website }}</td>
|
||||||
|
<td class="{{ commerce.hasWheelchair() ? 'filled' : '' }}">{{ commerce.wheelchair }}</td>
|
||||||
|
<td class="{{ commerce.hasNote() ? 'filled' : '' }}">{{ commerce.note }}</td>
|
||||||
|
<td class="{{ commerce.noteContent ? 'filled' : '' }}">{{ commerce.noteContent }}</td>
|
||||||
</tr>
|
</tr>
|
|
@ -23,6 +23,112 @@
|
||||||
<script src='https://cdn.jsdelivr.net/npm/maplibre-gl@3.6.2/dist/maplibre-gl.js'></script>
|
<script src='https://cdn.jsdelivr.net/npm/maplibre-gl@3.6.2/dist/maplibre-gl.js'></script>
|
||||||
<script >
|
<script >
|
||||||
|
|
||||||
|
|
||||||
|
// Fonction pour rechercher avec Addok
|
||||||
|
async function searchPostalCode(query) {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`https://api-adresse.data.gouv.fr/search/?q=${query}&type=municipality&autocomplete=1`);
|
||||||
|
const data = await response.json();
|
||||||
|
return data.features.map(feature => ({
|
||||||
|
label: `${feature.properties.city} (${feature.properties.postcode})`,
|
||||||
|
postcode: feature.properties.postcode,
|
||||||
|
city: feature.properties.city
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erreur lors de la recherche:', error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Créer et configurer la liste de suggestions
|
||||||
|
const suggestionList = document.createElement('ul');
|
||||||
|
suggestionList.style.cssText = `
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-top: none;
|
||||||
|
max-height: 200px;
|
||||||
|
overflow-y: auto;
|
||||||
|
position: absolute;
|
||||||
|
background: white;
|
||||||
|
width: 100%;
|
||||||
|
z-index: 1000;
|
||||||
|
`;
|
||||||
|
|
||||||
|
// Configurer l'input de recherche
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const searchInput = document.getElementById('app_admin_labourer');
|
||||||
|
const inputContainer = searchInput.parentElement;
|
||||||
|
|
||||||
|
// Ajouter un conteneur relatif pour le positionnement
|
||||||
|
const searchWrapper = document.createElement('div');
|
||||||
|
searchWrapper.style.position = 'relative';
|
||||||
|
inputContainer.appendChild(searchWrapper);
|
||||||
|
searchWrapper.appendChild(searchInput);
|
||||||
|
searchWrapper.appendChild(suggestionList);
|
||||||
|
|
||||||
|
let debounceTimer;
|
||||||
|
|
||||||
|
searchInput.addEventListener('input', async (e) => {
|
||||||
|
clearTimeout(debounceTimer);
|
||||||
|
debounceTimer = setTimeout(async () => {
|
||||||
|
const query = e.target.value;
|
||||||
|
if (query.length < 2) {
|
||||||
|
suggestionList.innerHTML = '';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const suggestions = await searchPostalCode(query);
|
||||||
|
suggestionList.innerHTML = '';
|
||||||
|
|
||||||
|
if (suggestions.length === 0) {
|
||||||
|
const li = document.createElement('li');
|
||||||
|
li.style.cssText = `
|
||||||
|
padding: 8px 12px;
|
||||||
|
color: #666;
|
||||||
|
font-style: italic;
|
||||||
|
`;
|
||||||
|
li.textContent = 'Aucun résultat trouvé';
|
||||||
|
suggestionList.appendChild(li);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
suggestions.forEach(suggestion => {
|
||||||
|
const li = document.createElement('li');
|
||||||
|
li.style.cssText = `
|
||||||
|
padding: 8px 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
border-bottom: 1px solid #eee;
|
||||||
|
`;
|
||||||
|
li.textContent = suggestion.label;
|
||||||
|
|
||||||
|
li.addEventListener('mouseenter', () => {
|
||||||
|
li.style.backgroundColor = '#f0f0f0';
|
||||||
|
});
|
||||||
|
|
||||||
|
li.addEventListener('mouseleave', () => {
|
||||||
|
li.style.backgroundColor = 'white';
|
||||||
|
});
|
||||||
|
|
||||||
|
li.addEventListener('click', () => {
|
||||||
|
searchInput.value = suggestion.postcode;
|
||||||
|
suggestionList.innerHTML = '';
|
||||||
|
labourer();
|
||||||
|
});
|
||||||
|
|
||||||
|
suggestionList.appendChild(li);
|
||||||
|
});
|
||||||
|
}, 300);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Cacher la liste quand on clique ailleurs
|
||||||
|
document.addEventListener('click', (e) => {
|
||||||
|
if (!inputContainer.contains(e.target)) {
|
||||||
|
suggestionList.innerHTML = '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
// Définir la fonction labourer dans le scope global
|
// Définir la fonction labourer dans le scope global
|
||||||
function labourer() {
|
function labourer() {
|
||||||
window.location.href = '/admin/labourer/' + document.getElementById('app_admin_labourer').value;
|
window.location.href = '/admin/labourer/' + document.getElementById('app_admin_labourer').value;
|
||||||
|
@ -60,35 +166,25 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const postalCodes = [{% for stat in stats %}'{{ stat.zone }}'{% if not loop.last %}, {% endif %}{% endfor %}];
|
const postalCodes = [{% for stat in stats %}'{{ stat.zone }}'{% if not loop.last %}, {% endif %}{% endfor %}];
|
||||||
{% verbatim %}
|
{% verbatim %}
|
||||||
|
|
||||||
// exemple de recherche de villes par leur code postal:
|
|
||||||
// [out:json][timeout:25];
|
|
||||||
// (
|
|
||||||
// {{geocodeArea:76200}}->.searchArea_1;
|
|
||||||
// nwr["boundary"="administrative"]["admin_level"="8"]
|
|
||||||
// ["name"](area.searchArea_1);
|
|
||||||
// {{geocodeArea:76000}}->.searchArea_2;
|
|
||||||
// nwr["boundary"="administrative"]["admin_level"="8"]["name"](area.searchArea_2);
|
|
||||||
// ) ;
|
|
||||||
// out center;
|
|
||||||
{% endverbatim %}
|
|
||||||
|
|
||||||
console.log(postalCodes);
|
console.log(postalCodes);
|
||||||
let postalLines = ``;
|
let postalLines = ``;
|
||||||
postalCodes.forEach(code => {
|
postalCodes.forEach(code => {
|
||||||
if (/^\d+$/.test(code)) {
|
if (/^\d+$/.test(code)) {
|
||||||
|
postalLines += `
|
||||||
{% verbatim %}
|
area["postal_code"="${code}"]->.searchArea_${code};
|
||||||
postalLines += `\n{{geocodeArea:${code}}}->.searchArea_${code};\nnwr[admin_level=8]["name"](area.searchArea_${code});`
|
nwr["admin_level"="8"]["name"](area.searchArea_${code});`;
|
||||||
{% endverbatim %}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const query = `[out:json][timeout:25];
|
const query = `[out:json][timeout:25];
|
||||||
(
|
(
|
||||||
${postalLines}
|
${postalLines}
|
||||||
);
|
);
|
||||||
out center;` ;
|
out body;
|
||||||
|
>;
|
||||||
|
out skel qt;`;
|
||||||
|
{% endverbatim %}
|
||||||
|
|
||||||
console.log(query);
|
console.log(query);
|
||||||
console.log('https://overpass-api.de/api/interpreter');
|
console.log('https://overpass-api.de/api/interpreter');
|
||||||
const response = await fetch('https://overpass-api.de/api/interpreter', {
|
const response = await fetch('https://overpass-api.de/api/interpreter', {
|
||||||
|
@ -141,9 +237,7 @@
|
||||||
<h2>Statistiques : {{ stats|length }} codes postaux</h2>
|
<h2>Statistiques : {{ stats|length }} codes postaux</h2>
|
||||||
|
|
||||||
<div id="mapDashboard"></div>
|
<div id="mapDashboard"></div>
|
||||||
<input class="form-control" type="text" id="app_admin_labourer" value="75013">
|
|
||||||
<button class="btn btn-primary" id="labourer">Labourer les mises à jour</button>
|
|
||||||
|
|
||||||
|
|
||||||
<table class="table table-hover table-striped table-responsive">
|
<table class="table table-hover table-striped table-responsive">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -158,7 +252,7 @@
|
||||||
{% for stat in stats %}
|
{% for stat in stats %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ path('app_admin_stats', {'zip_code': stat.zone}) }}">{{ stat.zone }}</a>
|
<a href="{{ path('app_admin_stats', {'zip_code': stat.zone}) }}">{{ stat.zone }} {{ stat.name }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ stat.placesCount }}</td>
|
<td>{{ stat.placesCount }}</td>
|
||||||
<td style="background : rgba(0 , 255, 0, {{stat.completionPercent / 100 }} )">{{ stat.completionPercent }}</td>
|
<td style="background : rgba(0 , 255, 0, {{stat.completionPercent / 100 }} )">{{ stat.completionPercent }}</td>
|
||||||
|
@ -173,7 +267,11 @@
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h2>{{ places|length }} Lieux</h2>
|
<h2>{{ places|length }} Lieux</h2>
|
||||||
|
<h2><button class="btn btn-primary" id="labourer">Labourer les mises à jour</button></h2>
|
||||||
|
<label for="app_admin_labourer">Rechercher une ville </label>
|
||||||
|
<input class="form-control" type="text" id="app_admin_labourer" value="75013">
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -71,11 +71,16 @@ display:
|
||||||
tourism: "Tourisme"
|
tourism: "Tourisme"
|
||||||
wheelchair: "Accès Personnes à mobilité réduite (PMR)"
|
wheelchair: "Accès Personnes à mobilité réduite (PMR)"
|
||||||
addr:housenumber: "Numéro de rue"
|
addr:housenumber: "Numéro de rue"
|
||||||
|
contact:housenumber: "Numéro de rue"
|
||||||
addr:street: "Rue"
|
addr:street: "Rue"
|
||||||
|
contact:street: "Rue"
|
||||||
addr:city: "Ville"
|
addr:city: "Ville"
|
||||||
addr:postcode: "Code postal"
|
addr:postcode: "Code postal"
|
||||||
amenity: "Équipement"
|
amenity: "Équipement"
|
||||||
source: "Source"
|
source: "Source"
|
||||||
|
description: "Description"
|
||||||
|
healthcare: "Santé"
|
||||||
|
healthcare:speciality: "Spécialité Médicale"
|
||||||
ref:FR:SIRET: "SIRET"
|
ref:FR:SIRET: "SIRET"
|
||||||
image: "URL vers une Image"
|
image: "URL vers une Image"
|
||||||
note: "Champ libre, pour des informations complémentaires. Ne pas mettre de publicité"
|
note: "Champ libre, pour des informations complémentaires. Ne pas mettre de publicité"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue