Skip to content

Commit

Permalink
Merge pull request #946 from geoadmin/bug_PB-681_identify_on_external…
Browse files Browse the repository at this point in the history
…_group_of_layers

PB-681 : add support for group of external layers getFeatureInfo
  • Loading branch information
pakb authored Jun 21, 2024
2 parents 7566663 + e67702b commit 92cd225
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/api/features/features.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { WMSGetFeatureInfo } from 'ol/format'
import GeoJSON from 'ol/format/GeoJSON'

import LayerFeature from '@/api/features/LayerFeature.class'
import ExternalGroupOfLayers from '@/api/layers/ExternalGroupOfLayers.class'
import ExternalLayer from '@/api/layers/ExternalLayer.class'
import ExternalWMSLayer from '@/api/layers/ExternalWMSLayer.class'
import GeoAdminLayer from '@/api/layers/GeoAdminLayer.class'
Expand Down Expand Up @@ -261,6 +262,27 @@ async function identifyOnExternalLayer(config) {
tolerance,
outputProjection: projection,
})
} else if (layer instanceof ExternalGroupOfLayers) {
// firing one request per sub-layer
const allRequests = [
layer.layers.map((subLayer) =>
identifyOnExternalLayer({
...config,
layer: subLayer,
})
),
]
const allResponses = await Promise.allSettled(allRequests)
// logging any error
allResponses
.filter((response) => response.status !== 'fulfilled')
.forEach((failedResponse) => {
log.error('Error while identify an external sub-layer', failedResponse)
})
return allResponses
.filter((response) => response.status === 'fulfilled' && response.value)
.map((response) => response.value)
.flat()
} else {
throw new GetFeatureInfoError(
`Unsupported external layer type to build getFeatureInfo request: ${layer.type}`
Expand Down

0 comments on commit 92cd225

Please sign in to comment.