Skip to content

Commit

Permalink
Add aliases to query results if any
Browse files Browse the repository at this point in the history
  • Loading branch information
asaunier committed Dec 7, 2017
1 parent 28c22d6 commit 00eed0b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/services/mapquerent.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ ngeo.MapQuerent = class {
let label = dataSource.name;
goog.asserts.assert(dataSource);


const querentResultItem = response[id];
const features = querentResultItem.features;
const limit = querentResultItem.limit;
Expand All @@ -180,6 +179,21 @@ ngeo.MapQuerent = class {
if (!typeSeparatedFeatures[type]) {
typeSeparatedFeatures[type] = [];
}
// Use properties aliases if any
if (dataSource.attributes && dataSource.attributes.length) {
const properties = feature.getProperties();
const filteredProperties = {};
dataSource.attributes.forEach((attribute) => {
if (attribute.alias) {
filteredProperties[attribute.alias] = properties[attribute.name];
feature.unset(attribute.name, /* silent */ true);
} else {
// No alias is available => use the attribute as is.
filteredProperties[attribute.name] = properties[attribute.name];
}
});
feature.setProperties(filteredProperties, /* silent */ true);
}
typeSeparatedFeatures[type].push(feature);
});

Expand Down

0 comments on commit 00eed0b

Please sign in to comment.