From 542510cf83661a0fb82596d46ffcc694b10139de Mon Sep 17 00:00:00 2001 From: arnold-pichler Date: Wed, 4 Sep 2024 10:55:17 +0200 Subject: [PATCH 01/17] zoomto function + icona --- src/components/TheEntryList.vue | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/TheEntryList.vue b/src/components/TheEntryList.vue index 2f921a8..88b0e14 100644 --- a/src/components/TheEntryList.vue +++ b/src/components/TheEntryList.vue @@ -24,7 +24,14 @@ > + Date: Tue, 3 Sep 2024 21:34:51 +0200 Subject: [PATCH 02/17] Zoom to saved schlag geometry parts --- public/map/style.json | 593 ------------------------------ src/components/TheEntryList.vue | 4 +- src/composables/useDataEntries.js | 6 +- src/composables/useMap.js | 6 +- src/composables/useSchlag.js | 42 ++- src/constants.js | 4 +- 6 files changed, 50 insertions(+), 605 deletions(-) delete mode 100644 public/map/style.json diff --git a/public/map/style.json b/public/map/style.json deleted file mode 100644 index ccd168e..0000000 --- a/public/map/style.json +++ /dev/null @@ -1,593 +0,0 @@ -{ - "version": 8, - "center": [15.88623, 46.754915], - "zoom": 6, - "sources": { - "geolandbasemap": { - "type": "raster", - "tiles": [ - "https://mapsneu.wien.gv.at/basemap/geolandbasemap/normal/google3857/{z}/{y}/{x}.png" - ], - "tileSize": 256, - "maxzoom": 19, - "attribution": "Grundkarte: basemap.at", - "bounds": [8.782379, 46.35877, 17.5, 49.037872] - }, - "bmaporthofoto30cm": { - "type": "raster", - "tiles": [ - "https://mapsneu.wien.gv.at/basemap/bmaporthofoto30cm/normal/google3857/{z}/{y}/{x}.jpeg" - ], - "tileSize": 256, - "maxzoom": 19, - "attribution": "Grundkarte: basemap.at", - "bounds": [8.782379, 46.35877, 17.5, 49.037872] - }, - "neigungsklassen": { - "type": "raster", - "tileSize": 512, - "tiles": [ - "https://inspire.lfrz.gv.at/000504/ows?SERVICE=WMS&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=neigungsklassen&STYLES=&WIDTH=512&HEIGHT=512&CRS=EPSG%3A3857&BBOX={bbox-epsg-3857}" - ], - "minzoom": 9, - "maxzoom": 14, - "layout": { - "visibility": "none" - } - }, - "agrargis": { - "type": "vector", - "tiles": ["https://agraratlas.inspire.gv.at/map/tiles/{z}/{x}/{y}.pbf"], - "attribution": "© BML", - "maxzoom": 15, - "bounds": [9.532874, 46.367811, 17.160773, 49.001157] - } - }, - "layers": [ - { - "id": "basemap.at", - "type": "raster", - "source": "geolandbasemap", - "metadata": { - "group": "base" - } - }, - { - "id": "Orthofoto", - "type": "raster", - "source": "bmaporthofoto30cm", - "layout": { - "visibility": "none" - }, - "metadata": { - "group": "base" - } - }, - { - "id": "neigungsklassen", - "type": "raster", - "source": "neigungsklassen", - "minzoom": 9, - "layout": { - "visibility": "none" - }, - "metadata": { - "group": "multi", - "classes": [ - { - "label": "0 - <10%", - "value": 1, - "color": [255, 255, 154] - }, - { - "label": "10 - <18%", - "value": 2, - "color": [12, 156, 205] - }, - { - "label": "18 - <25%", - "value": 3, - "color": [255, 190, 255] - }, - { - "label": "25 - <35%", - "value": 4, - "color": [0, 51, 255] - }, - { - "label": "35 - <50%", - "value": 5, - "color": [255, 0, 0] - }, - { - "label": ">=50%", - "value": 6, - "color": [164, 164, 164] - } - ] - } - }, - { - "id": "benachteiligte_gebiete-berggebiet", - "type": "fill", - "source": "agrargis", - "source-layer": "benachteiligte_gebiete", - "filter": ["==", "bengebcode", 3], - "paint": { - "fill-color": "#98e600" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "Benachteiligtes Gebiet – Berggebiet", - "urlSort": 17, - "group": "one", - "category": "Ausgleichszulage" - } - }, - { - "id": "benachteiligte_gebiete-kleines_gebiet", - "type": "fill", - "source": "agrargis", - "source-layer": "benachteiligte_gebiete", - "filter": ["==", "bengebcode", 5], - "paint": { - "fill-color": "#e69800" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "Benachteiligtes Gebiet – Kleines Gebiet", - "urlSort": 18, - "group": "one", - "category": "Ausgleichszulage" - } - }, - { - "id": "benachteiligte_gebiete-sonstiges", - "type": "fill", - "source": "agrargis", - "source-layer": "benachteiligte_gebiete", - "filter": ["==", "bengebcode", 4], - "paint": { - "fill-color": "#267300" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "Benachteiligtes Gebiet – Sonstiges", - "urlSort": 19, - "group": "one", - "category": "Ausgleichszulage" - } - }, - { - "id": "bdfl_l08_seehoehe_1200m-one", - "type": "fill", - "source": "agrargis", - "source-layer": "bdfl_l08_seehoehe_1200m", - "paint": { - "fill-color": "rgb(153, 153, 153)" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "Seehöhe über 1200m", - "urlSort": 11, - "group": "one", - "category": "ÖPUL" - } - }, - { - "id": "bdfl_l34_feucht_torfgebiete-one", - "type": "fill", - "source": "agrargis", - "source-layer": "bdfl_l34_feucht_torfgebiete", - "paint": { - "fill-color": "rgb(116, 216, 249)" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "2: Feuchtgebiete und Torfflächen", - "urlSort": 14, - "group": "one", - "category": "GLÖZ" - } - }, - { - "id": "bdfl_l33_pufferstreifen_belastete_gewaesser-one", - "type": "fill", - "source": "agrargis", - "source-layer": "bdfl_l33_pufferstreifen_belastete_gewaesser", - "paint": { - "fill-color": "rgb(147, 248, 104)" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "4: Pufferstreifen belasteter Gewässer", - "urlSort": 1, - "group": "one", - "category": "GLÖZ" - } - }, - { - "id": "schwere_boeden", - "type": "fill", - "source": "agrargis", - "source-layer": "schwere_boeden", - "paint": { - "fill-color": "#b4445a" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "6: Schwere Böden", - "urlSort": 21, - "group": "one", - "category": "GLÖZ" - } - }, - { - "id": "natura2000_ffh", - "type": "fill", - "source": "agrargis", - "source-layer": "natura2000", - "filter": ["==", "gebietsart", "FFH"], - "paint": { - "fill-color": "#ffe600" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "9: Natura 2000 Fauna Flora Habitat", - "urlSort": 22, - "group": "one", - "category": "GLÖZ" - } - }, - { - "id": "natura2000_vs", - "type": "fill", - "source": "agrargis", - "source-layer": "natura2000", - "filter": ["==", "gebietsart", "VS"], - "paint": { - "fill-color": "#b43200" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "9: Natura 2000 Vogelschutz", - "urlSort": 23, - "group": "one", - "category": "GLÖZ" - } - }, - { - "id": "bdfl_l16_grundwasserschutz_acker-one", - "type": "fill", - "source": "agrargis", - "source-layer": "bdfl_l16_grundwasserschutz_acker", - "paint": { - "fill-color": "rgb(0, 97, 241)" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "Grundwasserschutz Acker", - "urlSort": 9, - "group": "one", - "category": "ÖPUL" - } - }, - { - "id": "nitrataktionsprogramm", - "source": "agrargis", - "source-layer": "nitrataktionsprogramm", - "type": "fill", - "filter": ["==", "in_napv", 1], - "paint": { - "fill-color": "#89ce64" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "2: NAPV-Anlage 5 Gebiete", - "urlSort": 20, - "group": "one", - "category": "GAB" - } - }, - { - "id": "bdfl_l40_gab8-one", - "type": "fill", - "source": "agrargis", - "source-layer": "bdfl_l40_gab8", - "paint": { - "fill-color": "rgb(191, 191, 191)" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "8: PSM-Schutzgebiete (WRRL)", - "urlSort": 15, - "group": "one", - "category": "GAB" - } - }, - { - "id": "bdfl_l13_besondere_lebensraumtypen-one", - "type": "fill", - "source": "agrargis", - "source-layer": "bdfl_l13_besondere_lebensraumtypen", - "paint": { - "fill-color": "rgb(255, 0, 255)" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "9: Besondere Lebensraumtypen", - "urlSort": 10, - "group": "one", - "category": "GLÖZ" - } - }, - { - "id": "bdfl_l26_wasserrahmenrichtlinie_ertragslagen-el_hoch_3", - "type": "fill", - "source": "agrargis", - "source-layer": "bdfl_l26_wasserrahmenrichtlinie_ertragslagen", - "filter": ["==", "el", "EL hoch 3"], - "paint": { - "fill-color": "rgb(33, 32, 255)" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "WRRL Steiermark EL hoch 3", - "urlSort": 3, - "group": "one", - "category": "ÖPUL" - } - }, - { - "id": "bdfl_l26_wasserrahmenrichtlinie_ertragslagen-el_hoch_2", - "type": "fill", - "source": "agrargis", - "source-layer": "bdfl_l26_wasserrahmenrichtlinie_ertragslagen", - "filter": ["==", "el", "EL hoch 2"], - "paint": { - "fill-color": "rgb(60, 255, 40)" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "WRRL Steiermark EL hoch 2", - "urlSort": 4, - "group": "one", - "category": "ÖPUL" - } - }, - { - "id": "bdfl_l26_wasserrahmenrichtlinie_ertragslagen-el_hoch_1", - "type": "fill", - "source": "agrargis", - "source-layer": "bdfl_l26_wasserrahmenrichtlinie_ertragslagen", - "filter": ["==", "el", "EL hoch 1"], - "paint": { - "fill-color": "rgb(253, 241, 45)" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "WRRL Steiermark EL hoch 1", - "urlSort": 5, - "group": "one", - "category": "ÖPUL" - } - }, - { - "id": "bdfl_l26_wasserrahmenrichtlinie_ertragslagen-el_mittel", - "type": "fill", - "source": "agrargis", - "source-layer": "bdfl_l26_wasserrahmenrichtlinie_ertragslagen", - "filter": ["==", "el", "EL mittel"], - "paint": { - "fill-color": "rgb(198, 35, 197)" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "WRRL Steiermark EL mittel", - "urlSort": 6, - "group": "one", - "category": "ÖPUL" - } - }, - { - "id": "bdfl_l26_wasserrahmenrichtlinie_ertragslagen-el_mittel_10", - "type": "fill", - "source": "agrargis", - "source-layer": "bdfl_l26_wasserrahmenrichtlinie_ertragslagen", - "filter": ["==", "el", "EL mittel -10%"], - "paint": { - "fill-color": "rgb(252, 93, 33)" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "WRRL Steiermark EL mittel -10%", - "urlSort": 7, - "group": "one", - "category": "ÖPUL" - } - }, - { - "id": "bdfl_l26_wasserrahmenrichtlinie_ertragslagen-el_niedrig", - "type": "fill", - "source": "agrargis", - "source-layer": "bdfl_l26_wasserrahmenrichtlinie_ertragslagen", - "filter": ["==", "el", "EL niedrig"], - "paint": { - "fill-color": "rgb(44, 214, 248)" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "WRRL Steiermark EL niedrig", - "urlSort": 8, - "group": "one", - "category": "ÖPUL" - } - }, - { - "id": "bdfl_l31_begruente_abflusswege-one", - "type": "fill", - "source": "agrargis", - "source-layer": "bdfl_l31_begruente_abflusswege", - "paint": { - "fill-color": "rgb(108, 143, 235)" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "Begrünte Abflusswege", - "urlSort": 2, - "group": "one", - "category": "ÖPUL" - } - }, - { - "id": "stehende_gewaesser-one", - "type": "fill", - "source": "agrargis", - "source-layer": "stehende_gewaesser", - "paint": { - "fill-color": "rgb(29, 105, 174)" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "Gewässer", - "urlSort": 12, - "group": "one", - "category": "GAB" - } - }, - { - "id": "gewaessernetz-one", - "type": "line", - "source": "agrargis", - "source-layer": "gewaessernetz", - "paint": { - "line-color": "rgb(29, 105, 174)", - "line-width": 4 - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "Gewässer", - "urlSort": 13, - "group": "one", - "category": "GAB" - } - }, - { - "id": "invekos_schlaege_20241_polygon-fill", - "type": "fill", - "source": "agrargis", - "source-layer": "invekos_schlaege_20241_polygon", - "paint": { - "fill-color": [ - "case", - ["boolean", ["feature-state", "selected"], false], - "rgba(0, 0, 0, 0)", - "rgba(0, 0, 0, 0.1)" - ] - } - }, - { - "id": "invekos_schlaege_polygon-line", - "type": "line", - "source": "agrargis", - "source-layer": "invekos_schlaege_20241_polygon", - "paint": { - "line-color": [ - "case", - ["boolean", ["feature-state", "selected"], false], - "rgba(0, 0, 0, 0)", - "rgb(238, 90, 78)" - ], - "line-width": 2 - } - }, - { - "id": "invekos_schlaege_polygon-bio", - "type": "fill", - "source": "agrargis", - "source-layer": "invekos_schlaege_2023_bio_polygon", - "filter": ["any", ["==", "kz_bio_oepul_jn", "J"], ["!", ["has", "kz_bio_oepul_jn"]]], - "paint": { - "fill-color": "red", - "fill-outline-color": "rgb(139, 0, 0)" - }, - "layout": { - "visibility": "none" - }, - "metadata": { - "label": "Bio-Schläge MFA 2023", - "warning": "Die rot dargestellten Flächen werden biologisch bewirtschaftet. Es ist daher bei der Ausbringung von Betriebsmitteln auf Nachbarfeldstücken besondere Sorgfalt walten zu lassen", - "urlSort": 16, - "displaySort": 1, - "group": "one", - "category": "BIO" - } - }, - { - "id": "invekos_schlaege_polygon-line-selected", - "type": "line", - "source": "agrargis", - "source-layer": "invekos_schlaege_20241_polygon", - "paint": { - "line-color": [ - "case", - ["boolean", ["feature-state", "selected"], false], - "#65000B", - "rgba(0, 0, 0, 0)" - ], - "line-width": 5 - } - } - ], - "metadata": { - "sources": { - "invekos_schlaege_20241_polygon": { - "lastModified": "2024-06-14T00:00:00Z" - } - } - } -} diff --git a/src/components/TheEntryList.vue b/src/components/TheEntryList.vue index 88b0e14..2363dbf 100644 --- a/src/components/TheEntryList.vue +++ b/src/components/TheEntryList.vue @@ -65,13 +65,15 @@ - - From 8b76a480b7c56620ce2d30ff59002f5b8c7a858c Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Wed, 4 Sep 2024 17:33:20 +0200 Subject: [PATCH 07/17] Remove unused emit --- src/components/TheEntryForm.vue | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/components/TheEntryForm.vue b/src/components/TheEntryForm.vue index 6a403e5..aed5cdd 100644 --- a/src/components/TheEntryForm.vue +++ b/src/components/TheEntryForm.vue @@ -594,7 +594,6 @@ const { map } = useMap(); const route = useRoute(); const router = useRouter(); const { topicHectars } = useTopicIntersections(); -const emit = defineEmits(['schlag']); const schlaegeLastModified = ref(); const { lookup } = useLookup(); const tempData = ref({ basic: null, programs: null }); @@ -778,9 +777,6 @@ watch(schlagInfo, (value) => { } router.push({ params: { ...route.params, schlagId: value?.id } }); } - if (value && !value.loading) { - emit('schlag', true); - } }); // Area of relevant topics inside the current schlag From 26a65533d50df4bf8020c4f2c26cdbddfd3dc0f8 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Wed, 4 Sep 2024 17:33:59 +0200 Subject: [PATCH 08/17] Do not reference ref in ref --- src/components/TheEntryForm.vue | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/TheEntryForm.vue b/src/components/TheEntryForm.vue index aed5cdd..94a9394 100644 --- a/src/components/TheEntryForm.vue +++ b/src/components/TheEntryForm.vue @@ -764,9 +764,7 @@ watch(schlagInfo, (value) => { entry.value.flaechennutzungsart = tempData.value.basic.fnar_code; entry.value.flaeche = tempData.value.basic.sl_flaeche_brutto_ha; - entry.value.schlaginfo.basic = schlagInfo.value; - - entry.value.extent = tempData.value.basic.extent; + entry.value.schlaginfo.basic = JSON.parse(JSON.stringify(schlagInfo.value)); entry.value.jahr = new Date().getFullYear(); From 939a560127cbf1aefb06be509d255278c80d187a Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Wed, 4 Sep 2024 17:34:57 +0200 Subject: [PATCH 09/17] Always show schlag parts instead of feature state selection --- src/components/TheEntryList.vue | 9 ++---- src/composables/useSchlag.js | 57 +++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/components/TheEntryList.vue b/src/components/TheEntryList.vue index 5827f43..487601c 100644 --- a/src/components/TheEntryList.vue +++ b/src/components/TheEntryList.vue @@ -70,17 +70,14 @@ import { useDataEntries } from '../composables/useDataEntries.js'; import { watch } from 'vue'; const { allData, emptyEntry, entry } = useDataEntries(); -const { showSchlagParts } = useSchlag(); +const { showSchlagParts, removeSchlagParts } = useSchlag(); -let removeSchlagParts; watch(entry, (value) => { - if (removeSchlagParts) { - removeSchlagParts(); - } + removeSchlagParts(); if (!value.schlaginfo?.basic?.parts) { return; } - removeSchlagParts = showSchlagParts(value.schlaginfo.basic.parts); + showSchlagParts(value.schlaginfo.basic.parts); }); function zoomTo(nr) { entry.value = JSON.parse(JSON.stringify(allData.value.saved[nr])); diff --git a/src/composables/useSchlag.js b/src/composables/useSchlag.js index 8bce3b7..b78b16f 100644 --- a/src/composables/useSchlag.js +++ b/src/composables/useSchlag.js @@ -1,4 +1,4 @@ -import { getSource, setFeatureState } from 'ol-mapbox-style'; +import { getSource } from 'ol-mapbox-style'; import { createEmpty, extend } from 'ol/extent'; import { transformExtent } from 'ol/proj'; import { toGeometry } from 'ol/render/Feature'; @@ -21,7 +21,7 @@ import VectorSource from 'ol/source/Vector.js'; * @property {string} [fnar_code] * @property {string} [kz_bio_oepul_jn] * @property {import("ol/extent").Extent} [extent] - * @property {Array} [parts] + * @property {Array} [parts] */ const geojson = new GeoJSON(); @@ -145,28 +145,36 @@ map.on('pointermove', (event) => { allData.value.datawindow === 1 && getSchlagAtPixel(event.pixel) ? 'pointer' : ''; }); -watch(schlagInfo, (value, oldValue) => { - if (oldValue && !oldValue.loading) { - setFeatureState(map, { source: 'agrargis', id: oldValue.id }, null); +watch(schlagInfo, (value) => { + removeSchlagParts(); + if (!value) { + return; } - if (value) { - if (value.loading) { - findSchlag(value.id).then((feature) => { - setSchlagInfo(feature); - }); - } else { - setFeatureState(map, { source: 'agrargis', id: value.id }, { selected: true }); - } + if (value?.loading) { + findSchlag(value.id).then((feature) => { + setSchlagInfo(feature); + }); + return; } + showSchlagParts(value.parts, { zoom: false }); }); +let partsLayer; +function removeSchlagParts() { + if (!partsLayer) { + return; + } + map.removeLayer(partsLayer); +} + /** * @param {Array} parts - * @returns {() => void} Call this function to remove schlag parts from the map */ -function showSchlagParts(parts) { - const partsLayer = new VectorLayer({ +function showSchlagParts(parts, options = { zoom: true }) { + removeSchlagParts(); + partsLayer = new VectorLayer({ source: new VectorSource({ + overlaps: false, features: geojson.readFeatures({ type: 'FeatureCollection', features: parts.map((geometry) => ({ @@ -175,24 +183,25 @@ function showSchlagParts(parts) { })), }), }), - opacity: 0.5, style: { - 'fill-color': 'rgb(30, 30, 30)', + 'fill-color': 'rgba(255, 0, 0, 0.25)', }, }); - map - .getView() - .fit(partsLayer.getSource().getExtent(), { duration: 500, padding: [50, 50, 50, 400] }); + if (options.zoom) { + map + .getView() + .fit(partsLayer.getSource().getExtent(), { duration: 500, padding: [50, 50, 50, 400] }); + } map.addLayer(partsLayer); - return () => map.removeLayer(partsLayer); } /** * @returns {{ * schlagInfo: import('vue').Ref, - * showSchlagParts: (parts: Array) => () => void, + * showSchlagParts: (parts: Array) => void, + * removeSchlagParts: () => void, * }} */ export function useSchlag() { - return { schlagInfo, showSchlagParts }; + return { schlagInfo, showSchlagParts, removeSchlagParts }; } From dd9d2ef2faceeb9a1de01724b8bb528993ca23eb Mon Sep 17 00:00:00 2001 From: arnold-pichler Date: Thu, 5 Sep 2024 12:12:26 +0200 Subject: [PATCH 10/17] replace allData with single Refs (yet) --- src/components/TheEntryForm.vue | 29 +++++++++++++------------ src/components/TheEntryList.vue | 27 +++++++++++------------ src/components/TheFertilizerBalance.vue | 4 ++-- src/components/TheLoadSavePanel.vue | 12 +++++----- src/composables/useDataEntries.js | 29 +++++++++++++++---------- src/composables/useSchlag.js | 6 ++--- 6 files changed, 57 insertions(+), 50 deletions(-) diff --git a/src/components/TheEntryForm.vue b/src/components/TheEntryForm.vue index 94a9394..e83f2b8 100644 --- a/src/components/TheEntryForm.vue +++ b/src/components/TheEntryForm.vue @@ -1,7 +1,7 @@