fix: masquer les zones d'observation sans sargasses (afaiIndex = 0)
Passe afaiIndex en propriété GeoJSON et applique un filtre MapLibre sur les layers observation : seules les features avec afai > 0 sont affichées. Fallback : si la propriété est absente, affichage normal. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
9
backend/public/assets/index-DwKkpLRn.js
Normal file
9
backend/public/assets/index-DwKkpLRn.js
Normal file
File diff suppressed because one or more lines are too long
756
backend/public/assets/maplibre-gl-C-PZyP1r.js
Normal file
756
backend/public/assets/maplibre-gl-C-PZyP1r.js
Normal file
File diff suppressed because one or more lines are too long
@@ -8,7 +8,7 @@
|
|||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Fredoka+One&family=Fredoka:wght@400;500;600&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=Fredoka+One&family=Fredoka:wght@400;500;600&display=swap" rel="stylesheet">
|
||||||
<script type="module" crossorigin src="/assets/index-B_-zKuKT.js"></script>
|
<script type="module" crossorigin src="/assets/index-DwKkpLRn.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-RGvCvNm_.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-RGvCvNm_.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -64,12 +64,17 @@ function cartoonizeStyle(style) {
|
|||||||
return { ...style, layers };
|
return { ...style, layers };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filtre : affiche uniquement les features avec sargasses (afai > 0),
|
||||||
|
// ou si la propriété est absente (données legacy sans afaiIndex).
|
||||||
|
const OBS_FILTER = ['any', ['!', ['has', 'afai']], ['>', ['get', 'afai'], 0]];
|
||||||
|
|
||||||
// ── Layer style factories ──────────────────────────────────────────────────
|
// ── Layer style factories ──────────────────────────────────────────────────
|
||||||
const makeLayerStyles = (isPrediction, opacity, hasPattern) => ({
|
const makeLayerStyles = (isPrediction, opacity, hasPattern) => ({
|
||||||
fill: {
|
fill: {
|
||||||
id: isPrediction ? 'forecasts-fill' : 'observations-fill',
|
id: isPrediction ? 'forecasts-fill' : 'observations-fill',
|
||||||
type: 'fill',
|
type: 'fill',
|
||||||
source: isPrediction ? 'forecasts' : 'observations',
|
source: isPrediction ? 'forecasts' : 'observations',
|
||||||
|
...(!isPrediction ? { filter: OBS_FILTER } : {}),
|
||||||
paint: {
|
paint: {
|
||||||
'fill-color': isPrediction ? '#818cf8' : '#f4a020',
|
'fill-color': isPrediction ? '#818cf8' : '#f4a020',
|
||||||
'fill-opacity': (isPrediction ? 0.55 : 0.7) * opacity,
|
'fill-opacity': (isPrediction ? 0.55 : 0.7) * opacity,
|
||||||
@@ -80,6 +85,7 @@ const makeLayerStyles = (isPrediction, opacity, hasPattern) => ({
|
|||||||
id: isPrediction ? 'forecasts-line' : 'observations-line',
|
id: isPrediction ? 'forecasts-line' : 'observations-line',
|
||||||
type: 'line',
|
type: 'line',
|
||||||
source: isPrediction ? 'forecasts' : 'observations',
|
source: isPrediction ? 'forecasts' : 'observations',
|
||||||
|
...(!isPrediction ? { filter: OBS_FILTER } : {}),
|
||||||
paint: {
|
paint: {
|
||||||
'line-color': isPrediction ? '#6366f1' : '#c47a10',
|
'line-color': isPrediction ? '#6366f1' : '#c47a10',
|
||||||
'line-width': isPrediction ? 2 : 3.5,
|
'line-width': isPrediction ? 2 : 3.5,
|
||||||
@@ -94,6 +100,7 @@ const makeLayerStyles = (isPrediction, opacity, hasPattern) => ({
|
|||||||
id: 'observations-dots',
|
id: 'observations-dots',
|
||||||
type: 'fill',
|
type: 'fill',
|
||||||
source: 'observations',
|
source: 'observations',
|
||||||
|
filter: OBS_FILTER,
|
||||||
paint: {
|
paint: {
|
||||||
'fill-pattern': 'sargasse-dots',
|
'fill-pattern': 'sargasse-dots',
|
||||||
'fill-opacity': opacity * 0.7,
|
'fill-opacity': opacity * 0.7,
|
||||||
@@ -227,7 +234,14 @@ export default function SargassesMap({ onSpotSelect, selectedSpotId, activeStep,
|
|||||||
|
|
||||||
const toFeatureCollection = (items = []) => {
|
const toFeatureCollection = (items = []) => {
|
||||||
const features = (items ?? []).filter(i => i.geometry)
|
const features = (items ?? []).filter(i => i.geometry)
|
||||||
.map(i => ({ type: 'Feature', geometry: i.geometry, properties: {} }));
|
.map(i => ({
|
||||||
|
type: 'Feature',
|
||||||
|
geometry: i.geometry,
|
||||||
|
properties: {
|
||||||
|
// afai absent → null → filtre "!has" prend le relais (affichage normal)
|
||||||
|
afai: typeof i.afaiIndex === 'number' ? i.afaiIndex : null,
|
||||||
|
},
|
||||||
|
}));
|
||||||
return features.length ? { type: 'FeatureCollection', features } : null;
|
return features.length ? { type: 'FeatureCollection', features } : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user