Skip to content

Commit

Permalink
fix(query): wms query in geojson format now use source fields as alias (
Browse files Browse the repository at this point in the history
#862)

Co-authored-by: Pierre-Étienne Lord <[email protected]>
  • Loading branch information
pelord and Pierre-Étienne Lord authored May 19, 2021
1 parent d3015d0 commit 818cc7f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/geo/src/lib/query/shared/query.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export class QueryService {
case QueryFormat.JSON:
case QueryFormat.GEOJSON:
case QueryFormat.GEOJSON2:
features = this.extractGeoJSONData(res);
features = this.extractGeoJSONData(res, layer.zIndex, allowedFieldsAndAlias);
break;
case QueryFormat.ESRIJSON:
features = this.extractEsriJSONData(res, layer.zIndex, allowedFieldsAndAlias);
Expand Down Expand Up @@ -413,13 +413,18 @@ export class QueryService {
);
}

private extractGeoJSONData(res) {
private extractGeoJSONData(res, zIndex, allowedFieldsAndAlias?) {
let features = [];
try {
features = JSON.parse(res).features;
} catch (e) {
console.warn('query.service: Unable to parse geojson', '\n', res);
}
features.map(feature => feature.meta = {
id: uuid(),
order: 1000 - zIndex,
alias: allowedFieldsAndAlias
});
return features;
}

Expand Down

0 comments on commit 818cc7f

Please sign in to comment.