Skip to content

Commit

Permalink
Merge pull request #296 from IGNF/fix/recette-drawing
Browse files Browse the repository at this point in the history
fix(drawing): Titre par défaut à la couche du croquis
  • Loading branch information
elias75015 authored Dec 12, 2024
2 parents d293cad + 33ccc9b commit 2a21a44
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 20 deletions.
2 changes: 2 additions & 0 deletions DRAFT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ __DATE__
* 🔥 [Removed]

* 🐛 [Fixed]

- Ajout d'un titre par défaut à la couche vectorielle du drawing (#296)

* 🔒 [Security]

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "geopf-extensions-openlayers",
"description": "French Geoportal Extensions for OpenLayers libraries",
"version": "1.0.0-beta.1",
"date": "10/12/2024",
"version": "1.0.0-beta.1-296",
"date": "11/12/2024",
"module": "src/index.js",
"directories": {},
"engines": {
Expand Down
3 changes: 2 additions & 1 deletion src/packages/Controls/Drawing/Drawing.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,8 @@ var Drawing = class Drawing extends Control {
var layer = new VectorLayer({
source : new VectorSource({
features : features
})
}),
title : "Mon Croquis"
});
// on rajoute le champ gpResultLayerId permettant d'identifier une couche crée par le composant.
layer.gpResultLayerId = "drawing";
Expand Down
2 changes: 1 addition & 1 deletion src/packages/Controls/GetFeatureInfo/GetFeatureInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ var GetFeatureInfo = class GetFeatureInfo extends Control {
var src = layerProperties.source;
var layerTitle = "";
if (src) {
layerTitle = src._title || src.name || src.url_;
layerTitle = src._title || src.name || layerProperties.title || layerProperties.name || src.url_ || "Couche de données";
}
}
return layerTitle;
Expand Down
9 changes: 6 additions & 3 deletions src/packages/Controls/Isocurve/Isocurve.js
Original file line number Diff line number Diff line change
Expand Up @@ -1348,21 +1348,24 @@ var Isocurve = class Isocurve extends Control {
);

// 2. ajout de la géométrie comme nouvelle couche vecteur à la carte
var method = (this._currentComputation === "time") ? "Isochrone" : "Isodistance";

this._geojsonLayer = new VectorLayer({
source : new VectorSource({
features : features
}),
style : this._defaultFeatureStyle,
opacity : 0.9
opacity : 0.9,
title : "Mon " + method
});
// ajout d'un identifiant à la couche
var graph;
if (this._currentTransport === "Pieton") {
graph = "piéton";
this._geojsonLayer.gpResultLayerId = "Pieton$GEOPORTAIL:GPP:Isocurve";
this._geojsonLayer.gpResultLayerId = "compute:Pieton$GEOPORTAIL:GPP:Isocurve";
} else {
graph = "voiture";
this._geojsonLayer.gpResultLayerId = "Voiture$GEOPORTAIL:GPP:Isocurve";
this._geojsonLayer.gpResultLayerId = "compute:Voiture$GEOPORTAIL:GPP:Isocurve";
}
// ajout à la carte
map.addLayer(this._geojsonLayer);
Expand Down
20 changes: 11 additions & 9 deletions src/packages/Controls/LayerSwitcher/LayerSwitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -1229,9 +1229,11 @@ var LayerSwitcher = class LayerSwitcher extends Control {
var error = null;

var map = this.getMap();
// cas d'un layer vecteur importé
if (data.layer.hasOwnProperty("gpResultLayerId") && data.layer.gpResultLayerId.split(":")[0] === "layerimport") {
// TODO : appeler fonction commune
// cas d'un layer vecteur importé, d'un croquis, d'une couche de calcul
if (data.layer.hasOwnProperty("gpResultLayerId") &&
(data.layer.gpResultLayerId.split(":")[0] === "layerimport" || data.layer.gpResultLayerId.split(":")[0] === "drawing"
|| data.layer.gpResultLayerId.split(":")[0] === "compute")) {
// TODO : appeler fonc tion commune
// zoom sur l'étendue des entités récupérées (si possible)
if (map.getView() && map.getSize()) {
var sourceExtent = data.layer.getExtent() || data.layer.getSource().getExtent();
Expand All @@ -1240,7 +1242,7 @@ var LayerSwitcher = class LayerSwitcher extends Control {
}
}
} else {
try {
try {
// Check if configuration is loaded
if (!Config.isConfigLoaded()) {
throw "ERROR : contract key configuration has to be loaded to load Geoportal layers.";
Expand Down Expand Up @@ -1399,11 +1401,11 @@ var LayerSwitcher = class LayerSwitcher extends Control {
var layerProperties = layer.getProperties();
var src = layerProperties.source;
if (src) {
layerInfo._title = src._title || layerProperties.id || "";
layerInfo._description = src._description || "";
layerInfo._quicklookUrl = src._quicklookUrl || "";
layerInfo._metadata = src._metadata || [];
layerInfo._legends = src._legends || [];
layerInfo._title = src._title || layerProperties.title || layerProperties.id || "";
layerInfo._description = src._description || layerProperties.description || "";
layerInfo._quicklookUrl = src._quicklookUrl || layerProperties.quicklookUrl || "";
layerInfo._metadata = src._metadata || layerProperties.metadata || [];
layerInfo._legends = src._legends || layerProperties.legends || [];
}
}
return layerInfo;
Expand Down
10 changes: 6 additions & 4 deletions src/packages/Controls/Route/Route.js
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,8 @@ var Route = class Route extends Control {
source : new VectorSource({
features : features
}),
style : style
style : style,
title : "Mon Itinéraire"
});
map.addLayer(this._geojsonRoute);
}
Expand Down Expand Up @@ -1776,16 +1777,17 @@ var Route = class Route extends Control {
features : features
}),
style : style,
opacity : 0.9
opacity : 0.9,
title : "Mon Itinéraire"
});

var graph;
if (this._currentTransport === "Pieton") {
graph = "piéton";
this._geojsonSections.gpResultLayerId = "Pieton$OGC:OPENLS;Itineraire";
this._geojsonSections.gpResultLayerId = "compute:Pieton$OGC:OPENLS;Itineraire";
} else {
graph = "voiture";
this._geojsonSections.gpResultLayerId = "Voiture$OGC:OPENLS;Itineraire";
this._geojsonSections.gpResultLayerId = "compute:Voiture$OGC:OPENLS;Itineraire";
}
// ajout à la carte
map.addLayer(this._geojsonSections);
Expand Down

0 comments on commit 2a21a44

Please sign in to comment.