@defra/interactive-map 0.0.55-alpha → 0.0.56-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/assets/templates/style-switcher.njk +2 -2
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/context.md +2 -0
- package/docs/api.md +17 -1
- package/docs/architecture/interactive-map.likec4 +4 -4
- package/docs/plugins/datasets.md +11 -0
- package/docs/plugins/draw.md +8 -2
- package/docs/plugins/interact.md +24 -1
- package/docs/plugins/search.md +2 -2
- package/docusaurus.config.cjs +25 -3
- package/govuk-prototype-kit.config.json +6 -7
- package/package.json +20 -23
- package/plugins/datasets/dist/esm/im-datasets-esri-adapter.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/index.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/dist/umd/index.js +1 -1
- package/plugins/datasets/src/adapters/esri/esriLayerAdapter.js +18 -16
- package/plugins/datasets/src/adapters/esri/esriLayerAdapter.test.js +2 -2
- package/plugins/datasets/src/adapters/esri/registry/esriDataset.js +2 -3
- package/plugins/datasets/src/adapters/esri/registry/esriDataset.test.js +1 -1
- package/plugins/datasets/src/adapters/loadLayerAdapter.js +2 -20
- package/plugins/datasets/src/adapters/loadLayerAdapter.test.js +9 -9
- package/plugins/datasets/src/adapters/mapboxStyleLayerAdapter.js +7 -7
- package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +19 -19
- package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.test.js +1 -1
- package/plugins/datasets/src/adapters/maplibre/registry/mapLibreDataset.test.js +1 -1
- package/plugins/datasets/src/adapters/openlayers/canvasPatternStyle.test.js +2 -2
- package/plugins/datasets/src/adapters/openlayers/layerBuilders.test.js +1 -1
- package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.js +21 -21
- package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.test.js +5 -5
- package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.js +2 -3
- package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.test.js +2 -2
- package/plugins/datasets/src/api/getOpacity.js +1 -2
- package/plugins/datasets/src/api/getOpacity.test.js +9 -12
- package/plugins/datasets/src/api/getStyle.js +1 -2
- package/plugins/datasets/src/api/getStyle.test.js +5 -8
- package/plugins/datasets/src/api/removeDataset.js +2 -4
- package/plugins/datasets/src/api/removeDataset.test.js +5 -10
- package/plugins/datasets/src/api/setData.js +2 -4
- package/plugins/datasets/src/api/setData.test.js +6 -14
- package/plugins/datasets/src/api/setFeatureVisibility.js +1 -2
- package/plugins/datasets/src/api/setFeatureVisibility.test.js +8 -11
- package/plugins/datasets/src/components/LayersMenu/LayersMenu.jsx +1 -0
- package/plugins/datasets/src/components/LayersMenu/LayersMenuCheckbox.jsx +1 -3
- package/plugins/datasets/src/components/LayersMenu/LayersMenuCheckbox.test.jsx +13 -18
- package/plugins/datasets/src/index.js +2 -2
- package/plugins/datasets/src/index.test.js +8 -1
- package/plugins/datasets/src/initialise/DatasetsInit.jsx +48 -26
- package/plugins/datasets/src/initialise/DatasetsInit.test.jsx +160 -89
- package/plugins/datasets/src/initialise/initialiseDatasets.js +2 -3
- package/plugins/datasets/src/initialise/initialiseDatasets.test.js +23 -10
- package/plugins/datasets/src/manifest.js +53 -44
- package/plugins/datasets/src/manifest.test.js +36 -4
- package/plugins/datasets/src/reducers/pluginState.js +5 -5
- package/plugins/datasets/src/reducers/pluginState.test.js +21 -20
- package/plugins/datasets/src/registry/__mocks__/datasetRegistry.js +7 -6
- package/plugins/datasets/src/registry/createDataset.js +2 -2
- package/plugins/datasets/src/registry/dataset.js +9 -10
- package/plugins/datasets/src/registry/dataset.test.js +63 -64
- package/plugins/datasets/src/registry/datasetRegistry.js +39 -10
- package/plugins/datasets/src/registry/datasetRegistry.test.js +83 -1
- package/plugins/datasets/src/registry/globalDataset.js +9 -17
- package/plugins/datasets/src/registry/isVisibleWhen.js +9 -17
- package/plugins/datasets/src/registry/isVisibleWhen.test.js +27 -20
- package/plugins/datasets/src/registry/mapboxStyleDataset.test.js +26 -27
- package/plugins/datasets/src/utils/hasLayersMenu.js +13 -0
- package/plugins/datasets/src/utils/hasLayersMenu.test.js +25 -0
- package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/esm/index.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 +47 -26
- package/plugins/draw/src/DrawInit.test.jsx +90 -2
- package/plugins/draw/src/adapters/openlayers/core/styles.test.js +1 -1
- package/plugins/draw/src/adapters/openlayers/point/pointSymbolImages.test.js +1 -1
- package/plugins/draw/src/manifest.js +3 -2
- package/plugins/draw/src/manifest.test.js +13 -1
- package/plugins/draw/src/utils/needsDrawTarget.js +22 -0
- package/plugins/draw/src/utils/needsDrawTarget.test.js +42 -0
- package/plugins/draw-es/dist/esm/index.js +1 -0
- package/plugins/{beta/draw-es → draw-es}/src/DrawInit.jsx +1 -1
- package/plugins/{beta/draw-es → draw-es}/src/events.test.js +1 -1
- package/plugins/{beta/draw-es → draw-es}/src/graphic.js +1 -1
- package/plugins/frame/dist/esm/index.js +1 -0
- package/plugins/{beta/frame → frame}/dist/umd/im-frame-plugin.js +1 -1
- package/plugins/{beta/frame → frame}/dist/umd/index.js +1 -1
- package/plugins/{beta/frame → frame}/package.json +2 -2
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/esm/index.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/interact/src/InteractInit.jsx +3 -3
- package/plugins/interact/src/api/enable.test.js +13 -0
- package/plugins/interact/src/defaults.js +1 -0
- package/plugins/interact/src/hooks/useCrossHairVisibility.js +27 -17
- package/plugins/interact/src/hooks/useCrossHairVisibility.test.js +72 -7
- package/plugins/interact/src/manifest.js +4 -4
- package/plugins/interact/src/manifest.test.js +29 -0
- package/plugins/interact/src/reducer.js +7 -2
- package/plugins/interact/src/reducer.test.js +12 -2
- package/plugins/interact/src/utils/needsTarget.js +20 -0
- package/plugins/interact/src/utils/needsTarget.test.js +36 -0
- package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/esm/index.js +1 -1
- package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/umd/index.js +1 -1
- package/plugins/map-key/src/components/Key/KeySvgSymbol.jsx +4 -0
- package/plugins/map-key/src/components/Key/MapKey.jsx +15 -15
- package/plugins/map-key/src/components/Key/MapKey.test.jsx +29 -15
- package/plugins/map-key/src/initialise/MapKeyInit.jsx +5 -8
- package/plugins/map-key/src/initialise/MapKeyInit.test.jsx +9 -7
- package/plugins/map-key/src/manifest.test.js +0 -1
- package/plugins/map-key/src/reducers/mergeKeyGroupItems.js +14 -33
- package/plugins/map-key/src/reducers/mergeKeyGroupItems.test.js +34 -50
- package/plugins/map-key/src/reducers/pluginState.js +6 -1
- package/plugins/map-key/src/reducers/pluginState.test.js +13 -4
- package/plugins/map-styles/dist/esm/index.js +1 -0
- package/plugins/{beta/map-styles → map-styles}/dist/umd/im-map-styles-plugin.js +1 -1
- package/plugins/{beta/map-styles → map-styles}/dist/umd/index.js +1 -1
- package/plugins/{beta/map-styles → map-styles}/src/MapStyles.jsx +2 -2
- package/plugins/{beta/map-styles → map-styles}/src/MapStylesInit.jsx +1 -1
- package/plugins/menu/dist/esm/index.js +1 -1
- package/plugins/scale-bar/dist/esm/index.js +1 -0
- package/plugins/{beta/scale-bar → scale-bar}/dist/umd/im-scale-bar-plugin.js +1 -1
- package/plugins/{beta/scale-bar → scale-bar}/dist/umd/index.js +1 -1
- package/plugins/{beta/scale-bar → scale-bar}/package.json +2 -2
- package/plugins/search/dist/esm/im-search-plugin.js +1 -1
- package/plugins/search/dist/esm/index.js +1 -1
- package/plugins/search/dist/umd/im-search-plugin.js +1 -1
- package/plugins/search/dist/umd/index.js +1 -1
- package/plugins/search/src/components/Suggestions/Suggestions.jsx +3 -1
- package/plugins/search/src/components/Suggestions/Suggestions.test.jsx +11 -0
- package/plugins/search/src/utils/markedToElements.jsx +25 -0
- package/plugins/search/src/utils/markedToElements.test.jsx +49 -0
- package/plugins/search/src/utils/parseOsNamesResults.js +6 -4
- package/plugins/search/src/utils/parseOsNamesResults.test.js +18 -0
- package/plugins/use-location/dist/esm/index.js +1 -0
- package/plugins/{beta/use-location → use-location}/dist/umd/im-use-location-plugin.js +1 -1
- package/plugins/{beta/use-location → use-location}/dist/umd/index.js +1 -1
- package/providers/esri/dist/esm/index.js +1 -0
- package/providers/{beta/esri → esri}/src/esriProvider.js +1 -1
- package/providers/{beta/esri → esri}/src/mapEvents.js +2 -2
- package/providers/maplibre/dist/esm/index.js +1 -1
- package/providers/open-names/dist/esm/index.js +1 -0
- package/providers/{beta/open-names → open-names}/dist/umd/im-reverse-geocode.js +1 -1
- package/providers/{beta/open-names → open-names}/dist/umd/index.js +1 -1
- package/providers/openlayers/dist/esm/index.js +1 -0
- package/providers/openlayers/dist/umd/im-openlayers-provider.js +2 -0
- package/providers/{beta/openlayers → openlayers}/dist/umd/index.js +1 -1
- package/providers/{beta/openlayers → openlayers}/src/index.js +4 -4
- package/providers/{beta/openlayers → openlayers}/src/mapEvents.js +2 -2
- package/providers/{beta/openlayers → openlayers}/src/mapEvents.test.js +2 -2
- package/providers/{beta/openlayers → openlayers}/src/openlayersProvider.js +3 -3
- package/providers/{beta/openlayers → openlayers}/src/utils/highlightFeatures.js +1 -1
- package/providers/{beta/openlayers → openlayers}/src/utils/patternImages.js +1 -1
- package/providers/{beta/openlayers → openlayers}/src/utils/symbolImages.js +1 -1
- package/rollup.esm.mjs +43 -47
- package/sonar-project.properties +1 -1
- package/src/App/App.jsx +4 -1
- package/src/App/App.test.jsx +6 -0
- package/src/App/renderer/PluginInits.jsx +8 -7
- package/src/App/renderer/PluginInits.test.jsx +20 -5
- package/src/App/renderer/SlotItemsProvider.jsx +33 -0
- package/src/App/renderer/SlotItemsProvider.test.jsx +59 -0
- package/src/App/renderer/SlotRenderer.jsx +3 -14
- package/src/App/renderer/SlotRenderer.test.jsx +11 -44
- package/src/App/renderer/mapButtons.js +22 -11
- package/src/App/renderer/mapButtons.test.js +23 -1
- package/src/App/renderer/mapControls.js +6 -8
- package/src/App/renderer/mapControls.test.js +10 -0
- package/src/App/renderer/mapPanels.js +16 -19
- package/src/App/renderer/mapPanels.test.js +37 -9
- package/src/App/renderer/pluginWrapper.js +10 -8
- package/src/App/renderer/pluginWrapper.test.js +23 -9
- package/src/App/renderer/slotAggregator.js +18 -5
- package/src/App/renderer/slotAggregator.test.js +68 -25
- package/src/App/renderer/slotHelpers.js +13 -0
- package/src/App/renderer/slotHelpers.test.js +16 -1
- package/src/App/store/AppProvider.jsx +19 -1
- package/src/App/store/AppProvider.test.jsx +41 -0
- package/src/App/store/appActionsMap.js +10 -1
- package/src/App/store/appActionsMap.test.js +21 -0
- package/src/App/store/appDispatchMiddleware.js +29 -17
- package/src/App/store/appDispatchMiddleware.test.js +31 -0
- package/src/InteractiveMap/parseDataProperties.js +4 -4
- package/src/InteractiveMap/parseDataProperties.test.js +62 -6
- package/src/config/events.js +4 -2
- package/src/scss/tools/_govuk-content.scss +4 -3
- package/webpack.dev.mjs +9 -3
- package/webpack.prod.mjs +11 -4
- package/webpack.umd.mjs +6 -7
- package/plugins/beta/draw-es/dist/esm/index.js +0 -1
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +0 -1
- package/plugins/beta/draw-ml/dist/esm/index.js +0 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +0 -1
- package/plugins/beta/draw-ml/dist/umd/index.js +0 -2
- package/plugins/beta/draw-ml/src/DrawInit.jsx +0 -85
- package/plugins/beta/draw-ml/src/api/addFeature.js +0 -27
- package/plugins/beta/draw-ml/src/api/deleteFeature.js +0 -13
- package/plugins/beta/draw-ml/src/api/editFeature.js +0 -75
- package/plugins/beta/draw-ml/src/api/merge.js +0 -9
- package/plugins/beta/draw-ml/src/api/newLine.js +0 -68
- package/plugins/beta/draw-ml/src/api/newPolygon.js +0 -68
- package/plugins/beta/draw-ml/src/api/split.js +0 -81
- package/plugins/beta/draw-ml/src/defaults.js +0 -17
- package/plugins/beta/draw-ml/src/draw.scss +0 -26
- package/plugins/beta/draw-ml/src/events.js +0 -185
- package/plugins/beta/draw-ml/src/index.js +0 -13
- package/plugins/beta/draw-ml/src/manifest.js +0 -110
- package/plugins/beta/draw-ml/src/mapboxDraw.js +0 -143
- package/plugins/beta/draw-ml/src/mapboxSnap.js +0 -321
- package/plugins/beta/draw-ml/src/modes/createDrawMode.js +0 -552
- package/plugins/beta/draw-ml/src/modes/disabledMode.js +0 -23
- package/plugins/beta/draw-ml/src/modes/drawLineMode.js +0 -18
- package/plugins/beta/draw-ml/src/modes/drawPolygonMode.js +0 -16
- package/plugins/beta/draw-ml/src/modes/editVertex/geometryHelpers.js +0 -135
- package/plugins/beta/draw-ml/src/modes/editVertex/helpers.js +0 -2
- package/plugins/beta/draw-ml/src/modes/editVertex/touchHandlers.js +0 -142
- package/plugins/beta/draw-ml/src/modes/editVertex/undoHandlers.js +0 -133
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexOperations.js +0 -142
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexQueries.js +0 -121
- package/plugins/beta/draw-ml/src/modes/editVertexMode.js +0 -495
- package/plugins/beta/draw-ml/src/reducer.js +0 -90
- package/plugins/beta/draw-ml/src/styles.js +0 -190
- package/plugins/beta/draw-ml/src/undoStack.js +0 -50
- package/plugins/beta/draw-ml/src/utils/debounce.js +0 -16
- package/plugins/beta/draw-ml/src/utils/flattenStyleProperties.js +0 -49
- package/plugins/beta/draw-ml/src/utils/snapHelpers.js +0 -200
- package/plugins/beta/draw-ml/src/utils/spatial.js +0 -258
- package/plugins/beta/draw-ol/dist/css/index.css +0 -1
- package/plugins/beta/draw-ol/dist/esm/DrawMode.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/EditMode.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/geometryHelpers.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/index.js +0 -1
- package/plugins/beta/draw-ol/src/DrawInit.jsx +0 -65
- package/plugins/beta/draw-ol/src/api/addFeature.js +0 -29
- package/plugins/beta/draw-ol/src/api/deleteFeature.js +0 -11
- package/plugins/beta/draw-ol/src/api/editFeature.js +0 -50
- package/plugins/beta/draw-ol/src/api/newLine.js +0 -44
- package/plugins/beta/draw-ol/src/api/newPolygon.js +0 -44
- package/plugins/beta/draw-ol/src/core/OLDrawManager.js +0 -153
- package/plugins/beta/draw-ol/src/core/featureStore.js +0 -65
- package/plugins/beta/draw-ol/src/core/styles.js +0 -98
- package/plugins/beta/draw-ol/src/core/undoStack.js +0 -31
- package/plugins/beta/draw-ol/src/defaults.js +0 -16
- package/plugins/beta/draw-ol/src/draw/DrawMode.js +0 -121
- package/plugins/beta/draw-ol/src/draw/drawInput.js +0 -243
- package/plugins/beta/draw-ol/src/draw.scss +0 -17
- package/plugins/beta/draw-ol/src/edit/EditMode.js +0 -424
- package/plugins/beta/draw-ol/src/edit/keyboardHandler.js +0 -229
- package/plugins/beta/draw-ol/src/edit/midpointLayer.js +0 -57
- package/plugins/beta/draw-ol/src/edit/touchHandler.js +0 -171
- package/plugins/beta/draw-ol/src/edit/undoOps.js +0 -95
- package/plugins/beta/draw-ol/src/edit/vertexHitTest.js +0 -72
- package/plugins/beta/draw-ol/src/edit/vertexLayer.js +0 -49
- package/plugins/beta/draw-ol/src/edit/vertexOps.js +0 -99
- package/plugins/beta/draw-ol/src/events.js +0 -114
- package/plugins/beta/draw-ol/src/index.js +0 -12
- package/plugins/beta/draw-ol/src/manifest.js +0 -125
- package/plugins/beta/draw-ol/src/olDraw.js +0 -38
- package/plugins/beta/draw-ol/src/reducer.js +0 -41
- package/plugins/beta/draw-ol/src/snap/snapEngine.js +0 -153
- package/plugins/beta/draw-ol/src/snap/snapGeometry.js +0 -177
- package/plugins/beta/draw-ol/src/snap/snapIndicator.js +0 -81
- package/plugins/beta/draw-ol/src/snap/snapInteraction.js +0 -57
- package/plugins/beta/draw-ol/src/snap/snapManager.js +0 -99
- package/plugins/beta/draw-ol/src/utils/flattenStyleProperties.js +0 -47
- package/plugins/beta/draw-ol/src/utils/geometryHelpers.js +0 -103
- package/plugins/beta/draw-ol/src/utils/olCoords.js +0 -35
- package/plugins/beta/draw-ol/src/utils/resolveColors.js +0 -39
- package/plugins/beta/draw-ol/src/utils/spatial.js +0 -24
- package/plugins/beta/draw-ol/src/utils/touchTarget.js +0 -61
- package/plugins/beta/frame/dist/esm/index.js +0 -1
- package/plugins/beta/map-styles/dist/esm/index.js +0 -1
- package/plugins/beta/scale-bar/dist/esm/index.js +0 -1
- package/plugins/beta/use-location/dist/esm/index.js +0 -1
- package/plugins/map-key/src/registry/getDatasetRegistry.js +0 -6
- package/plugins/map-key/src/registry/getDatasetRegistry.test.js +0 -23
- package/plugins/map-key/src/registry/index.js +0 -1
- package/plugins/map-key/src/registry/index.test.js +0 -7
- package/providers/beta/esri/dist/esm/index.js +0 -1
- package/providers/beta/open-names/dist/esm/index.js +0 -1
- package/providers/beta/openlayers/dist/esm/index.js +0 -1
- package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +0 -2
- package/providers/beta/openlayers/dist/umd/index.js.LICENSE.txt +0 -1
- /package/plugins/{beta/draw-es → draw-es}/dist/esm/im-draw-es-plugin.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/addFeature.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/deleteFeature.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/editFeature.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/newPolygon.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/removeSafeZone.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/events.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/index.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/manifest.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/reducer.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/sketchViewModel.js +0 -0
- /package/plugins/{beta/frame → frame}/dist/css/index.css +0 -0
- /package/plugins/{beta/frame → frame}/dist/esm/im-frame-plugin.js +0 -0
- /package/plugins/{beta/draw-ml → frame}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/frame → frame}/src/Frame.jsx +0 -0
- /package/plugins/{beta/frame → frame}/src/FrameInit.jsx +0 -0
- /package/plugins/{beta/frame → frame}/src/api/addFrame.js +0 -0
- /package/plugins/{beta/frame → frame}/src/api/editFeature.js +0 -0
- /package/plugins/{beta/frame → frame}/src/config.js +0 -0
- /package/plugins/{beta/frame → frame}/src/frame.scss +0 -0
- /package/plugins/{beta/frame → frame}/src/index.js +0 -0
- /package/plugins/{beta/frame → frame}/src/manifest.js +0 -0
- /package/plugins/{beta/frame → frame}/src/reducer.js +0 -0
- /package/plugins/{beta/frame → frame}/src/utils.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/dist/css/index.css +0 -0
- /package/plugins/{beta/map-styles → map-styles}/dist/esm/im-map-styles-plugin.js +0 -0
- /package/plugins/{beta/frame → map-styles}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/config.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/index.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/manifest.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/mapStyles.scss +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/dist/css/index.css +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/dist/esm/im-scale-bar-plugin.js +0 -0
- /package/plugins/{beta/map-styles → scale-bar}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/ScaleBar.jsx +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/ScaleBar.test.jsx +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/index.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/index.test.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/manifest.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/scaleBar.scss +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/utils.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/utils.test.js +0 -0
- /package/plugins/{beta/use-location → use-location}/dist/esm/im-use-location-plugin.js +0 -0
- /package/plugins/{beta/scale-bar → use-location}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/use-location → use-location}/src/UseLocation.jsx +0 -0
- /package/plugins/{beta/use-location → use-location}/src/UseLocationInit.jsx +0 -0
- /package/plugins/{beta/use-location → use-location}/src/defaults.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/events.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/index.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/manifest.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/reducer.js +0 -0
- /package/providers/{beta/esri → esri}/dist/css/index.css +0 -0
- /package/providers/{beta/esri → esri}/dist/esm/im-esri-provider.js +0 -0
- /package/providers/{beta/esri → esri}/src/appEvents.js +0 -0
- /package/providers/{beta/esri → esri}/src/defaults.js +0 -0
- /package/providers/{beta/esri → esri}/src/esriProvider.scss +0 -0
- /package/providers/{beta/esri → esri}/src/index.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/coords.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/coords.test.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/detectWebGL.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/esriFixes.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/query.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/spatial.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/spatial.test.js +0 -0
- /package/providers/{beta/open-names → open-names}/dist/esm/im-reverse-geocode.js +0 -0
- /package/providers/{beta/open-names → open-names}/dist/umd/im-reverse-geocode.js.LICENSE.txt +0 -0
- /package/{plugins/beta/use-location → providers/open-names}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/providers/{beta/open-names → open-names}/src/index.js +0 -0
- /package/providers/{beta/open-names → open-names}/src/reverseGeocode.js +0 -0
- /package/providers/{beta/open-names → open-names}/src/utils/mapToLocationModel.js +0 -0
- /package/providers/{beta/open-names → open-names}/src/utils/mapToLocationModel.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/dist/esm/im-openlayers-provider.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/dist/umd/im-openlayers-provider.js.LICENSE.txt +0 -0
- /package/providers/{beta/open-names → openlayers}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/appEvents.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/appEvents.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/defaults.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/index.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/openlayersProvider.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/bngProjection.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/filterEvaluator.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/filterEvaluator.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/highlightFeatures.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/hoverCursor.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/hoverCursor.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/openLayersFixes.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/openLayersFixes.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/patternImages.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/queryFeatures.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/queryFeatures.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/spatial.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/spatial.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/symbolImages.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/tileLayers.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/tileLayers.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/vtTileFragments.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/vtTileFragments.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/zoom.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/zoom.test.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadLayerAdapter
|
|
1
|
+
import { loadLayerAdapter } from './loadLayerAdapter.js'
|
|
2
2
|
|
|
3
3
|
const makeAdapterInstance = (type) => ({
|
|
4
4
|
type,
|
|
@@ -31,6 +31,7 @@ jest.mock('./openlayers/openlayersLayerAdapter.js', () => ({
|
|
|
31
31
|
const makeMapProvider = (name) => ({ name })
|
|
32
32
|
const symbolRegistry = {}
|
|
33
33
|
const patternRegistry = {}
|
|
34
|
+
const datasetRegistry = {}
|
|
34
35
|
|
|
35
36
|
describe('loadLayerAdapter', () => {
|
|
36
37
|
beforeEach(() => {
|
|
@@ -55,11 +56,11 @@ describe('loadLayerAdapter', () => {
|
|
|
55
56
|
expect(adapter.type).toBe('openlayers')
|
|
56
57
|
})
|
|
57
58
|
|
|
58
|
-
it('passes
|
|
59
|
+
it('passes the registries through to the adapter constructor', async () => {
|
|
59
60
|
const OpenLayersLayerAdapter = (await import('./openlayers/openlayersLayerAdapter.js')).default
|
|
60
61
|
const mapProvider = makeMapProvider('OpenLayersProvider')
|
|
61
|
-
await loadLayerAdapter(mapProvider, symbolRegistry, patternRegistry,
|
|
62
|
-
expect(OpenLayersLayerAdapter).toHaveBeenCalledWith(mapProvider, symbolRegistry, patternRegistry,
|
|
62
|
+
await loadLayerAdapter(mapProvider, symbolRegistry, patternRegistry, datasetRegistry)
|
|
63
|
+
expect(OpenLayersLayerAdapter).toHaveBeenCalledWith(mapProvider, symbolRegistry, patternRegistry, datasetRegistry)
|
|
63
64
|
})
|
|
64
65
|
|
|
65
66
|
it('throws for an unknown provider', async () => {
|
|
@@ -68,11 +69,10 @@ describe('loadLayerAdapter', () => {
|
|
|
68
69
|
.rejects.toThrow('No layer adapter available for map provider UnknownProvider')
|
|
69
70
|
})
|
|
70
71
|
|
|
71
|
-
it('
|
|
72
|
+
it('returns a new adapter instance for each call', async () => {
|
|
72
73
|
const mapProvider = makeMapProvider('MapLibreProvider')
|
|
73
|
-
await loadLayerAdapter(mapProvider, symbolRegistry, patternRegistry)
|
|
74
|
-
|
|
75
|
-
expect(
|
|
76
|
-
expect(typeof layerAdapter.setData).toBe('function')
|
|
74
|
+
const adapterA = await loadLayerAdapter(mapProvider, symbolRegistry, patternRegistry, datasetRegistry)
|
|
75
|
+
const adapterB = await loadLayerAdapter(mapProvider, symbolRegistry, patternRegistry, datasetRegistry)
|
|
76
|
+
expect(adapterA).not.toBe(adapterB)
|
|
77
77
|
})
|
|
78
78
|
})
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { LayerAdapter } from './layerAdapter.js'
|
|
2
|
-
import { datasetRegistry } from '../registry/datasetRegistry.js'
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Shared orchestration for adapters whose registry Dataset extends MapboxStyleDataset
|
|
@@ -16,12 +15,13 @@ import { datasetRegistry } from '../registry/datasetRegistry.js'
|
|
|
16
15
|
* much (e.g. OpenLayers has no per-layer setFilter, so it rebuilds the whole style instead).
|
|
17
16
|
*/
|
|
18
17
|
export class MapboxStyleLayerAdapter extends LayerAdapter {
|
|
19
|
-
constructor (mapProvider, symbolRegistry, patternRegistry) {
|
|
18
|
+
constructor (mapProvider, symbolRegistry, patternRegistry, datasetRegistry) {
|
|
20
19
|
super()
|
|
21
20
|
this._mapProvider = mapProvider
|
|
22
21
|
this._map = mapProvider.map
|
|
23
22
|
this._symbolRegistry = symbolRegistry
|
|
24
23
|
this._patternRegistry = patternRegistry
|
|
24
|
+
this._datasetRegistry = datasetRegistry
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// Live — reflects the map's current pixelRatio, which can change on resize.
|
|
@@ -30,7 +30,7 @@ export class MapboxStyleLayerAdapter extends LayerAdapter {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
async addDataset (datasetId) {
|
|
33
|
-
const registryDataset =
|
|
33
|
+
const registryDataset = this._datasetRegistry.getDataset(datasetId)
|
|
34
34
|
if (!registryDataset) {
|
|
35
35
|
return
|
|
36
36
|
}
|
|
@@ -39,7 +39,7 @@ export class MapboxStyleLayerAdapter extends LayerAdapter {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
applyDatasetOpacity (datasetId) {
|
|
42
|
-
const registryDataset =
|
|
42
|
+
const registryDataset = this._datasetRegistry.getDataset(datasetId)
|
|
43
43
|
if (registryDataset) {
|
|
44
44
|
this._applyRegistryDatasetOpacity(registryDataset)
|
|
45
45
|
}
|
|
@@ -52,11 +52,11 @@ export class MapboxStyleLayerAdapter extends LayerAdapter {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
applyGlobalOpacity () {
|
|
55
|
-
|
|
55
|
+
this._datasetRegistry.forEachDataset(registryDataset => this._applyRegistryDatasetOpacity(registryDataset))
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
applyDatasetVisibility (datasetId) {
|
|
59
|
-
const registryDataset =
|
|
59
|
+
const registryDataset = this._datasetRegistry.getDataset(datasetId)
|
|
60
60
|
if (registryDataset) {
|
|
61
61
|
this._applyRegistryDatasetVisibility(registryDataset)
|
|
62
62
|
}
|
|
@@ -69,6 +69,6 @@ export class MapboxStyleLayerAdapter extends LayerAdapter {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
applyGlobalVisibility () {
|
|
72
|
-
|
|
72
|
+
this._datasetRegistry.forEachDataset(registryDataset => this._applyRegistryDatasetVisibility(registryDataset))
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { addDatasetLayers } from './layerBuilders.js'
|
|
2
2
|
import { MapLibreDataset } from './registry/mapLibreDataset.js'
|
|
3
|
-
import { datasetRegistry } from '../../registry/datasetRegistry.js'
|
|
4
3
|
import { MapboxStyleLayerAdapter } from '../mapboxStyleLayerAdapter.js'
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -20,9 +19,10 @@ export default class MaplibreLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
20
19
|
* @param {Object} mapProvider - Map provider instance (e.g. MapLibreProvider)
|
|
21
20
|
* @param {Object} symbolRegistry
|
|
22
21
|
* @param {Object} patternRegistry
|
|
22
|
+
* @param {Object} datasetRegistry - This plugin instance's dataset registry
|
|
23
23
|
*/
|
|
24
|
-
constructor (mapProvider, symbolRegistry, patternRegistry) {
|
|
25
|
-
super(mapProvider, symbolRegistry, patternRegistry)
|
|
24
|
+
constructor (mapProvider, symbolRegistry, patternRegistry, datasetRegistry) {
|
|
25
|
+
super(mapProvider, symbolRegistry, patternRegistry, datasetRegistry)
|
|
26
26
|
// datasetId → sourceId, used by setData to update the correct source
|
|
27
27
|
this._datasetSourceMap = new Map()
|
|
28
28
|
window._datasetSourceMap = this._datasetSourceMap // Expose for debugging
|
|
@@ -30,8 +30,8 @@ export default class MaplibreLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
30
30
|
this._symbolLayerIds = new Set()
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
createDataset (datasetDefinition) {
|
|
34
|
-
return new MapLibreDataset(datasetDefinition)
|
|
33
|
+
createDataset (datasetDefinition, datasetRegistry) {
|
|
34
|
+
return new MapLibreDataset(datasetDefinition, datasetRegistry)
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// ─── Lifecycle ──────────────────────────────────────────────────────────────
|
|
@@ -41,11 +41,11 @@ export default class MaplibreLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
41
41
|
* @returns {Promise<void>} Resolves once the map has processed all layers.
|
|
42
42
|
*/
|
|
43
43
|
async init () {
|
|
44
|
-
const { patternConfigs, symbolConfigs } =
|
|
44
|
+
const { patternConfigs, symbolConfigs } = this._datasetRegistry.getPatternAndSymbolConfigs()
|
|
45
45
|
await this.addPatternsAndSymbolsToMap(patternConfigs, symbolConfigs)
|
|
46
46
|
|
|
47
47
|
this._symbolLayerIds.clear()
|
|
48
|
-
|
|
48
|
+
this._datasetRegistry.forEachDataset(registryDataset => this._addLayers(registryDataset))
|
|
49
49
|
await new Promise(resolve => this._map.once('idle', resolve))
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -57,7 +57,7 @@ export default class MaplibreLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
async addPatternsAndSymbolsToMap (patterns, symbols) {
|
|
60
|
-
const mapStyle =
|
|
60
|
+
const mapStyle = this._datasetRegistry.mapStyle
|
|
61
61
|
const mapStyleId = mapStyle.id
|
|
62
62
|
return Promise.all([
|
|
63
63
|
this._mapProvider.addPatternsToMap(patterns, mapStyleId, this._patternRegistry),
|
|
@@ -70,7 +70,7 @@ export default class MaplibreLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
70
70
|
*/
|
|
71
71
|
destroy () {
|
|
72
72
|
const removedSourceIds = new Set()
|
|
73
|
-
|
|
73
|
+
this._datasetRegistry.forEachDataset(registryDataset => {
|
|
74
74
|
const sourceId = registryDataset.sourceId
|
|
75
75
|
this._getLayersUsingSource(sourceId).forEach(layerId => this.removeLayer(layerId))
|
|
76
76
|
if (!removedSourceIds.has(sourceId) && this._map.getSource(sourceId)) {
|
|
@@ -90,11 +90,11 @@ export default class MaplibreLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
90
90
|
// MapLibre wipes all sources/layers on style change — must wait for idle first
|
|
91
91
|
await new Promise(resolve => this._map.once('idle', resolve))
|
|
92
92
|
|
|
93
|
-
const { patternConfigs, symbolConfigs } =
|
|
93
|
+
const { patternConfigs, symbolConfigs } = this._datasetRegistry.getPatternAndSymbolConfigs()
|
|
94
94
|
await this.addPatternsAndSymbolsToMap(patternConfigs, symbolConfigs)
|
|
95
95
|
this._symbolLayerIds.clear()
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
this._datasetRegistry.forEachDataset(registryDataset => {
|
|
98
98
|
this._addLayers(registryDataset)
|
|
99
99
|
this._applyFeatureFilter(registryDataset)
|
|
100
100
|
})
|
|
@@ -109,9 +109,9 @@ export default class MaplibreLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
109
109
|
* @returns {Promise<void>}
|
|
110
110
|
*/
|
|
111
111
|
async onMapSizeChange () {
|
|
112
|
-
const { mapStyle } =
|
|
112
|
+
const { mapStyle } = this._datasetRegistry
|
|
113
113
|
const pixelRatio = this._pixelRatio
|
|
114
|
-
const { patternConfigs, symbolConfigs } =
|
|
114
|
+
const { patternConfigs, symbolConfigs } = this._datasetRegistry.getPatternAndSymbolConfigs()
|
|
115
115
|
await this.addPatternsAndSymbolsToMap(patternConfigs, symbolConfigs)
|
|
116
116
|
// A later size change has moved the map on to another ratio while these images were being
|
|
117
117
|
// registered — its own call applies that ratio's images, which may not be registered yet
|
|
@@ -119,7 +119,7 @@ export default class MaplibreLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
119
119
|
return
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
this._datasetRegistry.forEach(registryDataset => {
|
|
123
123
|
const { fillLayerId, symbolLayerId } = registryDataset
|
|
124
124
|
if (symbolLayerId && this._symbolLayerIds.has(symbolLayerId) && this._map.getLayer(symbolLayerId)) {
|
|
125
125
|
const imageId = this._symbolRegistry.getSymbolImageId(registryDataset.style, mapStyle, 'normal', pixelRatio)
|
|
@@ -152,7 +152,7 @@ export default class MaplibreLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
152
152
|
* @param {string} datasetId
|
|
153
153
|
*/
|
|
154
154
|
removeDataset (datasetId) {
|
|
155
|
-
const registryDataset =
|
|
155
|
+
const registryDataset = this._datasetRegistry.getDataset(datasetId)
|
|
156
156
|
if (!registryDataset) {
|
|
157
157
|
return
|
|
158
158
|
}
|
|
@@ -161,7 +161,7 @@ export default class MaplibreLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
161
161
|
layerIds.forEach(layerId => this.removeLayer(layerId))
|
|
162
162
|
|
|
163
163
|
// Remove source if no other dataset is using it
|
|
164
|
-
const sourceIsShared =
|
|
164
|
+
const sourceIsShared = this._datasetRegistry.topLevelDatasets()
|
|
165
165
|
.some(dataset => dataset.id !== datasetId && dataset.sourceId === sourceId)
|
|
166
166
|
|
|
167
167
|
if (!sourceIsShared && this._map.getSource(sourceId)) {
|
|
@@ -178,7 +178,7 @@ export default class MaplibreLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
178
178
|
* @param {string} datasetId
|
|
179
179
|
*/
|
|
180
180
|
applyFeatureFilter (datasetId) {
|
|
181
|
-
const registryDataset =
|
|
181
|
+
const registryDataset = this._datasetRegistry.getDataset(datasetId)
|
|
182
182
|
if (!registryDataset) {
|
|
183
183
|
return
|
|
184
184
|
}
|
|
@@ -192,7 +192,7 @@ export default class MaplibreLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
192
192
|
* @returns {Promise<void>}
|
|
193
193
|
*/
|
|
194
194
|
async applyStyle (datasetId) {
|
|
195
|
-
const registryDataset =
|
|
195
|
+
const registryDataset = this._datasetRegistry.getDataset(datasetId)
|
|
196
196
|
registryDataset.layerIds.forEach(layerId => this.removeLayer(layerId))
|
|
197
197
|
await this._registerPatternsAndSymbols(registryDataset)
|
|
198
198
|
this._addLayers(registryDataset)
|
|
@@ -219,7 +219,7 @@ export default class MaplibreLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
219
219
|
// ─── Private ─────────────────────────────────────────────────────────────────
|
|
220
220
|
|
|
221
221
|
_addLayers (registryDataset) {
|
|
222
|
-
const { mapStyle } =
|
|
222
|
+
const { mapStyle } = this._datasetRegistry
|
|
223
223
|
const sourceId = addDatasetLayers(this._mapProvider, registryDataset, mapStyle, this._symbolRegistry, this._patternRegistry, this._pixelRatio)
|
|
224
224
|
this._datasetSourceMap.set(registryDataset.id, sourceId)
|
|
225
225
|
this._maintainSymbolOrdering(registryDataset)
|
|
@@ -57,7 +57,7 @@ beforeEach(() => {
|
|
|
57
57
|
|
|
58
58
|
map = makeMap()
|
|
59
59
|
mapProvider = makeMapProvider(map)
|
|
60
|
-
adapter = new MaplibreLayerAdapter(mapProvider, symbolRegistry, patternRegistry)
|
|
60
|
+
adapter = new MaplibreLayerAdapter(mapProvider, symbolRegistry, patternRegistry, datasetRegistry)
|
|
61
61
|
adapter.attachDynamicSources(dynamicSources)
|
|
62
62
|
datasetRegistry.attachCreateDataset(adapter.createDataset)
|
|
63
63
|
})
|
|
@@ -14,7 +14,7 @@ const STATIC_GEOJSON_SOURCE_ID = `geojson-${hashString('https://example.com/stat
|
|
|
14
14
|
describe('MapLibreDataset', () => {
|
|
15
15
|
beforeEach(() => {
|
|
16
16
|
logger.warn.mockClear()
|
|
17
|
-
datasetRegistry.attachCreateDataset(def => new MapLibreDataset(def))
|
|
17
|
+
datasetRegistry.attachCreateDataset(def => new MapLibreDataset(def, datasetRegistry))
|
|
18
18
|
datasetRegistry.mockExtend({
|
|
19
19
|
// layerIds
|
|
20
20
|
'ds-fill-only': { id: 'ds-fill-only', visible: true, minZoom: 10, maxZoom: 24, style: { fill: 'blue' } },
|
|
@@ -2,8 +2,8 @@ import Style from 'ol/style/Style.js'
|
|
|
2
2
|
import Feature from 'ol/Feature.js'
|
|
3
3
|
import Point from 'ol/geom/Point.js'
|
|
4
4
|
import { buildCanvasPatternStyle } from './canvasPatternStyle.js'
|
|
5
|
-
import { buildFilterEvaluator } from '../../../../../providers/
|
|
6
|
-
import { PatternImageCache } from '../../../../../providers/
|
|
5
|
+
import { buildFilterEvaluator } from '../../../../../providers/openlayers/src/utils/filterEvaluator.js'
|
|
6
|
+
import { PatternImageCache } from '../../../../../providers/openlayers/src/utils/patternImages.js'
|
|
7
7
|
|
|
8
8
|
const OUTDOOR = 'outdoor'
|
|
9
9
|
|
|
@@ -5,7 +5,7 @@ import VectorTileLayer from 'ol/layer/VectorTile.js'
|
|
|
5
5
|
import { createDatasetSource, createDatasetLayer, readGeoJSONFeatures } from './layerBuilders.js'
|
|
6
6
|
import { logger } from '../../../../../src/services/logger.js'
|
|
7
7
|
// The OL provider registers British National Grid when it loads
|
|
8
|
-
import '../../../../../providers/
|
|
8
|
+
import '../../../../../providers/openlayers/src/utils/bngProjection.js'
|
|
9
9
|
|
|
10
10
|
jest.mock('../../../../../src/services/logger.js', () => ({ logger: { warn: jest.fn() } }))
|
|
11
11
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { OpenLayersDataset } from './registry/openLayersDataset.js'
|
|
2
|
-
import { datasetRegistry } from '../../registry/datasetRegistry.js'
|
|
3
2
|
import { MapboxStyleLayerAdapter } from '../mapboxStyleLayerAdapter.js'
|
|
4
3
|
import { createDatasetSource, createDatasetLayer, resolveLayerStyle, readGeoJSONFeatures } from './layerBuilders.js'
|
|
5
4
|
import { logger } from '../../../../../src/services/logger.js'
|
|
@@ -21,21 +20,22 @@ export default class OpenLayersLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
21
20
|
* @param {Object} mapProvider - Map provider instance (e.g. OpenLayersProvider)
|
|
22
21
|
* @param {Object} symbolRegistry
|
|
23
22
|
* @param {Object} patternRegistry
|
|
23
|
+
* @param {Object} datasetRegistry - This plugin instance's dataset registry
|
|
24
24
|
*/
|
|
25
|
-
constructor (mapProvider, symbolRegistry, patternRegistry) {
|
|
26
|
-
super(mapProvider, symbolRegistry, patternRegistry)
|
|
25
|
+
constructor (mapProvider, symbolRegistry, patternRegistry, datasetRegistry) {
|
|
26
|
+
super(mapProvider, symbolRegistry, patternRegistry, datasetRegistry)
|
|
27
27
|
// sourceId → OL source, shared across sublayers of the same dataset
|
|
28
28
|
this._sourcesById = new Map()
|
|
29
29
|
// leaf layer id (== dataset/sublayer id) → OL layer
|
|
30
30
|
this._layersById = new Map()
|
|
31
31
|
// initialiseDatasets.js passes this to datasetRegistry.attachCreateDataset unbound, then
|
|
32
|
-
// calls it as
|
|
33
|
-
// the registry.
|
|
32
|
+
// calls it as datasetRegistry._createDataset(...) — bind so `this` still resolves here, not to
|
|
33
|
+
// the dataset registry.
|
|
34
34
|
this.createDataset = this.createDataset.bind(this)
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
createDataset (datasetDefinition) {
|
|
38
|
-
return new OpenLayersDataset(datasetDefinition)
|
|
37
|
+
createDataset (datasetDefinition, datasetRegistry) {
|
|
38
|
+
return new OpenLayersDataset(datasetDefinition, datasetRegistry)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
// What layer styles are resolved against — see layerBuilders.js's resolveLayerStyle. Symbol
|
|
@@ -43,7 +43,7 @@ export default class OpenLayersLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
43
43
|
// from there rather than from a module of its own.
|
|
44
44
|
get _styleContext () {
|
|
45
45
|
return {
|
|
46
|
-
mapStyleId:
|
|
46
|
+
mapStyleId: this._datasetRegistry.mapStyle?.id,
|
|
47
47
|
pixelRatio: this._pixelRatio,
|
|
48
48
|
patternRegistry: this._patternRegistry,
|
|
49
49
|
symbolRegistry: this._symbolRegistry,
|
|
@@ -57,7 +57,7 @@ export default class OpenLayersLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
57
57
|
|
|
58
58
|
async init () {
|
|
59
59
|
await Promise.all([this._registerPatterns(), this._registerSymbols()])
|
|
60
|
-
|
|
60
|
+
this._datasetRegistry.forEachDataset(registryDataset => this._addLayers(registryDataset))
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
destroy () {
|
|
@@ -66,13 +66,13 @@ export default class OpenLayersLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
66
66
|
this._sourcesById.clear()
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
// OL's basemap swap (see providers/
|
|
69
|
+
// OL's basemap swap (see providers/openlayers's appEvents.js) only replaces the base
|
|
70
70
|
// tile layer — dataset layers are separate map.addLayer() entries and are never wiped, so
|
|
71
71
|
// unlike MapLibre there's nothing to rebuild here, just colour tokens to re-resolve. Pattern
|
|
72
72
|
// fg/bg colours can be mapStyle-keyed too, so re-registering (not just re-styling) is needed.
|
|
73
73
|
async onMapStyleChange () {
|
|
74
74
|
await Promise.all([this._registerPatterns(), this._registerSymbols()])
|
|
75
|
-
|
|
75
|
+
this._datasetRegistry.forEachDataset(registryDataset => this._forEachLeafDataset(registryDataset, leaf => {
|
|
76
76
|
this._setLayerStyle(leaf)
|
|
77
77
|
}))
|
|
78
78
|
this._reapplyHighlights()
|
|
@@ -91,7 +91,7 @@ export default class OpenLayersLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
91
91
|
if (this._pixelRatio !== pixelRatio) {
|
|
92
92
|
return
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
this._datasetRegistry.forEachDataset(registryDataset => this._forEachLeafDataset(registryDataset, leaf => {
|
|
95
95
|
if (leaf.hasPattern || leaf.hasSymbol) {
|
|
96
96
|
this._setLayerStyle(leaf)
|
|
97
97
|
}
|
|
@@ -116,7 +116,7 @@ export default class OpenLayersLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
removeDataset (datasetId) {
|
|
119
|
-
const registryDataset =
|
|
119
|
+
const registryDataset = this._datasetRegistry.getDataset(datasetId)
|
|
120
120
|
if (!registryDataset) {
|
|
121
121
|
return
|
|
122
122
|
}
|
|
@@ -129,7 +129,7 @@ export default class OpenLayersLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
129
129
|
})
|
|
130
130
|
|
|
131
131
|
const { sourceId } = registryDataset
|
|
132
|
-
const sourceIsShared =
|
|
132
|
+
const sourceIsShared = this._datasetRegistry.topLevelDatasets()
|
|
133
133
|
.some(dataset => dataset.id !== datasetId && dataset.sourceId === sourceId)
|
|
134
134
|
if (!sourceIsShared) {
|
|
135
135
|
this._sourcesById.delete(sourceId)
|
|
@@ -137,7 +137,7 @@ export default class OpenLayersLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
async applyStyle (datasetId) {
|
|
140
|
-
const registryDataset =
|
|
140
|
+
const registryDataset = this._datasetRegistry.getDataset(datasetId)
|
|
141
141
|
if (!registryDataset) {
|
|
142
142
|
return
|
|
143
143
|
}
|
|
@@ -167,7 +167,7 @@ export default class OpenLayersLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
167
167
|
// filter means recomputing and re-setting style rather than a separate declarative call like
|
|
168
168
|
// MapLibre's map.setFilter.
|
|
169
169
|
applyFeatureFilter (datasetId) {
|
|
170
|
-
const registryDataset =
|
|
170
|
+
const registryDataset = this._datasetRegistry.getDataset(datasetId)
|
|
171
171
|
if (!registryDataset) {
|
|
172
172
|
return
|
|
173
173
|
}
|
|
@@ -177,7 +177,7 @@ export default class OpenLayersLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
setData (datasetId, geojson) {
|
|
180
|
-
const registryDataset =
|
|
180
|
+
const registryDataset = this._datasetRegistry.getDataset(datasetId)
|
|
181
181
|
const olSource = registryDataset && this._sourcesById.get(registryDataset.sourceId)
|
|
182
182
|
if (!olSource) {
|
|
183
183
|
return
|
|
@@ -194,7 +194,7 @@ export default class OpenLayersLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
194
194
|
// pixelRatio, so resolveLayerStyle (synchronous) can find it already resolved — mirrors
|
|
195
195
|
// MapLibreLayerAdapter's addPatternsAndSymbolsToMap, which likewise runs before _addLayers
|
|
196
196
|
// reads the dataset's style. See canvasPatternStyle.js for how the fill is used.
|
|
197
|
-
async _registerPatterns (registryDatasets =
|
|
197
|
+
async _registerPatterns (registryDatasets = this._datasetRegistry.topLevelDatasets()) {
|
|
198
198
|
const styles = []
|
|
199
199
|
registryDatasets.forEach(registryDataset => this._forEachLeafDataset(registryDataset, leaf => {
|
|
200
200
|
if (leaf.hasPattern) {
|
|
@@ -202,14 +202,14 @@ export default class OpenLayersLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
202
202
|
}
|
|
203
203
|
}))
|
|
204
204
|
if (styles.length) {
|
|
205
|
-
await this._mapProvider.addPatternsToMap(styles,
|
|
205
|
+
await this._mapProvider.addPatternsToMap(styles, this._datasetRegistry.mapStyle?.id, this._patternRegistry, this._pixelRatio)
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
// Rasterises and caches each symbol's icon image ahead of time, at the map's current
|
|
210
210
|
// pixelRatio, so OpenLayersDataset.getFlatStyle (synchronous) can find it already resolved —
|
|
211
211
|
// same convention as _registerPatterns.
|
|
212
|
-
async _registerSymbols (registryDatasets =
|
|
212
|
+
async _registerSymbols (registryDatasets = this._datasetRegistry.topLevelDatasets()) {
|
|
213
213
|
const styles = []
|
|
214
214
|
registryDatasets.forEach(registryDataset => this._forEachLeafDataset(registryDataset, leaf => {
|
|
215
215
|
if (leaf.hasSymbol) {
|
|
@@ -217,7 +217,7 @@ export default class OpenLayersLayerAdapter extends MapboxStyleLayerAdapter {
|
|
|
217
217
|
}
|
|
218
218
|
}))
|
|
219
219
|
if (styles.length) {
|
|
220
|
-
await this._mapProvider.addSymbolsToMap(styles,
|
|
220
|
+
await this._mapProvider.addSymbolsToMap(styles, this._datasetRegistry.mapStyle, this._symbolRegistry, this._pixelRatio)
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
|
|
@@ -3,11 +3,11 @@ import { datasetRegistry } from '../../registry/datasetRegistry.js'
|
|
|
3
3
|
import { createPatternRegistry } from '../../../../../src/services/patternRegistry.js'
|
|
4
4
|
import { createSymbolRegistry } from '../../../../../src/services/symbolRegistry.js'
|
|
5
5
|
import { logger } from '../../../../../src/services/logger.js'
|
|
6
|
-
import { SymbolImageCache } from '../../../../../providers/
|
|
7
|
-
import { PatternImageCache } from '../../../../../providers/
|
|
8
|
-
import { buildFilterEvaluator } from '../../../../../providers/
|
|
6
|
+
import { SymbolImageCache } from '../../../../../providers/openlayers/src/utils/symbolImages.js'
|
|
7
|
+
import { PatternImageCache } from '../../../../../providers/openlayers/src/utils/patternImages.js'
|
|
8
|
+
import { buildFilterEvaluator } from '../../../../../providers/openlayers/src/utils/filterEvaluator.js'
|
|
9
9
|
// The OL provider registers British National Grid when it loads
|
|
10
|
-
import '../../../../../providers/
|
|
10
|
+
import '../../../../../providers/openlayers/src/utils/bngProjection.js'
|
|
11
11
|
import VectorLayer from 'ol/layer/Vector.js'
|
|
12
12
|
import VectorTileLayer from 'ol/layer/VectorTile.js'
|
|
13
13
|
import * as layerBuilders from './layerBuilders.js'
|
|
@@ -72,7 +72,7 @@ let map, mapProvider, adapter
|
|
|
72
72
|
beforeEach(() => {
|
|
73
73
|
map = makeMap()
|
|
74
74
|
mapProvider = makeMapProvider(map)
|
|
75
|
-
adapter = new OpenLayersLayerAdapter(mapProvider, symbolRegistry, patternRegistry)
|
|
75
|
+
adapter = new OpenLayersLayerAdapter(mapProvider, symbolRegistry, patternRegistry, datasetRegistry)
|
|
76
76
|
datasetRegistry.attachCreateDataset(adapter.createDataset)
|
|
77
77
|
datasetRegistry.mockExtend({
|
|
78
78
|
'ds-fill': { id: 'ds-fill', style: { fill: '#0000ff' }, geojson: { type: 'FeatureCollection', features: [point(1, [0, 0])] } },
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { MapboxStyleDataset } from '../../../registry/mapboxStyleDataset.js'
|
|
2
|
-
import { datasetRegistry } from '../../../registry/datasetRegistry.js'
|
|
3
2
|
import { getValueForStyle } from '../../../../../../src/utils/getValueForStyle.js'
|
|
4
3
|
|
|
5
4
|
const MAX_TILE_ZOOM = 22
|
|
@@ -111,7 +110,7 @@ export class OpenLayersDataset extends MapboxStyleDataset {
|
|
|
111
110
|
if (!this.hasSymbol) {
|
|
112
111
|
return null
|
|
113
112
|
}
|
|
114
|
-
const imageId = symbolRegistry.getSymbolImageId(this.style,
|
|
113
|
+
const imageId = symbolRegistry.getSymbolImageId(this.style, this._datasetRegistry.mapStyle, 'normal', pixelRatio)
|
|
115
114
|
if (!imageId) {
|
|
116
115
|
return null
|
|
117
116
|
}
|
|
@@ -154,7 +153,7 @@ export class OpenLayersDataset extends MapboxStyleDataset {
|
|
|
154
153
|
if (this.hasSymbol) {
|
|
155
154
|
return this._symbolStyle(context)
|
|
156
155
|
}
|
|
157
|
-
const mapStyleId =
|
|
156
|
+
const mapStyleId = this._datasetRegistry.mapStyle?.id
|
|
158
157
|
const style = {}
|
|
159
158
|
if (this.hasFill && !this.hasPattern) {
|
|
160
159
|
style['fill-color'] = getValueForStyle(this.style.fill, mapStyleId)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenLayersDataset } from './openLayersDataset.js'
|
|
2
2
|
import { datasetRegistry } from '../../../registry/datasetRegistry.js'
|
|
3
3
|
import { createSymbolRegistry } from '../../../../../../src/services/symbolRegistry.js'
|
|
4
|
-
import { SymbolImageCache } from '../../../../../../providers/
|
|
4
|
+
import { SymbolImageCache } from '../../../../../../providers/openlayers/src/utils/symbolImages.js'
|
|
5
5
|
|
|
6
6
|
const symbolRegistry = createSymbolRegistry()
|
|
7
7
|
// Use the mock datasetRegistry with the demo datasets attached before each test
|
|
@@ -34,7 +34,7 @@ beforeAll(() => {
|
|
|
34
34
|
|
|
35
35
|
describe('OpenLayersDataset', () => {
|
|
36
36
|
beforeEach(() => {
|
|
37
|
-
datasetRegistry.attachCreateDataset(def => new OpenLayersDataset(def))
|
|
37
|
+
datasetRegistry.attachCreateDataset(def => new OpenLayersDataset(def, datasetRegistry))
|
|
38
38
|
datasetRegistry.mockExtend({
|
|
39
39
|
'ds-fill-only': { id: 'ds-fill-only', style: { fill: 'blue' } },
|
|
40
40
|
'ds-stroke-only': { id: 'ds-stroke-only', style: { stroke: 'red', strokeWidth: 2 } },
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { logger } from '../../../../src/services/logger.js'
|
|
2
|
-
import { datasetRegistry } from '../registry/datasetRegistry.js'
|
|
3
2
|
|
|
4
|
-
export const getOpacity = ({ pluginState: { globals } }, options = {}) => {
|
|
3
|
+
export const getOpacity = ({ pluginState: { globals, datasetRegistry } }, options = {}) => {
|
|
5
4
|
const { datasetId, sublayerId } = options
|
|
6
5
|
const fullId = sublayerId ? `${datasetId}-${sublayerId}` : datasetId
|
|
7
6
|
if (fullId) {
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { getOpacity } from './getOpacity.js'
|
|
2
|
-
import { datasetRegistry } from '../registry/datasetRegistry.js'
|
|
3
2
|
import { logger } from '../../../../src/services/logger.js'
|
|
4
3
|
|
|
5
|
-
jest.
|
|
6
|
-
datasetRegistry: { getDataset: jest.fn() }
|
|
7
|
-
}))
|
|
4
|
+
const datasetRegistry = { getDataset: jest.fn() }
|
|
8
5
|
|
|
9
6
|
jest.mock('../../../../src/services/logger.js')
|
|
10
7
|
|
|
@@ -15,12 +12,12 @@ describe('getOpacity', () => {
|
|
|
15
12
|
|
|
16
13
|
describe('global (no datasetId)', () => {
|
|
17
14
|
it('returns globals.opacity when set', () => {
|
|
18
|
-
const ctx = { pluginState: { globals: { opacity: 0.5 } } }
|
|
15
|
+
const ctx = { pluginState: { globals: { opacity: 0.5 }, datasetRegistry } }
|
|
19
16
|
expect(getOpacity(ctx)).toBe(0.5)
|
|
20
17
|
})
|
|
21
18
|
|
|
22
19
|
it('returns null when globals.opacity is undefined', () => {
|
|
23
|
-
const ctx = { pluginState: { globals: {} } }
|
|
20
|
+
const ctx = { pluginState: { globals: {}, datasetRegistry } }
|
|
24
21
|
expect(getOpacity(ctx)).toBeNull()
|
|
25
22
|
})
|
|
26
23
|
})
|
|
@@ -28,19 +25,19 @@ describe('getOpacity', () => {
|
|
|
28
25
|
describe('with datasetId', () => {
|
|
29
26
|
it('returns opacity from the registry dataset', () => {
|
|
30
27
|
datasetRegistry.getDataset.mockReturnValue({ opacity: 0.7 })
|
|
31
|
-
const ctx = { pluginState: { globals: {} } }
|
|
28
|
+
const ctx = { pluginState: { globals: {}, datasetRegistry } }
|
|
32
29
|
expect(getOpacity(ctx, { datasetId: 'my-dataset' })).toBe(0.7)
|
|
33
30
|
})
|
|
34
31
|
|
|
35
32
|
it('returns null when the dataset has no opacity property', () => {
|
|
36
33
|
datasetRegistry.getDataset.mockReturnValue({})
|
|
37
|
-
const ctx = { pluginState: { globals: {} } }
|
|
34
|
+
const ctx = { pluginState: { globals: {}, datasetRegistry } }
|
|
38
35
|
expect(getOpacity(ctx, { datasetId: 'my-dataset' })).toBeNull()
|
|
39
36
|
})
|
|
40
37
|
|
|
41
38
|
it('returns null and warns when the dataset is not found', () => {
|
|
42
39
|
datasetRegistry.getDataset.mockReturnValue(undefined)
|
|
43
|
-
const ctx = { pluginState: { globals: {} } }
|
|
40
|
+
const ctx = { pluginState: { globals: {}, datasetRegistry } }
|
|
44
41
|
expect(getOpacity(ctx, { datasetId: 'missing' })).toBeNull()
|
|
45
42
|
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining('missing'))
|
|
46
43
|
})
|
|
@@ -49,20 +46,20 @@ describe('getOpacity', () => {
|
|
|
49
46
|
describe('with sublayerId', () => {
|
|
50
47
|
it('combines datasetId and sublayerId for the registry lookup', () => {
|
|
51
48
|
datasetRegistry.getDataset.mockReturnValue({ opacity: 0.3 })
|
|
52
|
-
const ctx = { pluginState: { globals: {} } }
|
|
49
|
+
const ctx = { pluginState: { globals: {}, datasetRegistry } }
|
|
53
50
|
getOpacity(ctx, { datasetId: 'parent', sublayerId: 'child' })
|
|
54
51
|
expect(datasetRegistry.getDataset).toHaveBeenCalledWith('parent-child')
|
|
55
52
|
})
|
|
56
53
|
|
|
57
54
|
it('returns opacity for the combined id', () => {
|
|
58
55
|
datasetRegistry.getDataset.mockReturnValue({ opacity: 0.3 })
|
|
59
|
-
const ctx = { pluginState: { globals: {} } }
|
|
56
|
+
const ctx = { pluginState: { globals: {}, datasetRegistry } }
|
|
60
57
|
expect(getOpacity(ctx, { datasetId: 'parent', sublayerId: 'child' })).toBe(0.3)
|
|
61
58
|
})
|
|
62
59
|
|
|
63
60
|
it('returns null and warns when the sublayer dataset is not found', () => {
|
|
64
61
|
datasetRegistry.getDataset.mockReturnValue(undefined)
|
|
65
|
-
const ctx = { pluginState: { globals: {} } }
|
|
62
|
+
const ctx = { pluginState: { globals: {}, datasetRegistry } }
|
|
66
63
|
expect(getOpacity(ctx, { datasetId: 'parent', sublayerId: 'missing' })).toBeNull()
|
|
67
64
|
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining('parent-missing'))
|
|
68
65
|
})
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { logger } from '../../../../src/services/logger.js'
|
|
2
|
-
import { datasetRegistry } from '../registry/datasetRegistry.js'
|
|
3
2
|
|
|
4
|
-
export const getStyle = ({
|
|
3
|
+
export const getStyle = ({ pluginState: { datasetRegistry } }, { datasetId, sublayerId } = {}) => {
|
|
5
4
|
datasetId = sublayerId ? `${datasetId}-${sublayerId}` : datasetId
|
|
6
5
|
const registryDataset = datasetRegistry.getDataset(datasetId)
|
|
7
6
|
if (!registryDataset) {
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { getStyle } from './getStyle.js'
|
|
2
|
-
import { datasetRegistry } from '../registry/datasetRegistry.js'
|
|
3
2
|
import { logger } from '../../../../src/services/logger.js'
|
|
4
3
|
|
|
5
|
-
jest.
|
|
6
|
-
datasetRegistry: { getDataset: jest.fn() }
|
|
7
|
-
}))
|
|
4
|
+
const datasetRegistry = { getDataset: jest.fn() }
|
|
8
5
|
|
|
9
6
|
jest.mock('../../../../src/services/logger.js')
|
|
10
7
|
|
|
@@ -16,25 +13,25 @@ describe('getStyle', () => {
|
|
|
16
13
|
it('returns the style for a known dataset', () => {
|
|
17
14
|
const style = { fill: 'blue', stroke: 'red' }
|
|
18
15
|
datasetRegistry.getDataset.mockReturnValue({ style })
|
|
19
|
-
expect(getStyle({}, { datasetId: 'roads' })).toBe(style)
|
|
16
|
+
expect(getStyle({ pluginState: { datasetRegistry } }, { datasetId: 'roads' })).toBe(style)
|
|
20
17
|
})
|
|
21
18
|
|
|
22
19
|
it('returns style for the combined sublayer id', () => {
|
|
23
20
|
const style = { fill: 'green' }
|
|
24
21
|
datasetRegistry.getDataset.mockReturnValue({ style })
|
|
25
|
-
expect(getStyle({}, { datasetId: 'parent', sublayerId: 'child' })).toBe(style)
|
|
22
|
+
expect(getStyle({ pluginState: { datasetRegistry } }, { datasetId: 'parent', sublayerId: 'child' })).toBe(style)
|
|
26
23
|
expect(datasetRegistry.getDataset).toHaveBeenCalledWith('parent-child')
|
|
27
24
|
})
|
|
28
25
|
|
|
29
26
|
it('returns null and warns when a sublayer dataset is not found', () => {
|
|
30
27
|
datasetRegistry.getDataset.mockReturnValue(undefined)
|
|
31
|
-
expect(getStyle({}, { datasetId: 'parent', sublayerId: 'missing' })).toBeNull()
|
|
28
|
+
expect(getStyle({ pluginState: { datasetRegistry } }, { datasetId: 'parent', sublayerId: 'missing' })).toBeNull()
|
|
32
29
|
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining('parent-missing'))
|
|
33
30
|
})
|
|
34
31
|
|
|
35
32
|
it('uses undefined datasetId when options argument is omitted', () => {
|
|
36
33
|
datasetRegistry.getDataset.mockReturnValue(undefined)
|
|
37
|
-
expect(getStyle({})).toBeNull()
|
|
34
|
+
expect(getStyle({ pluginState: { datasetRegistry } })).toBeNull()
|
|
38
35
|
expect(logger.warn).toHaveBeenCalledWith('getStyle: Dataset with id undefined not found')
|
|
39
36
|
})
|
|
40
37
|
})
|