diff --git a/src/js/data-layer/code_cultu-caption.json b/src/js/data-layer/code_cultu-caption.json index a81945d4..f616b2c5 100644 --- a/src/js/data-layer/code_cultu-caption.json +++ b/src/js/data-layer/code_cultu-caption.json @@ -1,35 +1,35 @@ { "BTH": "blé", "BTP": "blé", - "MID": "maïs", - "MIE": "maïs", - "MIS": "maïs", + "MID": "🌽 maïs", + "MIE": "🌽 maïs", + "MIS": "🌽 maïs", "ORH": "orge", "ORP": "orge", "AVH": "avoine", "AVP": "avoine", - "BDH": "blé", - "BDP": "blé", - "BDT": "blé", - "CAG": "céréales", - "CAH": "céréales", - "CGF": "céréales", - "CGH": "céréales", - "CGO": "céréales", - "CGP": "céréales", - "CGS": "céréales", - "CHA": "céréales", - "CHH": "céréales", - "CHS": "céréales", - "CHT": "céréales", - "CPA": "céréales", - "CPH": "céréales", - "CPS": "céréales", - "CPT": "céréales", - "CPZ": "céréales", + "BDH": "🌾 blé", + "BDP": "🌾 blé", + "BDT": "🌾 blé", + "CAG": "🌾 céréales", + "CAH": "🌾 céréales", + "CGF": "🌾 céréales", + "CGH": "🌾 céréales", + "CGO": "🌾 céréales", + "CGP": "🌾 céréales", + "CGS": "🌾 céréales", + "CHA": "🌾 céréales", + "CHH": "🌾 céréales", + "CHS": "🌾 céréales", + "CHT": "🌾 céréales", + "CPA": "🌾 céréales", + "CPH": "🌾 céréales", + "CPS": "🌾 céréales", + "CPT": "🌾 céréales", + "CPZ": "🌾 céréales", "EPE": "épeautre", - "MCR": "céréales", - "MCS": "céréales", + "MCR": "🌾 céréales", + "MCS": "🌾 céréales", "MLT": "millet", "SGH": "seigle", "SGP": "seigle", @@ -39,8 +39,8 @@ "TTP": "triticale", "CZH": "colza", "CZP": "colza", - "TRN": "tournesol", - "ARA": "arachide", + "TRN": "🌻 tournesol", + "ARA": "🥜 arachide", "LIH": "lin", "LIP": "lin", "MOL": "oléagineux", @@ -65,26 +65,21 @@ "MPP": "protéagineux", "MPT": "protéagineux", "PAG": "légumineuses", - "PHF": "pois et haricots frais", - "PHI": "pois protéagineux", - "PHS": "pois et haricots secs", - "PPR": "pois protéagineux", - "PPT": "pois", + "PHF": "🫛 pois et haricots frais", + "PHI": "🫛 pois protéagineux", + "PHS": "🫛 pois et haricots secs", + "PPR": "🫛 pois protéagineux", + "PPT": "🫛 pois", "CHV": "chanvre", "CSE": "chanvre", "LIF": "lin", - "J5M": "jachère", - "J6P": "jachère", - "J6S": "jachère", - "JAC": "jachère", - "JNO": "jachère", "RIZ": "riz", "LEC": "lentilles", "PCH": "pois chiches", "AFG": "plantes fourragères", "BVF": "betteraves", - "CAF": "carottes", - "CHF": "chou", + "CAF": "🥕 carottes", + "CHF": "🥬 chou", "DTY": "dactyle", "FAG": "plantes fourragères", "FET": "fétuque", @@ -151,16 +146,16 @@ "MOH": "moha", "NVF": "navets", "PAT": "pâturin", - "PFH": "pois", - "PFP": "pois", - "PH5": "pois", - "PH6": "pois", - "PH7": "pois", - "PH8": "pois", - "PP5": "pois", - "PP6": "pois", - "PP7": "pois", - "PP8": "pois", + "PFH": "🫛 pois", + "PFP": "🫛 pois", + "PH5": "🫛 pois", + "PH6": "🫛 pois", + "PH7": "🫛 pois", + "PH8": "🫛 pois", + "PP5": "🫛 pois", + "PP6": "🫛 pois", + "PP7": "🫛 pois", + "PP8": "🫛 pois", "RDF": "radis", "SA5": "sainfoin", "SA6": "sainfoin", @@ -174,12 +169,12 @@ "SE8": "serradelle", "SED": "serradelle", "SER": "serradelle", - "TR5": "trèfle", - "TR6": "trèfle", - "TR7": "trèfle", - "TR8": "trèfle", - "TRD": "trèfle", - "TRE": "trèfle", + "TR5": "☘️ trèfle", + "TR6": "☘️ trèfle", + "TR7": "☘️ trèfle", + "TR8": "☘️ trèfle", + "TRD": "☘️ trèfle", + "TRE": "☘️ trèfle", "VE5": "vesce", "VE6": "vesce", "VE7": "vesce", @@ -187,41 +182,41 @@ "VED": "vesce", "VES": "vesce", "XFE": "x-felium", - "AGR": "agrumes", - "ANA": "ananas", - "AVO": "avocats", - "BCA": "bananes", - "BCF": "bananes", - "BCI": "bananes", - "BCP": "bananes", - "BCR": "bananes", - "BEA": "bananes", - "BEF": "bananes", - "BEI": "bananes", - "BEP": "bananes", - "BER": "bananes", + "AGR": "🍊 🍋 agrumes", + "ANA": "🍍 ananas", + "AVO": "🥑 avocats", + "BCA": "🍌 bananes", + "BCF": "🍌 bananes", + "BCI": "🍌 bananes", + "BCP": "🍌 bananes", + "BCR": "🍌 bananes", + "BEA": "🍌 bananes", + "BEF": "🍌 bananes", + "BEI": "🍌 bananes", + "BEP": "🍌 bananes", + "BER": "🍌 bananes", "CAC": "café et cacao", - "CBT": "cerises", - "PFR": "fruits à baie", + "CBT": "🍒 cerises", + "PFR": "🫐 fruits à baie", "PRU": "prunes", - "PVT": "pêches", - "PWT": "poires", - "VRC": "vignes", - "VRN": "vignes", - "VRT": "vignes", + "PVT": "🍑 pêches", + "PWT": "🍐 poires", + "VRC": "🍇 vignes", + "VRN": "🍇 vignes", + "VRT": "🍇 vignes", "CAB": "caroube", - "CTG": "châtaignes", + "CTG": "🌰 châtaignes ", "NOS": "noisettes", "NOX": "noix", "PIS": "pistaches", - "OLI": "olives", + "OLI": "🫒 olives", "ANE": "aneth", "ANG": "angélique", "ANI": "anis", - "AAR": "plantes aromatiques", - "ARP": "plantes aromatiques", + "AAR": "🌿 plantes aromatiques ", + "ARP": "🌿 plantes aromatiques ", "BAR": "bardane", - "BAS": "basilic", + "BAS": "🌱 basilic ", "BRH": "bourrache", "BTN": "betteraves", "CAV": "carvi", @@ -246,8 +241,8 @@ "MTH": "menthe", "ORT": "ortie", "OSE": "oseille", - "PAR": "plantes aromatiques", - "PMD": "plantes médicinales", + "PAR": "🌿 plantes aromatiques", + "PMD": "🌿 plantes médicinales", "PME": "plantes à parfum", "PPA": "plantes à parfum", "PPF": "plantes à parfum", @@ -261,37 +256,37 @@ "SRI": "sarriette", "TAB": "tabac", "THY": "thym", - "TOT": "tomates", + "TOT": "🍅 tomates", "VAL": "valériane", "VNB": "vanille sous bois", "VNL": "vanille", "VNV": "vanille", "YLA": "ylang-ylang", - "AIL": "aïl", + "AIL": "🧄 aïl", "ART": "artichauts", - "AUB": "aubergines", + "AUB": "🍆 aubergines", "BLT": "bleuets", "BUR": "bugle rampante", - "CAR": "carottes", - "CCN": "concombres, cornichons, courgettes", - "CCT": "courgettes, citrouilles", + "CAR": "🥕 carottes", + "CCN": "🥒 concombres, cornichons, courgettes", + "CCT": "courgettes, 🎃 citrouilles", "CEL": "céleris", "CES": "chicorées, endives, scaroles", - "CHU": "choux", + "CHU": "🥬 choux", "CMB": "courges musquées, butternuts", "CRA": "cresson", "CRN": "cornille", "CRS": "cresson", "DOL": "dolique", "EPI": "épinards, oseille et bettes", - "FRA": "fraises", + "FRA": "🍓 fraises", "GER": "géranium", - "HAR": "haricots, flageolets", - "HPC": "horticulture ornementale", - "HSA": "horticulture ornementale", + "HAR": "🫘 haricots, flageolets", + "HPC": "🌷 horticulture ornementale", + "HSA": "🌷 horticulture ornementale", "LBF": "salades", "MAC": "mâche", - "MLO": "melons, pastèques", + "MLO": "🍈 melons, 🍉 pastèques", "MRG": "marguerites", "NVT": "légumes racines", "OIG": "oignons, échalottes", @@ -301,17 +296,17 @@ "PMV": "primevères", "POR": "poireaux", "POT": "courges", - "PPO": "petits pois", + "PPO": "🫛 petits pois", "PSE": "pensées", - "PTC": "pommes de terre", - "PTF": "pommes de terre", - "PVP": "poivrons, piments, aubergines", - "RDI": "radis", - "ROQ": "roquette", - "RUT": "rutabagas", + "PTC": "🍠 pommes de terre", + "PTF": "🍠 pommes de terre", + "PVP": "🫑 poivrons,🌶 piments,🍆 aubergines", + "RDI": " radis", + "ROQ": "🥬 roquette", + "RUT": " rutabagas", "SFI": "salsifis", - "TOM": "tomates", - "TOP": "topinambours", + "TOM": "🍅 tomates", + "TOP": " topinambours", "VER": "véronique", "CSA": "cannes à sucre", "CSF": "cannes à sucre", @@ -326,4 +321,4 @@ "TBT": "tubercules tropicales", "VET": "vétivier", "MLS": "mélange de légumineuses" -} \ No newline at end of file +} diff --git a/src/js/data-layer/code_tfv-caption.json b/src/js/data-layer/code_tfv-caption.json new file mode 100644 index 00000000..78bb7f85 --- /dev/null +++ b/src/js/data-layer/code_tfv-caption.json @@ -0,0 +1,26 @@ +{ + "FF1-00" : "feuillus", + "FF1G01-01" : "chênes", + "FF1G06-06" : "chênes", + "FF1-09-09" : "hêtres", + "FF1-10-10" : "châtaigniers", + "FF1-14-14" : "robiniers", + "FF1-49-49" : "feuillus", + "FF1-00-00" : "feuillus", + "FF2-00" : "conifères", + "FF2-51-51" : "pins maritimes", + "FF2-52-52" : "pins sylvestres", + "FF2G53-53" : "pins laricio, pins noirs", + "FF2-57-57" : "pins d'Alep", + "FF2G58-58" : "pins à crochets ou pins cembro", + "FF2-81-81" : "pins", + "FF2-80-80" : "pins", + "FF2G61-61" : "sapins ou épicéas", + "FF2-63-63" : "mélèzes", + "FF2-64-64" : "douglas", + "FF2-90-90" : "conifères", + "FF2-91-91" : "conifères", + "FF2-00-00" : "conifères", + "FO1" : "feuillus", + "FO2" : "conifères" +} diff --git a/src/js/data-layer/immersvie-position-config.json b/src/js/data-layer/immersvie-position-config.json index d8b60e4e..755a47f1 100644 --- a/src/js/data-layer/immersvie-position-config.json +++ b/src/js/data-layer/immersvie-position-config.json @@ -32,51 +32,53 @@ { "id": "LANDCOVER.FORESTINVENTORY.V2:formation_vegetale", "layer": "LANDCOVER.FORESTINVENTORY.V2:formation_vegetale", - "attributes": ["essence"], - "around": 5, + "attributes": ["code_tfv"], + "around": 2, "epsg": 2154 }, { "id": "Essence intesection", "layer": "LANDCOVER.FORESTINVENTORY.V2:formation_vegetale", - "attributes": ["essence"], + "attributes": ["code_tfv"], "epsg": 2154 }, { "id": "RPG.LATEST:parcelles_graphiques", "layer": "RPG.LATEST:parcelles_graphiques", "attributes": ["code_cultu"], - "around": 5 + "around": 2 }, { "id": "BDTOPO_V3:zone_d_activite_ou_d_interet", "layer": "BDTOPO_V3:zone_d_activite_ou_d_interet", "attributes": ["nature", "toponyme"], "geom_name": "geometrie", - "around": 5, - "additional_cql": "AND categorie='Culture et loisirs' AND nature IN ('Abri de montagne', 'Construction', 'Ecomusée', 'Monument', 'Musée', 'Parc de loisirs', 'Parc zoologique', 'Refuge', 'Vestige archéologique')" + "around": 2, + "additional_cql": "AND categorie='Culture et loisirs' AND nature IN ('Abri de montagne', 'Construction', 'Ecomusée', 'Monument', 'Musée', 'Parc de loisirs', 'Parc zoologique', 'Refuge', 'Vestige archéologique')", + "get_geom": true }, { "id": "BDTOPO_V3:zone_d_habitation", "layer": "BDTOPO_V3:zone_d_habitation", "attributes": ["toponyme"], "geom_name": "geometrie", - "around": 5, - "additional_cql": "AND nature IN ('Château')" + "around": 2, + "additional_cql": "AND nature IN ('Château')", + "get_geom": true }, { "id": "BDTOPO_V3:cours_d_eau", "layer": "BDTOPO_V3:cours_d_eau", "attributes": ["toponyme"], "geom_name": "geometrie", - "around": 5 + "around": 2 }, { "id": "BDTOPO_V3:plan_d_eau", "layer": "BDTOPO_V3:plan_d_eau", "attributes": ["nature", "toponyme"], "geom_name": "geometrie", - "around": 5, - "additional_cql": "AND nature IN ('Canal', 'Estuaire', 'Camping', 'Glacier, névé', 'Lac', 'Lagune', 'Mangrove', 'Marais', 'Mare')" + "around": 2, + "additional_cql": "AND nature IN ('Canal', 'Estuaire', 'Retenue', 'Glacier, névé', 'Lac', 'Lagune', 'Mangrove', 'Marais', 'Mare')" } -] \ No newline at end of file +] diff --git a/src/js/immersive-position.js b/src/js/immersive-position.js index 2754fb7a..1b37320e 100644 --- a/src/js/immersive-position.js +++ b/src/js/immersive-position.js @@ -6,7 +6,11 @@ import queryConfig from "./data-layer/immersvie-position-config.json"; import code_cultuCaption from "./data-layer/code_cultu-caption.json"; +import code_tfvCaption from "./data-layer/code_tfv-caption.json"; + +import maplibregl from "maplibre-gl"; import proj4 from "proj4"; + proj4.defs("EPSG:2154","+proj=lcc +lat_0=46.5 +lon_0=3 +lat_1=49 +lat_2=44 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs"); /** @@ -30,6 +34,9 @@ class ImmersivePosion extends EventTarget { this.lng = this.options.lng; this.data = {}; + this.hasFeuillu = false; + this.hasConnifere = false; + this.hasNatural2000 = false; } /** @@ -37,10 +44,28 @@ class ImmersivePosion extends EventTarget { */ computeHtml() { let htmlTemplate = ` -
Localisation
-Vous êtes sur la commune de ${this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune"] ? this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune"][0][0] : "chargement..."} (${this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune"] ? this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune"][0][1] : "chargement..."} habitants), du département de ${this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:departement"] ? this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:departement"][0] : "chargement..."}
+🏘️ Vous êtes sur la commune de ${this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune"] ? this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune"][0][0] : "chargement..."}, qui compte ${this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune"] ? this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune"][0][1] : "chargement..."} habitants, située dans le département de ${this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:departement"] ? this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:departement"][0] : "chargement..."}
`; + if (this.data["BDTOPO_V3:parc_ou_reserve"] && this.data["BDTOPO_V3:parc_ou_reserve"].length) { + let parcHtml = ""; + for (let i = 0; i < this.data["BDTOPO_V3:parc_ou_reserve"].length; i++) { + let egalementStr = i === 0 ? "" : "également "; + if (["Parc naturel régional", "Parc national"].includes(this.data["BDTOPO_V3:parc_ou_reserve"][i][0])) { + parcHtml += `🏞️ Vous êtes ${egalementStr}situé au sein du ${this.data["BDTOPO_V3:parc_ou_reserve"][i][1]}. `; + } else if (["Réserve naturelle"].includes(this.data["BDTOPO_V3:parc_ou_reserve"][i][0])) { + parcHtml += `Vous êtes ${egalementStr}situé au sein de la ${this.data["BDTOPO_V3:parc_ou_reserve"][i][1]}. `; + } else if (this.data["BDTOPO_V3:parc_ou_reserve"][i][0] === "Site Natura 2000") { + let name = this.data["BDTOPO_V3:parc_ou_reserve"].length === 1 ? ` (${this.data["BDTOPO_V3:parc_ou_reserve"][i][1]})` : ""; + parcHtml += `Vous êtes sur un site classé Natura 2000${name} où la faune et la flore sont protégés.`; + } else { + parcHtml += `Vous êtes ${egalementStr}situé au sein du/de la ${this.data["BDTOPO_V3:parc_ou_reserve"][i][0]} de ${this.data["BDTOPO_V3:parc_ou_reserve"][i][1]}. `; + } + } + parcHtml += "
"; + htmlTemplate += parcHtml; + } + if (this.data["BDTOPO_V3:foret_publique"] && this.data["BDTOPO_V3:foret_publique"].length) { let forestHTML; if (this.data["Essence intesection"] && this.data["Essence intesection"].length) { @@ -55,74 +80,57 @@ class ImmersivePosion extends EventTarget { htmlTemplate += forestHTML; } - if (this.data["BDTOPO_V3:parc_ou_reserve"] && this.data["BDTOPO_V3:parc_ou_reserve"].length) { - let parcHtml = ` -Vous êtes situé au sein ${this.data["BDTOPO_V3:parc_ou_reserve"][0][0]} de ${this.data["BDTOPO_V3:parc_ou_reserve"][0][1]}. - `; - if (this.data["BDTOPO_V3:parc_ou_reserve"][0][0] === "Site Natura 2000") { - parcHtml += " Vous êtes sur un site classé Natura 2000 où la faune et la flore sont protégés."; + if (this.data["BDTOPO_V3:toponymie_lieux_nommes"] && this.data["BDTOPO_V3:toponymie_lieux_nommes"].length) { + let boisList = this.data["BDTOPO_V3:toponymie_lieux_nommes"][0]; + for (let i = 1; i < this.data["BDTOPO_V3:toponymie_lieux_nommes"].length; i++) { + boisList += ", " + this.data["BDTOPO_V3:toponymie_lieux_nommes"][i]; } - parcHtml += "
"; - htmlTemplate += parcHtml; + const boisHtml = `Vous êtes à proximité des bois suivants : ${boisList}.
`; + htmlTemplate += boisHtml; } - htmlTemplate += "Alentours
"; - if (this.data["LANDCOVER.FORESTINVENTORY.V2:formation_vegetale"] && this.data["LANDCOVER.FORESTINVENTORY.V2:formation_vegetale"].length) { let plantHtml; + let feuilluStr = this.hasFeuillu ? "🌳 " : ""; + let connifereStr = this.hasConnifere ? "🌲 " : ""; if (this.data["LANDCOVER.FORESTINVENTORY.V2:formation_vegetale"].length === 1) { plantHtml = ` -Aux alentous, l'essence principale des bois et fôrets est ${this.data["LANDCOVER.FORESTINVENTORY.V2:formation_vegetale"][0]} - `; +
Aux alentours, l’essence des bois et forêts est principalement constituée de ${feuilluStr}${connifereStr} ${this.data["LANDCOVER.FORESTINVENTORY.V2:formation_vegetale"][0]}.`; } else { - let essenceList = ""; - for (let i = 0; i < this.data["LANDCOVER.FORESTINVENTORY.V2:formation_vegetale"].length - 1; i++) { - essenceList += this.data["LANDCOVER.FORESTINVENTORY.V2:formation_vegetale"][i] + ", "; + let essenceList = this.data["LANDCOVER.FORESTINVENTORY.V2:formation_vegetale"][0]; + for (let i = 1; i < this.data["LANDCOVER.FORESTINVENTORY.V2:formation_vegetale"].length - 1; i++) { + essenceList += ", " + this.data["LANDCOVER.FORESTINVENTORY.V2:formation_vegetale"][i]; } essenceList += " et " + this.data["LANDCOVER.FORESTINVENTORY.V2:formation_vegetale"][this.data["LANDCOVER.FORESTINVENTORY.V2:formation_vegetale"].length - 1]; plantHtml = ` -
Aux alentous, les essences principales des bois et forêts sont ${essenceList} - `; +
Aux alentours, l’essence des bois et forêts est principalement constituée de ${feuilluStr}${connifereStr} ${essenceList}.`; } if (this.data["RPG.LATEST:parcelles_graphiques"] && this.data["RPG.LATEST:parcelles_graphiques"].length) { - let cultureList = ""; - if (this.data["RPG.LATEST:parcelles_graphiques"].length === 1) { - cultureList = this.data["RPG.LATEST:parcelles_graphiques"][0]; - } else { - for (let i = 0; i < this.data["RPG.LATEST:parcelles_graphiques"].length - 1; i++) { - cultureList += this.data["RPG.LATEST:parcelles_graphiques"][i] + ", "; + let cultureList = this.data["RPG.LATEST:parcelles_graphiques"][0]; + if (this.data["RPG.LATEST:parcelles_graphiques"].length > 1) { + for (let i = 1; i < this.data["RPG.LATEST:parcelles_graphiques"].length - 1; i++) { + cultureList += ", " + this.data["RPG.LATEST:parcelles_graphiques"][i]; } cultureList += " et " + this.data["RPG.LATEST:parcelles_graphiques"][this.data["RPG.LATEST:parcelles_graphiques"].length - 1]; } - plantHtml += ` et les cultures agricoles sont ${cultureList}`; + plantHtml += ` L'agriculture est dédiée à la production de cultures telles que ${cultureList}.`; } - plantHtml += ".
"; + plantHtml += ""; htmlTemplate += plantHtml; } else if (this.data["RPG.LATEST:parcelles_graphiques"] && this.data["RPG.LATEST:parcelles_graphiques"].length) { - let cultureList = ""; - if (this.data["RPG.LATEST:parcelles_graphiques"].length === 1) { - cultureList = this.data["RPG.LATEST:parcelles_graphiques"][0]; - } else { - for (let i = 0; i < this.data["RPG.LATEST:parcelles_graphiques"].length - 1; i++) { - cultureList += this.data["RPG.LATEST:parcelles_graphiques"][i] + ", "; + let cultureList = this.data["RPG.LATEST:parcelles_graphiques"][0]; + if (this.data["RPG.LATEST:parcelles_graphiques"].length > 1) { + for (let i = 1; i < this.data["RPG.LATEST:parcelles_graphiques"].length - 1; i++) { + cultureList += ", " + this.data["RPG.LATEST:parcelles_graphiques"][i]; } cultureList += " et " + this.data["RPG.LATEST:parcelles_graphiques"][this.data["RPG.LATEST:parcelles_graphiques"].length - 1]; } - const plantHtml = `Aux alentours, les cultures agricoles sont ${cultureList}.`; + const plantHtml = `Aux alentours, l'agriculture est dédiée à la production de cultures telles que ${cultureList}.`; htmlTemplate += plantHtml; } - if (this.data["BDTOPO_V3:toponymie_lieux_nommes"] && this.data["BDTOPO_V3:toponymie_lieux_nommes"].length) { - let boisList = this.data["BDTOPO_V3:toponymie_lieux_nommes"][0]; - for (let i = 1; i < this.data["BDTOPO_V3:toponymie_lieux_nommes"].length; i++) { - boisList += ", " + this.data["BDTOPO_V3:toponymie_lieux_nommes"][i]; - } - const boisHtml = `Vous êtes à proximité des bois suivants : ${boisList}.
`; - htmlTemplate += boisHtml; - } - if (this.data["BDTOPO_V3:cours_d_eau"] && this.data["BDTOPO_V3:cours_d_eau"].length) { let waterList = this.data["BDTOPO_V3:cours_d_eau"][0]; for (let i = 1; i < this.data["BDTOPO_V3:cours_d_eau"].length; i++) { @@ -134,7 +142,7 @@ class ImmersivePosion extends EventTarget { waterList += ", " + this.data["BDTOPO_V3:plan_d_eau"][i][1]; } } - const waterHtml = `Les cours d'eau environnants sont ${waterList}.
`; + const waterHtml = `🌊 Les cours d'eau environnants sont ${waterList}.
`; htmlTemplate += waterHtml; } else if (this.data["BDTOPO_V3:plan_d_eau"] && this.data["BDTOPO_V3:plan_d_eau"].length) { @@ -142,12 +150,12 @@ class ImmersivePosion extends EventTarget { for (let i = 1; i < this.data["BDTOPO_V3:plan_d_eau"].length; i++) { waterList += ", " + this.data["BDTOPO_V3:plan_d_eau"][i][1]; } - const waterHtml = `Les cours d'eau environnants sont ${waterList}.
`; + const waterHtml = `🌊 Les cours d'eau environnants sont ${waterList}.
`; htmlTemplate += waterHtml; } if (this.data["BDTOPO_V3:zone_d_habitation"] && this.data["BDTOPO_V3:zone_d_habitation"].length) { - let otherList = this.data["BDTOPO_V3:zone_d_habitation"][0]; + let otherList = "🏰 " + this.data["BDTOPO_V3:zone_d_habitation"][0]; for (let i = 1; i < this.data["BDTOPO_V3:zone_d_habitation"].length; i++) { otherList += ", " + this.data["BDTOPO_V3:zone_d_habitation"][i]; } @@ -156,15 +164,19 @@ class ImmersivePosion extends EventTarget { otherList += `, ${this.data["BDTOPO_V3:zone_d_activite_ou_d_interet"][i][1]} (${this.data["BDTOPO_V3:zone_d_activite_ou_d_interet"][i][0]})`; } } - const otherHtml = `Non loin se trouvent également : ${otherList}.
`; + const otherHtml = `🧐 Non loin se trouvent également : ${otherList}.
`; htmlTemplate += otherHtml; } else if (this.data["BDTOPO_V3:zone_d_activite_ou_d_interet"] && this.data["BDTOPO_V3:zone_d_activite_ou_d_interet"].length) { let otherList = `${this.data["BDTOPO_V3:zone_d_activite_ou_d_interet"][0][1]} (${this.data["BDTOPO_V3:zone_d_activite_ou_d_interet"][0][0]})`; for (let i = 1; i < this.data["BDTOPO_V3:zone_d_activite_ou_d_interet"].length; i++) { - otherList += `, ${this.data["BDTOPO_V3:zone_d_activite_ou_d_interet"][i][1]} (${this.data["BDTOPO_V3:zone_d_activite_ou_d_interet"][i][0]})`; + if (this.data["BDTOPO_V3:zone_d_activite_ou_d_interet"][i][0] === "Construction") { + otherList += `, ${this.data["BDTOPO_V3:zone_d_activite_ou_d_interet"][i][1]}`; + } else { + otherList += `, ${this.data["BDTOPO_V3:zone_d_activite_ou_d_interet"][i][1]} (${this.data["BDTOPO_V3:zone_d_activite_ou_d_interet"][i][0]})`; + } } - const otherHtml = `Non loin se trouvent également : ${otherList}.
`; + const otherHtml = `🧐 Non loin se trouvent également : ${otherList}.
`; htmlTemplate += otherHtml; } @@ -191,6 +203,7 @@ class ImmersivePosion extends EventTarget { config.geom_name || "geom", config.additional_cql || "", config.epsg || 4326, + config.get_geom || false, ); this.data[config.id] = result; @@ -210,16 +223,89 @@ class ImmersivePosion extends EventTarget { */ #filterData(layer, dataResults) { if (layer === "LANDCOVER.FORESTINVENTORY.V2:formation_vegetale") { - dataResults = dataResults.filter( (essence) => essence !== "NC"); + dataResults = dataResults.filter( (essence) => essence !== "NC" && essence !== "NR"); + } + if (layer === "BDTOPO_V3:parc_ou_reserve") { + dataResults = dataResults.filter( (parc) => { + if ( !(["Site Natura 2000", "Parc naturel régional", "Parc national", "Réserve naturelle"].includes(parc[0])) ) { + return false; + } + if (parc[0] === "Site Natura 2000") { + if (this.hasNatural2000) { + return false; + } + this.hasNatural2000 = true; + } + return true; + }).sort((a, b) => { + if (a[0] === "Parc national") { + return -1; + } + if (b[0] === "Parc national") { + return 1; + } + if (b[0] === "Parc naturel régional" && a[0] !== "Parc national") { + return 1; + } + if (a[0] === "Parc naturel régional" && b[0] !== "Parc national") { + return -1; + } + if (a[0] === "Site Natura 2000") { + return 1; + } + if (b[0] === "Site Natura 2000") { + return -1; + } + }); } if (layer === "BDTOPO_V3:zone_d_activite_ou_d_interet") { - dataResults = dataResults.filter( (zai) => zai[1] !== null); + dataResults = dataResults.filter( (zai) => zai[1] !== null).sort( (a, b) => { + const coordsA = new maplibregl.LngLat(...a[2].coordinates[0][0][0]); + const coordsB = new maplibregl.LngLat(...b[2].coordinates[0][0][0]); + const coordsRef = new maplibregl.LngLat(this.lng, this.lat); + return coordsRef.distanceTo(coordsA) - coordsRef.distanceTo(coordsB); + }).slice(0, 5); + } + if (layer === "BDTOPO_V3:plan_d_eau") { + dataResults = dataResults.filter( (plan) => plan[1] !== null); } if (layer === "RPG.LATEST:parcelles_graphiques") { dataResults = dataResults.map( (code_cultu) => code_cultuCaption[code_cultu]).filter((culture) => culture); } + if (layer === "LANDCOVER.FORESTINVENTORY.V2:formation_vegetale") { + dataResults = dataResults.map( (code_tfv) => { + if (code_tfvCaption[code_tfv]) { + if (code_tfv[2] === "1") { + this.hasFeuillu = true; + } + if (code_tfv[2] === "2") { + this.hasConnifere = true; + } + } + return code_tfvCaption[code_tfv]; + }).filter((essence) => essence); + } if (layer === "BDTOPO_V3:zone_d_habitation") { - dataResults = dataResults.filter( (name) => name); + dataResults = dataResults.filter( (feat) => feat[0]).sort( (a, b) => { + const coordsA = new maplibregl.LngLat(...a[1].coordinates[0][0][0]); + const coordsB = new maplibregl.LngLat(...b[1].coordinates[0][0][0]); + const coordsRef = new maplibregl.LngLat(this.lng, this.lat); + return coordsRef.distanceTo(coordsA) - coordsRef.distanceTo(coordsB); + }).map( feat => feat[0]).slice(0, 5); + } + if (layer === "BDTOPO_V3:cours_d_eau") { + dataResults = dataResults.filter( (cours) => { + if (cours.split(" ")[0] === "Bras") { + return false; + } + const splitted = cours.split(" "); + for (let word of splitted) { + if (word.match(/[0-9][0-9]/g)) { + return false; + } + } + return true; + }); } return dataResults; } @@ -234,7 +320,7 @@ class ImmersivePosion extends EventTarget { * @param {number} epsg epsg number of the layer's CRS, default 4326 * @returns {Promise(Array)} results of each attributes (no duplicates) */ - async #computeGenericGPFWFS(layer, attributes, around=0, geom_name="geom", additional_cql="", epsg=4326) { + async #computeGenericGPFWFS(layer, attributes, around=0, geom_name="geom", additional_cql="", epsg=4326, getGeom=false) { let coord1 = this.lat; let coord2 = this.lng; if (epsg !== 4326) { @@ -249,7 +335,7 @@ class ImmersivePosion extends EventTarget { } const results = await fetch( - `https://data.geopf.fr/wfs/ows?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&typename=${layer}&outputFormat=json&count=10&CQL_FILTER=${cql_filter}` + `https://data.geopf.fr/wfs/ows?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&typename=${layer}&outputFormat=json&count=50&CQL_FILTER=${cql_filter}` ); const json = await results.json(); @@ -259,9 +345,12 @@ class ImmersivePosion extends EventTarget { attributes.forEach((attribute) => { feature_attributes.push(feature.properties[attribute]); }); - if (attributes.length === 1) { + if (getGeom) { + feature_attributes.push(feature.geometry); + } + if (attributes.length === 1 && feature_attributes[0] !== null && !getGeom) { results_attributes.push(feature_attributes[0]); - } else { + } else if (attributes.length > 1 || getGeom) { results_attributes.push(feature_attributes); } });