Skip to content

Commit eff001a

Browse files
authored
Merge pull request #213 from Dataport/feature/stadtwald-layer-for-clerks
add stadtwald layer for Meldemichel clerks
2 parents 8dee461 + ff1d9fa commit eff001a

File tree

8 files changed

+68
-12
lines changed

8 files changed

+68
-12
lines changed

packages/clients/meldemichel/API.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The method expects a single object with the following parameters.
1616
| - | - | - |
1717
| containerId | string | ID of the container the map is supposed to render itself to. |
1818
| mode | enum["REPORT", "SINGLE", "COMPLETE"] | See chapters below for an overview of the modes. |
19+
| stadtwaldActive | boolean? | This layer only works in 'SINGLE' mode and should not be activated in the others. If not set, any existing previous state is kept; off by default. |
1920
| afmUrl | string? | `COMPLETE` mode only. The URL used here is the URL of the AfM service to open to create a new damage report. |
2021
| reportServiceId | string? | `COMPLETE` mode only. ID of the report layer to display. Both the Filter and the Feature List will work with this layer. The client will also provide tooltips and cluster the features. |
2122
| configOverride | object? | This can be used to override the configuration of any installed plugin; see full documentation. It is also used to set initial pins in `SINGLE` mode. See documentation of `SINGLE` further below. |
@@ -77,6 +78,8 @@ A document rendering the map client could e.g. look like this:
7778
const meldemichelMapInstance = await meldemichelMapClient.createMap({
7879
containerId: 'meldemichel-map-client',
7980
mode: 'REPORT', // or 'SINGLE',
81+
// This layer only works in 'SINGLE' mode and should not be activated in the others
82+
stadtwaldActive: true, // or `false`; if not set, previous state is kept; off by default
8083
// For 'SINGLE' mode where a singular coordinate is inspected/worked on
8184
configOverride: {
8285
pins: {
@@ -104,6 +107,12 @@ A document rendering the map client could e.g. look like this:
104107
// NOTE: vendor_maps_distance_to and -_plz are not read
105108
})
106109
110+
/* To change the stadtwald layer's visibility in 'SINGLE' mode, use this;
111+
* this key can be used standalone or within the call seen above */
112+
meldemichelMapInstance.$store.dispatch('meldemichel/setMapState', {
113+
stadtwaldActive: true, // or false
114+
})
115+
107116
// to retrieve map state updates, use this snippet:
108117
const unwatch = mapInstance.$store.watch(
109118
(_, getters) => getters["meldemichel/mapState"],

packages/clients/meldemichel/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## unpublished
44

5+
- Feature: Add `stadtwaldActive` as startup parameter for `createMap` object and `meldemichel/setMapState` action. Refer to the API.md regarding further details.
56
- Fix: Import type `MpApiParameters` from correct position.
67
- Chore: Change value of `pins.movable` configuration to `'drag'` as using a boolean has been deprecated in a future release.
78
- Chore: Update `@polar`-dependencies to the latest versions.

packages/clients/meldemichel/src/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
stage ? 'stage.' : ''
4444
}afm.hamburg.de/intelliform/forms/mml_melde_michel/standard/mml_melde_michel/index`,
4545
reportServiceId: stage ? '6061' : '6059',
46+
// stadtwaldActive: true, // false
4647
/*
4748
configOverride: {
4849
pins: {

packages/clients/meldemichel/src/language.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ const language: LanguageOption[] = [
5454
attributions: {
5555
stadtplan:
5656
'Kartografie Stadtplan: <a target="_blank" href="https://www.hamburg.de/bsw/landesbetrieb-geoinformation-und-vermessung/">Landesbetrieb Geoinformation und Vermessung</a>',
57+
stadtwald:
58+
'Kartografie Stadtwald: <a target="_blank" href="https://www.hamburg.de/politik-und-verwaltung/behoerden/bukea">Freie und Hansestadt Hamburg, Behörde für Umwelt, Klima, Energie und Agrarwirtschaft (BUKEA)</a>',
5759
luftbilder:
5860
'Kartografie Luftbilder: <a target="_blank" href="https://www.hamburg.de/bsw/landesbetrieb-geoinformation-und-vermessung/">Landesbetrieb Geoinformation und Vermessung</a>',
5961
reports: 'Meldungen durch Bürger',
@@ -73,6 +75,7 @@ const language: LanguageOption[] = [
7375
},
7476
layers: {
7577
stadtplan: 'Stadtplan',
78+
stadtwald: 'Stadtwald',
7679
luftbilder: 'Luftbildansicht',
7780
reports: 'Meldungen',
7881
hamburgBorder: 'Stadtgrenze Hamburg',

packages/clients/meldemichel/src/mapConfigurations.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import language from './language'
1515
import { MeldemichelCreateMapParams } from './types'
1616
import { showTooltip } from './utils/showTooltip'
1717

18+
export const stadtwald = '18746'
1819
const stadtplan = '453'
1920
const luftbilder = '452'
2021
export const hamburgBorder = '1693' // boundary layer for pins / geolocalization
@@ -237,9 +238,24 @@ const mapConfigurations: Record<
237238
[MODE.SINGLE]: () => ({
238239
...commonMapConfiguration,
239240
addressSearch,
240-
layers: commonLayers,
241+
layers: [
242+
...commonLayers,
243+
{
244+
id: stadtwald,
245+
visibility: false,
246+
type: 'mask',
247+
name: 'meldemichel.layers.stadtwald',
248+
} as LayerConfiguration,
249+
],
241250
attributions: {
242251
...commonAttributions,
252+
layerAttributions: [
253+
...(commonAttributions.layerAttributions as Attribution[]),
254+
{
255+
id: stadtwald,
256+
title: 'meldemichel.attributions.stadtwald',
257+
},
258+
],
243259
},
244260
pins: commonPins,
245261
reverseGeocoder,

packages/clients/meldemichel/src/polar-client.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const memory: {
4848
client: null,
4949
}
5050

51-
const rerender = (containerId, configOverride) => {
51+
const rerender = (containerId, configOverride, stadtwaldActive) => {
5252
document
5353
.getElementById(containerId)
5454
?.replaceWith(memory.wrapper as HTMLElement)
@@ -61,6 +61,11 @@ const rerender = (containerId, configOverride) => {
6161
})
6262
client.$store.dispatch('plugin/pins/setupInitial')
6363
}
64+
if (typeof stadtwaldActive === 'boolean' && memory.client) {
65+
memory.client.$store.dispatch('meldemichel/setMapState', {
66+
stadtwaldActive,
67+
})
68+
}
6469
return memory.client
6570
}
6671

@@ -69,29 +74,26 @@ export default {
6974
containerId,
7075
mode,
7176
afmUrl,
77+
stadtwaldActive,
7278
reportServiceId,
7379
configOverride,
7480
}: MeldemichelCreateMapParams) =>
7581
new Promise((resolve) => {
7682
if (memory.wrapper) {
77-
return resolve(rerender(containerId, configOverride))
83+
return resolve(rerender(containerId, configOverride, stadtwaldActive))
7884
}
79-
8085
if (!Object.keys(MODE).includes(mode)) {
8186
console.error(
8287
`@polar/client-meldemichel: Critical error. Unknown mode "${mode}" configured. Please use 'COMPLETE', 'REPORT', or 'SINGLE'.`
8388
)
8489
}
85-
8690
const meldemichelCore = { ...core }
8791
addPlugins(meldemichelCore, mode)
88-
8992
// NOTE initializeLayerList is async in this scenario
9093
meldemichelCore.rawLayerList.initializeLayerList(
9194
serviceRegister,
9295
async (layerConf) => {
9396
enableClustering(layerConf, reportServiceId)
94-
9597
const client = await meldemichelCore.createMap({
9698
containerId,
9799
mapConfiguration: merge(
@@ -102,15 +104,17 @@ export default {
102104
configOverride || {}
103105
),
104106
})
105-
106107
client.$store.registerModule('meldemichel', meldemichelModule)
107108
registerAfmButton(client, mode)
108109
hideHamburgBorder(client.$store.getters.map)
109110
setBackgroundImage(containerId)
110-
111+
if (typeof stadtwaldActive === 'boolean') {
112+
client.$store.dispatch('meldemichel/setMapState', {
113+
stadtwaldActive,
114+
})
115+
}
111116
memory.wrapper = document.getElementById(`${containerId}-wrapper`)
112117
memory.client = client
113-
114118
resolve(client)
115119
}
116120
)

packages/clients/meldemichel/src/store/module.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
/* eslint-disable camelcase */
33

44
import { PolarModule } from '@polar/lib-custom-types'
5+
import { stadtwald } from '../mapConfigurations'
56

67
interface SetMapStatePayload {
78
mapCenter?: string // resembling 'number,number'
89
mapZoomLevel?: number | string
910
mapBaseLayer?: number | string
11+
stadtwaldActive?: boolean
1012
vendor_maps_position?: string // resembling 'number,number'
1113
vendor_maps_address_str?: string
1214
vendor_maps_address_hnr?: number | string
@@ -35,26 +37,32 @@ const meldemichelModule: PolarModule<
3537
namespaced: true,
3638
state: {},
3739
actions: {
38-
// setupModule({ getters }): void {},
40+
// length deemed acceptable due to function simplicity (forwarder)
41+
// eslint-disable-next-line max-lines-per-function
3942
setMapState: (
40-
{ commit, dispatch, rootGetters: { map } },
43+
{ commit, dispatch, rootGetters },
4144
{
4245
mapCenter,
4346
mapZoomLevel,
4447
mapBaseLayer,
48+
stadtwaldActive,
4549
vendor_maps_position,
4650
vendor_maps_address_str,
4751
vendor_maps_address_hnr,
4852
}: SetMapStatePayload
4953
) => {
54+
const { map } = rootGetters
55+
5056
if (mapCenter) {
5157
map.getView().setCenter(readAfmCoordinate(mapCenter))
5258
}
59+
5360
if (mapZoomLevel) {
5461
dispatch('plugin/zoom/setZoomLevel', Number(mapZoomLevel), {
5562
root: true,
5663
})
5764
}
65+
5866
if (mapBaseLayer) {
5967
dispatch(
6068
'plugin/layerChooser/setActiveBackgroundId',
@@ -64,13 +72,26 @@ const meldemichelModule: PolarModule<
6472
}
6573
)
6674
}
75+
76+
if (typeof stadtwaldActive === 'boolean') {
77+
const oldActiveMasks = rootGetters['plugin/layerChooser/activeMaskIds']
78+
const newActiveMasks = stadtwaldActive
79+
? [...new Set([...oldActiveMasks, stadtwald])]
80+
: oldActiveMasks.filter((id) => id !== stadtwald)
81+
82+
dispatch('plugin/layerChooser/setActiveMaskIds', newActiveMasks, {
83+
root: true,
84+
})
85+
}
86+
6787
if (vendor_maps_address_str && vendor_maps_address_hnr) {
6888
commit(
6989
'plugin/addressSearch/setInputValue',
7090
`${vendor_maps_address_str} ${vendor_maps_address_hnr}`,
7191
{ root: true }
7292
)
7393
}
94+
7495
if (vendor_maps_position) {
7596
dispatch(
7697
'plugin/pins/showMarker',

packages/clients/meldemichel/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export interface MeldemichelCreateMapParams {
44
containerId: string
55
mode: keyof typeof MODE
66
afmUrl?: string
7+
stadtwaldActive?: boolean
78
reportServiceId?: string
89
configOverride?: object
910
}

0 commit comments

Comments
 (0)