@defra/interactive-map 0.0.52-alpha → 0.0.53-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/im-core.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/context.md +18 -12
- package/docs/api/marker-config.md +16 -8
- package/docs/api/symbol-config.md +24 -9
- package/docs/api/symbol-registry.md +49 -14
- package/docs/plugins/datasets.md +4 -10
- package/docs/plugins/draw.md +2 -1
- package/docs/plugins/map-key.md +6 -4
- package/package.json +1 -1
- package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/index.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-ol-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/esm/mapboxStyleLayerAdapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ol-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/datasets/src/adapters/maplibre/layerBuilders.js +9 -9
- package/plugins/datasets/src/adapters/maplibre/layerBuilders.test.js +19 -3
- package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +9 -3
- package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.test.js +18 -3
- package/plugins/datasets/src/adapters/maplibre/registry/mapLibreDataset.js +3 -3
- package/plugins/datasets/src/adapters/maplibre/registry/mapLibreDataset.test.js +19 -26
- package/plugins/datasets/src/adapters/openlayers/canvasPatternStyle.js +15 -67
- package/plugins/datasets/src/adapters/openlayers/canvasPatternStyle.test.js +32 -105
- package/plugins/datasets/src/adapters/openlayers/layerBuilders.js +11 -13
- package/plugins/datasets/src/adapters/openlayers/layerBuilders.test.js +11 -3
- package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.js +48 -19
- package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.test.js +99 -11
- package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.js +26 -26
- package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.test.js +48 -29
- package/plugins/datasets/src/initialise/defaults.js +4 -3
- package/plugins/datasets/src/reducers/__data__/demoDatasets.js +1 -3
- package/plugins/datasets/src/registry/dataset.js +2 -1
- package/plugins/datasets/src/registry/dataset.test.js +13 -0
- package/plugins/datasets/src/registry/mapboxStyleDataset.js +1 -1
- package/plugins/datasets/src/registry/mapboxStyleDataset.test.js +1 -1
- package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/esm/index.js +1 -1
- package/plugins/draw/dist/esm/liveDrawChecks.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/umd/index.js +1 -1
- package/plugins/draw/src/DrawInit.jsx +7 -5
- package/plugins/draw/src/DrawInit.test.jsx +18 -2
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +11 -5
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +27 -11
- package/plugins/draw/src/adapters/maplibre/mapboxDraw.js +12 -9
- package/plugins/draw/src/adapters/maplibre/mapboxDraw.test.js +18 -0
- package/plugins/draw/src/adapters/maplibre/pointSymbolImages.js +81 -56
- package/plugins/draw/src/adapters/maplibre/pointSymbolImages.test.js +149 -80
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +7 -6
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +22 -25
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +26 -8
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +58 -16
- package/plugins/draw/src/adapters/openlayers/core/styles.js +33 -20
- package/plugins/draw/src/adapters/openlayers/core/styles.test.js +47 -21
- package/plugins/draw/src/adapters/openlayers/olDraw.js +16 -12
- package/plugins/draw/src/adapters/openlayers/olDraw.test.js +27 -32
- package/plugins/draw/src/adapters/openlayers/point/pointSymbolImages.js +44 -49
- package/plugins/draw/src/adapters/openlayers/point/pointSymbolImages.test.js +100 -119
- package/plugins/draw/src/defaults.js +2 -6
- package/plugins/draw/src/utils/stripInternalProperties.test.js +2 -1
- package/plugins/draw/src/utils/symbolKeys.js +3 -4
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/index.js +1 -1
- package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -2
- package/plugins/map-key/dist/umd/index.js +1 -1
- package/plugins/map-key/src/components/Key/Key.jsx +8 -4
- package/plugins/map-key/src/components/Key/KeyGroupItem.jsx +3 -1
- package/plugins/map-key/src/components/Key/KeyItem.jsx +2 -2
- package/plugins/map-key/src/components/Key/KeySvg.jsx +15 -14
- package/plugins/map-key/src/components/Key/KeySvg.test.jsx +21 -14
- package/plugins/map-key/src/components/Key/KeySvgPattern.jsx +1 -2
- package/plugins/map-key/src/components/Key/KeySvgPattern.test.jsx +3 -1
- package/plugins/map-key/src/components/Key/KeySvgSymbol.jsx +26 -12
- package/plugins/map-key/src/components/Key/KeySvgSymbol.test.jsx +24 -74
- package/plugins/map-key/src/components/Key/MapKey.jsx +3 -1
- package/plugins/map-key/src/components/Key/svgProperties.js +8 -2
- package/plugins/map-key/src/reducers/mergeKeyGroupItems.test.js +15 -0
- package/plugins/map-key/src/registry/index.js +0 -2
- package/plugins/map-key/src/registry/index.test.js +1 -9
- package/plugins/menu/src/registry/index.js +0 -2
- package/plugins/menu/src/registry/index.test.js +1 -9
- package/providers/beta/esri/dist/esm/im-esri-provider.js +1 -1
- package/providers/beta/openlayers/dist/esm/im-openlayers-provider.js +1 -1
- package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +1 -1
- package/providers/beta/openlayers/dist/umd/index.js +1 -1
- package/providers/beta/openlayers/src/openlayersProvider.js +102 -2
- package/providers/beta/openlayers/src/openlayersProvider.test.js +95 -0
- package/providers/beta/openlayers/src/utils/highlightFeatures.js +20 -25
- package/providers/beta/openlayers/src/utils/highlightFeatures.test.js +73 -38
- package/providers/beta/openlayers/src/utils/patternImages.js +61 -0
- package/providers/beta/openlayers/src/utils/patternImages.test.js +74 -0
- package/providers/beta/openlayers/src/utils/symbolImages.js +103 -95
- package/providers/beta/openlayers/src/utils/symbolImages.test.js +136 -85
- package/providers/mapProvider.js +53 -1
- package/providers/mapProvider.test.js +6 -0
- package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/index.js +1 -1
- package/providers/maplibre/src/maplibreProvider.js +50 -17
- package/providers/maplibre/src/maplibreProvider.test.js +74 -20
- package/providers/maplibre/src/utils/highlightFeatures.js +19 -14
- package/providers/maplibre/src/utils/highlightFeatures.test.js +20 -14
- package/providers/maplibre/src/utils/patternImages.js +46 -29
- package/providers/maplibre/src/utils/patternImages.test.js +52 -4
- package/providers/maplibre/src/utils/symbolImages.js +80 -39
- package/providers/maplibre/src/utils/symbolImages.test.js +157 -54
- package/src/App/components/Markers/Markers.jsx +16 -25
- package/src/App/components/Markers/Markers.test.jsx +34 -48
- package/src/App/components/Markers/SymbolLabelMarker.jsx +1 -1
- package/src/App/components/Markers/SymbolMarker.jsx +1 -1
- package/src/App/store/ServiceProvider.jsx +6 -3
- package/src/App/store/ServiceProvider.test.jsx +24 -0
- package/src/config/appConfig.js +1 -5
- package/src/config/mapSizeScales.js +8 -0
- package/src/config/symbolConfig.js +101 -25
- package/src/services/patternRegistry.js +97 -76
- package/src/services/patternRegistry.test.js +19 -1
- package/src/services/symbolComposer.js +184 -0
- package/src/services/symbolComposer.test.js +132 -0
- package/src/services/symbolRegistry.js +326 -155
- package/src/services/symbolRegistry.test.js +334 -32
- package/src/types.js +9 -3
- package/src/utils/hashString.js +23 -0
- package/src/utils/hashString.test.js +29 -0
- package/src/utils/imageDataCache.js +43 -0
- package/src/utils/imageDataCache.test.js +38 -0
- package/src/utils/pathBounds.js +330 -0
- package/src/utils/pathBounds.test.js +145 -0
- package/src/utils/patternUtils.js +0 -8
- package/src/utils/patternUtils.test.js +0 -25
- package/src/utils/recentImageSets.js +35 -0
- package/src/utils/recentImageSets.test.js +46 -0
- package/src/utils/symbolUtils.js +26 -29
- package/src/utils/symbolUtils.test.js +27 -41
- package/plugins/map-key/dist/umd/im-map-key-plugin.js.LICENSE.txt +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createOLDraw } from './olDraw.js'
|
|
2
2
|
import { OLDrawManager } from './core/OLDrawManager.js'
|
|
3
3
|
import { refreshAllPointSymbols } from './point/pointSymbolImages.js'
|
|
4
|
-
import {
|
|
4
|
+
import { logger } from '../../../../../src/services/logger.js'
|
|
5
5
|
|
|
6
6
|
jest.mock('./core/OLDrawManager.js', () => ({
|
|
7
7
|
OLDrawManager: jest.fn(function () {
|
|
@@ -10,8 +10,10 @@ jest.mock('./core/OLDrawManager.js', () => ({
|
|
|
10
10
|
})
|
|
11
11
|
}))
|
|
12
12
|
jest.mock('./point/pointSymbolImages.js', () => ({ refreshAllPointSymbols: jest.fn(() => Promise.resolve()) }))
|
|
13
|
+
jest.mock('../../../../../src/services/logger.js', () => ({ logger: { error: jest.fn() } }))
|
|
13
14
|
|
|
14
|
-
const
|
|
15
|
+
const symbolRegistry = { id: 'app-symbol-registry' }
|
|
16
|
+
const events = { MAP_SET_PIXEL_RATIO: 'app:pixelratio', MAP_SET_STYLE: 'app:style', MAP_DATA_CHANGE: 'app:datachange' }
|
|
15
17
|
|
|
16
18
|
const setup = (mapStyle = null) => {
|
|
17
19
|
const listeners = {}
|
|
@@ -21,7 +23,7 @@ const setup = (mapStyle = null) => {
|
|
|
21
23
|
emit: jest.fn((type, payload) => listeners[type]?.(payload))
|
|
22
24
|
}
|
|
23
25
|
const mapProvider = { map: { id: 'ol-map' } }
|
|
24
|
-
const olDraw = createOLDraw({ mapProvider, events, eventBus, pluginConfig: { snapRadius: 5 }, mapStyle })
|
|
26
|
+
const olDraw = createOLDraw({ mapProvider, symbolRegistry, events, eventBus, pluginConfig: { snapRadius: 5 }, mapStyle })
|
|
25
27
|
const manager = OLDrawManager.mock.instances.at(-1)
|
|
26
28
|
return { eventBus, mapProvider, olDraw, manager }
|
|
27
29
|
}
|
|
@@ -30,38 +32,21 @@ afterEach(() => jest.clearAllMocks())
|
|
|
30
32
|
|
|
31
33
|
test('creates the manager for the map, exposes it as mapProvider.draw and applies an initial style', () => {
|
|
32
34
|
const { mapProvider, manager } = setup({ id: 'dark' })
|
|
33
|
-
|
|
35
|
+
// the provider and the app's registry, for resolving drawn points' symbols
|
|
36
|
+
expect(OLDrawManager).toHaveBeenCalledWith(mapProvider.map, { snapRadius: 5 }, { mapProvider, symbolRegistry })
|
|
34
37
|
expect(mapProvider.draw).toBe(manager)
|
|
35
38
|
expect(manager.setMapStyle).toHaveBeenCalledWith({ id: 'dark' })
|
|
36
39
|
|
|
37
40
|
expect(setup().manager.setMapStyle).not.toHaveBeenCalled() // no initial style
|
|
38
41
|
})
|
|
39
42
|
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
test('seeds drawScale from the provider\'s own starting map size, before any size-change event', () => {
|
|
45
|
-
const eventBus = { on: jest.fn(), off: jest.fn() }
|
|
46
|
-
const mapProvider = { map: { id: 'ol-map' }, mapSize: 'large' }
|
|
47
|
-
createOLDraw({ mapProvider, events, eventBus })
|
|
48
|
-
expect(mapProvider.drawScale).toBe(MAP_SIZE_SCALES.large)
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
test('defaults the seeded drawScale to 1 when the provider has no starting map size', () => {
|
|
52
|
-
const eventBus = { on: jest.fn(), off: jest.fn() }
|
|
53
|
-
const mapProvider = { map: { id: 'ol-map' } }
|
|
54
|
-
createOLDraw({ mapProvider, events, eventBus })
|
|
55
|
-
expect(mapProvider.drawScale).toBe(1)
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
test('map size changes update the draw UI scale, defaulting to 1 for unknown sizes, and re-resolve point symbols', async () => {
|
|
43
|
+
// Point symbols are rasterised at the map's own pixelRatio (see point/pointSymbolImages.js's
|
|
44
|
+
// getPixelRatio), which the map is created with — so a map that loads straight at medium/large
|
|
45
|
+
// is already right. A runtime map-size change sets a new ratio, which re-resolves them.
|
|
46
|
+
test('pixel ratio changes re-resolve point symbols at the new ratio carried by the event', () => {
|
|
59
47
|
const { eventBus, mapProvider, manager } = setup()
|
|
60
|
-
eventBus.emit(events.
|
|
61
|
-
expect(
|
|
62
|
-
expect(refreshAllPointSymbols).toHaveBeenCalledWith({ manager, mapProvider })
|
|
63
|
-
eventBus.emit(events.MAP_SET_SIZE, 'enormous')
|
|
64
|
-
expect(mapProvider.drawScale).toBe(1)
|
|
48
|
+
eventBus.emit(events.MAP_SET_PIXEL_RATIO, 3)
|
|
49
|
+
expect(refreshAllPointSymbols).toHaveBeenCalledWith({ manager, mapProvider, pixelRatioOverride: 3 })
|
|
65
50
|
})
|
|
66
51
|
|
|
67
52
|
// A selected point's highlight overlay only re-applies on MAP_DATA_CHANGE, and (unlike
|
|
@@ -71,18 +56,28 @@ test('map size changes update the draw UI scale, defaulting to 1 for unknown siz
|
|
|
71
56
|
// already-selected point's ring stuck on its old (now wrong-resolution) icon.
|
|
72
57
|
test('emits MAP_DATA_CHANGE once point symbols have actually finished re-resolving after a size change', async () => {
|
|
73
58
|
const { eventBus, manager, mapProvider } = setup()
|
|
74
|
-
eventBus.emit(events.
|
|
59
|
+
eventBus.emit(events.MAP_SET_PIXEL_RATIO, 4)
|
|
75
60
|
await Promise.resolve() // flush the refreshAllPointSymbols().then(...) microtask
|
|
76
|
-
expect(refreshAllPointSymbols).toHaveBeenCalledWith({ manager, mapProvider })
|
|
61
|
+
expect(refreshAllPointSymbols).toHaveBeenCalledWith({ manager, mapProvider, pixelRatioOverride: 4 })
|
|
77
62
|
expect(eventBus.emit).toHaveBeenCalledWith(events.MAP_DATA_CHANGE)
|
|
78
63
|
})
|
|
79
64
|
|
|
65
|
+
test('logs, rather than leaving unhandled, a failure to refresh point symbols', async () => {
|
|
66
|
+
const { eventBus } = setup()
|
|
67
|
+
const failure = new Error('rasterise failed')
|
|
68
|
+
refreshAllPointSymbols.mockReturnValueOnce(Promise.reject(failure))
|
|
69
|
+
eventBus.emit(events.MAP_SET_PIXEL_RATIO, 2)
|
|
70
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
71
|
+
expect(logger.error).toHaveBeenCalledWith('[draw] failed to refresh point symbols', failure)
|
|
72
|
+
expect(eventBus.emit).not.toHaveBeenCalledWith(events.MAP_DATA_CHANGE)
|
|
73
|
+
})
|
|
74
|
+
|
|
80
75
|
test('pluginConfig and mapStyle are optional, defaulting to {} and no initial style', () => {
|
|
81
76
|
const eventBus = { on: jest.fn(), off: jest.fn() }
|
|
82
77
|
const mapProvider = { map: { id: 'ol-map' } }
|
|
83
78
|
const olDraw = createOLDraw({ mapProvider, events, eventBus }) // no pluginConfig, no mapStyle
|
|
84
79
|
const manager = OLDrawManager.mock.instances.at(-1)
|
|
85
|
-
expect(OLDrawManager).toHaveBeenCalledWith(mapProvider.map, {})
|
|
80
|
+
expect(OLDrawManager).toHaveBeenCalledWith(mapProvider.map, {}, { mapProvider, symbolRegistry: undefined })
|
|
86
81
|
expect(manager.setMapStyle).not.toHaveBeenCalled()
|
|
87
82
|
expect(mapProvider.draw).toBe(manager)
|
|
88
83
|
olDraw.remove()
|
|
@@ -105,7 +100,7 @@ test('emits MAP_DATA_CHANGE once point symbols have actually finished re-resolvi
|
|
|
105
100
|
test('remove unsubscribes, destroys the manager and clears mapProvider.draw', () => {
|
|
106
101
|
const { eventBus, mapProvider, olDraw, manager } = setup()
|
|
107
102
|
olDraw.remove()
|
|
108
|
-
expect(eventBus.off).toHaveBeenCalledWith(events.
|
|
103
|
+
expect(eventBus.off).toHaveBeenCalledWith(events.MAP_SET_PIXEL_RATIO, expect.any(Function))
|
|
109
104
|
expect(eventBus.off).toHaveBeenCalledWith(events.MAP_SET_STYLE, expect.any(Function))
|
|
110
105
|
expect(manager.remove).toHaveBeenCalled()
|
|
111
106
|
expect(mapProvider.draw).toBeNull()
|
|
@@ -1,69 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getOrCreateSymbolImage } from '../../../../../../providers/beta/openlayers/src/utils/symbolImages.js'
|
|
1
|
+
import { hasSymbol } from '../../../../../../src/utils/symbolUtils.js'
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
|
-
* Resolves a drawn point's symbol-config icon
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Resolves a drawn point's symbol-config icon: registers its images with the OL provider (as
|
|
5
|
+
* the MapLibre adapter does with its own provider), then writes the resolved image ids — normal,
|
|
6
|
+
* active and selected — plus the anchor and pixel ratio they were drawn at back onto the OL
|
|
7
|
+
* feature. core/styles.js renders the icon from these, and the provider's highlightFeatures.js
|
|
8
|
+
* the selection ring.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export const hasSymbolStyle = (properties) => !!(properties?.symbol || properties?.symbolSvgContent)
|
|
15
|
-
|
|
16
|
-
// Combines the browser's native devicePixelRatio with this app's own map-size scale factor
|
|
17
|
-
// (mapProvider.drawScale), matching MapController.jsx's construction-time formula.
|
|
18
|
-
export const getPixelRatio = (mapProvider) => (globalThis.devicePixelRatio || 1) * (mapProvider?.drawScale ?? 1)
|
|
11
|
+
// The map's own pixelRatio (device pixel ratio × map-size scale factor) — the same source the
|
|
12
|
+
// datasets plugin rasterises its OL symbols at, so both draw them 1:1.
|
|
13
|
+
export const getPixelRatio = (mapProvider) => mapProvider?.map?.getPixelRatio?.() || 1
|
|
19
14
|
|
|
20
15
|
/**
|
|
21
16
|
* Resolve one point feature's symbol image and write it back onto the feature.
|
|
22
17
|
* A no-op for points with no symbol config (nothing to render as an icon).
|
|
23
18
|
*
|
|
24
19
|
* @param {Object} params
|
|
25
|
-
* @param {Object} params.manager - OLDrawManager (needs store.source, mapStyle)
|
|
26
|
-
* @param {Object} params.mapProvider
|
|
20
|
+
* @param {Object} params.manager - OLDrawManager (needs store.source, mapStyle, symbolRegistry)
|
|
21
|
+
* @param {Object} params.mapProvider - OpenLayersProvider (needs addSymbolsToMap and the
|
|
22
|
+
* active/selected image id lookups)
|
|
27
23
|
* @param {import('ol/Feature.js').default} params.olFeature
|
|
28
|
-
* @
|
|
24
|
+
* @param {number} [params.pixelRatioOverride] - use this instead of the map's pixelRatio, for
|
|
25
|
+
* callers (MAP_SET_PIXEL_RATIO) that already have the freshly set value
|
|
26
|
+
* @param {number} [params.refreshId] - set by refreshAllPointSymbols; the result is dropped if a
|
|
27
|
+
* newer refresh has started since
|
|
28
|
+
* @returns {Promise<void>} rejects if the symbol's images couldn't be registered
|
|
29
29
|
*/
|
|
30
|
-
export const resolvePointSymbol = async ({ manager, mapProvider, olFeature }) => {
|
|
30
|
+
export const resolvePointSymbol = async ({ manager, mapProvider, olFeature, pixelRatioOverride, refreshId }) => {
|
|
31
31
|
const properties = olFeature.getProperties()
|
|
32
|
-
if (!
|
|
32
|
+
if (!hasSymbol(properties)) {
|
|
33
33
|
return
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
const
|
|
36
|
+
const { symbolRegistry, mapStyle } = manager
|
|
37
|
+
const pixelRatio = pixelRatioOverride ?? getPixelRatio(mapProvider)
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
VARIANTS.forEach((variant, i) => {
|
|
53
|
-
const result = results[i]
|
|
54
|
-
if (!result) { return }
|
|
55
|
-
getOrCreateSymbolImage(result.imageId, result.imageData)
|
|
56
|
-
olFeature.set(PROPERTY_FOR_VARIANT[variant], result.imageId)
|
|
57
|
-
})
|
|
39
|
+
await mapProvider.addSymbolsToMap([properties], mapStyle, symbolRegistry, pixelRatio)
|
|
40
|
+
const symbolImageId = symbolRegistry.getSymbolImageId(properties, mapStyle, 'normal', pixelRatio)
|
|
41
|
+
// Unresolvable (e.g. an unknown symbol id), deleted/cancelled while registering, or
|
|
42
|
+
// superseded by a newer refresh (another size or style change)
|
|
43
|
+
if (!symbolImageId || !manager.store.source.hasFeature(olFeature) || (refreshId !== undefined && refreshId !== manager.pointSymbolRefreshId)) {
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
// One write, so the feature changes (and re-renders) once
|
|
47
|
+
olFeature.setProperties({
|
|
48
|
+
symbolImageId,
|
|
49
|
+
symbolActiveImageId: mapProvider.getActiveSymbolImageId(symbolImageId),
|
|
50
|
+
symbolSelectedImageId: mapProvider.getSelectedSymbolImageId(symbolImageId),
|
|
51
|
+
symbolImageAnchor: symbolRegistry.getSymbolDef(properties).anchor,
|
|
58
52
|
// ol/style/Icon draws its source canvas at native pixel size — core/styles.js reads this
|
|
59
53
|
// back to apply `scale: 1 / symbolPixelRatio`, correcting for the canvas being rasterised
|
|
60
54
|
// at pixelRatio device pixels for crispness.
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
// A silent failure here means a point simply never gets/keeps an icon, with nothing in
|
|
64
|
-
// the UI to explain why — surface it instead of letting the rejection vanish.
|
|
65
|
-
console.error('[draw] failed to resolve point symbol', olFeature.getId(), err) // NOSONAR
|
|
66
|
-
}
|
|
55
|
+
symbolPixelRatio: pixelRatio
|
|
56
|
+
})
|
|
67
57
|
}
|
|
68
58
|
|
|
69
59
|
/**
|
|
@@ -73,11 +63,16 @@ export const resolvePointSymbol = async ({ manager, mapProvider, olFeature }) =>
|
|
|
73
63
|
* @param {Object} params
|
|
74
64
|
* @param {Object} params.manager
|
|
75
65
|
* @param {Object} params.mapProvider
|
|
66
|
+
* @param {number} [params.pixelRatioOverride] - see resolvePointSymbol
|
|
76
67
|
* @returns {Promise<void>}
|
|
77
68
|
*/
|
|
78
|
-
export const refreshAllPointSymbols = ({ manager, mapProvider }) => {
|
|
69
|
+
export const refreshAllPointSymbols = ({ manager, mapProvider, pixelRatioOverride }) => {
|
|
70
|
+
// Refreshes overlap when the map size or style changes again before one finishes; only the
|
|
71
|
+
// latest may write back, so an older one finishing last can't restore its stale images
|
|
72
|
+
manager.pointSymbolRefreshId = (manager.pointSymbolRefreshId ?? 0) + 1
|
|
73
|
+
const refreshId = manager.pointSymbolRefreshId
|
|
79
74
|
const points = manager.store.source.getFeatures().filter(
|
|
80
|
-
(
|
|
75
|
+
(feature) => feature.getGeometry()?.getType() === 'Point' && hasSymbol(feature.getProperties())
|
|
81
76
|
)
|
|
82
|
-
return Promise.all(points.map((olFeature) => resolvePointSymbol({ manager, mapProvider, olFeature })))
|
|
77
|
+
return Promise.all(points.map((olFeature) => resolvePointSymbol({ manager, mapProvider, olFeature, pixelRatioOverride, refreshId })))
|
|
83
78
|
}
|
|
@@ -1,23 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { getPixelRatio, resolvePointSymbol, refreshAllPointSymbols } from './pointSymbolImages.js'
|
|
2
|
+
import { createSymbolRegistry } from '../../../../../../src/services/symbolRegistry.js'
|
|
3
|
+
import { SymbolImageCache } from '../../../../../../providers/beta/openlayers/src/utils/symbolImages.js'
|
|
4
|
+
|
|
5
|
+
const symbolRegistry = createSymbolRegistry()
|
|
4
6
|
|
|
5
7
|
const mapStyle = { id: 'outdoor', mapColorScheme: 'light' }
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
// The OL provider's symbol image methods, backed by a real cache
|
|
10
|
+
const createMapProvider = ({ pixelRatio = 1 } = {}) => {
|
|
11
|
+
const symbolImages = new SymbolImageCache()
|
|
12
|
+
return {
|
|
13
|
+
map: { getPixelRatio: () => pixelRatio },
|
|
14
|
+
symbolImages,
|
|
15
|
+
addSymbolsToMap: jest.fn((configs, ms, registry, ratio) => symbolImages.registerSymbols(configs, ms, registry, ratio)),
|
|
16
|
+
getActiveSymbolImageId: (imageId) => symbolImages.getActiveImageId(imageId),
|
|
17
|
+
getSelectedSymbolImageId: (imageId) => symbolImages.getSelectedImageId(imageId)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
8
20
|
|
|
9
|
-
// A minimal ol.Feature stand-in — resolvePointSymbol only ever calls
|
|
10
|
-
//
|
|
21
|
+
// A minimal ol.Feature stand-in — resolvePointSymbol only ever calls getProperties()/
|
|
22
|
+
// setProperties() on it, and manager.store.source.hasFeature() to check liveness.
|
|
11
23
|
const createOlFeature = (properties) => {
|
|
12
24
|
const props = { ...properties }
|
|
13
25
|
return {
|
|
14
26
|
getProperties: () => props,
|
|
15
|
-
|
|
27
|
+
setProperties: jest.fn((values) => { Object.assign(props, values) })
|
|
16
28
|
}
|
|
17
29
|
}
|
|
18
30
|
|
|
19
31
|
const createManager = ({ features = [] } = {}) => ({
|
|
20
32
|
mapStyle,
|
|
33
|
+
symbolRegistry,
|
|
21
34
|
store: {
|
|
22
35
|
source: {
|
|
23
36
|
hasFeature: jest.fn((f) => features.includes(f)),
|
|
@@ -27,162 +40,101 @@ const createManager = ({ features = [] } = {}) => ({
|
|
|
27
40
|
})
|
|
28
41
|
|
|
29
42
|
// symbolRegistry.rasteriseSymbolImage() draws an SVG through a real `new Image()`/onload
|
|
30
|
-
// round-trip that jsdom never resolves
|
|
31
|
-
//
|
|
32
|
-
// (addSymbolsToMap) stand in for it. This adapter calls rasteriseSymbolImage directly (it
|
|
33
|
-
// *is* the last-mile pipeline, with no provider-level call to mock instead), so it's stubbed
|
|
34
|
-
// here with a fake resolved ImageData keyed to the properties/pixelRatio, matching
|
|
35
|
-
// getSymbolImageId's own id shape closely enough for assertions to key off it.
|
|
43
|
+
// round-trip that jsdom never resolves, so it's stubbed with a fake ImageData under the ids the
|
|
44
|
+
// real one would give.
|
|
36
45
|
const stubRasterise = () => jest.spyOn(symbolRegistry, 'rasteriseSymbolImage')
|
|
37
|
-
.mockImplementation(async (style, ms, variant, pixelRatio) =>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
imageData: { width: 10, height: 10 }
|
|
42
|
-
}))
|
|
46
|
+
.mockImplementation(async (style, ms, variant, pixelRatio) => {
|
|
47
|
+
const imageId = symbolRegistry.getSymbolImageId(style, ms, variant, pixelRatio)
|
|
48
|
+
return imageId ? { imageId, imageData: { width: 10, height: 10 } } : null
|
|
49
|
+
})
|
|
43
50
|
|
|
44
51
|
beforeEach(() => {
|
|
45
|
-
clearSymbolImageCache()
|
|
46
52
|
HTMLCanvasElement.prototype.getContext = jest.fn(function () {
|
|
47
53
|
this._ctx ??= { putImageData: jest.fn() }
|
|
48
54
|
return this._ctx
|
|
49
55
|
})
|
|
56
|
+
HTMLCanvasElement.prototype.toDataURL = jest.fn(() => 'data:image/png;base64,mock')
|
|
50
57
|
stubRasterise()
|
|
51
58
|
})
|
|
52
59
|
|
|
53
60
|
afterEach(() => jest.restoreAllMocks())
|
|
54
61
|
|
|
55
|
-
describe('hasSymbolStyle', () => {
|
|
56
|
-
it('is true when symbol is set', () => {
|
|
57
|
-
expect(hasSymbolStyle({ symbol: 'pin' })).toBe(true)
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it('is true when symbolSvgContent is set', () => {
|
|
61
|
-
expect(hasSymbolStyle({ symbolSvgContent: '<path/>' })).toBe(true)
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
it('is false with neither, or no properties at all', () => {
|
|
65
|
-
expect(hasSymbolStyle({})).toBe(false)
|
|
66
|
-
expect(hasSymbolStyle(undefined)).toBe(false)
|
|
67
|
-
})
|
|
68
|
-
})
|
|
69
|
-
|
|
70
62
|
describe('getPixelRatio', () => {
|
|
71
|
-
it('
|
|
72
|
-
|
|
73
|
-
globalThis.devicePixelRatio = 2
|
|
74
|
-
expect(getPixelRatio(createMapProvider({ drawScale: 1.5 }))).toBe(3)
|
|
75
|
-
globalThis.devicePixelRatio = restore
|
|
63
|
+
it('reads the map\'s own pixelRatio (device pixel ratio × map-size scale)', () => {
|
|
64
|
+
expect(getPixelRatio(createMapProvider({ pixelRatio: 3 }))).toBe(3)
|
|
76
65
|
})
|
|
77
66
|
|
|
78
|
-
it('falls back to 1
|
|
79
|
-
const restore = globalThis.devicePixelRatio
|
|
80
|
-
delete globalThis.devicePixelRatio
|
|
81
|
-
expect(getPixelRatio(createMapProvider({ drawScale: undefined }))).toBe(1)
|
|
67
|
+
it('falls back to 1 when there is no map or no ratio', () => {
|
|
82
68
|
expect(getPixelRatio(undefined)).toBe(1)
|
|
83
|
-
|
|
69
|
+
expect(getPixelRatio({ map: {} })).toBe(1)
|
|
70
|
+
expect(getPixelRatio(createMapProvider({ pixelRatio: 0 }))).toBe(1)
|
|
84
71
|
})
|
|
85
72
|
})
|
|
86
73
|
|
|
87
74
|
describe('resolvePointSymbol', () => {
|
|
88
75
|
it('does nothing for a feature with no symbol config', async () => {
|
|
89
76
|
const olFeature = createOlFeature({})
|
|
90
|
-
const
|
|
91
|
-
await resolvePointSymbol({ manager
|
|
92
|
-
expect(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
it('rasterises, caches the canvas and writes symbolImageId/symbolPixelRatio back onto the feature', async () => {
|
|
96
|
-
const properties = { symbol: 'pin' }
|
|
97
|
-
const olFeature = createOlFeature(properties)
|
|
98
|
-
const manager = createManager({ features: [olFeature] })
|
|
99
|
-
const mapProvider = createMapProvider({ drawScale: 2 })
|
|
100
|
-
|
|
101
|
-
await resolvePointSymbol({ manager, mapProvider, olFeature })
|
|
102
|
-
|
|
103
|
-
const pixelRatio = getPixelRatio(mapProvider)
|
|
104
|
-
const baseId = symbolRegistry.getSymbolImageId(properties, mapStyle, false, pixelRatio)
|
|
105
|
-
expect(olFeature.set).toHaveBeenCalledWith('symbolImageId', `normal-${baseId}`)
|
|
106
|
-
// symbolPixelRatio is what core/styles.js later uses to scale the (pixelRatio×-oversized)
|
|
107
|
-
// cached canvas back down to its intended CSS display size.
|
|
108
|
-
expect(olFeature.set).toHaveBeenCalledWith('symbolPixelRatio', pixelRatio)
|
|
109
|
-
expect(getCachedSymbolImage(`normal-${baseId}`)).toBeInstanceOf(HTMLCanvasElement)
|
|
77
|
+
const mapProvider = createMapProvider()
|
|
78
|
+
await resolvePointSymbol({ manager: createManager(), mapProvider, olFeature })
|
|
79
|
+
expect(mapProvider.addSymbolsToMap).not.toHaveBeenCalled()
|
|
80
|
+
expect(olFeature.setProperties).not.toHaveBeenCalled()
|
|
110
81
|
})
|
|
111
82
|
|
|
112
|
-
it('
|
|
83
|
+
it('registers the images with the provider at the map\'s pixel ratio, then writes every resolved property in one go', async () => {
|
|
113
84
|
const properties = { symbol: 'pin' }
|
|
114
85
|
const olFeature = createOlFeature(properties)
|
|
115
86
|
const manager = createManager({ features: [olFeature] })
|
|
116
|
-
const mapProvider = createMapProvider()
|
|
87
|
+
const mapProvider = createMapProvider({ pixelRatio: 2 })
|
|
117
88
|
|
|
118
89
|
await resolvePointSymbol({ manager, mapProvider, olFeature })
|
|
119
90
|
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
expect(olFeature.
|
|
123
|
-
expect(olFeature.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
expect(
|
|
132
|
-
expect(symbolRegistry.rasteriseSymbolImage).toHaveBeenCalledWith(symbolMatch, mapStyle, 'selected', pixelRatio)
|
|
91
|
+
expect(mapProvider.addSymbolsToMap).toHaveBeenCalledWith([expect.objectContaining({ symbol: 'pin' })], mapStyle, symbolRegistry, 2)
|
|
92
|
+
const imageId = symbolRegistry.getSymbolImageId(properties, mapStyle, 'normal', 2)
|
|
93
|
+
expect(olFeature.setProperties).toHaveBeenCalledTimes(1)
|
|
94
|
+
expect(olFeature.setProperties).toHaveBeenCalledWith({
|
|
95
|
+
symbolImageId: imageId,
|
|
96
|
+
symbolActiveImageId: symbolRegistry.getSymbolImageId(properties, mapStyle, 'active', 2),
|
|
97
|
+
symbolSelectedImageId: symbolRegistry.getSymbolImageId(properties, mapStyle, 'selected', 2),
|
|
98
|
+
symbolImageAnchor: symbolRegistry.getSymbolDef(properties).anchor,
|
|
99
|
+
// core/styles.js scales the (pixelRatio×-oversized) canvas back down by this
|
|
100
|
+
symbolPixelRatio: 2
|
|
101
|
+
})
|
|
102
|
+
expect(mapProvider.symbolImages.getImage(imageId)).toBeInstanceOf(HTMLCanvasElement)
|
|
133
103
|
})
|
|
134
104
|
|
|
135
|
-
it('
|
|
136
|
-
const properties = { symbol: '
|
|
105
|
+
it('resolves a symbolAnchor override to the shape, as the anchor every style uses', async () => {
|
|
106
|
+
const properties = { symbol: 'circle', symbolAnchor: [0.5, 1] }
|
|
137
107
|
const olFeature = createOlFeature(properties)
|
|
138
|
-
const manager = createManager({ features: [olFeature] })
|
|
139
|
-
symbolRegistry.rasteriseSymbolImage
|
|
140
|
-
.mockImplementationOnce(async (style, ms, variant, pixelRatio) => // normal — real stub behaviour
|
|
141
|
-
({ imageId: `${variant}-${symbolRegistry.getSymbolImageId(style, ms, false, pixelRatio)}`, imageData: { width: 10, height: 10 } }))
|
|
142
|
-
.mockResolvedValueOnce(null) // active
|
|
143
|
-
.mockResolvedValueOnce(null) // selected
|
|
144
108
|
|
|
145
|
-
await resolvePointSymbol({ manager, mapProvider: createMapProvider(), olFeature })
|
|
109
|
+
await resolvePointSymbol({ manager: createManager({ features: [olFeature] }), mapProvider: createMapProvider(), olFeature })
|
|
146
110
|
|
|
147
|
-
expect(olFeature.
|
|
148
|
-
expect(olFeature.set).not.toHaveBeenCalledWith('symbolActiveImageId', expect.anything())
|
|
149
|
-
expect(olFeature.set).not.toHaveBeenCalledWith('symbolSelectedImageId', expect.anything())
|
|
111
|
+
expect(olFeature.getProperties().symbolImageAnchor).toEqual(symbolRegistry.getSymbolDef(properties).anchor)
|
|
150
112
|
})
|
|
151
113
|
|
|
152
|
-
it('does nothing
|
|
153
|
-
const
|
|
154
|
-
const olFeature = createOlFeature(properties)
|
|
155
|
-
const manager = createManager({ features: [olFeature] })
|
|
156
|
-
symbolRegistry.rasteriseSymbolImage.mockResolvedValueOnce(null)
|
|
114
|
+
it('does nothing for an unresolvable symbol id', async () => {
|
|
115
|
+
const olFeature = createOlFeature({ symbol: 'not-a-real-symbol' })
|
|
157
116
|
|
|
158
|
-
await resolvePointSymbol({ manager, mapProvider: createMapProvider(), olFeature })
|
|
117
|
+
await resolvePointSymbol({ manager: createManager({ features: [olFeature] }), mapProvider: createMapProvider(), olFeature })
|
|
159
118
|
|
|
160
|
-
expect(olFeature.
|
|
119
|
+
expect(olFeature.setProperties).not.toHaveBeenCalled()
|
|
161
120
|
})
|
|
162
121
|
|
|
163
|
-
it('does not write back if the feature was removed from the source while
|
|
164
|
-
const
|
|
165
|
-
const olFeature = createOlFeature(properties)
|
|
166
|
-
const manager = createManager({ features: [] }) // not present in the source
|
|
122
|
+
it('does not write back if the feature was removed from the source while registering', async () => {
|
|
123
|
+
const olFeature = createOlFeature({ symbol: 'pin' })
|
|
167
124
|
|
|
168
|
-
await resolvePointSymbol({ manager, mapProvider: createMapProvider(), olFeature })
|
|
125
|
+
await resolvePointSymbol({ manager: createManager({ features: [] }), mapProvider: createMapProvider(), olFeature })
|
|
169
126
|
|
|
170
|
-
expect(olFeature.
|
|
127
|
+
expect(olFeature.setProperties).not.toHaveBeenCalled()
|
|
171
128
|
})
|
|
172
129
|
|
|
173
|
-
it('
|
|
174
|
-
const
|
|
175
|
-
const
|
|
176
|
-
olFeature.getId = () => 'p1'
|
|
177
|
-
const manager = createManager({ features: [olFeature] })
|
|
130
|
+
it('rejects, without writing to the feature, when registration fails', async () => {
|
|
131
|
+
const olFeature = createOlFeature({ symbol: 'pin' })
|
|
132
|
+
const mapProvider = createMapProvider()
|
|
178
133
|
const error = new Error('rasterise failed')
|
|
179
|
-
|
|
180
|
-
const consoleError = jest.spyOn(console, 'error').mockImplementation(() => {})
|
|
181
|
-
|
|
182
|
-
await resolvePointSymbol({ manager, mapProvider: createMapProvider(), olFeature })
|
|
134
|
+
mapProvider.addSymbolsToMap.mockRejectedValueOnce(error)
|
|
183
135
|
|
|
184
|
-
expect(olFeature
|
|
185
|
-
expect(
|
|
136
|
+
await expect(resolvePointSymbol({ manager: createManager({ features: [olFeature] }), mapProvider, olFeature })).rejects.toBe(error)
|
|
137
|
+
expect(olFeature.setProperties).not.toHaveBeenCalled()
|
|
186
138
|
})
|
|
187
139
|
})
|
|
188
140
|
|
|
@@ -202,9 +154,38 @@ describe('refreshAllPointSymbols', () => {
|
|
|
202
154
|
|
|
203
155
|
await refreshAllPointSymbols({ manager, mapProvider: createMapProvider() })
|
|
204
156
|
|
|
205
|
-
expect(pointWithSymbol.
|
|
206
|
-
expect(pointWithoutSymbol.
|
|
207
|
-
expect(polygon.
|
|
157
|
+
expect(pointWithSymbol.setProperties).toHaveBeenCalledWith(expect.objectContaining({ symbolImageId: expect.any(String) }))
|
|
158
|
+
expect(pointWithoutSymbol.setProperties).not.toHaveBeenCalled()
|
|
159
|
+
expect(polygon.setProperties).not.toHaveBeenCalled()
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
it('registers at pixelRatioOverride rather than the map\'s current ratio when given', async () => {
|
|
163
|
+
const point = feature('Point', { symbol: 'pin' })
|
|
164
|
+
const manager = createManager({ features: [point] })
|
|
165
|
+
const mapProvider = createMapProvider({ pixelRatio: 2 })
|
|
166
|
+
|
|
167
|
+
await refreshAllPointSymbols({ manager, mapProvider, pixelRatioOverride: 4 })
|
|
168
|
+
|
|
169
|
+
expect(mapProvider.addSymbolsToMap).toHaveBeenCalledWith(expect.any(Array), mapStyle, symbolRegistry, 4)
|
|
170
|
+
expect(point.setProperties).toHaveBeenCalledWith(expect.objectContaining({ symbolPixelRatio: 4 }))
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
it('drops an older refresh\'s results when a newer one has started since', async () => {
|
|
174
|
+
const point = feature('Point', { symbol: 'pin' })
|
|
175
|
+
const manager = createManager({ features: [point] })
|
|
176
|
+
const mapProvider = createMapProvider()
|
|
177
|
+
// the first refresh's registration is held until after the second has finished
|
|
178
|
+
let releaseFirst
|
|
179
|
+
const held = new Promise((resolve) => { releaseFirst = resolve })
|
|
180
|
+
mapProvider.addSymbolsToMap.mockImplementationOnce(() => held)
|
|
181
|
+
|
|
182
|
+
const first = refreshAllPointSymbols({ manager, mapProvider, pixelRatioOverride: 1 })
|
|
183
|
+
await refreshAllPointSymbols({ manager, mapProvider, pixelRatioOverride: 2 })
|
|
184
|
+
releaseFirst()
|
|
185
|
+
await first
|
|
186
|
+
|
|
187
|
+
expect(point.setProperties).toHaveBeenCalledTimes(1)
|
|
188
|
+
expect(point.setProperties).toHaveBeenCalledWith(expect.objectContaining({ symbolPixelRatio: 2 }))
|
|
208
189
|
})
|
|
209
190
|
|
|
210
191
|
it('does nothing when there are no drawn points', async () => {
|
|
@@ -44,12 +44,8 @@ export const KEYBOARD = {
|
|
|
44
44
|
stepAmount: 5
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
// Scale factor applied to draw UI (touch targets, vertex handles) per app map size
|
|
48
|
-
export
|
|
49
|
-
small: 1,
|
|
50
|
-
medium: 1.5,
|
|
51
|
-
large: 2
|
|
52
|
-
}
|
|
47
|
+
// Scale factor applied to draw UI (touch targets, vertex handles) per app map size — the app's own table
|
|
48
|
+
export { scaleFactor as MAP_SIZE_SCALES } from '../../../src/config/mapSizeScales.js'
|
|
53
49
|
|
|
54
50
|
// The application mode draw enters while drawing or editing (declared in manifest.js)
|
|
55
51
|
export const APPLICATION_MODE_ID = 'draw'
|
|
@@ -7,6 +7,7 @@ describe('stripInternalProperties', () => {
|
|
|
7
7
|
properties: {
|
|
8
8
|
symbol: 'pin',
|
|
9
9
|
symbolBackgroundColor: '#ca3535',
|
|
10
|
+
symbolSize: 'large',
|
|
10
11
|
symbolImageId: 'symbol-abc-2x',
|
|
11
12
|
symbolIconAnchor: 'bottom',
|
|
12
13
|
symbolIconOffset: [0, -10],
|
|
@@ -18,7 +19,7 @@ describe('stripInternalProperties', () => {
|
|
|
18
19
|
|
|
19
20
|
expect(stripInternalProperties(feature)).toEqual({
|
|
20
21
|
id: 'a',
|
|
21
|
-
properties: { symbol: 'pin', symbolBackgroundColor: '#ca3535' }
|
|
22
|
+
properties: { symbol: 'pin', symbolBackgroundColor: '#ca3535', symbolSize: 'large' }
|
|
22
23
|
})
|
|
23
24
|
})
|
|
24
25
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
+
import { SYMBOL_STYLE_KEYS } from '../../../../src/config/symbolConfig.js'
|
|
2
|
+
|
|
1
3
|
// Public symbol-config keys a caller can set on a Point (see docs/api/symbol-config.md).
|
|
2
|
-
export const SYMBOL_KEYS = new Set(
|
|
3
|
-
'symbol', 'symbolSvgContent', 'symbolBackgroundColor', 'symbolForegroundColor',
|
|
4
|
-
'symbolHaloWidth', 'symbolGraphic', 'symbolViewBox', 'symbolAnchor'
|
|
5
|
-
])
|
|
4
|
+
export const SYMBOL_KEYS = new Set(SYMBOL_STYLE_KEYS)
|