Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DRAFT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ __DATE__

- ContextMenu : correction de l'affichage de numéro de parcelle cadastrale lorsqu'on clique sur "Adresse & Coordonnées du lieu" (#587)
- ContextMenu : correction de l’affichage de l’entête du panel (#589)

- SearchEngine : correction de la recherche de POI des communes de 3 caractères (#593)

* 🔒 [Security]

---
6 changes: 3 additions & 3 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.14-589",
"date": "16/09/2026",
"version": "1.0.0-beta.14-593",
"date": "22/09/2026",
"module": "src/index.js",
"main": "src/index.js",
"types": "src/index.d.ts",
Expand Down Expand Up @@ -57,7 +57,7 @@
"doctoc": "^2.4.0",
"dompurify": "^3.4.5",
"eventbusjs": "0.2.0",
"geoportal-access-lib": "3.4.6",
"geoportal-access-lib": "3.4.7",
"lit": "^3.2.1",
"loglevel": "^1.9.1",
"marked": "^16.2.1",
Expand Down
8 changes: 5 additions & 3 deletions src/packages/Controls/SearchEngine/SearchEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,7 @@ class SearchEngine extends Control {
Gp.Services.geocode({
apiKey : this.options.apiKey,
ssl : this.options.ssl,
q : GeocodeUtils.getSuggestedLocationFreeform(suggestedLocation),
q : GeocodeUtils.getSuggestedLocationQuery(suggestedLocation),
index : suggestedLocation.type,
// callback onSuccess
onSuccess : function (response) {
Expand Down Expand Up @@ -2038,7 +2038,9 @@ class SearchEngine extends Control {
};

// on ajoute le texte de l'autocomplétion dans l'input
var label = GeocodeUtils.getSuggestedLocationFreeform(this._locationsToBeDisplayed[idx]);
var location = this._locationsToBeDisplayed[idx];
var label = GeocodeUtils.getSuggestedLocationFreeform(location);
var query = GeocodeUtils.getSuggestedLocationQuery(location);
this._setLabel(label);

// on sauvegarde le localisant
Expand All @@ -2056,7 +2058,7 @@ class SearchEngine extends Control {
index : "address,poi",
limit : 1,
returnTrueGeometry : true,
location : label,
location : query,
onSuccess : (results) => {
if (results.locations[0].placeAttributes.truegeometry) {
var geom = JSON.parse(results.locations[0].placeAttributes.truegeometry);
Expand Down
9 changes: 6 additions & 3 deletions src/packages/Services/IGNSearchService.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class IGNSearchService extends AbstractSearchService {
* @returns {String} Titre à afficher
*/
getItemTitle (obj) {
return obj.fullText;
return obj && obj.fullText ? obj.fullText : "";
}

/**
Expand Down Expand Up @@ -361,7 +361,7 @@ class IGNSearchService extends AbstractSearchService {
Gp.Services.geocode({
apiKey : this.options.apiKey,
ssl : this.options.ssl,
q : GeocodeUtils.getSuggestedLocationFreeform(suggestedLocation),
q : GeocodeUtils.getSuggestedLocationQuery(suggestedLocation),
index : suggestedLocation.type,
// callback onSuccess
onSuccess : function (response) {
Expand Down Expand Up @@ -411,17 +411,20 @@ class IGNSearchService extends AbstractSearchService {
}
// on ajoute le texte de l'autocomplétion dans l'input
let label;
let query = null;
let index = this.get("index");
let truegeometry = this.get("returnTrueGeometry");
if (typeof location === "string") {
// Location est un texte, on prend les valeurs par défaut
label = location;
query = location;
} else {
// location est un objet : on vérifie les informations qu'il comporte

// Récupère les infos (s'il y'en a)
index = location.type ? location.type : index;
label = GeocodeUtils.getSuggestedLocationFreeform(location);
query = GeocodeUtils.getSuggestedLocationQuery(location);
// TODO : AMÉLIORER CETTE PARTIE (REDONDANTE)
// Enlève l'ajout du prettify
if ((location.type === "PositionOfInterest" && location.poiType[0] === "administratif" &&
Expand Down Expand Up @@ -467,7 +470,7 @@ class IGNSearchService extends AbstractSearchService {
index : index,
limit : this.get("limit"),
returnTrueGeometry : truegeometry,
location : label,
location : query,
filters : filters,
onSuccess : this._onSuccessSearch.bind(this),
onFailure : this._onFailureSearch.bind(this, location),
Expand Down
36 changes: 26 additions & 10 deletions src/packages/Utils/GeocodeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,34 @@ var GeocodeUtils = {
getSuggestedLocationFreeform : function (suggestedLocation) {
if (suggestedLocation.fullText) {
return suggestedLocation.fullText;
} else {
var values = [];
values.push(suggestedLocation.street || "");
values.push(suggestedLocation.postalCode || "");
values.push(suggestedLocation.commune || "");
}
if (suggestedLocation.type === "PositionOfInterest" && Array.isArray(suggestedLocation.names) && suggestedLocation.names.length > 0 && suggestedLocation.names[0]) {
return suggestedLocation.names[0];
}
var values = [];
values.push(suggestedLocation.street || "");
values.push(suggestedLocation.postalCode || "");
values.push(suggestedLocation.commune || "");

if (suggestedLocation.type === "PositionOfInterest") {
values.push(suggestedLocation.poi || "");
values.push(suggestedLocation.kind || "");
}
return values.join(" - ");
if (suggestedLocation.type === "PositionOfInterest") {
values.push(suggestedLocation.poi || "");
values.push(suggestedLocation.kind || "");
}
return values.join(" - ");
},

/**
* Return the geocoding query term of a structured suggested item.
* Prefer the POI display name when available, while keeping the fullText label for UI display.
*
* @param {Object} suggestedLocation - Suggested location
* @returns {String} query string for geocoding
*/
getSuggestedLocationQuery : function (suggestedLocation) {
if (suggestedLocation.type === "PositionOfInterest" && Array.isArray(suggestedLocation.names) && suggestedLocation.names.length > 0 && suggestedLocation.names[0]) {
return suggestedLocation.names[0];
}
return GeocodeUtils.getSuggestedLocationFreeform(suggestedLocation);
}
};

Expand Down
Loading