From 87c60d5e293232ee3424fb90f2ce11987ac15468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Wed, 25 Oct 2023 16:06:25 +0200 Subject: [PATCH] Support application/geo+json --- src/datasource/ExternalDataSourcesManager.js | 5 ++++- src/datasource/Manager.js | 12 ++++++++++++ src/datasource/OGC.js | 8 ++++++-- src/options.js | 5 +++++ srcapi/store/config.ts | 7 +++++++ 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/datasource/ExternalDataSourcesManager.js b/src/datasource/ExternalDataSourcesManager.js index e1a325c11c21..11d3db8d63b8 100644 --- a/src/datasource/ExternalDataSourcesManager.js +++ b/src/datasource/ExternalDataSourcesManager.js @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2017-2022 Camptocamp SA +// Copyright (c) 2017-2023 Camptocamp SA // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -374,6 +374,9 @@ export class ExternalDatSourcesManager { if (wmsInfoFormat === undefined) { wmsInfoFormat = infoFormats.includes(WMSInfoFormat.GEOJSON) ? WMSInfoFormat.GEOJSON : undefined; } + if (wmsInfoFormat === undefined) { + wmsInfoFormat = infoFormats.includes(WMSInfoFormat.GEO_JSON) ? WMSInfoFormat.GEO_JSON : undefined; + } // queryable const queryable = layer.queryable === true && wmsInfoFormat !== undefined; diff --git a/src/datasource/Manager.js b/src/datasource/Manager.js index 9d459948600f..15de923a5b3f 100644 --- a/src/datasource/Manager.js +++ b/src/datasource/Manager.js @@ -79,6 +79,7 @@ export class DatasourceManager { * @param {angular.IQService} $q Angular q service * @param {angular.IScope} $rootScope Angular rootScope. * @param {angular.ITimeoutService} $timeout Angular timeout service. + * @param {angular.IInjectorService} $injector Main injector. * @param {import('gmf/theme/Themes').ThemesService} gmfThemes The gmf Themes service. * @param {import('gmf/layertree/TreeManager').LayertreeTreeManager} gmfTreeManager The gmf TreeManager * service. @@ -99,6 +100,7 @@ export class DatasourceManager { $q, $rootScope, $timeout, + $injector, gmfThemes, gmfTreeManager, ngeoBackgroundLayerMgr, @@ -233,6 +235,13 @@ export class DatasourceManager { */ this.treeCtrlsUnregister_ = null; + /** + * @type {{import('gmf/options').gmfDatasourceOptions} + */ + this.gmfDatasourceOptions = $injector.has('gmfDatasourceOptions') + ? $injector.get('gmfDatasourceOptions') + : {}; + // === Events === listen(this.ngeoBackgroundLayerMgr_, 'change', this.handleNgeoBackgroundLayerChange_, this); listen(this.gmfThemes_, 'change', this.handleThemesChange_, this); @@ -738,6 +747,9 @@ export class DatasourceManager { if (wmtsUrl) { options.wmtsUrl = wmtsUrl; } + if (ogcServerType === ServerType.ARCGIS && this.gmfDatasourceOptions.arcgisWMSInfoFormat) { + options.wmsInfoFormat = this.gmfDatasourceOptions.arcgisWMSInfoFormat; + } // Create the data source and add it to the cache this.dataSourcesCache_[id] = new GmfDatasourceOGC(options); } diff --git a/src/datasource/OGC.js b/src/datasource/OGC.js index c4858beeb2e6..842b1674946e 100644 --- a/src/datasource/OGC.js +++ b/src/datasource/OGC.js @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2017-2022 Camptocamp SA +// Copyright (c) 2017-2023 Camptocamp SA // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -89,6 +89,7 @@ export const WFSOutputFormat = { */ export const WMSInfoFormat = { GEOJSON: 'application/geojson', + GEO_JSON: 'application/geo+json', GML: 'application/vnd.ogc.gml', }; @@ -587,7 +588,10 @@ export class GmfDatasourceOGC extends ngeoDatasourceDataSource { wmsFormat = new olFormatWMSGetFeatureInfo({ layers: wmsLayerNames, }); - } else if (this.wmsInfoFormat === WMSInfoFormat.GEOJSON) { + } else if ( + this.wmsInfoFormat === WMSInfoFormat.GEOJSON || + this.wmsInfoFormat === WMSInfoFormat.GEO_JSON + ) { wmsFormat = new ngeoFormatArcGISGeoJSON({ layers: wmsLayerNames, }); diff --git a/src/options.js b/src/options.js index 3c62f984c67e..c08861be9399 100644 --- a/src/options.js +++ b/src/options.js @@ -908,4 +908,9 @@ export function buildStyle(styleDescriptor) { * @typedef {string} gmfCustomStylesheetUrl */ +/** + * @typedef {Object} gmfDatasourceOptions + * @property {string} arcgisWMSInfoFormat The WMS info format to be use with Argis OGC server. + */ + export default null; diff --git a/srcapi/store/config.ts b/srcapi/store/config.ts index 7715da41a08f..fd87349370a2 100644 --- a/srcapi/store/config.ts +++ b/srcapi/store/config.ts @@ -1382,6 +1382,12 @@ export type gmfCustomCSS = { */ export type pytreeLidarprofileJsonUrl = string; +export type gmfDatasourceOptions = { + /** + * The WMS info format to be use with Argis OGC server. + */ + arcgisWMSInfoFormat: string; +}; /** * The full configuration */ @@ -1452,6 +1458,7 @@ export type Configuration = { gmfCustomCSS: gmfCustomCSS; gmfI18nextConfiguration: InitOptions; pytreeLidarprofileJsonUrl: pytreeLidarprofileJsonUrl; + gmfDatasourceOptions: gmfDatasourceOptions; }; export type APIConfig = {