diff --git a/DRAFT_CHANGELOG.md b/DRAFT_CHANGELOG.md index e4e58ad31..069203cf9 100644 --- a/DRAFT_CHANGELOG.md +++ b/DRAFT_CHANGELOG.md @@ -6,18 +6,21 @@ ## Summary +Corrections styles couches COMPUTE et imports + ## Changelog * [Added] * [Changed] - - mise à jour ol-ext 3.2.21 - * [Removed] * [Fixed] + - fix sur le styles des couches COMPUTE (6c2f07f7a743825ce52fd7c0093941d5dd2ac8eb) + - fix import KML (e3ff993104854c45a87e71b702a40c42f0d2479d et 450e32de52b60624a22f6d60ddc11b0c57116d38) + * [Deprecated] * [Security] diff --git a/package.json b/package.json index e5bbf2289..9cc677c87 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "geoportal-sdk", - "version": "3.3.24", - "date": "23/03/2023", - "SDK2DVersion": "3.3.24", - "SDK3DVersion": "3.3.24", + "version": "3.3.25", + "date": "03/04/2023", + "SDK2DVersion": "3.3.25", + "SDK3DVersion": "3.3.25", "description": "French Geoportal SDK based on OpenLayers (2D) and iTowns (3D) libraries", "main": "dist/2d/GpSDK2D-src.js, dist/3d/GpSDK3d-src.js", "module": "src/SDK2D.js, src/SDK3D.js", diff --git a/src/Interface/IMapBase.js b/src/Interface/IMapBase.js index 673d3feb8..4e0ba3a14 100644 --- a/src/Interface/IMapBase.js +++ b/src/Interface/IMapBase.js @@ -41,10 +41,12 @@ var switch2D3D = function (viewMode) { // traitement des couches de calcul if (layer.options.format.toUpperCase() === "COMPUTE") { // TODO : - // transmettre les bons styles à la couche 2D->3D - // isocurve = fill-color : "rgba(0, 183, 152, 0.7)" - // itineraire = stroke-color : "rgba(0,183,152,0.9)", - // stroke-width : 12 + // les styles pour la 2D et 3D sont ajoutés à la volée, + // une evolution est à mettre en place sur les contrôles, + // les contrôles doivent transmettre les styles à la couche 2D & 3D. + // ex. isocurve = fill-color : "rgba(0,183,152,0.7)" + // ex. itineraire = stroke-color : "rgba(0,183,152,0.9)", + // stroke-width : 12 // les controles fournissent leurs méta-informations utiles à leur reconstruction en 2D. // les infos issues de la methode getData() : @@ -65,9 +67,19 @@ var switch2D3D = function (viewMode) { geojsonStr = this.getLibMapControl("route").getGeoJSON(); geojsonObj = JSON.parse(geojsonStr); geojsonObj.features.forEach(feature => { + if (!feature.properties) { + feature.properties = {}; + } if (feature.geometry.type === "Point") { + // style propre à la 3D feature.properties.icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAmCAYAAABpuqMCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAQxSURBVFiF3ZldaBxVFMd/d2ayTRtjQpo2mlilWBEMshoj+FAERZIHIdA3iw+V1icRREFIQAKNgsUHQfBFwZI2WgWxqYUiVTDBBj9ILC5Nu2tjdjemsR+mSZNNNvsxO8eHTTRuk+zMnQmCf9iHnXvO+Z//nDvn3rmjRIT/C6zAI4ZVFRbtKDpQNCM0AvXANIo/EC4inMbmLBFZDJJaBVaZJ9Sd2HQCrwDbXHikgfewOMKPMh9ECsGIeVx1IHxEsQJeMY3iEMNy2m8aht8AtKpOhH70hADUI/TTqjr9puKvMsUE3vabxCp0MSJHdJ31xRSnVj9BVPcfOCj26U45PTHFh30c/am1EaaxuF+nKejd1WLX2gwhAPXL8T3De2XCqooKbuCu/eoiTZ6dXtch75WxaMeNENOyOXx8kHOpGMPOIudSMQ4fH8S0bBcs25Z5PMF7ZVpVL3BgQxvTsvn6+kVq6sK3jc3NRGhraKZgl9t9HGNEXvCSmvfKKJrL2nQfHVpTCEBNXZjuo0OB8JTAu5jiXmtjPL3vLl/jbnlKoNPN6spaVFbt8jXulqcEOmKSZS0yi5O+xt3ylEBHTLSsxbf913yNu+UpgU4DKE/Sc3AvczORNcfmZiL0HNwbCE8JvItxWDvJ1SjYFm0NzZzpG2RpIYbIIksLMc70Dbpsy+54SqCzzlQAY8B9Xsk8YAJ4gBHJe3HyXpkRyaN407OfN7zlVQjobjTv4BgQ1/ItjzjV9Oo46okZEBuhS8u3PDoZEDf7t9vg903zBLBfP8C/4cAnD87teclIGyFlLoVyllWh8vmQYRgVAOI4OQmFciKSFZFsMpmck1UC/Il5VNViEgHu9StkQYyb7bNNH1wrmDm3PgqWUHLBhl+SyeRV/6czLepJDAbw8fos4HTNb+/9PFv9u3YMU/X6f38/L98B7/gJ8U2uasiPEADTcRqDOozoBn7WcbzqmFOvpnYM+uTPpvP5SDBiimvP8xRPKV3DFpV7fX7HyYyD44M96xicmpqaSgd3TDQsv6J4zYvLx5nqsz/kK29qcyq5kFpafD+RSMSKf4P+CvCY+hJFRzmzmB2KPTvb+JnX8CsdzDGM8/F4/PrqseC/AggvZlGXtyipXc8kLcbCy6mdrg/6lBIbR41DYXR8cjIqIoW17IIXc17+nHnEOnS3VfhiHQt5d7HmVMK2Nn6+DHLiOGMmRLdMVI+NymjZ9Sf4abaMqZbQp01G/rnS60P5rT8duNXw1TpuGaXksmMYlxKJxLiIt23NponhKVV5a874rdZwmlYuTTvmjWdmGj9Mifl3kkpJ2hGJGY4THb9yJS4i2p0t+Gm2ggHJxMNb94eNzIAJZgEKbyxsP5kS00ZJSkG0oFQ0mZyYkKDuqIhs6u/7hyt75luM2RMPVfft3rW7bU9T0z2bxbV50+w/wF8f81R5OpwBhwAAAABJRU5ErkJggg=="; } + // style pour la 2D et 3D + if (feature.geometry.type === "LineString") { + feature.properties["stroke"] = "#00B798"; + feature.properties["stroke-opacity"] = 0.9; + feature.properties["stroke-width"] = 12; + } }); oldMap.layersOptions[layer.id].data = JSON.stringify(geojsonObj); break; @@ -76,9 +88,18 @@ var switch2D3D = function (viewMode) { geojsonStr = this.getLibMapControl("isocurve").getGeoJSON(); geojsonObj = JSON.parse(geojsonStr); geojsonObj.features.forEach(feature => { + if (!feature.properties) { + feature.properties = {}; + } if (feature.geometry.type === "Point") { + // style propre à la 3D feature.properties.icon = "data:image/png;base64,iVBORw0KGgoAAAANSUh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TcRqDOozoBn7WcbzqmFOvpnYM+uTPpvP5SDBiimvP8xRPKV3DFpV7fX7HyYyD44M96xicmpqaSgd3TDQsv6J4zYvLx5nqsz/kK29qcyq5kFpafD+RSMSKf4P+CvCY+hJFRzmzmB2KPTvb+JnX8CsdzDGM8/F4/PrqseC/AggvZlGXtyipXc8kLcbCy6mdrg/6lBIbR41DYXR8cjIqIoW17IIXc17+nHnEOnS3VfhiHQt5d7HmVMK2Nn6+DHLiOGMmRLdMVI+NymjZ9Sf4abaMqZbQp01G/rnS60P5rT8duNXw1TpuGaXksmMYlxKJxLiIt23NponhKVV5a874rdZwmlYuTTvmjWdmGj9Mifl3kkpJ2hGJGY4THb9yJS4i2p0t+Gm2ggHJxMNb94eNzIAJZgEKbyxsP5kS00ZJSkG0oFQ0mZyYkKDuqIhs6u/7hyt75luM2RMPVfft3rW7bU9T0z2bxbV50+w/wF8f81R5OpwBhwAAAABJRU5ErkJggg=="; } + // style pour la 2D et 3D + if (feature.geometry.type === "Polygon") { + feature.properties["fill"] = "#00B798"; + feature.properties["fill-opacity"] = 0.7; + } }); oldMap.layersOptions[layer.id].data = JSON.stringify(geojsonObj); break; diff --git a/src/OpenLayers/OlMapLayers.js b/src/OpenLayers/OlMapLayers.js index 130516231..71b872dd3 100644 --- a/src/OpenLayers/OlMapLayers.js +++ b/src/OpenLayers/OlMapLayers.js @@ -735,64 +735,109 @@ OlMap.prototype._getLayerOpts = function (layerObj, layersStack) { * @returns {Object} - new layer index in this._layers */ OlMap.prototype._registerUnknownLayer = function (layerObj) { - // couches de résultats ou de calcul (itineraire, isochrone, ...) + // couches de résultats (imports) ou de calcul (itineraire, isochrone, ...) var layerId = "unknownLayer"; if (layerObj.hasOwnProperty("gpResultLayerId")) { - // isochrones : [GraphName]$GEOPORTAIL:GPP:Isocurve - // itineraire : [GraphName]$GEOPORTAIL:GPP:Itineraire layerId = layerObj.gpResultLayerId; } - // on rajoute un timestamp - layerId += "-" + Date.now(); // on rajoute des infos quand on en a var options = {}; - if (layerId.indexOf("drawing-") === 0) { - options.format = "drawing"; - } else if (layerId.indexOf("layerimport:KML") === 0) { - options.format = "KML"; - } else if (layerId.indexOf("layerimport:GPX") === 0) { - options.format = "GPX"; - } else if (layerId.indexOf("layerimport:GeoJSON") === 0) { - options.format = "GeoJSON"; - } else if (layerId.indexOf("layerimport:WMS") === 0) { - options.format = "WMS"; - if (layerObj.gpGFIparams) { - if (layerObj.gpGFIparams.queryable) { - options.queryable = true; - } - if (Array.isArray(layerObj.gpGFIparams.formats)) { - // par défaut on prend le premier - options.gfiFormat = layerObj.gpGFIparams.formats[0]; - // si on trouve "text/html" dans les formats disponibles, on prend "text/html" par défaut - for (var i = 0; i < layerObj.gpGFIparams.formats.length; i++) { - if (layerObj.gpGFIparams.formats[i] === "text/html") { - options.gfiFormat = "text/html"; - break; + + switch (layerId.toLowerCase()) { + case "drawing": + options.format = "drawing"; + break; + case "layerimport:kml": + options.format = "KML"; + break; + case "layerimport:gpx": + options.format = "GPX"; + break; + case "layerimport:geojson": + options.format = "GeoJSON"; + break; + case "layerimport:wms": + options.format = "WMS"; + if (layerObj.gpGFIparams) { + if (layerObj.gpGFIparams.queryable) { + options.queryable = true; + } + if (Array.isArray(layerObj.gpGFIparams.formats)) { + // par défaut on prend le premier + options.gfiFormat = layerObj.gpGFIparams.formats[0]; + // si on trouve "text/html" dans les formats disponibles, on prend "text/html" par défaut + for (var i = 0; i < layerObj.gpGFIparams.formats.length; i++) { + if (layerObj.gpGFIparams.formats[i] === "text/html") { + options.gfiFormat = "text/html"; + break; + } } } } - } - } else if (layerId.indexOf("layerimport:WMTS") === 0) { - options.format = "WMTS"; - } else if (layerId.indexOf("layerimport:MAPBOX") === 0) { - options.format = "MAPBOX"; + break; + case "layerimport:wmts": + options.format = "WMTS"; + break; + case "layerimport:mapbox": + options.format = "MAPBOX"; + break; + case "layerimport:compute": + // TODO + // Evolution : à mettre en place au niveau des extensions + // Le widget d'import recherche si le fichier KML, GeoJSON ou GPX + // est un fichier de calcul avec la lecture de la balise 'geoportail:compute'. + // Si oui, on modifie la property 'gpResultLayerId' -> layerimport:COMPUTE + // Et, on ajoute les options du calcul dans les properties de la couche. + options.format = "COMPUTE"; + var prop = layerObj.getProperties(); + options.graph = prop.graph || ""; + options.control = prop.control || ""; + options.title = prop.title || ""; + options.controlOptions = prop.controlOptions || {}; + options.data = prop.data || {}; + break; + default: + // FIXME + // cas où l'ID est de la forme : + // ex. isochrones : + // Voiture$OGC:OPENLS;Isocurve + // Voiture$GEOPORTAIL:GPP:Isocurve + // Pieton$OGC:OPENLS;Isocurve + // Pieton$GEOPORTAIL:GPP:Isocurve + // ex. itineraire : + // Voiture$OGC:OPENLS;Itineraire + // Voiture$GEOPORTAIL:GPP:Itineraire + // Pieton$OGC:OPENLS;Itineraire + // Pieton$GEOPORTAIL:GPP:Itineraire + var key = layerId.toLowerCase(); + if (key.includes("ogc:openls;isocurve") || + key.includes("ogc:openls;itineraire") || + key.includes("geoportail:gpp:isocurve") || + key.includes("geoportail:gpp:itineraire")) { + // result layer name + options.format = "COMPUTE"; + // graph name (voiture / pieton) + options.graph = layerId.split(/[$:;]/)[0]; + // control name (isocurve / itineraire) + options.control = layerId.split(/[$:;]/).slice(-1)[0]; + // title by default + options.title = options.control + " (" + options.graph + ")"; + // options control + options.controlOptions = {}; + // features to geojson + options.data = {}; + } + break; } - if (layerObj.hasOwnProperty("gpResultLayerId")) { - // result layer name - options.format = "COMPUTE"; - // graph name (voiture / pieton) - options.graph = layerObj.gpResultLayerId.split(/[$:;]/)[0]; - // control name (isocurve / itineraire) - options.control = layerObj.gpResultLayerId.split(/[$:;]/).slice(-1)[0]; - // title by default - options.title = options.control + " (" + options.graph + ")"; - // options control - options.controlOptions = {}; - // features to geojson - options.data = {}; + // Et, si la couche est toujours non reconnue !? + if (layerId === "unknownLayer") { + return; // pas super... } + // on rajoute un timestamp + layerId += "-" + Date.now(); + this._layers.push({ id : layerId, obj : layerObj,