Skip to content

Commit

Permalink
Remove calculation of extent of more than one
Browse files Browse the repository at this point in the history
layer, as there will be only one layer with
several features
  • Loading branch information
Angi-Kinas committed Jul 31, 2024
1 parent 0c5bd5d commit 0226510
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,18 @@ export class FormFieldMapContainerComponent implements OnChanges {
}[]

error = ''
viewExtent: Extent
mapContext$: Observable<MapContextModel> = this.mapFacade.layers$.pipe(
switchMap((layers) =>
from(this.mapUtils.getLayerExtent(layers[layers.length - 1])).pipe(
from(this.mapUtils.getLayerExtent(layers[0])).pipe(
catchError(() => {
this.error = 'The layer has no extent'
return of(undefined)
}),
map((extent) => {
this.viewExtent = this.mapUtils.getGeoJSONLayersExtent([
this.viewExtent,
extent,
])

return {
layers: [DEFAULT_BASELAYER_CONTEXT, ...layers],
view: {
extent: this.viewExtent,
extent: extent,
},
} as MapContextModel
})
Expand Down
7 changes: 0 additions & 7 deletions libs/feature/map/src/lib/utils/map-utils.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,6 @@ export class MapUtilsService {
return transformExtent(latLonExtent, 'EPSG:4326', 'EPSG:3857')
}

getGeoJSONLayersExtent(extents: Extent[]) {
return extents.reduce(
(prev, curr) => (prev ? extend(prev, curr) : curr),
null as Extent
)
}

async getWmsLayerExtent(
layer: MapContextLayerWmsModel
): Promise<Extent | null> {
Expand Down

0 comments on commit 0226510

Please sign in to comment.