@defra/interactive-map 0.0.54-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/add-polygons.njk +1 -1
- package/assets/templates/add-symbols.njk +4 -4
- package/assets/templates/draw-tools.njk +7 -7
- package/assets/templates/marker-panel.njk +5 -5
- package/assets/templates/place-marker.njk +8 -8
- package/assets/templates/search-control.njk +1 -1
- package/assets/templates/select-feature.njk +7 -7
- package/assets/templates/style-switcher.njk +6 -6
- package/assets/templates/toggle-marker-label.njk +3 -3
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/im-core.js.LICENSE.txt +0 -30
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.LICENSE.txt +0 -20
- package/docs/api/context.md +2 -0
- package/docs/api.md +20 -14
- package/docs/architecture/interactive-map.likec4 +4 -4
- package/docs/building-a-plugin.md +2 -2
- package/docs/examples/add-marker-with-panel.mdx +46 -44
- package/docs/examples/add-polygons.mdx +100 -98
- package/docs/examples/add-symbols.mdx +75 -73
- package/docs/examples/basic-map.mdx +16 -14
- package/docs/examples/button-map.mdx +16 -14
- package/docs/examples/draw-tools.mdx +119 -117
- package/docs/examples/place-marker.mdx +51 -49
- package/docs/examples/search-control.mdx +22 -20
- package/docs/examples/select-feature.mdx +107 -105
- package/docs/examples/style-switcher.mdx +47 -45
- package/docs/examples/toggle-marker-label.mdx +30 -28
- package/docs/getting-started.md +26 -24
- package/docs/plugins/datasets.md +11 -0
- package/docs/plugins/draw.md +18 -12
- package/docs/plugins/interact.md +33 -10
- package/docs/plugins/plugin-descriptor.md +1 -1
- package/docs/plugins/search.md +5 -5
- package/docusaurus.config.cjs +48 -3
- package/govuk-prototype-kit.config.json +6 -7
- package/package.json +22 -29
- 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/layerAdapter.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-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 +47 -26
- package/plugins/draw/src/DrawInit.test.jsx +90 -2
- package/plugins/draw/src/adapters/maplibre/styles.js +3 -2
- package/plugins/draw/src/adapters/maplibre/styles.test.js +3 -3
- 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/im-draw-es-plugin.js +1 -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/im-frame-plugin.js +1 -0
- package/plugins/frame/dist/esm/index.js +1 -0
- package/plugins/frame/dist/umd/im-frame-plugin.js +1 -0
- package/plugins/frame/dist/umd/index.js +2 -0
- 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/im-map-styles-plugin.js +1 -0
- package/plugins/map-styles/dist/esm/index.js +1 -0
- package/plugins/map-styles/dist/umd/im-map-styles-plugin.js +1 -0
- package/plugins/map-styles/dist/umd/index.js +2 -0
- 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/im-menu-plugin.js +1 -1
- package/plugins/menu/dist/esm/index.js +1 -1
- package/plugins/menu/dist/umd/im-menu-plugin.js +1 -1
- package/plugins/menu/dist/umd/index.js +1 -1
- package/plugins/scale-bar/dist/esm/im-scale-bar-plugin.js +1 -0
- package/plugins/scale-bar/dist/esm/index.js +1 -0
- package/plugins/scale-bar/dist/umd/im-scale-bar-plugin.js +1 -0
- package/plugins/scale-bar/dist/umd/index.js +2 -0
- 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/im-use-location-plugin.js +1 -0
- package/plugins/use-location/dist/esm/index.js +1 -0
- package/plugins/use-location/dist/umd/im-use-location-plugin.js +1 -0
- package/plugins/use-location/dist/umd/index.js +2 -0
- package/providers/esri/dist/esm/im-esri-provider.js +1 -0
- 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/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/esm/index.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js.LICENSE.txt +3 -3
- package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-worker.js +2 -0
- package/providers/maplibre/dist/umd/im-maplibre-worker.js.LICENSE.txt +4 -0
- package/providers/maplibre/dist/umd/index.js +1 -1
- package/providers/maplibre/src/index.js +41 -12
- package/providers/maplibre/src/index.test.js +43 -12
- package/providers/maplibre/src/utils/detectModuleWorker.js +25 -0
- package/providers/maplibre/src/utils/detectModuleWorker.test.js +40 -0
- package/providers/maplibre/src/utils/spatial.js +22 -12
- package/providers/maplibre/src/utils/spatial.test.js +6 -6
- package/providers/maplibre/src/utils/workerUrl.js +15 -0
- package/providers/maplibre/src/utils/workerUrl.test.js +14 -0
- package/providers/open-names/dist/esm/im-reverse-geocode.js +1 -0
- package/providers/open-names/dist/esm/index.js +1 -0
- package/providers/open-names/dist/umd/im-reverse-geocode.js +2 -0
- package/providers/open-names/dist/umd/index.js +2 -0
- package/providers/openlayers/dist/esm/im-openlayers-provider.js +1 -0
- package/providers/openlayers/dist/esm/index.js +1 -0
- package/providers/openlayers/dist/umd/im-openlayers-provider.js +2 -0
- package/providers/openlayers/dist/umd/index.js +2 -0
- package/providers/openlayers/src/index.js +60 -0
- package/providers/openlayers/src/index.test.js +47 -0
- 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 +79 -46
- 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/InteractiveMap.js +2 -1
- package/src/InteractiveMap/InteractiveMap.test.js +9 -2
- package/src/InteractiveMap/domStateManager.js +21 -1
- package/src/InteractiveMap/domStateManager.test.js +48 -1
- package/src/InteractiveMap/parseDataProperties.js +4 -4
- package/src/InteractiveMap/parseDataProperties.test.js +62 -6
- package/src/InteractiveMap/polyfills.js +4 -3
- package/src/InteractiveMap/polyfills.test.js +12 -0
- package/src/config/events.js +4 -2
- package/src/scss/tools/_govuk-content.scss +4 -3
- package/src/types.js +3 -5
- package/webpack.dev.mjs +11 -3
- package/webpack.prod.mjs +11 -4
- package/webpack.umd.mjs +34 -14
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +0 -1
- 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/im-frame-plugin.js +0 -1
- package/plugins/beta/frame/dist/esm/index.js +0 -1
- package/plugins/beta/frame/dist/umd/im-frame-plugin.js +0 -1
- package/plugins/beta/frame/dist/umd/index.js +0 -2
- package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +0 -1
- package/plugins/beta/map-styles/dist/esm/index.js +0 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +0 -1
- package/plugins/beta/map-styles/dist/umd/index.js +0 -2
- package/plugins/beta/scale-bar/dist/esm/im-scale-bar-plugin.js +0 -1
- package/plugins/beta/scale-bar/dist/esm/index.js +0 -1
- package/plugins/beta/scale-bar/dist/umd/im-scale-bar-plugin.js +0 -1
- package/plugins/beta/scale-bar/dist/umd/index.js +0 -2
- package/plugins/beta/use-location/dist/esm/im-use-location-plugin.js +0 -1
- package/plugins/beta/use-location/dist/esm/index.js +0 -1
- package/plugins/beta/use-location/dist/umd/im-use-location-plugin.js +0 -1
- package/plugins/beta/use-location/dist/umd/index.js +0 -2
- 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/im-esri-provider.js +0 -1
- package/providers/beta/esri/dist/esm/index.js +0 -1
- package/providers/beta/open-names/dist/esm/im-reverse-geocode.js +0 -1
- package/providers/beta/open-names/dist/esm/index.js +0 -1
- package/providers/beta/open-names/dist/umd/im-reverse-geocode.js +0 -2
- package/providers/beta/open-names/dist/umd/index.js +0 -2
- package/providers/beta/openlayers/dist/esm/im-openlayers-provider.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 +0 -2
- package/providers/beta/openlayers/dist/umd/index.js.LICENSE.txt +0 -1
- package/providers/beta/openlayers/src/index.js +0 -37
- /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/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/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/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/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}/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/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/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/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,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("defra",[],r):"object"==typeof exports?exports.defra=r():(e.defra=e.defra||{},e.defra.maplibreProvider=r())}(this,()
|
|
2
|
+
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("defra",[],r):"object"==typeof exports?exports.defra=r():(e.defra=e.defra||{},e.defra.maplibreProvider=r())}(Object("undefined"!=typeof self?self:this),function(){return function(){"use strict";var e,r,t={21:function(e,r,t){e.exports=t.p+"im-maplibre-worker.js"}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.m=t,o.d=function(e,r){for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.f={},o.e=function(e){return Promise.all(Object.keys(o.f).reduce(function(r,t){return o.f[t](e,r),r},[]))},o.u=function(e){return{649:"im-maplibre-framework",772:"im-maplibre-provider"}[e]+".js"},o.miniCssF=function(e){},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},e={},r="defra.maplibreProvider:",o.l=function(t,n,i,u){if(e[t])e[t].push(n);else{var a,c;if(void 0!==i)for(var f=document.getElementsByTagName("script"),l=0;l<f.length;l++){var p=f[l];if(p.getAttribute("src")==t||p.getAttribute("data-webpack")==r+i){a=p;break}}a||(c=!0,(a=document.createElement("script")).charset="utf-8",o.nc&&a.setAttribute("nonce",o.nc),a.setAttribute("data-webpack",r+i),a.src=t),e[t]=[n];var s=function(r,n){a.onerror=a.onload=null,clearTimeout(d);var o=e[t];if(delete e[t],a.parentNode&&a.parentNode.removeChild(a),o&&o.forEach(function(e){return e(n)}),r)return r(n)},d=setTimeout(s.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=s.bind(null,a.onerror),a.onload=s.bind(null,a.onload),c&&document.head.appendChild(a)}},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},function(){var e;o.g.importScripts&&(e=o.g.location+"");var r=o.g.document;if(!e&&r&&(r.currentScript&&"SCRIPT"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName("script");if(t.length)for(var n=t.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=t[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e}(),function(){o.b="undefined"!=typeof document&&document.baseURI||self.location.href;var e={57:0};o.f.j=function(r,t){var n=o.o(e,r)?e[r]:void 0;if(0!==n)if(n)t.push(n[2]);else{var i=new Promise(function(t,o){n=e[r]=[t,o]});t.push(n[2]=i);var u=o.p+o.u(r),a=new Error;o.l(u,function(t){if(o.o(e,r)&&(0!==(n=e[r])&&(e[r]=void 0),n)){var i=t&&("load"===t.type?"missing":t.type),u=t&&t.target&&t.target.src;a.message="Loading chunk "+r+" failed.\n("+i+": "+u+")",a.name="ChunkLoadError",a.type=i,a.request=u,n[1](a)}},"chunk-"+r,r)}};var r=function(r,t){var n,i,u=t[0],a=t[1],c=t[2],f=0;if(u.some(function(r){return 0!==e[r]})){for(n in a)o.o(a,n)&&(o.m[n]=a[n]);c&&c(o)}for(r&&r(t);f<u.length;f++)i=u[f],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0},t=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))}();var i={};function u(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}o.d(i,{default:function(){return m}});var a=function(e){if(!window.WebGLRenderingContext)return{isEnabled:!1,error:"WebGL is not supported"};var r,t=document.createElement("canvas"),n=!1,o=function(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return u(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?u(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==t.return||t.return()}finally{if(c)throw i}}}}(e);try{for(o.s();!(r=o.n()).done;){var i=r.value;try{if((n=t.getContext(i))&&"function"==typeof n.getParameter)return{isEnabled:!0}}catch(e){}}}catch(e){o.e(e)}finally{o.f()}return{isEnabled:!1,error:"WebGL is supported, but disabled"}},c=function(){if("undefined"==typeof Worker)return!1;var e=!1,r={get type(){return e=!0,"module"}};try{new Worker("blob://",r).terminate()}catch(e){}return e},f=function(e){var r=new URL(o(21),o.b);return r.searchParams.set("v",e),r.href};function l(e){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l(e)}function p(){var e,r,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",o=t.toStringTag||"@@toStringTag";function i(t,n,o,i){var c=n&&n.prototype instanceof a?n:a,f=Object.create(c.prototype);return s(f,"_invoke",function(t,n,o){var i,a,c,f=0,l=o||[],p=!1,s={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(r,t){return i=r,a=0,c=e,s.n=t,u}};function d(t,n){for(a=t,c=n,r=0;!p&&f&&!o&&r<l.length;r++){var o,i=l[r],d=s.p,b=i[2];t>3?(o=b===n)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=t<2&&d<i[1])?(a=0,s.v=n,s.n=i[1]):d<b&&(o=t<3||i[0]>n||n>b)&&(i[4]=t,i[5]=n,s.n=b,a=0))}if(o||t>1)return u;throw p=!0,n}return function(o,l,b){if(f>1)throw TypeError("Generator is already running");for(p&&1===l&&d(l,b),a=l,c=b;(r=a<2?e:c)||!p;){i||(a?a<3?(a>1&&(s.n=-1),d(a,c)):s.n=c:s.v=c);try{if(f=2,i){if(a||(o="next"),r=i[o]){if(!(r=r.call(i,c)))throw TypeError("iterator result is not an object");if(!r.done)return r;c=r.value,a<2&&(a=0)}else 1===a&&(r=i.return)&&r.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=e}else if((r=(p=s.n<0)?c:t.call(n,s))!==u)break}catch(r){i=e,a=1,c=r}finally{f=1}}return{value:r,done:p}}}(t,o,i),!0),f}var u={};function a(){}function c(){}function f(){}r=Object.getPrototypeOf;var l=[][n]?r(r([][n]())):(s(r={},n,function(){return this}),r),d=f.prototype=a.prototype=Object.create(l);function b(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,s(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return c.prototype=f,s(d,"constructor",f),s(f,"constructor",c),c.displayName="GeneratorFunction",s(f,o,"GeneratorFunction"),s(d),s(d,o,"Generator"),s(d,n,function(){return this}),s(d,"toString",function(){return"[object Generator]"}),(p=function(){return{w:i,m:b}})()}function s(e,r,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}s=function(e,r,t,n){function i(r,t){s(e,r,function(e){return this._invoke(r,t,e)})}r?o?o(e,r,{value:t,enumerable:!n,configurable:!n,writable:!n}):e[r]=t:(i("next",0),i("throw",1),i("return",2))},s(e,r,t,n)}function d(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function b(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?d(Object(t),!0).forEach(function(r){y(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):d(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function y(e,r,t){return(r=function(e){var r=function(e){if("object"!=l(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var t=r.call(e,"string");if("object"!=l(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==l(r)?r:r+""}(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function v(e,r,t,n,o,i,u){try{var a=e[i](u),c=a.value}catch(e){return void t(e)}a.done?r(c):Promise.resolve(c).then(n,o)}function m(){var e,r,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{checkDeviceCapabilities:function(){var e=function(){if(document.documentMode)return"Internet Explorer is not supported";var e=a(["webgl2"]);return e.isEnabled?function(){if("function"!=typeof(null===Intl||void 0===Intl?void 0:Intl.supportedValuesOf))return!1;try{return new RegExp("(?<=a)b").test("ab")}catch(e){return!1}}()?c()?void 0:"Browser does not support module workers":"Browser does not support the JavaScript features MapLibre requires":e.error}();return{isSupported:!e,error:e}},load:(e=p().m(function e(){var r,n,i;return p().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,o.e(649).then(o.bind(o,868));case 1:return(r=e.v).setWorkerUrl(t.workerUrl||f(r.getVersion())),e.n=2,o.e(772).then(o.bind(o,988));case 2:return n=e.v.default,i=b(b({},t),{},{crs:"EPSG:4326"}),e.a(2,{MapProvider:n,mapProviderConfig:i,mapFramework:r})}},e)}),r=function(){var r=this,t=arguments;return new Promise(function(n,o){var i=e.apply(r,t);function u(e){v(i,n,o,u,a,"next",e)}function a(e){v(i,n,o,u,a,"throw",e)}u(void 0)})},function(){return r.apply(this,arguments)})}}return i.default}()});
|
|
@@ -6,17 +6,49 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { getWebGL } from './utils/detectWebgl.js'
|
|
9
|
+
import { supportsModuleWorkers } from './utils/detectModuleWorker.js'
|
|
10
|
+
import { getWorkerUrl } from './utils/workerUrl.js'
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
|
-
* Checks whether the browser
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* Checks whether the browser can parse and run MapLibre. Its newest syntax is class
|
|
14
|
+
* static blocks (Chrome 94 / Firefox 93 / Safari 16.4), which cannot be detected
|
|
15
|
+
* without `eval`, so two proxies that polyfills don't provide are used:
|
|
16
|
+
* `Intl.supportedValuesOf` (Chrome 99 / Firefox 93) and RegExp lookbehind, which
|
|
17
|
+
* Safari gained in 16.4.
|
|
15
18
|
*
|
|
16
19
|
* @returns {boolean} true if modern syntax is supported, false otherwise
|
|
17
20
|
*/
|
|
18
21
|
function supportsModernMaplibre () {
|
|
19
|
-
|
|
22
|
+
if (typeof Intl?.supportedValuesOf !== 'function') {
|
|
23
|
+
return false
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
return new RegExp('(?<=a)b').test('ab') // eslint-disable-line prefer-regex-literals -- NOSONAR: a literal would be a syntax error in browsers without lookbehind
|
|
27
|
+
} catch (_) { // NOSONAR - a SyntaxError means lookbehind is unsupported
|
|
28
|
+
return false
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Returns the reason the device cannot run MapLibre, or undefined if it can.
|
|
34
|
+
*
|
|
35
|
+
* @returns {string|undefined}
|
|
36
|
+
*/
|
|
37
|
+
function getUnsupportedReason () {
|
|
38
|
+
if (document.documentMode) {
|
|
39
|
+
return 'Internet Explorer is not supported'
|
|
40
|
+
}
|
|
41
|
+
const webGL = getWebGL(['webgl2'])
|
|
42
|
+
if (!webGL.isEnabled) {
|
|
43
|
+
return webGL.error
|
|
44
|
+
}
|
|
45
|
+
if (!supportsModernMaplibre()) {
|
|
46
|
+
return 'Browser does not support the JavaScript features MapLibre requires'
|
|
47
|
+
}
|
|
48
|
+
if (!supportsModuleWorkers()) {
|
|
49
|
+
return 'Browser does not support module workers'
|
|
50
|
+
}
|
|
51
|
+
return undefined
|
|
20
52
|
}
|
|
21
53
|
|
|
22
54
|
/**
|
|
@@ -28,20 +60,17 @@ function supportsModernMaplibre () {
|
|
|
28
60
|
export default function createMapLibreProvider (config = {}) {
|
|
29
61
|
return {
|
|
30
62
|
checkDeviceCapabilities: () => {
|
|
31
|
-
const
|
|
32
|
-
const isIE = document.documentMode
|
|
63
|
+
const error = getUnsupportedReason()
|
|
33
64
|
return {
|
|
34
|
-
isSupported:
|
|
35
|
-
error
|
|
65
|
+
isSupported: !error,
|
|
66
|
+
error
|
|
36
67
|
}
|
|
37
68
|
},
|
|
38
69
|
/** @returns {Promise<MapProviderLoadResult>} */
|
|
39
70
|
load: async () => {
|
|
40
71
|
const mapFramework = await import(/* webpackChunkName: "im-maplibre-framework" */ 'maplibre-gl')
|
|
41
72
|
|
|
42
|
-
|
|
43
|
-
mapFramework.setWorkerUrl(config.workerUrl)
|
|
44
|
-
}
|
|
73
|
+
mapFramework.setWorkerUrl(config.workerUrl || getWorkerUrl(mapFramework.getVersion()))
|
|
45
74
|
|
|
46
75
|
const MapProvider = (await import(/* webpackChunkName: "im-maplibre-provider" */ './maplibreProvider.js')).default
|
|
47
76
|
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import createMapLibreProvider from './index.js'
|
|
2
2
|
import { getWebGL } from './utils/detectWebgl.js'
|
|
3
|
+
import { supportsModuleWorkers } from './utils/detectModuleWorker.js'
|
|
3
4
|
import * as maplibreGl from 'maplibre-gl'
|
|
4
5
|
|
|
5
6
|
jest.mock('./utils/detectWebgl.js', () => ({ getWebGL: jest.fn() }))
|
|
6
|
-
jest.mock('
|
|
7
|
+
jest.mock('./utils/detectModuleWorker.js', () => ({ supportsModuleWorkers: jest.fn() }))
|
|
8
|
+
jest.mock('./utils/workerUrl.js', () => ({ getWorkerUrl: (version) => `http://localhost/maplibre-gl-worker.mjs?v=${version}` }))
|
|
9
|
+
jest.mock('maplibre-gl', () => ({ getVersion: () => '6.0.0', setWorkerUrl: jest.fn() }))
|
|
7
10
|
jest.mock('./maplibreProvider.js', () => ({ default: class MockProvider {} }))
|
|
8
11
|
|
|
9
12
|
describe('createMapLibreProvider', () => {
|
|
10
13
|
beforeEach(() => {
|
|
11
14
|
getWebGL.mockReturnValue({ isEnabled: true, error: null })
|
|
15
|
+
supportsModuleWorkers.mockReturnValue(true)
|
|
12
16
|
})
|
|
13
17
|
|
|
14
18
|
afterEach(() => {
|
|
15
19
|
jest.clearAllMocks()
|
|
16
20
|
})
|
|
17
21
|
|
|
18
|
-
test('checkDeviceCapabilities:
|
|
22
|
+
test('checkDeviceCapabilities: WebGL2, modern browser, module workers, no IE → isSupported true', () => {
|
|
19
23
|
const result = createMapLibreProvider().checkDeviceCapabilities()
|
|
20
24
|
|
|
21
25
|
expect(result.isSupported).toBe(true)
|
|
22
26
|
expect(result.error).toBeFalsy()
|
|
23
|
-
expect(getWebGL).toHaveBeenCalledWith(['webgl2'
|
|
27
|
+
expect(getWebGL).toHaveBeenCalledWith(['webgl2'])
|
|
24
28
|
})
|
|
25
29
|
|
|
26
30
|
test('checkDeviceCapabilities: WebGL disabled → isSupported false, returns webGL error', () => {
|
|
@@ -40,6 +44,7 @@ describe('createMapLibreProvider', () => {
|
|
|
40
44
|
|
|
41
45
|
try {
|
|
42
46
|
const result = createMapLibreProvider().checkDeviceCapabilities()
|
|
47
|
+
expect(result.isSupported).toBe(false)
|
|
43
48
|
expect(result.error).toBe('Internet Explorer is not supported')
|
|
44
49
|
} finally {
|
|
45
50
|
Object.defineProperty(document, 'documentMode', {
|
|
@@ -49,14 +54,40 @@ describe('createMapLibreProvider', () => {
|
|
|
49
54
|
}
|
|
50
55
|
})
|
|
51
56
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
// Not Object.hasOwn: polyfills.js adds it before this check runs
|
|
58
|
+
test('checkDeviceCapabilities: no Intl.supportedValuesOf → isSupported false', () => {
|
|
59
|
+
const restoreSupportedValuesOf = Intl.supportedValuesOf
|
|
60
|
+
delete Intl.supportedValuesOf
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
const result = createMapLibreProvider().checkDeviceCapabilities()
|
|
64
|
+
expect(result.isSupported).toBe(false)
|
|
65
|
+
expect(result.error).toBe('Browser does not support the JavaScript features MapLibre requires')
|
|
66
|
+
} finally {
|
|
67
|
+
Intl.supportedValuesOf = restoreSupportedValuesOf
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
test('checkDeviceCapabilities: no RegExp lookbehind → isSupported false', () => {
|
|
72
|
+
const NativeRegExp = globalThis.RegExp
|
|
73
|
+
globalThis.RegExp = function () { throw new SyntaxError('Invalid regular expression') }
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
const result = createMapLibreProvider().checkDeviceCapabilities()
|
|
77
|
+
expect(result.isSupported).toBe(false)
|
|
78
|
+
expect(result.error).toBe('Browser does not support the JavaScript features MapLibre requires')
|
|
79
|
+
} finally {
|
|
80
|
+
globalThis.RegExp = NativeRegExp
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
test('checkDeviceCapabilities: no module workers → isSupported false', () => {
|
|
85
|
+
supportsModuleWorkers.mockReturnValue(false)
|
|
55
86
|
|
|
56
87
|
const result = createMapLibreProvider().checkDeviceCapabilities()
|
|
57
88
|
|
|
58
89
|
expect(result.isSupported).toBe(false)
|
|
59
|
-
|
|
90
|
+
expect(result.error).toBe('Browser does not support module workers')
|
|
60
91
|
})
|
|
61
92
|
|
|
62
93
|
test('load returns MapProvider, mapFramework, and merged mapProviderConfig', async () => {
|
|
@@ -76,15 +107,15 @@ describe('createMapLibreProvider', () => {
|
|
|
76
107
|
expect(mapProviderConfig).toEqual({ crs: 'EPSG:4326' })
|
|
77
108
|
})
|
|
78
109
|
|
|
79
|
-
test('load
|
|
80
|
-
await createMapLibreProvider({ workerUrl: '/assets/maplibre-gl-
|
|
110
|
+
test('load sets the configured workerUrl when provided', async () => {
|
|
111
|
+
await createMapLibreProvider({ workerUrl: '/assets/maplibre-gl-worker.mjs' }).load()
|
|
81
112
|
|
|
82
|
-
expect(maplibreGl.setWorkerUrl).toHaveBeenCalledWith('/assets/maplibre-gl-
|
|
113
|
+
expect(maplibreGl.setWorkerUrl).toHaveBeenCalledWith('/assets/maplibre-gl-worker.mjs')
|
|
83
114
|
})
|
|
84
115
|
|
|
85
|
-
test('load
|
|
116
|
+
test('load sets the bundled worker URL when workerUrl is not provided', async () => {
|
|
86
117
|
await createMapLibreProvider().load()
|
|
87
118
|
|
|
88
|
-
expect(maplibreGl.setWorkerUrl).
|
|
119
|
+
expect(maplibreGl.setWorkerUrl).toHaveBeenCalledWith('http://localhost/maplibre-gl-worker.mjs?v=6.0.0')
|
|
89
120
|
})
|
|
90
121
|
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether the browser can run module workers (`new Worker(url, { type: 'module' })`).
|
|
3
|
+
*
|
|
4
|
+
* Browsers that support module workers read the `type` option while converting the options
|
|
5
|
+
* object, before the URL is validated, so the getter is called even though construction fails.
|
|
6
|
+
*
|
|
7
|
+
* @returns {boolean} true if module workers are supported, false otherwise
|
|
8
|
+
*/
|
|
9
|
+
export const supportsModuleWorkers = () => {
|
|
10
|
+
if (typeof Worker === 'undefined') {
|
|
11
|
+
return false
|
|
12
|
+
}
|
|
13
|
+
let supported = false
|
|
14
|
+
const options = {
|
|
15
|
+
get type () {
|
|
16
|
+
supported = true
|
|
17
|
+
return 'module'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
new Worker('blob://', options).terminate()
|
|
22
|
+
} catch (_) { // NOSONAR - construction is expected to fail; only the getter call matters
|
|
23
|
+
}
|
|
24
|
+
return supported
|
|
25
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { supportsModuleWorkers } from './detectModuleWorker.js'
|
|
2
|
+
|
|
3
|
+
describe('supportsModuleWorkers', () => {
|
|
4
|
+
const originalWorker = globalThis.Worker
|
|
5
|
+
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
globalThis.Worker = originalWorker
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
it('returns false when Worker is not available', () => {
|
|
11
|
+
delete globalThis.Worker
|
|
12
|
+
expect(supportsModuleWorkers()).toBe(false)
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('returns true when the Worker constructor reads the type option', () => {
|
|
16
|
+
globalThis.Worker = function (url, options) {
|
|
17
|
+
if (options.type !== 'module') {
|
|
18
|
+
throw new Error('unexpected type')
|
|
19
|
+
}
|
|
20
|
+
throw new TypeError('Invalid URL')
|
|
21
|
+
}
|
|
22
|
+
expect(supportsModuleWorkers()).toBe(true)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('terminates the worker if construction succeeds', () => {
|
|
26
|
+
const terminate = jest.fn()
|
|
27
|
+
globalThis.Worker = function (url, options) {
|
|
28
|
+
return { type: options.type, terminate }
|
|
29
|
+
}
|
|
30
|
+
expect(supportsModuleWorkers()).toBe(true)
|
|
31
|
+
expect(terminate).toHaveBeenCalled()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('returns false when the Worker constructor ignores the type option', () => {
|
|
35
|
+
globalThis.Worker = function () {
|
|
36
|
+
throw new TypeError('Invalid URL')
|
|
37
|
+
}
|
|
38
|
+
expect(supportsModuleWorkers()).toBe(false)
|
|
39
|
+
})
|
|
40
|
+
})
|
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
// src/utils/spatial.js
|
|
2
|
-
import LatLon from 'geodesy/latlon-spherical.js'
|
|
3
2
|
import turfBbox from '@turf/bbox'
|
|
4
3
|
|
|
5
4
|
// -----------------------------------------------------------------------------
|
|
6
5
|
// Internal (not exported)
|
|
7
6
|
// -----------------------------------------------------------------------------
|
|
8
7
|
|
|
8
|
+
const EARTH_RADIUS_METRES = 6371e3
|
|
9
|
+
const DEGREES_PER_HALF_TURN = 180
|
|
10
|
+
const RADIANS_PER_DEGREE = Math.PI / DEGREES_PER_HALF_TURN
|
|
11
|
+
const MIN_MOVE_DEGREES = 0.0001 // moves smaller than this aren't announced
|
|
12
|
+
|
|
13
|
+
const toRadians = (degrees) => degrees * RADIANS_PER_DEGREE
|
|
14
|
+
|
|
9
15
|
/**
|
|
10
|
-
* Calculate distance in metres between two [lng, lat] coordinates
|
|
16
|
+
* Calculate distance in metres between two [lng, lat] coordinates (haversine)
|
|
11
17
|
*/
|
|
12
18
|
const getDistance = (from, to) => {
|
|
13
19
|
const [lng1, lat1] = from
|
|
14
20
|
const [lng2, lat2] = to
|
|
15
21
|
|
|
16
|
-
const
|
|
17
|
-
const
|
|
22
|
+
const lat1Rad = toRadians(lat1)
|
|
23
|
+
const lat2Rad = toRadians(lat2)
|
|
24
|
+
const dLat = lat2Rad - lat1Rad
|
|
25
|
+
const dLng = toRadians(lng2 - lng1)
|
|
18
26
|
|
|
19
|
-
|
|
27
|
+
const haversine = Math.sin(dLat / 2) ** 2 + Math.cos(lat1Rad) * Math.cos(lat2Rad) * Math.sin(dLng / 2) ** 2
|
|
28
|
+
const centralAngle = 2 * Math.atan2(Math.sqrt(haversine), Math.sqrt(1 - haversine))
|
|
29
|
+
return EARTH_RADIUS_METRES * centralAngle
|
|
20
30
|
}
|
|
21
31
|
|
|
22
32
|
/**
|
|
@@ -95,12 +105,12 @@ const getCardinalMove = (from, to) => {
|
|
|
95
105
|
|
|
96
106
|
const moves = []
|
|
97
107
|
|
|
98
|
-
if (Math.abs(dLat) >
|
|
108
|
+
if (Math.abs(dLat) > MIN_MOVE_DEGREES) {
|
|
99
109
|
const metres = Math.round(getDistance([lng1, lat1], [lng1, lat2]))
|
|
100
110
|
moves.push(`${dLat > 0 ? 'north' : 'south'} ${formatDimension(metres)}`)
|
|
101
111
|
}
|
|
102
112
|
|
|
103
|
-
if (Math.abs(dLng) >
|
|
113
|
+
if (Math.abs(dLng) > MIN_MOVE_DEGREES) {
|
|
104
114
|
const metres = Math.round(getDistance([lng1, lat1], [lng2, lat1]))
|
|
105
115
|
moves.push(`${dLng > 0 ? 'east' : 'west'} ${formatDimension(metres)}`)
|
|
106
116
|
}
|
|
@@ -113,7 +123,7 @@ const getResolution = (center, zoom) => {
|
|
|
113
123
|
const TILE_SIZE = 512
|
|
114
124
|
const lat = center.lat
|
|
115
125
|
const scale = Math.pow(2, zoom)
|
|
116
|
-
const resolution = (EARTH_CIRCUMFERENCE * Math.cos((lat
|
|
126
|
+
const resolution = (EARTH_CIRCUMFERENCE * Math.cos(toRadians(lat))) / (scale * TILE_SIZE)
|
|
117
127
|
return resolution
|
|
118
128
|
}
|
|
119
129
|
|
|
@@ -161,10 +171,10 @@ const isGeometryObscured = (geojson, panelRect, map) => {
|
|
|
161
171
|
map.project([east, north])
|
|
162
172
|
]
|
|
163
173
|
|
|
164
|
-
const screenMinX = Math.min(...corners.map(
|
|
165
|
-
const screenMaxX = Math.max(...corners.map(
|
|
166
|
-
const screenMinY = Math.min(...corners.map(
|
|
167
|
-
const screenMaxY = Math.max(...corners.map(
|
|
174
|
+
const screenMinX = Math.min(...corners.map(corner => corner.x))
|
|
175
|
+
const screenMaxX = Math.max(...corners.map(corner => corner.x))
|
|
176
|
+
const screenMinY = Math.min(...corners.map(corner => corner.y))
|
|
177
|
+
const screenMaxY = Math.max(...corners.map(corner => corner.y))
|
|
168
178
|
|
|
169
179
|
// Convert panelRect from viewport coords to map-container-relative coords
|
|
170
180
|
const panelLeft = panelRect.left - containerRect.left
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
// tests/utils/spatial.test.js
|
|
2
2
|
import * as spatial from '../../src/utils/spatial.js'
|
|
3
3
|
|
|
4
|
-
jest.mock('geodesy/latlon-spherical.js', () =>
|
|
5
|
-
jest.fn().mockImplementation((lat, lng) => ({
|
|
6
|
-
distanceTo: jest.fn((other) => Math.abs(lat - (other.lat || 0)) * 1609 + Math.abs(lng - (other.lon || 0)) * 1609)
|
|
7
|
-
}))
|
|
8
|
-
)
|
|
9
|
-
|
|
10
4
|
jest.mock('@turf/bbox', () => jest.fn(() => [-1, 50, 1, 52]))
|
|
11
5
|
|
|
12
6
|
describe('spatial utils', () => {
|
|
@@ -53,6 +47,12 @@ describe('spatial utils', () => {
|
|
|
53
47
|
expect(spatial.getCardinalMove([0, 0], [0.00001, 0.00001])).toBe('')
|
|
54
48
|
})
|
|
55
49
|
|
|
50
|
+
test('cardinal moves use great-circle distance', () => {
|
|
51
|
+
// 1 degree of latitude on a 6371 km sphere is 111,195 metres (69.09 miles)
|
|
52
|
+
expect(spatial.getCardinalMove([0, 0], [0, 1])).toBe('north 69 miles')
|
|
53
|
+
expect(spatial.getCardinalMove([-0.12, 51.5], [-0.12, 51.5009])).toBe('north 100 metres')
|
|
54
|
+
})
|
|
55
|
+
|
|
56
56
|
test('getResolution returns positive value', () => {
|
|
57
57
|
expect(spatial.getResolution({ lat: 0 }, 1)).toBeGreaterThan(0)
|
|
58
58
|
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the URL of MapLibre's worker script.
|
|
3
|
+
*
|
|
4
|
+
* MapLibre looks for its worker next to its own module, which bundlers move and rename. Written as
|
|
5
|
+
* a static `new URL(..., import.meta.url)` so webpack and Vite emit the worker file and rewrite this
|
|
6
|
+
* URL to it. The version query stops browsers reusing a cached worker from another MapLibre release.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} version - MapLibre version, from `getVersion()`.
|
|
9
|
+
* @returns {string} The worker URL.
|
|
10
|
+
*/
|
|
11
|
+
export const getWorkerUrl = (version) => {
|
|
12
|
+
const url = new URL('maplibre-gl/dist/maplibre-gl-worker.mjs', import.meta.url)
|
|
13
|
+
url.searchParams.set('v', version)
|
|
14
|
+
return url.href
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getWorkerUrl } from './workerUrl.js'
|
|
2
|
+
|
|
3
|
+
describe('getWorkerUrl', () => {
|
|
4
|
+
test('resolves the maplibre-gl worker file relative to this module', () => {
|
|
5
|
+
const url = new URL(getWorkerUrl('6.0.0'))
|
|
6
|
+
|
|
7
|
+
expect(url.protocol).toBe('file:')
|
|
8
|
+
expect(url.pathname).toMatch(/\/maplibre-gl\/dist\/maplibre-gl-worker\.mjs$/)
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
test('adds the MapLibre version as a cache-busting query', () => {
|
|
12
|
+
expect(new URL(getWorkerUrl('6.0.0')).searchParams.get('v')).toBe('6.0.0')
|
|
13
|
+
})
|
|
14
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let t=" ";class e{static get separator(){return t}static set separator(e){t=e}static parse(t){if(!isNaN(parseFloat(t))&&isFinite(t))return Number(t);const e=String(t).trim().replace(/^-/,"").replace(/[NSEW]$/i,"").split(/[^0-9.,]+/);if(""==e[e.length-1]&&e.splice(e.length-1),""==e)return NaN;let r=null;switch(e.length){case 3:r=e[0]/1+e[1]/60+e[2]/3600;break;case 2:r=e[0]/1+e[1]/60;break;case 1:r=e[0];break;default:return NaN}return/^-|[WS]$/i.test(t.trim())&&(r=-r),Number(r)}static toDms(t,r="d",i=void 0){if(isNaN(t))return null;if("string"==typeof t&&""==t.trim())return null;if("boolean"==typeof t)return null;if(t==1/0)return null;if(null==t)return null;if(void 0===i)switch(r){case"d":case"deg":i=4;break;case"dm":case"deg+min":i=2;break;case"dms":case"deg+min+sec":i=0;break;default:r="d",i=4}t=Math.abs(t);let a=null,o=null,n=null,s=null;switch(r){default:case"d":case"deg":o=t.toFixed(i),o<100&&(o="0"+o),o<10&&(o="0"+o),a=o+"°";break;case"dm":case"deg+min":o=Math.floor(t),n=(60*t%60).toFixed(i),60==n&&(n=(0).toFixed(i),o++),o=("000"+o).slice(-3),n<10&&(n="0"+n),a=o+"°"+e.separator+n+"′";break;case"dms":case"deg+min+sec":o=Math.floor(t),n=Math.floor(3600*t/60)%60,s=(3600*t%60).toFixed(i),60==s&&(s=(0).toFixed(i),n++),60==n&&(n=0,o++),o=("000"+o).slice(-3),n=("00"+n).slice(-2),s<10&&(s="0"+s),a=o+"°"+e.separator+n+"′"+e.separator+s+"″"}return a}static toLat(t,r,i){const a=e.toDms(e.wrap90(t),r,i);return null===a?"–":a.slice(1)+e.separator+(t<0?"S":"N")}static toLon(t,r,i){const a=e.toDms(e.wrap180(t),r,i);return null===a?"–":a+e.separator+(t<0?"W":"E")}static toBrng(t,r,i){const a=e.toDms(e.wrap360(t),r,i);return null===a?"–":a.replace("360","0")}static fromLocale(t){const e=123456.789.toLocaleString(),r={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(r.thousands,"⁜").replace(r.decimal,".").replace("⁜",",")}static toLocale(t){const e=123456.789.toLocaleString(),r={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(/,([0-9])/,"⁜$1").replace(".",r.decimal).replace("⁜",r.thousands)}static compassPoint(t,r=3){if(![1,2,3].includes(Number(r)))throw new RangeError(`invalid precision ‘${r}’`);t=e.wrap360(t);const i=4*2**(r-1);return["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"][Math.round(t*i/360)%i*16/i]}static wrap90(t){if(-90<=t&&t<=90)return t;const e=t,r=360;return 1*Math.abs(((e-90)%r+r)%r-180)-90}static wrap180(t){if(-180<=t&&t<=180)return t;const e=360;return((360*t/e-180)%e+e)%e-180}static wrap360(t){if(0<=t&&t<360)return t;const e=360;return(360*t/e%e+e)%e}}Number.prototype.toRadians=function(){return this*Math.PI/180},Number.prototype.toDegrees=function(){return 180*this/Math.PI};class r{constructor(t,e,r){if(isNaN(t)||isNaN(e)||isNaN(r))throw new TypeError(`invalid vector [${t},${e},${r}]`);this.x=Number(t),this.y=Number(e),this.z=Number(r)}get length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}plus(t){if(!(t instanceof r))throw new TypeError("v is not Vector3d object");return new r(this.x+t.x,this.y+t.y,this.z+t.z)}minus(t){if(!(t instanceof r))throw new TypeError("v is not Vector3d object");return new r(this.x-t.x,this.y-t.y,this.z-t.z)}times(t){if(isNaN(t))throw new TypeError(`invalid scalar value ‘${t}’`);return new r(this.x*t,this.y*t,this.z*t)}dividedBy(t){if(isNaN(t))throw new TypeError(`invalid scalar value ‘${t}’`);return new r(this.x/t,this.y/t,this.z/t)}dot(t){if(!(t instanceof r))throw new TypeError("v is not Vector3d object");return this.x*t.x+this.y*t.y+this.z*t.z}cross(t){if(!(t instanceof r))throw new TypeError("v is not Vector3d object");const e=this.y*t.z-this.z*t.y,i=this.z*t.x-this.x*t.z,a=this.x*t.y-this.y*t.x;return new r(e,i,a)}negate(){return new r(-this.x,-this.y,-this.z)}unit(){const t=this.length;if(1==t)return this;if(0==t)return this;const e=this.x/t,i=this.y/t,a=this.z/t;return new r(e,i,a)}angleTo(t,e=void 0){if(!(t instanceof r))throw new TypeError("v is not Vector3d object");if(!(e instanceof r||null==e))throw new TypeError("n is not Vector3d object");const i=null==e||this.cross(t).dot(e)>=0?1:-1,a=this.cross(t).length*i,o=this.dot(t);return Math.atan2(a,o)}rotateAround(t,e){if(!(t instanceof r))throw new TypeError("axis is not Vector3d object");const i=e.toRadians(),a=this.unit(),o=t.unit(),n=Math.sin(i),s=Math.cos(i),l=1-s,c=o.x,h=o.y,u=o.z,d=[[l*c*c+s,l*c*h-n*u,l*c*u+n*h],[l*c*h+n*u,l*h*h+s,l*h*u-n*c],[l*c*u-n*h,l*h*u+n*c,l*u*u+s]],p=[d[0][0]*a.x+d[0][1]*a.y+d[0][2]*a.z,d[1][0]*a.x+d[1][1]*a.y+d[1][2]*a.z,d[2][0]*a.x+d[2][1]*a.y+d[2][2]*a.z];return new r(p[0],p[1],p[2])}toString(t=3){return`[${this.x.toFixed(t)},${this.y.toFixed(t)},${this.z.toFixed(t)}]`}}Number.prototype.toRadians=function(){return this*Math.PI/180},Number.prototype.toDegrees=function(){return 180*this/Math.PI};const i={WGS84:{a:6378137,b:6356752.314245,f:1/298.257223563}},a={WGS84:{ellipsoid:i.WGS84}};Object.freeze(i.WGS84),Object.freeze(a.WGS84);class o{constructor(t,r,i=0){if(isNaN(t)||null==t)throw new TypeError(`invalid lat ‘${t}’`);if(isNaN(r)||null==r)throw new TypeError(`invalid lon ‘${r}’`);if(isNaN(i)||null==i)throw new TypeError(`invalid height ‘${i}’`);this._lat=e.wrap90(Number(t)),this._lon=e.wrap180(Number(r)),this._height=Number(i)}get lat(){return this._lat}get latitude(){return this._lat}set lat(t){if(this._lat=isNaN(t)?e.wrap90(e.parse(t)):e.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid lat ‘${t}’`)}set latitude(t){if(this._lat=isNaN(t)?e.wrap90(e.parse(t)):e.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid latitude ‘${t}’`)}get lon(){return this._lon}get lng(){return this._lon}get longitude(){return this._lon}set lon(t){if(this._lon=isNaN(t)?e.wrap180(e.parse(t)):e.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lon ‘${t}’`)}set lng(t){if(this._lon=isNaN(t)?e.wrap180(e.parse(t)):e.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lng ‘${t}’`)}set longitude(t){if(this._lon=isNaN(t)?e.wrap180(e.parse(t)):e.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid longitude ‘${t}’`)}get height(){return this._height}set height(t){if(this._height=Number(t),isNaN(this._height))throw new TypeError(`invalid height ‘${t}’`)}get datum(){return this._datum}set datum(t){this._datum=t}static get ellipsoids(){return i}static get datums(){return a}static parse(...t){if(0==t.length)throw new TypeError("invalid (empty) point");let r,i,a;if("object"==typeof t[0]&&(1==t.length||!isNaN(parseFloat(t[1])))){const o=t[0];if("Point"==o.type&&Array.isArray(o.coordinates)?([i,r,a]=o.coordinates,a=a||0):(null!=o.latitude&&(r=o.latitude),null!=o.lat&&(r=o.lat),null!=o.longitude&&(i=o.longitude),null!=o.lng&&(i=o.lng),null!=o.lon&&(i=o.lon),null!=o.height&&(a=o.height),r=e.wrap90(e.parse(r)),i=e.wrap180(e.parse(i))),null!=t[1]&&(a=t[1]),isNaN(r)||isNaN(i))throw new TypeError(`invalid point ‘${JSON.stringify(t[0])}’`)}if("string"==typeof t[0]&&2==t[0].split(",").length&&([r,i]=t[0].split(","),r=e.wrap90(e.parse(r)),i=e.wrap180(e.parse(i)),a=t[1]||0,isNaN(r)||isNaN(i)))throw new TypeError(`invalid point ‘${t[0]}’`);if(null==r&&null==i&&([r,i]=t,r=e.wrap90(e.parse(r)),i=e.wrap180(e.parse(i)),a=t[2]||0,isNaN(r)||isNaN(i)))throw new TypeError(`invalid point ‘${t.toString()}’`);return new this(r,i,a)}toCartesian(){const t=this.datum?this.datum.ellipsoid:this.referenceFrame?this.referenceFrame.ellipsoid:i.WGS84,e=this.lat.toRadians(),r=this.lon.toRadians(),a=this.height,{a:o,f:s}=t,l=Math.sin(e),c=Math.cos(e),h=Math.sin(r),u=Math.cos(r),d=2*s-s*s,p=o/Math.sqrt(1-d*l*l);return new n((p+a)*c*u,(p+a)*c*h,(p*(1-d)+a)*l)}equals(t){if(!(t instanceof o))throw new TypeError(`invalid point ‘${t}’`);return!(Math.abs(this.lat-t.lat)>Number.EPSILON)&&(!(Math.abs(this.lon-t.lon)>Number.EPSILON)&&(!(Math.abs(this.height-t.height)>Number.EPSILON)&&(this.datum==t.datum&&(this.referenceFrame==t.referenceFrame&&this.epoch==t.epoch))))}toString(t="d",r=void 0,i=null){if(!["d","dm","dms","n"].includes(t))throw new RangeError(`invalid format ‘${t}’`);const a=(this.height>=0?" +":" ")+this.height.toFixed(i)+"m";if("n"==t){null==r&&(r=4);return`${this.lat.toFixed(r)}, ${this.lon.toFixed(r)}${null==i?"":a}`}return`${e.toLat(this.lat,t,r)}, ${e.toLon(this.lon,t,r)}${null==i?"":a}`}}class n extends r{constructor(t,e,r){super(t,e,r)}toLatLon(t=i.WGS84){if(!t||!t.a)throw new TypeError(`invalid ellipsoid ‘${t}’`);const{x:e,y:r,z:a}=this,{a:n,b:s,f:l}=t,c=2*l-l*l,h=c/(1-c),u=Math.sqrt(e*e+r*r),d=s*a/(n*u)*(1+h*s/Math.sqrt(u*u+a*a)),p=d/Math.sqrt(1+d*d),m=p/d,f=isNaN(m)?0:Math.atan2(a+h*s*p*p*p,u-c*n*m*m*m),g=Math.atan2(r,e),w=Math.sin(f),y=u*Math.cos(f)+a*w-n*n/(n/Math.sqrt(1-c*w*w));return new o(f.toDegrees(),g.toDegrees(),y)}toString(t=0){return`[${this.x.toFixed(t)},${this.y.toFixed(t)},${this.z.toFixed(t)}]`}}const s={WGS84:{a:6378137,b:6356752.314245,f:1/298.257223563},Airy1830:{a:6377563.396,b:6356256.909,f:1/299.3249646},AiryModified:{a:6377340.189,b:6356034.448,f:1/299.3249646},Bessel1841:{a:6377397.155,b:6356078.962818,f:1/299.1528128},Clarke1866:{a:6378206.4,b:6356583.8,f:1/294.978698214},Clarke1880IGN:{a:6378249.2,b:6356515,f:1/293.466021294},GRS80:{a:6378137,b:6356752.31414,f:1/298.257222101},Intl1924:{a:6378388,b:6356911.946,f:1/297},WGS72:{a:6378135,b:6356750.5,f:1/298.26}},l={ED50:{ellipsoid:s.Intl1924,transform:[89.5,93.8,123.1,-1.2,0,0,.156]},ETRS89:{ellipsoid:s.GRS80,transform:[0,0,0,0,0,0,0]},Irl1975:{ellipsoid:s.AiryModified,transform:[-482.53,130.596,-564.557,-8.15,1.042,.214,.631]},NAD27:{ellipsoid:s.Clarke1866,transform:[8,-160,-176,0,0,0,0]},NAD83:{ellipsoid:s.GRS80,transform:[.9956,-1.9103,-.5215,-62e-5,.025915,.009426,.011599]},NTF:{ellipsoid:s.Clarke1880IGN,transform:[168,60,-320,0,0,0,0]},OSGB36:{ellipsoid:s.Airy1830,transform:[-446.448,125.157,-542.06,20.4894,-.1502,-.247,-.8421]},Potsdam:{ellipsoid:s.Bessel1841,transform:[-582,-105,-414,-8.3,1.04,.35,-3.08]},TokyoJapan:{ellipsoid:s.Bessel1841,transform:[148,-507,-685,0,0,0,0]},WGS72:{ellipsoid:s.WGS72,transform:[0,0,-4.5,-.22,0,0,.554]},WGS84:{ellipsoid:s.WGS84,transform:[0,0,0,0,0,0,0]}};Object.keys(s).forEach(t=>Object.freeze(s[t])),Object.keys(l).forEach(t=>{Object.freeze(l[t]),Object.freeze(l[t].transform)});class c extends o{constructor(t,e,r=0,i=l.WGS84){if(!i||null==i.ellipsoid)throw new TypeError(`unrecognised datum ‘${i}’`);super(t,e,r),this._datum=i}get datum(){return this._datum}static get ellipsoids(){return s}static get datums(){return l}static parse(...t){let e=l.WGS84;if((4==t.length||3==t.length&&"object"==typeof t[2])&&(e=t.pop()),!e||null==e.ellipsoid)throw new TypeError(`unrecognised datum ‘${e}’`);const r=super.parse(...t);return r._datum=e,r}convertDatum(t){if(!t||null==t.ellipsoid)throw new TypeError(`unrecognised datum ‘${t}’`);return this.toCartesian().convertDatum(t).toLatLon()}toCartesian(){const t=super.toCartesian();return new h(t.x,t.y,t.z,this.datum)}}class h extends n{constructor(t,e,r,i=void 0){if(i&&null==i.ellipsoid)throw new TypeError(`unrecognised datum ‘${i}’`);super(t,e,r),i&&(this._datum=i)}get datum(){return this._datum}set datum(t){if(!t||null==t.ellipsoid)throw new TypeError(`unrecognised datum ‘${t}’`);this._datum=t}toLatLon(t=void 0){t&&(console.info("datum parameter to Cartesian_Datum.toLatLon is deprecated: set datum before calling toLatLon()"),this.datum=t);const e=this.datum||l.WGS84;if(!e||null==e.ellipsoid)throw new TypeError(`unrecognised datum ‘${e}’`);const r=super.toLatLon(e.ellipsoid);return new c(r.lat,r.lon,r.height,this.datum)}convertDatum(t){if(!t||null==t.ellipsoid)throw new TypeError(`unrecognised datum ‘${t}’`);if(!this.datum)throw new TypeError("cartesian coordinate has no datum");let e=null,r=null;null!=this.datum&&this.datum!=l.WGS84||(e=this,r=t.transform),t==l.WGS84&&(e=this,r=this.datum.transform.map(t=>-t)),null==r&&(e=this.convertDatum(l.WGS84),r=t.transform);const i=e.applyTransform(r);return i.datum=t,i}applyTransform(t){const{x:e,y:r,z:i}=this,a=t[0],o=t[1],n=t[2],s=t[3]/1e6+1,l=(t[4]/3600).toRadians(),c=(t[5]/3600).toRadians(),u=(t[6]/3600).toRadians();return new h(a+e*s-r*u+i*c,o+e*u+r*s-i*l,n-e*c+r*l+i*s)}}const u={trueOrigin:{lat:49,lon:-2},scaleFactor:.9996012717,ellipsoid:c.ellipsoids.Airy1830};class d{constructor(t,e){if(this.easting=Number(t),this.northing=Number(e),isNaN(t)||this.easting<0||this.easting>7e5)throw new RangeError(`invalid easting ‘${t}’`);if(isNaN(e)||this.northing<0||this.northing>13e5)throw new RangeError(`invalid northing ‘${e}’`)}toLatLon(t=c.datums.WGS84){const{easting:e,northing:r}=this,{a:i,b:a}=u.ellipsoid,o=u.trueOrigin.lat.toRadians(),n=u.trueOrigin.lon.toRadians(),s=-1e5,l=u.scaleFactor,h=1-a*a/(i*i),d=(i-a)/(i+a),m=d*d,f=d*d*d;let g=o,w=0;do{g=(r-s-w)/(i*l)+g;w=a*l*((1+d+5/4*m+5/4*f)*(g-o)-(3*d+3*d*d+21/8*f)*Math.sin(g-o)*Math.cos(g+o)+(15/8*m+15/8*f)*Math.sin(2*(g-o))*Math.cos(2*(g+o))-35/24*f*Math.sin(3*(g-o))*Math.cos(3*(g+o)))}while(Math.abs(r-s-w)>=1e-5);const y=Math.cos(g),N=Math.sin(g),_=i*l/Math.sqrt(1-h*N*N),E=i*l*(1-h)/Math.pow(1-h*N*N,1.5),S=_/E-1,b=Math.tan(g),M=b*b,$=M*M,T=1/y,x=_*_*_,v=x*_*_,G=e-4e5,R=G*G,W=R*G,F=R*R,O=W*R;g=g-b/(2*E*_)*R+b/(24*E*x)*(5+3*M+S-9*M*S)*F-b/(720*E*v)*(61+90*M+45*$)*(F*R);const L=n+T/_*G-T/(6*x)*(_/E+2*M)*W+T/(120*v)*(5+28*M+24*$)*O-T/(5040*(v*_*_))*(61+662*M+1320*$+720*($*M))*(O*R);let z=new p(g.toDegrees(),L.toDegrees(),0,c.datums.OSGB36);return t!=c.datums.OSGB36&&(z=z.convertDatum(t),z=new p(z.lat,z.lon,z.height,z.datum)),z}static parse(t){let e=(t=String(t).trim()).match(/^(\d+),\s*(\d+)$/);if(e)return new d(e[1],e[2]);if(e=t.match(/^[HNST][ABCDEFGHJKLMNOPQRSTUVWXYZ]\s*[0-9]+\s*[0-9]+$/i),!e)throw new Error(`invalid grid reference ‘${t}’`);let r=t.toUpperCase().charCodeAt(0)-"A".charCodeAt(0),i=t.toUpperCase().charCodeAt(1)-"A".charCodeAt(0);r>7&&r--,i>7&&i--;const a=(r-2)%5*5+i%5,o=19-5*Math.floor(r/5)-Math.floor(i/5);let n=t.slice(2).trim().split(/\s+/);if(1==n.length&&(n=[n[0].slice(0,n[0].length/2),n[0].slice(n[0].length/2)]),n[0].length!=n[1].length)throw new Error(`invalid grid reference ‘${t}’`);n[0]=n[0].padEnd(5,"0"),n[1]=n[1].padEnd(5,"0");const s=a+n[0],l=o+n[1];return new d(s,l)}toString(t=10){if(![0,2,4,6,8,10,12,14,16].includes(Number(t)))throw new RangeError(`invalid precision ‘${t}’`);let{easting:e,northing:r}=this;if(0==t){const t={useGrouping:!1,minimumIntegerDigits:6,maximumFractionDigits:3};return`${e.toLocaleString("en",t)},${r.toLocaleString("en",t)}`}const i=Math.floor(e/1e5),a=Math.floor(r/1e5);let o=19-a-(19-a)%5+Math.floor((i+10)/5),n=5*(19-a)%25+i%5;o>7&&o++,n>7&&n++;const s=String.fromCharCode(o+"A".charCodeAt(0),n+"A".charCodeAt(0));return e=Math.floor(e%1e5/Math.pow(10,5-t/2)),r=Math.floor(r%1e5/Math.pow(10,5-t/2)),e=e.toString().padStart(t/2,"0"),r=r.toString().padStart(t/2,"0"),`${s} ${e} ${r}`}}class p extends c{toOsGrid(){const t=this.datum==c.datums.OSGB36?this:this.convertDatum(c.datums.OSGB36),e=t.lat.toRadians(),r=t.lon.toRadians(),{a:i,b:a}=u.ellipsoid,o=u.trueOrigin.lat.toRadians(),n=u.trueOrigin.lon.toRadians(),s=u.scaleFactor,l=1-a*a/(i*i),h=(i-a)/(i+a),p=h*h,m=h*h*h,f=Math.cos(e),g=Math.sin(e),w=i*s/Math.sqrt(1-l*g*g),y=i*s*(1-l)/Math.pow(1-l*g*g,1.5),N=w/y-1,_=a*s*((1+h+5/4*p+5/4*m)*(e-o)-(3*h+3*h*h+21/8*m)*Math.sin(e-o)*Math.cos(e+o)+(15/8*p+15/8*m)*Math.sin(2*(e-o))*Math.cos(2*(e+o))-35/24*m*Math.sin(3*(e-o))*Math.cos(3*(e+o))),E=f*f*f,S=E*f*f,b=Math.tan(e)*Math.tan(e),M=b*b,$=r-n,T=$*$,x=T*$,v=x*$,G=v*$;let R=_+-1e5+w/2*g*f*T+w/24*g*E*(5-b+9*N)*v+w/720*g*S*(61-58*b+M)*(G*$),W=4e5+w*f*$+w/6*E*(w/y-b)*x+w/120*S*(5-18*b+M+14*N-58*b*N)*G;R=Number(R.toFixed(3)),W=Number(W.toFixed(3));try{return new d(W,R)}catch(e){throw new Error(`${e.message} from (${t.lat.toFixed(6)},${t.lon.toFixed(6)}).toOsGrid()`)}}convertDatum(t){const e=super.convertDatum(t);return new p(e.lat,e.lon,e.height,e.datum)}}const m=async(t="https://api.os.uk/search/names/v1/nearest?point={easting},{northing}&radius=1000&fq=local_type:Airfield%20local_type:Airport%20local_type:Bus_Station%20local_type:Chemical_Works%20local_type:City%20local_type:Coach_Station%20local_type:Electricity_Distribution%20local_type:Electricity_Production%20local_type:Further_Education%20local_type:Gas_Distribution_or_Storage%20local_type:Hamlet%20local_type:Harbour%20local_type:Helicopter_Station%20local_type:Heliport%20local_type:Higher_or_University_Education%20local_type:Hill_Or_Mountain%20local_type:Hospice%20local_type:Hospital%20local_type:Medical_Care_Accommodation%20local_type:Named_Road%20local_type:Non_State_Primary_Education%20local_type:Non_State_Secondary_Education%20local_type:Other_Settlement%20local_type:Passenger_Ferry_Terminal%20local_type:Port_Consisting_of_Docks_and_Nautical_Berthing%20local_type:Postcode%20local_type:Primary_Education%20local_type:Railway_Station%20local_type:Road_User_Services%20local_type:Secondary_Education%20local_type:Section_Of_Named_Road%20local_type:Section_Of_Numbered_Road%20local_type:Special_Needs_Education%20local_type:Suburban_Area%20local_type:Town%20local_type:Urban_Greenspace%20local_type:Vehicular_Ferry_Terminal%20local_type:Vehicular_Rail_Terminal%20local_type:Village%20local_type:Waterfall%20",e,r,i,a)=>{let o=a;if("EPSG:4326"===r)try{o=new p(a[1],a[0]).toOsGrid(),o=[o.easting,o.northing].map(t=>Math.round(t))}catch(t){return console.log(t),null}t=t.replace("{easting}",Math.round(o[0])).replace("{northing}",Math.round(o[1]));let n=new Request(t,{method:"GET"});if(e)try{n=await e(n)}catch(t){return console.log("Error transforming request:",t),null}const s=await fetch(n),l=await s.json(),c=function({ID:t,NAME1:e,POPULATED_PLACE:r,COUNTY_UNITARY:i,REGION:a,GEOMETRY_X:o,GEOMETRY_Y:n}){return{id:t||"",place:`${e}${r?", "+r:""}${i?", "+i:""}, ${a}`,county:i||"",coordinates:[o,n]}}(l.results[0].GAZETTEER_ENTRY);if("EPSG:4326"===r){const t=new d(c.coordinates[0],c.coordinates[1]).toLatLon();c.coordinates=[t.lat,t.lon]}const h=`Approximate centre ${c?.place}`;return l.results?h:null};export{m as reverseGeocode};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"@babel/runtime/helpers/regenerator";import r from"@babel/runtime/helpers/asyncToGenerator";import t from"@babel/runtime/helpers/objectSpread2";function o(){var o;return t(t({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{load:(o=r(e().m(function r(){var t;return e().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,import(/* webpackChunkName: "im-reverse-geocode" */ "./im-reverse-geocode.js");case 1:return t=e.v,e.a(2,t.reverseGeocode)}},r)})),function(){return o.apply(this,arguments)})})}export{o as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see im-reverse-geocode.js.LICENSE.txt */
|
|
2
|
+
"use strict";(Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[]).push([[627],{246:function(t,e,r){r.r(e),r.d(e,{reverseGeocode:function(){return E}});let n=" ";class i{static get separator(){return n}static set separator(t){n=t}static parse(t){if(!isNaN(parseFloat(t))&&isFinite(t))return Number(t);const e=String(t).trim().replace(/^-/,"").replace(/[NSEW]$/i,"").split(/[^0-9.,]+/);if(""==e[e.length-1]&&e.splice(e.length-1),""==e)return NaN;let r=null;switch(e.length){case 3:r=e[0]/1+e[1]/60+e[2]/3600;break;case 2:r=e[0]/1+e[1]/60;break;case 1:r=e[0];break;default:return NaN}return/^-|[WS]$/i.test(t.trim())&&(r=-r),Number(r)}static toDms(t,e="d",r=void 0){if(isNaN(t))return null;if("string"==typeof t&&""==t.trim())return null;if("boolean"==typeof t)return null;if(t==1/0)return null;if(null==t)return null;if(void 0===r)switch(e){case"d":case"deg":r=4;break;case"dm":case"deg+min":r=2;break;case"dms":case"deg+min+sec":r=0;break;default:e="d",r=4}t=Math.abs(t);let n=null,a=null,o=null,s=null;switch(e){default:case"d":case"deg":a=t.toFixed(r),a<100&&(a="0"+a),a<10&&(a="0"+a),n=a+"°";break;case"dm":case"deg+min":a=Math.floor(t),o=(60*t%60).toFixed(r),60==o&&(o=(0).toFixed(r),a++),a=("000"+a).slice(-3),o<10&&(o="0"+o),n=a+"°"+i.separator+o+"′";break;case"dms":case"deg+min+sec":a=Math.floor(t),o=Math.floor(3600*t/60)%60,s=(3600*t%60).toFixed(r),60==s&&(s=(0).toFixed(r),o++),60==o&&(o=0,a++),a=("000"+a).slice(-3),o=("00"+o).slice(-2),s<10&&(s="0"+s),n=a+"°"+i.separator+o+"′"+i.separator+s+"″"}return n}static toLat(t,e,r){const n=i.toDms(i.wrap90(t),e,r);return null===n?"–":n.slice(1)+i.separator+(t<0?"S":"N")}static toLon(t,e,r){const n=i.toDms(i.wrap180(t),e,r);return null===n?"–":n+i.separator+(t<0?"W":"E")}static toBrng(t,e,r){const n=i.toDms(i.wrap360(t),e,r);return null===n?"–":n.replace("360","0")}static fromLocale(t){const e=123456.789.toLocaleString(),r={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(r.thousands,"⁜").replace(r.decimal,".").replace("⁜",",")}static toLocale(t){const e=123456.789.toLocaleString(),r={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(/,([0-9])/,"⁜$1").replace(".",r.decimal).replace("⁜",r.thousands)}static compassPoint(t,e=3){if(![1,2,3].includes(Number(e)))throw new RangeError(`invalid precision ‘${e}’`);t=i.wrap360(t);const r=4*2**(e-1);return["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"][Math.round(t*r/360)%r*16/r]}static wrap90(t){if(-90<=t&&t<=90)return t;const e=t;return 1*Math.abs(((e-90)%360+360)%360-180)-90}static wrap180(t){if(-180<=t&&t<=180)return t;const e=360;return((360*t/e-180)%e+e)%e-180}static wrap360(t){if(0<=t&&t<360)return t;const e=360;return(360*t/e%e+e)%e}}Number.prototype.toRadians=function(){return this*Math.PI/180},Number.prototype.toDegrees=function(){return 180*this/Math.PI};var a=i;class o{constructor(t,e,r){if(isNaN(t)||isNaN(e)||isNaN(r))throw new TypeError(`invalid vector [${t},${e},${r}]`);this.x=Number(t),this.y=Number(e),this.z=Number(r)}get length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}plus(t){if(!(t instanceof o))throw new TypeError("v is not Vector3d object");return new o(this.x+t.x,this.y+t.y,this.z+t.z)}minus(t){if(!(t instanceof o))throw new TypeError("v is not Vector3d object");return new o(this.x-t.x,this.y-t.y,this.z-t.z)}times(t){if(isNaN(t))throw new TypeError(`invalid scalar value ‘${t}’`);return new o(this.x*t,this.y*t,this.z*t)}dividedBy(t){if(isNaN(t))throw new TypeError(`invalid scalar value ‘${t}’`);return new o(this.x/t,this.y/t,this.z/t)}dot(t){if(!(t instanceof o))throw new TypeError("v is not Vector3d object");return this.x*t.x+this.y*t.y+this.z*t.z}cross(t){if(!(t instanceof o))throw new TypeError("v is not Vector3d object");const e=this.y*t.z-this.z*t.y,r=this.z*t.x-this.x*t.z,n=this.x*t.y-this.y*t.x;return new o(e,r,n)}negate(){return new o(-this.x,-this.y,-this.z)}unit(){const t=this.length;if(1==t)return this;if(0==t)return this;const e=this.x/t,r=this.y/t,n=this.z/t;return new o(e,r,n)}angleTo(t,e=void 0){if(!(t instanceof o))throw new TypeError("v is not Vector3d object");if(!(e instanceof o||null==e))throw new TypeError("n is not Vector3d object");const r=null==e||this.cross(t).dot(e)>=0?1:-1,n=this.cross(t).length*r,i=this.dot(t);return Math.atan2(n,i)}rotateAround(t,e){if(!(t instanceof o))throw new TypeError("axis is not Vector3d object");const r=e.toRadians(),n=this.unit(),i=t.unit(),a=Math.sin(r),s=Math.cos(r),l=1-s,c=i.x,u=i.y,h=i.z,d=[[l*c*c+s,l*c*u-a*h,l*c*h+a*u],[l*c*u+a*h,l*u*u+s,l*u*h-a*c],[l*c*h-a*u,l*u*h+a*c,l*h*h+s]],p=[d[0][0]*n.x+d[0][1]*n.y+d[0][2]*n.z,d[1][0]*n.x+d[1][1]*n.y+d[1][2]*n.z,d[2][0]*n.x+d[2][1]*n.y+d[2][2]*n.z];return new o(p[0],p[1],p[2])}toString(t=3){return`[${this.x.toFixed(t)},${this.y.toFixed(t)},${this.z.toFixed(t)}]`}}Number.prototype.toRadians=function(){return this*Math.PI/180},Number.prototype.toDegrees=function(){return 180*this/Math.PI};var s=o;const l={WGS84:{a:6378137,b:6356752.314245,f:1/298.257223563}},c={WGS84:{ellipsoid:l.WGS84}};Object.freeze(l.WGS84),Object.freeze(c.WGS84);class u{constructor(t,e,r=0){if(isNaN(t)||null==t)throw new TypeError(`invalid lat ‘${t}’`);if(isNaN(e)||null==e)throw new TypeError(`invalid lon ‘${e}’`);if(isNaN(r)||null==r)throw new TypeError(`invalid height ‘${r}’`);this._lat=a.wrap90(Number(t)),this._lon=a.wrap180(Number(e)),this._height=Number(r)}get lat(){return this._lat}get latitude(){return this._lat}set lat(t){if(this._lat=isNaN(t)?a.wrap90(a.parse(t)):a.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid lat ‘${t}’`)}set latitude(t){if(this._lat=isNaN(t)?a.wrap90(a.parse(t)):a.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid latitude ‘${t}’`)}get lon(){return this._lon}get lng(){return this._lon}get longitude(){return this._lon}set lon(t){if(this._lon=isNaN(t)?a.wrap180(a.parse(t)):a.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lon ‘${t}’`)}set lng(t){if(this._lon=isNaN(t)?a.wrap180(a.parse(t)):a.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lng ‘${t}’`)}set longitude(t){if(this._lon=isNaN(t)?a.wrap180(a.parse(t)):a.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid longitude ‘${t}’`)}get height(){return this._height}set height(t){if(this._height=Number(t),isNaN(this._height))throw new TypeError(`invalid height ‘${t}’`)}get datum(){return this._datum}set datum(t){this._datum=t}static get ellipsoids(){return l}static get datums(){return c}static parse(...t){if(0==t.length)throw new TypeError("invalid (empty) point");let e,r,n;if("object"==typeof t[0]&&(1==t.length||!isNaN(parseFloat(t[1])))){const i=t[0];if("Point"==i.type&&Array.isArray(i.coordinates)?([r,e,n]=i.coordinates,n=n||0):(null!=i.latitude&&(e=i.latitude),null!=i.lat&&(e=i.lat),null!=i.longitude&&(r=i.longitude),null!=i.lng&&(r=i.lng),null!=i.lon&&(r=i.lon),null!=i.height&&(n=i.height),e=a.wrap90(a.parse(e)),r=a.wrap180(a.parse(r))),null!=t[1]&&(n=t[1]),isNaN(e)||isNaN(r))throw new TypeError(`invalid point ‘${JSON.stringify(t[0])}’`)}if("string"==typeof t[0]&&2==t[0].split(",").length&&([e,r]=t[0].split(","),e=a.wrap90(a.parse(e)),r=a.wrap180(a.parse(r)),n=t[1]||0,isNaN(e)||isNaN(r)))throw new TypeError(`invalid point ‘${t[0]}’`);if(null==e&&null==r&&([e,r]=t,e=a.wrap90(a.parse(e)),r=a.wrap180(a.parse(r)),n=t[2]||0,isNaN(e)||isNaN(r)))throw new TypeError(`invalid point ‘${t.toString()}’`);return new this(e,r,n)}toCartesian(){const t=this.datum?this.datum.ellipsoid:this.referenceFrame?this.referenceFrame.ellipsoid:l.WGS84,e=this.lat.toRadians(),r=this.lon.toRadians(),n=this.height,{a:i,f:a}=t,o=Math.sin(e),s=Math.cos(e),c=Math.sin(r),u=Math.cos(r),d=2*a-a*a,p=i/Math.sqrt(1-d*o*o);return new h((p+n)*s*u,(p+n)*s*c,(p*(1-d)+n)*o)}equals(t){if(!(t instanceof u))throw new TypeError(`invalid point ‘${t}’`);return!(Math.abs(this.lat-t.lat)>Number.EPSILON||Math.abs(this.lon-t.lon)>Number.EPSILON||Math.abs(this.height-t.height)>Number.EPSILON||this.datum!=t.datum||this.referenceFrame!=t.referenceFrame||this.epoch!=t.epoch)}toString(t="d",e=void 0,r=null){if(!["d","dm","dms","n"].includes(t))throw new RangeError(`invalid format ‘${t}’`);const n=(this.height>=0?" +":" ")+this.height.toFixed(r)+"m";return"n"==t?(null==e&&(e=4),`${this.lat.toFixed(e)}, ${this.lon.toFixed(e)}${null==r?"":n}`):`${a.toLat(this.lat,t,e)}, ${a.toLon(this.lon,t,e)}${null==r?"":n}`}}class h extends s{constructor(t,e,r){super(t,e,r)}toLatLon(t=l.WGS84){if(!t||!t.a)throw new TypeError(`invalid ellipsoid ‘${t}’`);const{x:e,y:r,z:n}=this,{a:i,b:a,f:o}=t,s=2*o-o*o,c=s/(1-s),h=Math.sqrt(e*e+r*r),d=a*n/(i*h)*(1+c*a/Math.sqrt(h*h+n*n)),p=d/Math.sqrt(1+d*d),f=p/d,m=isNaN(f)?0:Math.atan2(n+c*a*p*p*p,h-s*i*f*f*f),g=Math.atan2(r,e),y=Math.sin(m),w=h*Math.cos(m)+n*y-i*i/(i/Math.sqrt(1-s*y*y));return new u(m.toDegrees(),g.toDegrees(),w)}toString(t=0){return`[${this.x.toFixed(t)},${this.y.toFixed(t)},${this.z.toFixed(t)}]`}}const d={WGS84:{a:6378137,b:6356752.314245,f:1/298.257223563},Airy1830:{a:6377563.396,b:6356256.909,f:1/299.3249646},AiryModified:{a:6377340.189,b:6356034.448,f:1/299.3249646},Bessel1841:{a:6377397.155,b:6356078.962818,f:1/299.1528128},Clarke1866:{a:6378206.4,b:6356583.8,f:1/294.978698214},Clarke1880IGN:{a:6378249.2,b:6356515,f:1/293.466021294},GRS80:{a:6378137,b:6356752.31414,f:1/298.257222101},Intl1924:{a:6378388,b:6356911.946,f:1/297},WGS72:{a:6378135,b:6356750.5,f:1/298.26}},p={ED50:{ellipsoid:d.Intl1924,transform:[89.5,93.8,123.1,-1.2,0,0,.156]},ETRS89:{ellipsoid:d.GRS80,transform:[0,0,0,0,0,0,0]},Irl1975:{ellipsoid:d.AiryModified,transform:[-482.53,130.596,-564.557,-8.15,1.042,.214,.631]},NAD27:{ellipsoid:d.Clarke1866,transform:[8,-160,-176,0,0,0,0]},NAD83:{ellipsoid:d.GRS80,transform:[.9956,-1.9103,-.5215,-62e-5,.025915,.009426,.011599]},NTF:{ellipsoid:d.Clarke1880IGN,transform:[168,60,-320,0,0,0,0]},OSGB36:{ellipsoid:d.Airy1830,transform:[-446.448,125.157,-542.06,20.4894,-.1502,-.247,-.8421]},Potsdam:{ellipsoid:d.Bessel1841,transform:[-582,-105,-414,-8.3,1.04,.35,-3.08]},TokyoJapan:{ellipsoid:d.Bessel1841,transform:[148,-507,-685,0,0,0,0]},WGS72:{ellipsoid:d.WGS72,transform:[0,0,-4.5,-.22,0,0,.554]},WGS84:{ellipsoid:d.WGS84,transform:[0,0,0,0,0,0,0]}};Object.keys(d).forEach(t=>Object.freeze(d[t])),Object.keys(p).forEach(t=>{Object.freeze(p[t]),Object.freeze(p[t].transform)});class f extends u{constructor(t,e,r=0,n=p.WGS84){if(!n||null==n.ellipsoid)throw new TypeError(`unrecognised datum ‘${n}’`);super(t,e,r),this._datum=n}get datum(){return this._datum}static get ellipsoids(){return d}static get datums(){return p}static parse(...t){let e=p.WGS84;if((4==t.length||3==t.length&&"object"==typeof t[2])&&(e=t.pop()),!e||null==e.ellipsoid)throw new TypeError(`unrecognised datum ‘${e}’`);const r=super.parse(...t);return r._datum=e,r}convertDatum(t){if(!t||null==t.ellipsoid)throw new TypeError(`unrecognised datum ‘${t}’`);return this.toCartesian().convertDatum(t).toLatLon()}toCartesian(){const t=super.toCartesian();return new m(t.x,t.y,t.z,this.datum)}}class m extends h{constructor(t,e,r,n=void 0){if(n&&null==n.ellipsoid)throw new TypeError(`unrecognised datum ‘${n}’`);super(t,e,r),n&&(this._datum=n)}get datum(){return this._datum}set datum(t){if(!t||null==t.ellipsoid)throw new TypeError(`unrecognised datum ‘${t}’`);this._datum=t}toLatLon(t=void 0){t&&(console.info("datum parameter to Cartesian_Datum.toLatLon is deprecated: set datum before calling toLatLon()"),this.datum=t);const e=this.datum||p.WGS84;if(!e||null==e.ellipsoid)throw new TypeError(`unrecognised datum ‘${e}’`);const r=super.toLatLon(e.ellipsoid);return new f(r.lat,r.lon,r.height,this.datum)}convertDatum(t){if(!t||null==t.ellipsoid)throw new TypeError(`unrecognised datum ‘${t}’`);if(!this.datum)throw new TypeError("cartesian coordinate has no datum");let e=null,r=null;null!=this.datum&&this.datum!=p.WGS84||(e=this,r=t.transform),t==p.WGS84&&(e=this,r=this.datum.transform.map(t=>-t)),null==r&&(e=this.convertDatum(p.WGS84),r=t.transform);const n=e.applyTransform(r);return n.datum=t,n}applyTransform(t){const{x:e,y:r,z:n}=this,i=t[0],a=t[1],o=t[2],s=t[3]/1e6+1,l=(t[4]/3600).toRadians(),c=(t[5]/3600).toRadians(),u=(t[6]/3600).toRadians();return new m(i+e*s-r*u+n*c,a+e*u+r*s-n*l,o-e*c+r*l+n*s)}}const g={trueOrigin:{lat:49,lon:-2},falseOrigin:{easting:-4e5,northing:1e5},scaleFactor:.9996012717,ellipsoid:f.ellipsoids.Airy1830};class y{constructor(t,e){if(this.easting=Number(t),this.northing=Number(e),isNaN(t)||this.easting<0||this.easting>7e5)throw new RangeError(`invalid easting ‘${t}’`);if(isNaN(e)||this.northing<0||this.northing>13e5)throw new RangeError(`invalid northing ‘${e}’`)}toLatLon(t=f.datums.WGS84){const{easting:e,northing:r}=this,{a:n,b:i}=g.ellipsoid,a=g.trueOrigin.lat.toRadians(),o=g.trueOrigin.lon.toRadians(),s=-g.falseOrigin.easting,l=-g.falseOrigin.northing,c=g.scaleFactor,u=1-i*i/(n*n),h=(n-i)/(n+i),d=h*h,p=h*h*h;let m=a,y=0;do{m=(r-l-y)/(n*c)+m,y=i*c*((1+h+5/4*d+5/4*p)*(m-a)-(3*h+3*h*h+21/8*p)*Math.sin(m-a)*Math.cos(m+a)+(15/8*d+15/8*p)*Math.sin(2*(m-a))*Math.cos(2*(m+a))-35/24*p*Math.sin(3*(m-a))*Math.cos(3*(m+a)))}while(Math.abs(r-l-y)>=1e-5);const _=Math.cos(m),N=Math.sin(m),b=n*c/Math.sqrt(1-u*N*N),v=n*c*(1-u)/Math.pow(1-u*N*N,1.5),E=b/v-1,S=Math.tan(m),M=S*S,T=M*M,$=1/_,x=b*b*b,G=x*b*b,O=e-s,F=O*O,R=F*O,W=F*F,D=R*F;m=m-S/(2*v*b)*F+S/(24*v*x)*(5+3*M+E-9*M*E)*W-S/(720*v*G)*(61+90*M+45*T)*(W*F);const L=o+$/b*O-$/(6*x)*(b/v+2*M)*R+$/(120*G)*(5+28*M+24*T)*D-$/(G*b*b*5040)*(61+662*M+1320*T+T*M*720)*(D*F);let z=new w(m.toDegrees(),L.toDegrees(),0,f.datums.OSGB36);return t!=f.datums.OSGB36&&(z=z.convertDatum(t),z=new w(z.lat,z.lon,z.height,z.datum)),z}static parse(t){let e=(t=String(t).trim()).match(/^(\d+),\s*(\d+)$/);if(e)return new y(e[1],e[2]);if(e=t.match(/^[HNST][ABCDEFGHJKLMNOPQRSTUVWXYZ]\s*[0-9]+\s*[0-9]+$/i),!e)throw new Error(`invalid grid reference ‘${t}’`);let r=t.toUpperCase().charCodeAt(0)-"A".charCodeAt(0),n=t.toUpperCase().charCodeAt(1)-"A".charCodeAt(0);r>7&&r--,n>7&&n--;const i=(r-2)%5*5+n%5,a=19-5*Math.floor(r/5)-Math.floor(n/5);let o=t.slice(2).trim().split(/\s+/);if(1==o.length&&(o=[o[0].slice(0,o[0].length/2),o[0].slice(o[0].length/2)]),o[0].length!=o[1].length)throw new Error(`invalid grid reference ‘${t}’`);o[0]=o[0].padEnd(5,"0"),o[1]=o[1].padEnd(5,"0");const s=i+o[0],l=a+o[1];return new y(s,l)}toString(t=10){if(![0,2,4,6,8,10,12,14,16].includes(Number(t)))throw new RangeError(`invalid precision ‘${t}’`);let{easting:e,northing:r}=this;if(0==t){const t={useGrouping:!1,minimumIntegerDigits:6,maximumFractionDigits:3};return`${e.toLocaleString("en",t)},${r.toLocaleString("en",t)}`}const n=Math.floor(e/1e5),i=Math.floor(r/1e5);let a=19-i-(19-i)%5+Math.floor((n+10)/5),o=5*(19-i)%25+n%5;a>7&&a++,o>7&&o++;const s=String.fromCharCode(a+"A".charCodeAt(0),o+"A".charCodeAt(0));return e=Math.floor(e%1e5/Math.pow(10,5-t/2)),r=Math.floor(r%1e5/Math.pow(10,5-t/2)),e=e.toString().padStart(t/2,"0"),r=r.toString().padStart(t/2,"0"),`${s} ${e} ${r}`}}class w extends f{toOsGrid(){const t=this.datum==f.datums.OSGB36?this:this.convertDatum(f.datums.OSGB36),e=t.lat.toRadians(),r=t.lon.toRadians(),{a:n,b:i}=g.ellipsoid,a=g.trueOrigin.lat.toRadians(),o=g.trueOrigin.lon.toRadians(),s=-g.falseOrigin.easting,l=-g.falseOrigin.northing,c=g.scaleFactor,u=1-i*i/(n*n),h=(n-i)/(n+i),d=h*h,p=h*h*h,m=Math.cos(e),w=Math.sin(e),_=n*c/Math.sqrt(1-u*w*w),N=n*c*(1-u)/Math.pow(1-u*w*w,1.5),b=_/N-1,v=i*c*((1+h+5/4*d+5/4*p)*(e-a)-(3*h+3*h*h+21/8*p)*Math.sin(e-a)*Math.cos(e+a)+(15/8*d+15/8*p)*Math.sin(2*(e-a))*Math.cos(2*(e+a))-35/24*p*Math.sin(3*(e-a))*Math.cos(3*(e+a))),E=m*m*m,S=E*m*m,M=Math.tan(e)*Math.tan(e),T=M*M,$=r-o,x=$*$,G=x*$,O=G*$,F=O*$;let R=v+l+_/2*w*m*x+_/24*w*E*(5-M+9*b)*O+_/720*w*S*(61-58*M+T)*(F*$),W=s+_*m*$+_/6*E*(_/N-M)*G+_/120*S*(5-18*M+T+14*b-58*M*b)*F;R=Number(R.toFixed(3)),W=Number(W.toFixed(3));try{return new y(W,R)}catch(e){throw new Error(`${e.message} from (${t.lat.toFixed(6)},${t.lon.toFixed(6)}).toOsGrid()`)}}convertDatum(t){const e=super.convertDatum(t);return new w(e.lat,e.lon,e.height,e.datum)}}function _(t){var e=t.ID,r=t.NAME1,n=t.POPULATED_PLACE,i=t.COUNTY_UNITARY,a=t.REGION,o=t.GEOMETRY_X,s=t.GEOMETRY_Y;return{id:e||"",place:"".concat(r).concat(n?", "+n:"").concat(i?", "+i:"",", ").concat(a),county:i||"",coordinates:[o,s]}}function N(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function a(r,n,i,a){var l=n&&n.prototype instanceof s?n:s,c=Object.create(l.prototype);return b(c,"_invoke",function(r,n,i){var a,s,l,c=0,u=i||[],h=!1,d={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return a=e,s=0,l=t,d.n=r,o}};function p(r,n){for(s=r,l=n,e=0;!h&&c&&!i&&e<u.length;e++){var i,a=u[e],p=d.p,f=a[2];r>3?(i=f===n)&&(l=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=t):a[0]<=p&&((i=r<2&&p<a[1])?(s=0,d.v=n,d.n=a[1]):p<f&&(i=r<3||a[0]>n||n>f)&&(a[4]=r,a[5]=n,d.n=f,s=0))}if(i||r>1)return o;throw h=!0,n}return function(i,u,f){if(c>1)throw TypeError("Generator is already running");for(h&&1===u&&p(u,f),s=u,l=f;(e=s<2?t:l)||!h;){a||(s?s<3?(s>1&&(d.n=-1),p(s,l)):d.n=l:d.v=l);try{if(c=2,a){if(s||(i="next"),e=a[i]){if(!(e=e.call(a,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,s<2&&(s=0)}else 1===s&&(e=a.return)&&e.call(a),s<2&&(l=TypeError("The iterator does not provide a '"+i+"' method"),s=1);a=t}else if((e=(h=d.n<0)?l:r.call(n,d))!==o)break}catch(e){a=t,s=1,l=e}finally{c=1}}return{value:e,done:h}}}(r,i,a),!0),c}var o={};function s(){}function l(){}function c(){}e=Object.getPrototypeOf;var u=[][n]?e(e([][n]())):(b(e={},n,function(){return this}),e),h=c.prototype=s.prototype=Object.create(u);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,b(t,i,"GeneratorFunction")),t.prototype=Object.create(h),t}return l.prototype=c,b(h,"constructor",c),b(c,"constructor",l),l.displayName="GeneratorFunction",b(c,i,"GeneratorFunction"),b(h),b(h,i,"Generator"),b(h,n,function(){return this}),b(h,"toString",function(){return"[object Generator]"}),(N=function(){return{w:a,m:d}})()}function b(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}b=function(t,e,r,n){function a(e,r){b(t,e,function(t){return this._invoke(e,r,t)})}e?i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(a("next",0),a("throw",1),a("return",2))},b(t,e,r,n)}function v(t,e,r,n,i,a,o){try{var s=t[a](o),l=s.value}catch(t){return void r(t)}s.done?e(l):Promise.resolve(l).then(n,i)}var E=function(){var t,e=(t=N().m(function t(){var e,r,n,i,a,o,s,l,c,u,h,d,p,f,m=arguments;return N().w(function(t){for(;;)switch(t.p=t.n){case 0:if(e=m.length>0&&void 0!==m[0]?m[0]:"https://api.os.uk/search/names/v1/nearest?point={easting},{northing}&radius=1000&fq=local_type:Airfield%20local_type:Airport%20local_type:Bus_Station%20local_type:Chemical_Works%20local_type:City%20local_type:Coach_Station%20local_type:Electricity_Distribution%20local_type:Electricity_Production%20local_type:Further_Education%20local_type:Gas_Distribution_or_Storage%20local_type:Hamlet%20local_type:Harbour%20local_type:Helicopter_Station%20local_type:Heliport%20local_type:Higher_or_University_Education%20local_type:Hill_Or_Mountain%20local_type:Hospice%20local_type:Hospital%20local_type:Medical_Care_Accommodation%20local_type:Named_Road%20local_type:Non_State_Primary_Education%20local_type:Non_State_Secondary_Education%20local_type:Other_Settlement%20local_type:Passenger_Ferry_Terminal%20local_type:Port_Consisting_of_Docks_and_Nautical_Berthing%20local_type:Postcode%20local_type:Primary_Education%20local_type:Railway_Station%20local_type:Road_User_Services%20local_type:Secondary_Education%20local_type:Section_Of_Named_Road%20local_type:Section_Of_Numbered_Road%20local_type:Special_Needs_Education%20local_type:Suburban_Area%20local_type:Town%20local_type:Urban_Greenspace%20local_type:Vehicular_Ferry_Terminal%20local_type:Vehicular_Rail_Terminal%20local_type:Village%20local_type:Waterfall%20",r=m.length>1?m[1]:void 0,a=i=m.length>4?m[4]:void 0,"EPSG:4326"!==(n=m.length>2?m[2]:void 0)){t.n=3;break}t.p=1,a=[(a=new w(i[1],i[0]).toOsGrid()).easting,a.northing].map(function(t){return Math.round(t)}),t.n=3;break;case 2:return t.p=2,p=t.v,console.log(p),t.a(2,null);case 3:if(e=e.replace("{easting}",Math.round(a[0])).replace("{northing}",Math.round(a[1])),o=new Request(e,{method:"GET"}),!r){t.n=7;break}return t.p=4,t.n=5,r(o);case 5:o=t.v,t.n=7;break;case 6:return t.p=6,f=t.v,console.log("Error transforming request:",f),t.a(2,null);case 7:return t.n=8,fetch(o);case 8:return s=t.v,t.n=9,s.json();case 9:return l=t.v,c=_(l.results[0].GAZETTEER_ENTRY),"EPSG:4326"===n&&(u=new y(c.coordinates[0],c.coordinates[1]),h=u.toLatLon(),c.coordinates=[h.lat,h.lon]),d="Approximate centre ".concat(null==c?void 0:c.place),t.a(2,l.results?d:null)}},t,null,[[4,6],[1,2]])}),function(){var e=this,r=arguments;return new Promise(function(n,i){var a=t.apply(e,r);function o(t){v(a,n,i,o,s,"next",t)}function s(t){v(a,n,i,o,s,"throw",t)}o(void 0)})});return function(){return e.apply(this,arguments)}}()}}]);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("defra",[],t):"object"==typeof exports?exports.defra=t():(e.defra=e.defra||{},e.defra.openNamesProvider=t())}(Object("undefined"!=typeof self?self:this),function(){return function(){"use strict";var e,t,r={},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.m=r,o.d=function(e,t){for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.f={},o.e=function(e){return Promise.all(Object.keys(o.f).reduce(function(t,r){return o.f[r](e,t),t},[]))},o.u=function(e){return"im-reverse-geocode.js"},o.miniCssF=function(e){},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},e={},t="defra.openNamesProvider:",o.l=function(r,n,i,u){if(e[r])e[r].push(n);else{var c,a;if(void 0!==i)for(var f=document.getElementsByTagName("script"),p=0;p<f.length;p++){var l=f[p];if(l.getAttribute("src")==r||l.getAttribute("data-webpack")==t+i){c=l;break}}c||(a=!0,(c=document.createElement("script")).charset="utf-8",o.nc&&c.setAttribute("nonce",o.nc),c.setAttribute("data-webpack",t+i),c.src=r),e[r]=[n];var s=function(t,n){c.onerror=c.onload=null,clearTimeout(d);var o=e[r];if(delete e[r],c.parentNode&&c.parentNode.removeChild(c),o&&o.forEach(function(e){return e(n)}),t)return t(n)},d=setTimeout(s.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=s.bind(null,c.onerror),c.onload=s.bind(null,c.onload),a&&document.head.appendChild(c)}},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},function(){var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e}(),function(){var e={57:0};o.f.j=function(t,r){var n=o.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise(function(r,o){n=e[t]=[r,o]});r.push(n[2]=i);var u=o.p+o.u(t),c=new Error;o.l(u,function(r){if(o.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+t+" failed.\n("+i+": "+u+")",c.name="ChunkLoadError",c.type=i,c.request=u,n[1](c)}},"chunk-"+t,t)}};var t=function(t,r){var n,i,u=r[0],c=r[1],a=r[2],f=0;if(u.some(function(t){return 0!==e[t]})){for(n in c)o.o(c,n)&&(o.m[n]=c[n]);a&&a(o)}for(t&&t(r);f<u.length;f++)i=u[f],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))}();var i={};function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function c(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof f?n:f,p=Object.create(c.prototype);return a(p,"_invoke",function(r,n,o){var i,c,a,f=0,p=o||[],l=!1,s={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,c=0,a=e,s.n=r,u}};function d(r,n){for(c=r,a=n,t=0;!l&&f&&!o&&t<p.length;t++){var o,i=p[t],d=s.p,b=i[2];r>3?(o=b===n)&&(a=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,s.v=n,s.n=i[1]):d<b&&(o=r<3||i[0]>n||n>b)&&(i[4]=r,i[5]=n,s.n=b,c=0))}if(o||r>1)return u;throw l=!0,n}return function(o,p,b){if(f>1)throw TypeError("Generator is already running");for(l&&1===p&&d(p,b),c=p,a=b;(t=c<2?e:a)||!l;){i||(c?c<3?(c>1&&(s.n=-1),d(c,a)):s.n=a:s.v=a);try{if(f=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,a)))throw TypeError("iterator result is not an object");if(!t.done)return t;a=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(a=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(l=s.n<0)?a:r.call(n,s))!==u)break}catch(t){i=e,c=1,a=t}finally{f=1}}return{value:t,done:l}}}(r,o,i),!0),p}var u={};function f(){}function p(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(a(t={},n,function(){return this}),t),d=l.prototype=f.prototype=Object.create(s);function b(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,a(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return p.prototype=l,a(d,"constructor",l),a(l,"constructor",p),p.displayName="GeneratorFunction",a(l,o,"GeneratorFunction"),a(d),a(d,o,"Generator"),a(d,n,function(){return this}),a(d,"toString",function(){return"[object Generator]"}),(c=function(){return{w:i,m:b}})()}function a(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}a=function(e,t,r,n){function i(t,r){a(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},a(e,t,r,n)}function f(e,t,r,n,o,i,u){try{var c=e[i](u),a=c.value}catch(e){return void r(e)}c.done?t(a):Promise.resolve(a).then(n,o)}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t,r){return(t=function(e){var t=function(e){if("object"!=u(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=u(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==u(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(){var e,t;return l(l({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{load:(e=c().m(function e(){var t;return c().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,o.e(627).then(o.bind(o,246));case 1:return t=e.v,e.a(2,t.reverseGeocode)}},e)}),t=function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function u(e){f(i,n,o,u,c,"next",e)}function c(e){f(i,n,o,u,c,"throw",e)}u(void 0)})},function(){return t.apply(this,arguments)})})}return o.d(i,{default:function(){return d}}),i.default}()});
|