up labourage
This commit is contained in:
parent
7cde6a56aa
commit
1c24ae1fea
4 changed files with 32 additions and 18 deletions
|
@ -229,37 +229,35 @@ class PublicController extends AbstractController
|
||||||
// Récupérer les données POST
|
// Récupérer les données POST
|
||||||
$request = Request::createFromGlobals();
|
$request = Request::createFromGlobals();
|
||||||
|
|
||||||
|
$status = null;
|
||||||
|
$exception = false;
|
||||||
|
$exception_message = null;
|
||||||
|
$osm_kind = 'node';
|
||||||
// Vérifier si des données ont été soumises
|
// Vérifier si des données ont été soumises
|
||||||
if ($request->isMethod('POST')) {
|
if ($request->isMethod('POST')) {
|
||||||
$status = "non modifié";
|
$status = "non modifié";
|
||||||
|
|
||||||
// Récupérer le type d'objet (node ou way)
|
|
||||||
$osm_kind = $request->request->get('osm_kind', 'node');
|
$osm_kind = $request->request->get('osm_kind', 'node');
|
||||||
|
|
||||||
// Récupérer tous les tags du formulaire
|
// Récupérer tous les tags du formulaire
|
||||||
$tags = [];
|
$tags = [];
|
||||||
|
|
||||||
$request_post = $request->request->all();
|
$request_post = $request->request->all();
|
||||||
|
|
||||||
$request_post = $this->motocultrice->map_post_values($request_post);
|
$request_post = $this->motocultrice->map_post_values($request_post);
|
||||||
|
|
||||||
foreach ($request_post as $key => $value) {
|
foreach ($request_post as $key => $value) {
|
||||||
if (strpos($key, 'commerce_tag_value__') === 0) {
|
if (strpos($key, 'commerce_tag_value__') === 0) {
|
||||||
$tagKey = str_replace('commerce_tag_value__', '', $key);
|
$tagKey = str_replace('commerce_tag_value__', '', $key);
|
||||||
if (!empty($value)) {
|
if (!empty($value)) {
|
||||||
|
|
||||||
$tags[$tagKey] = trim($value);
|
$tags[$tagKey] = trim($value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var_dump('POST brut', $_POST);
|
||||||
var_dump($tags);
|
var_dump('request->request->all()', $request->request->all());
|
||||||
|
var_dump('tags extraits', $tags);
|
||||||
|
// DEBUG : enlever ce die après analyse
|
||||||
|
die('DEBUG avant envoi OSM');
|
||||||
|
|
||||||
// Récupérer le token OSM depuis les variables d'environnement
|
// Récupérer le token OSM depuis les variables d'environnement
|
||||||
$osm_api_token = $_ENV['APP_OSM_BEARER'];
|
$osm_api_token = $_ENV['APP_OSM_BEARER'];
|
||||||
|
|
||||||
$exception = false;
|
|
||||||
$exception_message = "";
|
|
||||||
try {
|
try {
|
||||||
$client = new Client();
|
$client = new Client();
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,8 @@ class FollowUpService
|
||||||
$objects = array_filter($elements, fn($el) => ($el['tags']['natural'] ?? null) === 'tree') ?? [];
|
$objects = array_filter($elements, fn($el) => ($el['tags']['natural'] ?? null) === 'tree') ?? [];
|
||||||
} elseif ($type === 'places') {
|
} elseif ($type === 'places') {
|
||||||
$objects = [];
|
$objects = [];
|
||||||
|
} elseif ($type === 'power_pole') {
|
||||||
|
$objects = array_filter($elements, fn($el) => ($el['tags']['power'] ?? null) === 'pole') ?? [];
|
||||||
} else {
|
} else {
|
||||||
$objects = [];
|
$objects = [];
|
||||||
}
|
}
|
||||||
|
@ -195,6 +197,14 @@ class FollowUpService
|
||||||
|| !empty($tags['leaf_fall'] ?? null);
|
|| !empty($tags['leaf_fall'] ?? null);
|
||||||
return $hasTaxonomy && $hasLeaf;
|
return $hasTaxonomy && $hasLeaf;
|
||||||
});
|
});
|
||||||
|
} elseif ($type === 'power_pole') {
|
||||||
|
$completed = array_filter($data['objects'], function($el) {
|
||||||
|
$tags = $el['tags'] ?? [];
|
||||||
|
return !empty($tags['ref'] ?? null)
|
||||||
|
|| !empty($tags['material'] ?? null)
|
||||||
|
|| !empty($tags['height'] ?? null)
|
||||||
|
|| !empty($tags['operator'] ?? null);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if ($type === 'places') {
|
if ($type === 'places') {
|
||||||
$completion = $stats->getCompletionPercent();
|
$completion = $stats->getCompletionPercent();
|
||||||
|
@ -360,7 +370,8 @@ class FollowUpService
|
||||||
'street_lamp' => 'Lampadaires',
|
'street_lamp' => 'Lampadaires',
|
||||||
'drinking_water' => 'Eau potable',
|
'drinking_water' => 'Eau potable',
|
||||||
'tree' => 'Arbres',
|
'tree' => 'Arbres',
|
||||||
'places' => 'Lieux'
|
'places' => 'Lieux',
|
||||||
|
'power_pole' => 'Poteaux électriques',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,7 +399,8 @@ class FollowUpService
|
||||||
'street_lamp' => 'bi-lightbulb',
|
'street_lamp' => 'bi-lightbulb',
|
||||||
'drinking_water' => 'bi-droplet-half',
|
'drinking_water' => 'bi-droplet-half',
|
||||||
'tree' => 'bi-tree',
|
'tree' => 'bi-tree',
|
||||||
'places' => 'bi-geo-alt'
|
'places' => 'bi-geo-alt',
|
||||||
|
'power_pole' => 'bi-signpost',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -592,6 +592,7 @@ area["ref:INSEE"="$zone"]->.searchArea;
|
||||||
nwr["highway"="street_lamp"](area.searchArea);
|
nwr["highway"="street_lamp"](area.searchArea);
|
||||||
nwr["amenity"="drinking_water"](area.searchArea);
|
nwr["amenity"="drinking_water"](area.searchArea);
|
||||||
nwr["natural"="tree"](area.searchArea);
|
nwr["natural"="tree"](area.searchArea);
|
||||||
|
nw["power"="pole"](area.searchArea);
|
||||||
);
|
);
|
||||||
(._;>;);
|
(._;>;);
|
||||||
out meta;
|
out meta;
|
||||||
|
|
|
@ -485,7 +485,7 @@
|
||||||
center: geojsonData.features[0].geometry.coordinates,
|
center: geojsonData.features[0].geometry.coordinates,
|
||||||
zoom: 14
|
zoom: 14
|
||||||
});
|
});
|
||||||
|
window.mapInstance = map;
|
||||||
map.on('load', function() {
|
map.on('load', function() {
|
||||||
map_is_loaded = true;
|
map_is_loaded = true;
|
||||||
document.getElementById('maploader').style.display = 'none';
|
document.getElementById('maploader').style.display = 'none';
|
||||||
|
@ -814,8 +814,10 @@ if(dc ){
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
const btn = document.getElementById('btn-geolocate');
|
const btn = document.getElementById('btn-geolocate');
|
||||||
btn && btn.addEventListener('click', function() {
|
btn && btn.addEventListener('click', function() {
|
||||||
|
console.log('[GEOLOC] Bouton cliqué');
|
||||||
if (!navigator.geolocation) {
|
if (!navigator.geolocation) {
|
||||||
alert('La géolocalisation n\'est pas supportée par ce navigateur.');
|
alert('La géolocalisation n\'est pas supportée par ce navigateur.');
|
||||||
|
console.error('[GEOLOC] navigator.geolocation non supporté');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
|
@ -823,7 +825,9 @@ if(dc ){
|
||||||
navigator.geolocation.getCurrentPosition(function(pos) {
|
navigator.geolocation.getCurrentPosition(function(pos) {
|
||||||
const lat = pos.coords.latitude;
|
const lat = pos.coords.latitude;
|
||||||
const lon = pos.coords.longitude;
|
const lon = pos.coords.longitude;
|
||||||
|
console.log('[GEOLOC] Position obtenue', lat, lon);
|
||||||
// MapLibre
|
// MapLibre
|
||||||
|
console.log('[GEOLOC] mapInstance', window.mapInstance);
|
||||||
if (window.mapInstance && typeof window.mapInstance.flyTo === 'function') {
|
if (window.mapInstance && typeof window.mapInstance.flyTo === 'function') {
|
||||||
window.mapInstance.flyTo({center: [lon, lat], zoom: 15});
|
window.mapInstance.flyTo({center: [lon, lat], zoom: 15});
|
||||||
if (window._geoMarker) window.mapInstance.removeLayer('geo-marker');
|
if (window._geoMarker) window.mapInstance.removeLayer('geo-marker');
|
||||||
|
@ -840,15 +844,14 @@ if(dc ){
|
||||||
});
|
});
|
||||||
window._geoMarker = true;
|
window._geoMarker = true;
|
||||||
window._geoMarkerSource = true;
|
window._geoMarkerSource = true;
|
||||||
} else if (window.L && window.map) { // Leaflet
|
} else {
|
||||||
window.map.setView([lat, lon], 15);
|
console.error('[GEOLOC] mapInstance non défini ou flyTo non disponible', window.mapInstance);
|
||||||
if (window._geoMarker) window.map.removeLayer(window._geoMarker);
|
|
||||||
window._geoMarker = window.L.marker([lat, lon], {icon: window.L.icon({iconUrl: 'https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/icons/geo-alt-fill.svg', iconSize: [32,32]})}).addTo(window.map);
|
|
||||||
}
|
}
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
btn.innerHTML = '<i class="bi bi-geo-alt"></i> Me localiser';
|
btn.innerHTML = '<i class="bi bi-geo-alt"></i> Me localiser';
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
alert('Impossible de vous localiser : ' + err.message);
|
alert('Impossible de vous localiser : ' + err.message);
|
||||||
|
console.error('[GEOLOC] Erreur de géolocalisation', err);
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
btn.innerHTML = '<i class="bi bi-geo-alt"></i> Me localiser';
|
btn.innerHTML = '<i class="bi bi-geo-alt"></i> Me localiser';
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue