@defra/interactive-map 0.0.45-alpha → 0.0.46-fmp-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/index.css +1 -1
- package/dist/esm/im-core.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/docs/api/map-style-config.md +7 -0
- package/docs/assets/images/select-feature.jpg +0 -0
- package/govuk-prototype-kit.config.json +1 -0
- package/package.json +1 -1
- package/plugins/draw/dist/esm/im-draw-ol-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/src/adapters/openlayers/core/OLDrawManager.js +5 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapEngine.js +10 -5
- package/plugins/draw/src/adapters/openlayers/snap/snapEngine.test.js +1 -0
- package/providers/beta/openlayers/dist/esm/im-openlayers-provider.js +1 -1
- package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +1 -1
- package/providers/beta/openlayers/src/openlayersProvider.js +1 -1
- package/providers/beta/openlayers/src/openlayersProvider.test.js +22 -0
- package/providers/beta/openlayers/src/utils/highlightFeatures.js +23 -11
- package/providers/beta/openlayers/src/utils/highlightFeatures.test.js +2 -0
- package/providers/beta/openlayers/src/utils/hoverCursor.js +6 -5
- package/providers/beta/openlayers/src/utils/hoverCursor.test.js +2 -1
- package/providers/beta/openlayers/src/utils/queryFeatures.js +9 -6
- package/providers/beta/openlayers/src/utils/queryFeatures.test.js +6 -3
- package/providers/beta/openlayers/src/utils/spatial.js +6 -15
- package/providers/beta/openlayers/src/utils/spatial.test.js +3 -9
- package/providers/beta/openlayers/src/utils/tileLayers.js +5 -0
- package/providers/beta/openlayers/src/utils/tileLayers.test.js +1 -1
- package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
- package/providers/maplibre/src/utils/labels.js +3 -3
- package/providers/maplibre/src/utils/labels.test.js +2 -2
- package/src/App/components/Attributions/Attributions.jsx +3 -1
- package/src/App/components/Attributions/Attributions.module.scss +7 -3
- package/src/App/components/Attributions/Attributions.test.jsx +8 -0
- package/src/App/hooks/useLayoutMeasurements.js +94 -29
- package/src/App/hooks/useLayoutMeasurements.test.js +55 -10
- package/src/App/layout/Layout.jsx +7 -3
- package/src/App/layout/layout.module.scss +30 -1
- package/src/types.js +5 -0
|
@@ -64,7 +64,7 @@ export default class OpenLayersProvider extends MapProvider {
|
|
|
64
64
|
projection: CRS,
|
|
65
65
|
center: center ?? (bounds ? getExtentCenter(bounds) : undefined),
|
|
66
66
|
zoom: zoom ?? viewResolutions.defaultMinZoom,
|
|
67
|
-
minZoom:
|
|
67
|
+
minZoom: minZoom ?? viewResolutions.defaultMinZoom,
|
|
68
68
|
maxZoom: maxZoom ?? viewResolutions.maxZoom,
|
|
69
69
|
resolutions: viewResolutions.resolutions,
|
|
70
70
|
constrainResolution: false,
|
|
@@ -174,6 +174,28 @@ describe('OpenLayersProvider', () => {
|
|
|
174
174
|
expect(View).toHaveBeenCalledWith(expect.objectContaining({ center: [400000, 300000] }))
|
|
175
175
|
})
|
|
176
176
|
|
|
177
|
+
it('passes minZoom and maxZoom through to the View unchanged', async () => {
|
|
178
|
+
const { provider } = makeProvider({ zoomAlignment: 'world' })
|
|
179
|
+
await provider.initMap({ ...defaultInitConfig, minZoom: 8, maxZoom: 12 })
|
|
180
|
+
expect(View).toHaveBeenCalledWith(expect.objectContaining({ minZoom: 8, maxZoom: 12 }))
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
// Regression: minZoom used to be floored at the zoom alignment's default via Math.max(),
|
|
184
|
+
// silently overriding any caller-supplied minZoom that was more permissive (lower) than
|
|
185
|
+
// that default — e.g. a consumer trying to let people zoom out further than the 'world'
|
|
186
|
+
// alignment's default minZoom of 6 had their config ignored.
|
|
187
|
+
it('does not clamp a minZoom below the zoom alignment default', async () => {
|
|
188
|
+
const { provider } = makeProvider({ zoomAlignment: 'world' })
|
|
189
|
+
await provider.initMap({ ...defaultInitConfig, minZoom: 0 })
|
|
190
|
+
expect(View).toHaveBeenCalledWith(expect.objectContaining({ minZoom: 0 }))
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
it('falls back to the zoom alignment defaults when minZoom/maxZoom are not provided', async () => {
|
|
194
|
+
const { provider } = makeProvider({ zoomAlignment: 'world' })
|
|
195
|
+
await provider.initMap({ ...defaultInitConfig, minZoom: null, maxZoom: null })
|
|
196
|
+
expect(View).toHaveBeenCalledWith(expect.objectContaining({ minZoom: 6, maxZoom: 20 }))
|
|
197
|
+
})
|
|
198
|
+
|
|
177
199
|
it('creates the initial layer from the map style', async () => {
|
|
178
200
|
const { provider } = makeProvider()
|
|
179
201
|
await provider.initMap(defaultInitConfig)
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import VectorTileLayer from 'ol/layer/VectorTile.js'
|
|
2
1
|
import VectorLayer from 'ol/layer/Vector.js'
|
|
3
2
|
import VectorSource from 'ol/source/Vector.js'
|
|
4
3
|
import Feature from 'ol/Feature.js'
|
|
@@ -18,6 +17,11 @@ const geoJsonFormat = new GeoJSON({ dataProjection: CRS, featureProjection: CRS
|
|
|
18
17
|
const HIGHLIGHT_MARKER = '_highlight'
|
|
19
18
|
const HIGHLIGHT_Z = 999
|
|
20
19
|
|
|
20
|
+
// Layers are classified by a `layerType` tag ('vector' | 'vectorTile') set at creation,
|
|
21
|
+
// not `instanceof VectorLayer`/`VectorTileLayer` — a UMD consumer loads this provider and
|
|
22
|
+
// other plugins (e.g. draw) as independently-bundled scripts, each with its own copy of
|
|
23
|
+
// ol, so a class reference from this bundle never matches an instance built by another.
|
|
24
|
+
|
|
21
25
|
const buildHighlightStyles = (styleEntry, isActive) => {
|
|
22
26
|
if (!styleEntry) {
|
|
23
27
|
return []
|
|
@@ -40,6 +44,13 @@ const buildHighlightStyles = (styleEntry, isActive) => {
|
|
|
40
44
|
|
|
41
45
|
const hasSymbolStyle = (properties) => !!(properties?.symbol || properties?.symbolSvgContent)
|
|
42
46
|
|
|
47
|
+
const toStyleArray = (style) => {
|
|
48
|
+
if (!style) {
|
|
49
|
+
return []
|
|
50
|
+
}
|
|
51
|
+
return Array.isArray(style) ? style : [style]
|
|
52
|
+
}
|
|
53
|
+
|
|
43
54
|
// A drawn point renders as a real symbol icon, not Stroke/Fill, so its selected/active ring is
|
|
44
55
|
// the active/selected variant of that same icon instead. Returns null (not []) for a
|
|
45
56
|
// non-symbol feature so the caller falls through to buildHighlightStyles.
|
|
@@ -83,7 +94,7 @@ const buildFeatureKeyIndex = (features) => {
|
|
|
83
94
|
|
|
84
95
|
const wrapVtLayers = (map, selectedKeys, activeKeys, idPropsMap, stylesMap) => {
|
|
85
96
|
map.getLayers().forEach(layer => {
|
|
86
|
-
if (
|
|
97
|
+
if (layer.get('layerType') !== 'vectorTile') {
|
|
87
98
|
return
|
|
88
99
|
}
|
|
89
100
|
|
|
@@ -124,8 +135,7 @@ const wrapVtLayers = (map, selectedKeys, activeKeys, idPropsMap, stylesMap) => {
|
|
|
124
135
|
return base
|
|
125
136
|
}
|
|
126
137
|
|
|
127
|
-
|
|
128
|
-
return [...baseArr, ...highlightStyles]
|
|
138
|
+
return [...toStyleArray(base), ...highlightStyles]
|
|
129
139
|
})
|
|
130
140
|
// setStyle() calls layer.changed() internally — no source.changed() needed
|
|
131
141
|
// (source.changed() works but causes a visible flicker on selection)
|
|
@@ -148,6 +158,7 @@ const getOrCreateHighlightLayer = (map) => {
|
|
|
148
158
|
if (!layer) {
|
|
149
159
|
layer = new VectorLayer({ source: new VectorSource(), zIndex: HIGHLIGHT_Z + 2 })
|
|
150
160
|
layer.set(HIGHLIGHT_MARKER, true)
|
|
161
|
+
layer.set('layerType', 'vector')
|
|
151
162
|
map.addLayer(layer)
|
|
152
163
|
}
|
|
153
164
|
return layer
|
|
@@ -162,7 +173,7 @@ const getLiveProperties = (map, layerId, featureId) => {
|
|
|
162
173
|
}
|
|
163
174
|
let properties
|
|
164
175
|
map.getLayers().forEach(l => {
|
|
165
|
-
if (properties ||
|
|
176
|
+
if (properties || l.get('layerType') !== 'vector' || l.get(HIGHLIGHT_MARKER) || l.get('layerId') !== layerId) {
|
|
166
177
|
return
|
|
167
178
|
}
|
|
168
179
|
const feature = l.getSource()?.getFeatureById(String(featureId))
|
|
@@ -180,12 +191,11 @@ const addVectorHighlights = (map, source, features, isActive, stylesMap) => {
|
|
|
180
191
|
}
|
|
181
192
|
const liveProperties = getLiveProperties(map, layerId, featureId)
|
|
182
193
|
const styles = buildSymbolHighlightStyle(liveProperties, isActive) ?? buildHighlightStyles(stylesMap?.[layerId], isActive)
|
|
183
|
-
if (
|
|
184
|
-
|
|
194
|
+
if (styles.length) {
|
|
195
|
+
const olFeature = new Feature({ geometry: geoJsonFormat.readGeometry(geometry) })
|
|
196
|
+
olFeature.setStyle(styles)
|
|
197
|
+
source.addFeature(olFeature)
|
|
185
198
|
}
|
|
186
|
-
const olFeature = new Feature({ geometry: geoJsonFormat.readGeometry(geometry) })
|
|
187
|
-
olFeature.setStyle(styles)
|
|
188
|
-
source.addFeature(olFeature)
|
|
189
199
|
}
|
|
190
200
|
}
|
|
191
201
|
|
|
@@ -206,6 +216,8 @@ const expandBoundsFromGeometry = (geometry, cb) => {
|
|
|
206
216
|
coordinates.forEach(visitRing)
|
|
207
217
|
} else if (type === 'MultiPolygon') {
|
|
208
218
|
coordinates.forEach(poly => poly.forEach(visitRing))
|
|
219
|
+
} else {
|
|
220
|
+
// unsupported/unrecognised geometry type — nothing to expand bounds by
|
|
209
221
|
}
|
|
210
222
|
}
|
|
211
223
|
|
|
@@ -260,7 +272,7 @@ export const updateHighlightedFeatures = (map, selectedFeatures, activeFeatures,
|
|
|
260
272
|
// Determine which layerIds belong to plain VectorLayers vs VT layers
|
|
261
273
|
const vectorLayerIds = new Set()
|
|
262
274
|
map.getLayers().forEach(l => {
|
|
263
|
-
if (l
|
|
275
|
+
if (l.get('layerType') === 'vector' && !l.get(HIGHLIGHT_MARKER)) {
|
|
264
276
|
const id = l.get('layerId')
|
|
265
277
|
if (id) {
|
|
266
278
|
vectorLayerIds.add(id)
|
|
@@ -38,6 +38,7 @@ const drawLayer = (features = []) => {
|
|
|
38
38
|
})
|
|
39
39
|
const layer = new VectorLayer({ source })
|
|
40
40
|
layer.set('layerId', 'draw')
|
|
41
|
+
layer.set('layerType', 'vector') // mirrors OLDrawManager.js's own tagging
|
|
41
42
|
return layer
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -170,6 +171,7 @@ describe('updateHighlightedFeatures', () => {
|
|
|
170
171
|
describe('VectorTileLayer style-wrap (smoke test — pre-existing, undocumented path)', () => {
|
|
171
172
|
test('does not throw when a VT layer is present alongside a draw VectorLayer', () => {
|
|
172
173
|
const vt = new VectorTileLayer({})
|
|
174
|
+
vt.set('layerType', 'vectorTile')
|
|
173
175
|
const map = createFakeMap([vt, drawLayer()])
|
|
174
176
|
expect(() => updateHighlightedFeatures(map, [], [], {})).not.toThrow()
|
|
175
177
|
})
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import VectorTileLayer from 'ol/layer/VectorTile.js'
|
|
2
|
-
import VectorLayer from 'ol/layer/Vector.js'
|
|
3
|
-
|
|
4
1
|
const HIGHLIGHT_MARKER = '_highlight'
|
|
5
2
|
const HIT_TOLERANCE = 8
|
|
6
3
|
|
|
4
|
+
// Layers are classified by a `layerType` tag ('vector' | 'vectorTile') set at creation,
|
|
5
|
+
// not `instanceof VectorLayer`/`VectorTileLayer` — a UMD consumer loads this provider and
|
|
6
|
+
// other plugins (e.g. draw) as independently-bundled scripts, each with its own copy of
|
|
7
|
+
// ol, so a class reference from this bundle never matches an instance built by another.
|
|
7
8
|
const isInteractiveFeature = (feature, layer, layerSet) => {
|
|
8
|
-
if (layer
|
|
9
|
+
if (layer.get('layerType') === 'vectorTile') {
|
|
9
10
|
const styleLayerId = feature.get('mapbox-layer')?.id
|
|
10
11
|
return Boolean(styleLayerId && layerSet.has(styleLayerId))
|
|
11
12
|
}
|
|
12
|
-
if (layer
|
|
13
|
+
if (layer.get('layerType') === 'vector' && !layer.get(HIGHLIGHT_MARKER)) {
|
|
13
14
|
const layerId = layer.get('layerId')
|
|
14
15
|
return Boolean(layerId && layerSet.has(layerId))
|
|
15
16
|
}
|
|
@@ -26,13 +26,14 @@ const makeVectorFeature = () => ({ get: () => undefined })
|
|
|
26
26
|
|
|
27
27
|
const makeVTLayer = () => {
|
|
28
28
|
const layer = new VectorTileLayer()
|
|
29
|
-
layer.get = () => undefined
|
|
29
|
+
layer.get = (key) => key === 'layerType' ? 'vectorTile' : undefined
|
|
30
30
|
return layer
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const makeVectorLayer = (layerId, isHighlight = false) => {
|
|
34
34
|
const layer = new VectorLayer()
|
|
35
35
|
layer.get = (key) => {
|
|
36
|
+
if (key === 'layerType') return 'vector'
|
|
36
37
|
if (key === '_highlight') return isHighlight ? true : undefined
|
|
37
38
|
if (key === 'layerId') return layerId
|
|
38
39
|
return undefined
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import VectorTileLayer from 'ol/layer/VectorTile.js'
|
|
2
|
-
import VectorLayer from 'ol/layer/Vector.js'
|
|
3
1
|
import GeoJSON from 'ol/format/GeoJSON.js'
|
|
4
2
|
import TileState from 'ol/TileState.js'
|
|
5
3
|
import { renderFeatureToGeoJSON } from './vtTileFragments.js'
|
|
@@ -8,6 +6,11 @@ const CRS = 'EPSG:27700'
|
|
|
8
6
|
|
|
9
7
|
const geoJsonFormat = new GeoJSON({ dataProjection: CRS, featureProjection: CRS })
|
|
10
8
|
|
|
9
|
+
// Layers are classified by a `layerType` tag ('vector' | 'vectorTile') set at creation,
|
|
10
|
+
// not `instanceof VectorLayer`/`VectorTileLayer` — a UMD consumer loads this provider and
|
|
11
|
+
// other plugins (e.g. draw) as independently-bundled scripts, each with its own copy of
|
|
12
|
+
// ol, so a class reference from this bundle never matches an instance built by another.
|
|
13
|
+
|
|
11
14
|
// Mirror MapLibre's fallback: use property hash when feature has no explicit MVT ID.
|
|
12
15
|
// This deduplicates tile-split fragments that share the same properties.
|
|
13
16
|
const getVtFeatureId = (feature) => {
|
|
@@ -32,7 +35,7 @@ export const queryFeatures = (map, point, options = {}) => {
|
|
|
32
35
|
map.forEachFeatureAtPixel(
|
|
33
36
|
pixel,
|
|
34
37
|
(feature, layer) => {
|
|
35
|
-
if (layer
|
|
38
|
+
if (layer.get('layerType') === 'vectorTile') {
|
|
36
39
|
const mapboxLayer = feature.get('mapbox-layer')
|
|
37
40
|
const styleLayerId = mapboxLayer?.id
|
|
38
41
|
// background-type layers have no features in MapLibre — skip to match behaviour
|
|
@@ -50,7 +53,7 @@ export const queryFeatures = (map, point, options = {}) => {
|
|
|
50
53
|
geometry: renderFeatureToGeoJSON(feature),
|
|
51
54
|
properties: feature.getProperties()
|
|
52
55
|
})
|
|
53
|
-
} else if (layer
|
|
56
|
+
} else if (layer.get('layerType') === 'vector') {
|
|
54
57
|
const layerId = layer.get('layerId')
|
|
55
58
|
if (!layerId || layer.get('_highlight')) {
|
|
56
59
|
return
|
|
@@ -98,7 +101,7 @@ export const getVisibleFeatures = (map, layerIds) => {
|
|
|
98
101
|
const extent = map.getView().calculateExtent(map.getSize())
|
|
99
102
|
|
|
100
103
|
map.getLayers().forEach(mapLayer => {
|
|
101
|
-
if (mapLayer
|
|
104
|
+
if (mapLayer.get('layerType') === 'vectorTile') {
|
|
102
105
|
const sourceTiles = mapLayer.getSource()?.sourceTiles_
|
|
103
106
|
if (!sourceTiles) {
|
|
104
107
|
return
|
|
@@ -127,7 +130,7 @@ export const getVisibleFeatures = (map, layerIds) => {
|
|
|
127
130
|
})
|
|
128
131
|
})
|
|
129
132
|
})
|
|
130
|
-
} else if (mapLayer
|
|
133
|
+
} else if (mapLayer.get('layerType') === 'vector') {
|
|
131
134
|
const layerId = mapLayer.get('layerId')
|
|
132
135
|
if (!layerId || !wanted.has(layerId) || mapLayer.get('_highlight')) {
|
|
133
136
|
return
|
|
@@ -24,7 +24,7 @@ const makeMap = (hits = []) => ({
|
|
|
24
24
|
})
|
|
25
25
|
})
|
|
26
26
|
|
|
27
|
-
const makeVTLayer = () => Object.assign(new VectorTileLayer(), { get: () => undefined })
|
|
27
|
+
const makeVTLayer = () => Object.assign(new VectorTileLayer(), { get: (key) => key === 'layerType' ? 'vectorTile' : undefined })
|
|
28
28
|
|
|
29
29
|
const makeVTFeature = ({ id = undefined, styleLayerId = 'roads', type = 'fill', props = {} } = {}) => ({
|
|
30
30
|
getId: () => id,
|
|
@@ -37,6 +37,7 @@ const makeVTFeature = ({ id = undefined, styleLayerId = 'roads', type = 'fill',
|
|
|
37
37
|
|
|
38
38
|
const makeVectorLayer = (layerId, isHighlight = false) => Object.assign(new VectorLayer(), {
|
|
39
39
|
get: (key) => {
|
|
40
|
+
if (key === 'layerType') return 'vector'
|
|
40
41
|
if (key === 'layerId') return layerId
|
|
41
42
|
if (key === '_highlight') return isHighlight || undefined
|
|
42
43
|
return undefined
|
|
@@ -170,7 +171,7 @@ describe('queryFeatures', () => {
|
|
|
170
171
|
|
|
171
172
|
it('skips features from other layer types', () => {
|
|
172
173
|
const feature = makeVectorFeature('f1')
|
|
173
|
-
const map = makeMap([[feature, {}]]) //
|
|
174
|
+
const map = makeMap([[feature, { get: () => undefined }]]) // untagged, not a vector/vectorTile layer
|
|
174
175
|
expect(queryFeatures(map, { x: 0, y: 0 })).toEqual([])
|
|
175
176
|
})
|
|
176
177
|
|
|
@@ -199,6 +200,7 @@ describe('getVisibleFeatures', () => {
|
|
|
199
200
|
})
|
|
200
201
|
|
|
201
202
|
const makeVTLayerWithTiles = (tiles) => Object.assign(new VectorTileLayer(), {
|
|
203
|
+
get: (key) => key === 'layerType' ? 'vectorTile' : undefined,
|
|
202
204
|
getSource: () => ({ sourceTiles_: tiles })
|
|
203
205
|
})
|
|
204
206
|
|
|
@@ -206,6 +208,7 @@ describe('getVisibleFeatures', () => {
|
|
|
206
208
|
const source = { getFeaturesInExtent: jest.fn(() => features) }
|
|
207
209
|
return Object.assign(new VectorLayer(), {
|
|
208
210
|
get: (key) => {
|
|
211
|
+
if (key === 'layerType') return 'vector'
|
|
209
212
|
if (key === 'layerId') return layerId
|
|
210
213
|
if (key === '_highlight') return isHighlight || undefined
|
|
211
214
|
return undefined
|
|
@@ -290,7 +293,7 @@ describe('getVisibleFeatures', () => {
|
|
|
290
293
|
/* ------------------------------------------------------------------ */
|
|
291
294
|
|
|
292
295
|
it('skips layers that are neither VectorTileLayer nor VectorLayer', () => {
|
|
293
|
-
expect(getVisibleFeatures(makeExtentMap([{}]), ['draw'])).toEqual([])
|
|
296
|
+
expect(getVisibleFeatures(makeExtentMap([{ get: () => undefined }]), ['draw'])).toEqual([])
|
|
294
297
|
})
|
|
295
298
|
|
|
296
299
|
it('returns results from both VT and Vector layers in one call', () => {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import turfBbox from '@turf/bbox'
|
|
2
|
-
import { transformExtent } from 'ol/proj.js'
|
|
3
2
|
|
|
4
3
|
// In EPSG:27700 coordinates are projected metres — distances are Pythagorean, no geodesy needed
|
|
5
4
|
|
|
@@ -63,18 +62,11 @@ const getCardinalMove = (from, to) => {
|
|
|
63
62
|
}
|
|
64
63
|
|
|
65
64
|
/**
|
|
66
|
-
* Get a flat
|
|
65
|
+
* Get a flat extent [xmin, ymin, xmax, ymax] from any GeoJSON object.
|
|
66
|
+
* GeoJSON fed into the OL provider is already in EPSG:27700 (the view's native
|
|
67
|
+
* CRS), not WGS84, so this is a straight bbox — no reprojection.
|
|
67
68
|
*/
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Get a flat extent [xmin, ymin, xmax, ymax] in EPSG:27700 from any GeoJSON object.
|
|
72
|
-
* GeoJSON is always WGS84, so this transforms the bbox.
|
|
73
|
-
*/
|
|
74
|
-
const getExtentFromGeoJSON = (geojson) => {
|
|
75
|
-
const wgs84Bbox = turfBbox(geojson)
|
|
76
|
-
return transformExtent(wgs84Bbox, 'EPSG:4326', 'EPSG:27700')
|
|
77
|
-
}
|
|
69
|
+
const getExtentFromGeoJSON = (geojson) => turfBbox(geojson)
|
|
78
70
|
|
|
79
71
|
/**
|
|
80
72
|
* Returns the visible (padded) extent [xmin, ymin, xmax, ymax] in EPSG:27700.
|
|
@@ -114,9 +106,9 @@ const isGeometryObscured = (geojson, panelRect, map) => {
|
|
|
114
106
|
const scaleX = viewportRect.width / containerRect.width
|
|
115
107
|
const scaleY = viewportRect.height / containerRect.height
|
|
116
108
|
|
|
117
|
-
const [
|
|
109
|
+
const [xmin, ymin, xmax, ymax] = getExtentFromGeoJSON(geojson)
|
|
118
110
|
|
|
119
|
-
const corners = [[
|
|
111
|
+
const corners = [[xmin, ymin], [xmin, ymax], [xmax, ymin], [xmax, ymax]].map(coord => {
|
|
120
112
|
return map.getPixelFromCoordinate(coord)
|
|
121
113
|
}).filter(Boolean)
|
|
122
114
|
|
|
@@ -140,7 +132,6 @@ const isGeometryObscured = (geojson, panelRect, map) => {
|
|
|
140
132
|
export {
|
|
141
133
|
getAreaDimensions,
|
|
142
134
|
getCardinalMove,
|
|
143
|
-
getBboxFromGeoJSON,
|
|
144
135
|
getExtentFromGeoJSON,
|
|
145
136
|
getPaddedExtent,
|
|
146
137
|
isGeometryObscured,
|
|
@@ -7,12 +7,6 @@ import {
|
|
|
7
7
|
isGeometryObscured
|
|
8
8
|
} from './spatial.js'
|
|
9
9
|
|
|
10
|
-
jest.mock('ol/proj.js', () => ({
|
|
11
|
-
__esModule: true,
|
|
12
|
-
transform: (coord) => coord,
|
|
13
|
-
transformExtent: (extent) => extent
|
|
14
|
-
}))
|
|
15
|
-
|
|
16
10
|
describe('formatDimension', () => {
|
|
17
11
|
it('formats sub-mile distances in metres', () => {
|
|
18
12
|
expect(formatDimension(400)).toBe('400 metres')
|
|
@@ -65,9 +59,9 @@ describe('getCardinalMove', () => {
|
|
|
65
59
|
})
|
|
66
60
|
|
|
67
61
|
describe('getExtentFromGeoJSON', () => {
|
|
68
|
-
it('returns a 4-element extent from a GeoJSON point', () => {
|
|
69
|
-
const point = { type: 'Feature', geometry: { type: 'Point', coordinates: [
|
|
70
|
-
expect(getExtentFromGeoJSON(point)).toEqual([
|
|
62
|
+
it('returns a 4-element extent from a GeoJSON point, unchanged (no reprojection)', () => {
|
|
63
|
+
const point = { type: 'Feature', geometry: { type: 'Point', coordinates: [432500, 250000] } }
|
|
64
|
+
expect(getExtentFromGeoJSON(point)).toEqual([432500, 250000, 432500, 250000])
|
|
71
65
|
})
|
|
72
66
|
})
|
|
73
67
|
|
|
@@ -139,6 +139,10 @@ export async function createVectorTileLayer (url, transformRequest, { renderMode
|
|
|
139
139
|
tileGrid
|
|
140
140
|
})
|
|
141
141
|
const layer = new VectorTileLayer({ source, declutter: true, ...(renderMode && { renderMode }) })
|
|
142
|
+
// Tagged rather than left to `instanceof VectorTileLayer` — a UMD consumer loads this
|
|
143
|
+
// provider and other plugins as independently-bundled scripts, each with its own copy
|
|
144
|
+
// of ol, so a class reference from one bundle never matches an instance from another.
|
|
145
|
+
layer.set('layerType', 'vectorTile')
|
|
142
146
|
|
|
143
147
|
stylefunction(layer, styleJson, sourceId, resolutions, spritesJson, sprite.pngUrl)
|
|
144
148
|
|
|
@@ -171,6 +175,7 @@ export async function createOGCVectorTileLayer (url, transformRequest, { renderM
|
|
|
171
175
|
const tileGrid = new TileGrid({ resolutions, origin, tileSize })
|
|
172
176
|
const source = new OGCVectorTile({ url: tilesUrl, format, tileGrid, projection: CRS })
|
|
173
177
|
const layer = new VectorTileLayer({ source, declutter: true, ...(renderMode && { renderMode }) })
|
|
178
|
+
layer.set('layerType', 'vectorTile')
|
|
174
179
|
|
|
175
180
|
stylefunction(layer, styleJson, sourceId, resolutions, spritesJson, sprite.pngUrl)
|
|
176
181
|
|
|
@@ -14,7 +14,7 @@ const mockWMSSourceInstance = {}
|
|
|
14
14
|
const mockTileLayerInstance = {}
|
|
15
15
|
const mockVectorTileSourceInstance = {}
|
|
16
16
|
const mockOGCVectorTileSourceInstance = { supportedMediaTypes: [] }
|
|
17
|
-
const mockVectorTileLayerInstance = {}
|
|
17
|
+
const mockVectorTileLayerInstance = { set: jest.fn() }
|
|
18
18
|
const mockMVTInstance = { supportedMediaTypes: [] }
|
|
19
19
|
|
|
20
20
|
jest.mock('ol/source/XYZ.js', () => ({ __esModule: true, default: jest.fn(() => mockSourceInstance) }))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"@babel/runtime/helpers/defineProperty";import e from"@babel/runtime/helpers/objectWithoutProperties";import a from"@babel/runtime/helpers/asyncToGenerator";class r{isBaseMapReady(){throw new Error(this.name+" must implement isBaseMapReady()")}}var n=400,i=7,o=["showKeyboardHelp","selectControl","moveLarge","nudgeMap","zoomLarge","nudgeZoom","highlightLabelAtCenter","highlightNextLabel"];var s=(t,e)=>{var a=null,r=function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];clearTimeout(a),a=setTimeout(()=>{t(...n)},e)};return r.cancel=()=>{a&&(clearTimeout(a),a=null)},r};function l(t){var{map:e,events:a,eventBus:r,getCenter:n,getZoom:i,getBounds:o,getResolution:l}=t,c=[],h=[],u=()=>{var t=i();return{center:n(),bounds:o(),resolution:l(),zoom:t,isAtMaxZoom:e.getMaxZoom()<=t,isAtMinZoom:e.getMinZoom()>=t}},d=(t,e)=>r.emit(t,e),p=()=>d(a.MAP_LOADED);e.on("load",p),c.push(["load",p]);e.once("idle",()=>d(a.MAP_FIRST_IDLE,u()));var g=()=>d(a.MAP_MOVE_START);e.on("movestart",g),c.push(["movestart",g]);var f=s(()=>{d(a.MAP_MOVE_END,u())},500);e.on("moveend",f),c.push(["moveend",f]);var y,m,v,M=(y=()=>{d(a.MAP_MOVE,u())},m=10,v=0,function(){var t=Date.now();t-v>=m&&(v=t,y(...arguments))});e.on("zoom",M),c.push(["zoom",M]);var b=()=>d(a.MAP_RENDER);e.on("render",b),c.push(["render",b]);var w=s(()=>{d(a.MAP_DATA_CHANGE,u())},500),x=t=>{t.isSourceLoaded&&w()};e.on("styledata",w),e.on("sourcedata",x),c.push(["styledata",w],["sourcedata",x]);var P=()=>d(a.MAP_STYLE_CHANGE);e.on("style.load",P),c.push(["style.load",P]);var N=t=>d(a.MAP_CLICK,{point:t.point,coords:[t.lngLat.lng,t.lngLat.lat]});return e.on("click",N),c.push(["click",N]),h.push(f,M,w),{remove(){h.forEach(t=>t.cancel()),c.forEach(t=>{var[a,r]=t;return e.off(a,r)})}}}let c=" ";class h{static get separator(){return c}static set separator(t){c=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 a=null;switch(e.length){case 3:a=e[0]/1+e[1]/60+e[2]/3600;break;case 2:a=e[0]/1+e[1]/60;break;case 1:a=e[0];break;default:return NaN}return/^-|[WS]$/i.test(t.trim())&&(a=-a),Number(a)}static toDms(t,e="d",a=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===a)switch(e){case"d":case"deg":a=4;break;case"dm":case"deg+min":a=2;break;case"dms":case"deg+min+sec":a=0;break;default:e="d",a=4}t=Math.abs(t);let r=null,n=null,i=null,o=null;switch(e){default:case"d":case"deg":n=t.toFixed(a),n<100&&(n="0"+n),n<10&&(n="0"+n),r=n+"°";break;case"dm":case"deg+min":n=Math.floor(t),i=(60*t%60).toFixed(a),60==i&&(i=(0).toFixed(a),n++),n=("000"+n).slice(-3),i<10&&(i="0"+i),r=n+"°"+h.separator+i+"′";break;case"dms":case"deg+min+sec":n=Math.floor(t),i=Math.floor(3600*t/60)%60,o=(3600*t%60).toFixed(a),60==o&&(o=(0).toFixed(a),i++),60==i&&(i=0,n++),n=("000"+n).slice(-3),i=("00"+i).slice(-2),o<10&&(o="0"+o),r=n+"°"+h.separator+i+"′"+h.separator+o+"″"}return r}static toLat(t,e,a){const r=h.toDms(h.wrap90(t),e,a);return null===r?"–":r.slice(1)+h.separator+(t<0?"S":"N")}static toLon(t,e,a){const r=h.toDms(h.wrap180(t),e,a);return null===r?"–":r+h.separator+(t<0?"W":"E")}static toBrng(t,e,a){const r=h.toDms(h.wrap360(t),e,a);return null===r?"–":r.replace("360","0")}static fromLocale(t){const e=123456.789.toLocaleString(),a={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(a.thousands,"⁜").replace(a.decimal,".").replace("⁜",",")}static toLocale(t){const e=123456.789.toLocaleString(),a={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(/,([0-9])/,"⁜$1").replace(".",a.decimal).replace("⁜",a.thousands)}static compassPoint(t,e=3){if(![1,2,3].includes(Number(e)))throw new RangeError(`invalid precision ‘${e}’`);t=h.wrap360(t);const a=4*2**(e-1);return["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"][Math.round(t*a/360)%a*16/a]}static wrap90(t){if(-90<=t&&t<=90)return t;const e=t,a=360;return 1*Math.abs(((e-90)%a+a)%a-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};const u=Math.PI;class d{constructor(t,e){if(isNaN(t))throw new TypeError(`invalid lat ‘${t}’`);if(isNaN(e))throw new TypeError(`invalid lon ‘${e}’`);this._lat=h.wrap90(Number(t)),this._lon=h.wrap180(Number(e))}get lat(){return this._lat}get latitude(){return this._lat}set lat(t){if(this._lat=isNaN(t)?h.wrap90(h.parse(t)):h.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid lat ‘${t}’`)}set latitude(t){if(this._lat=isNaN(t)?h.wrap90(h.parse(t)):h.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)?h.wrap180(h.parse(t)):h.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lon ‘${t}’`)}set lng(t){if(this._lon=isNaN(t)?h.wrap180(h.parse(t)):h.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lng ‘${t}’`)}set longitude(t){if(this._lon=isNaN(t)?h.wrap180(h.parse(t)):h.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid longitude ‘${t}’`)}static get metresToKm(){return.001}static get metresToMiles(){return 1/1609.344}static get metresToNauticalMiles(){return 1/1852}static parse(...t){if(0==t.length)throw new TypeError("invalid (empty) point");if(null===t[0]||null===t[1])throw new TypeError("invalid (null) point");let e,a;if(2==t.length&&([e,a]=t,e=h.wrap90(h.parse(e)),a=h.wrap180(h.parse(a)),isNaN(e)||isNaN(a)))throw new TypeError(`invalid point ‘${t.toString()}’`);if(1==t.length&&"string"==typeof t[0]&&([e,a]=t[0].split(","),e=h.wrap90(h.parse(e)),a=h.wrap180(h.parse(a)),isNaN(e)||isNaN(a)))throw new TypeError(`invalid point ‘${t[0]}’`);if(1==t.length&&"object"==typeof t[0]){const r=t[0];if("Point"==r.type&&Array.isArray(r.coordinates)?[a,e]=r.coordinates:(null!=r.latitude&&(e=r.latitude),null!=r.lat&&(e=r.lat),null!=r.longitude&&(a=r.longitude),null!=r.lng&&(a=r.lng),null!=r.lon&&(a=r.lon),e=h.wrap90(h.parse(e)),a=h.wrap180(h.parse(a))),isNaN(e)||isNaN(a))throw new TypeError(`invalid point ‘${JSON.stringify(t[0])}’`)}if(isNaN(e)||isNaN(a))throw new TypeError(`invalid point ‘${t.toString()}’`);return new d(e,a)}distanceTo(t,e=6371e3){if(t instanceof d||(t=d.parse(t)),isNaN(e))throw new TypeError(`invalid radius ‘${e}’`);const a=e,r=this.lat.toRadians(),n=this.lon.toRadians(),i=t.lat.toRadians(),o=i-r,s=t.lon.toRadians()-n,l=Math.sin(o/2)*Math.sin(o/2)+Math.cos(r)*Math.cos(i)*Math.sin(s/2)*Math.sin(s/2);return a*(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)))}initialBearingTo(t){if(t instanceof d||(t=d.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),a=t.lat.toRadians(),r=(t.lon-this.lon).toRadians(),n=Math.cos(e)*Math.sin(a)-Math.sin(e)*Math.cos(a)*Math.cos(r),i=Math.sin(r)*Math.cos(a),o=Math.atan2(i,n).toDegrees();return h.wrap360(o)}finalBearingTo(t){t instanceof d||(t=d.parse(t));const e=t.initialBearingTo(this)+180;return h.wrap360(e)}midpointTo(t){t instanceof d||(t=d.parse(t));const e=this.lat.toRadians(),a=this.lon.toRadians(),r=t.lat.toRadians(),n=(t.lon-this.lon).toRadians(),i=Math.cos(e),o=0,s=Math.sin(e),l={x:i+Math.cos(r)*Math.cos(n),y:o+Math.cos(r)*Math.sin(n),z:s+Math.sin(r)},c=Math.atan2(l.z,Math.sqrt(l.x*l.x+l.y*l.y)),h=a+Math.atan2(l.y,l.x),u=c.toDegrees(),p=h.toDegrees();return new d(u,p)}intermediatePointTo(t,e){if(t instanceof d||(t=d.parse(t)),this.equals(t))return new d(this.lat,this.lon);const a=this.lat.toRadians(),r=this.lon.toRadians(),n=t.lat.toRadians(),i=t.lon.toRadians(),o=n-a,s=i-r,l=Math.sin(o/2)*Math.sin(o/2)+Math.cos(a)*Math.cos(n)*Math.sin(s/2)*Math.sin(s/2),c=2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)),h=Math.sin((1-e)*c)/Math.sin(c),u=Math.sin(e*c)/Math.sin(c),p=h*Math.cos(a)*Math.cos(r)+u*Math.cos(n)*Math.cos(i),g=h*Math.cos(a)*Math.sin(r)+u*Math.cos(n)*Math.sin(i),f=h*Math.sin(a)+u*Math.sin(n),y=Math.atan2(f,Math.sqrt(p*p+g*g)),m=Math.atan2(g,p),v=y.toDegrees(),M=m.toDegrees();return new d(v,M)}destinationPoint(t,e,a=6371e3){const r=t/a,n=Number(e).toRadians(),i=this.lat.toRadians(),o=this.lon.toRadians(),s=Math.sin(i)*Math.cos(r)+Math.cos(i)*Math.sin(r)*Math.cos(n),l=Math.asin(s),c=Math.sin(n)*Math.sin(r)*Math.cos(i),h=Math.cos(r)-Math.sin(i)*s,u=o+Math.atan2(c,h),p=l.toDegrees(),g=u.toDegrees();return new d(p,g)}static intersection(t,e,a,r){if(t instanceof d||(t=d.parse(t)),a instanceof d||(a=d.parse(a)),isNaN(e))throw new TypeError(`invalid brng1 ‘${e}’`);if(isNaN(r))throw new TypeError(`invalid brng2 ‘${r}’`);const n=t.lat.toRadians(),i=t.lon.toRadians(),o=a.lat.toRadians(),s=a.lon.toRadians(),l=Number(e).toRadians(),c=Number(r).toRadians(),h=o-n,p=s-i,g=2*Math.asin(Math.sqrt(Math.sin(h/2)*Math.sin(h/2)+Math.cos(n)*Math.cos(o)*Math.sin(p/2)*Math.sin(p/2)));if(Math.abs(g)<Number.EPSILON)return new d(t.lat,t.lon);const f=(Math.sin(o)-Math.sin(n)*Math.cos(g))/(Math.sin(g)*Math.cos(n)),y=(Math.sin(n)-Math.sin(o)*Math.cos(g))/(Math.sin(g)*Math.cos(o)),m=Math.acos(Math.min(Math.max(f,-1),1)),v=Math.acos(Math.min(Math.max(y,-1),1)),M=l-(Math.sin(s-i)>0?m:2*u-m),b=(Math.sin(s-i)>0?2*u-v:v)-c;if(0==Math.sin(M)&&0==Math.sin(b))return null;if(Math.sin(M)*Math.sin(b)<0)return null;const w=-Math.cos(M)*Math.cos(b)+Math.sin(M)*Math.sin(b)*Math.cos(g),x=Math.atan2(Math.sin(g)*Math.sin(M)*Math.sin(b),Math.cos(b)+Math.cos(M)*w),P=Math.asin(Math.min(Math.max(Math.sin(n)*Math.cos(x)+Math.cos(n)*Math.sin(x)*Math.cos(l),-1),1)),N=i+Math.atan2(Math.sin(l)*Math.sin(x)*Math.cos(n),Math.cos(x)-Math.sin(n)*Math.sin(P)),S=P.toDegrees(),E=N.toDegrees();return new d(S,E)}crossTrackDistanceTo(t,e,a=6371e3){t instanceof d||(t=d.parse(t)),e instanceof d||(e=d.parse(e));const r=a;if(this.equals(t))return 0;const n=t.distanceTo(this,r)/r,i=t.initialBearingTo(this).toRadians(),o=t.initialBearingTo(e).toRadians();return Math.asin(Math.sin(n)*Math.sin(i-o))*r}alongTrackDistanceTo(t,e,a=6371e3){t instanceof d||(t=d.parse(t)),e instanceof d||(e=d.parse(e));const r=a;if(this.equals(t))return 0;const n=t.distanceTo(this,r)/r,i=t.initialBearingTo(this).toRadians(),o=t.initialBearingTo(e).toRadians(),s=Math.asin(Math.sin(n)*Math.sin(i-o));return Math.acos(Math.cos(n)/Math.abs(Math.cos(s)))*Math.sign(Math.cos(o-i))*r}maxLatitude(t){const e=Number(t).toRadians(),a=this.lat.toRadians();return Math.acos(Math.abs(Math.sin(e)*Math.cos(a))).toDegrees()}static crossingParallels(t,e,a){if(t.equals(e))return null;const r=Number(a).toRadians(),n=t.lat.toRadians(),i=t.lon.toRadians(),o=e.lat.toRadians(),s=e.lon.toRadians()-i,l=Math.sin(n)*Math.cos(o)*Math.cos(r)*Math.sin(s),c=Math.sin(n)*Math.cos(o)*Math.cos(r)*Math.cos(s)-Math.cos(n)*Math.sin(o)*Math.cos(r),u=Math.cos(n)*Math.cos(o)*Math.sin(r)*Math.sin(s);if(u*u>l*l+c*c)return null;const d=Math.atan2(-c,l),p=Math.acos(u/Math.sqrt(l*l+c*c)),g=i+d+p,f=(i+d-p).toDegrees(),y=g.toDegrees();return{lon1:h.wrap180(f),lon2:h.wrap180(y)}}rhumbDistanceTo(t,e=6371e3){t instanceof d||(t=d.parse(t));const a=e,r=this.lat.toRadians(),n=t.lat.toRadians(),i=n-r;let o=Math.abs(t.lon-this.lon).toRadians();Math.abs(o)>u&&(o=o>0?-(2*u-o):2*u+o);const s=Math.log(Math.tan(n/2+u/4)/Math.tan(r/2+u/4)),l=Math.abs(s)>1e-11?i/s:Math.cos(r);return Math.sqrt(i*i+l*l*o*o)*a}rhumbBearingTo(t){if(t instanceof d||(t=d.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),a=t.lat.toRadians();let r=(t.lon-this.lon).toRadians();Math.abs(r)>u&&(r=r>0?-(2*u-r):2*u+r);const n=Math.log(Math.tan(a/2+u/4)/Math.tan(e/2+u/4)),i=Math.atan2(r,n).toDegrees();return h.wrap360(i)}rhumbDestinationPoint(t,e,a=6371e3){const r=this.lat.toRadians(),n=this.lon.toRadians(),i=Number(e).toRadians(),o=t/a,s=o*Math.cos(i);let l=r+s;Math.abs(l)>u/2&&(l=l>0?u-l:-u-l);const c=Math.log(Math.tan(l/2+u/4)/Math.tan(r/2+u/4)),h=Math.abs(c)>1e-11?s/c:Math.cos(r),p=n+o*Math.sin(i)/h,g=l.toDegrees(),f=p.toDegrees();return new d(g,f)}rhumbMidpointTo(t){t instanceof d||(t=d.parse(t));const e=this.lat.toRadians();let a=this.lon.toRadians();const r=t.lat.toRadians(),n=t.lon.toRadians();Math.abs(n-a)>u&&(a+=2*u);const i=(e+r)/2,o=Math.tan(u/4+e/2),s=Math.tan(u/4+r/2),l=Math.tan(u/4+i/2);let c=((n-a)*Math.log(l)+a*Math.log(s)-n*Math.log(o))/Math.log(s/o);isFinite(c)||(c=(a+n)/2);const h=i.toDegrees(),p=c.toDegrees();return new d(h,p)}static areaOf(t,e=6371e3){const a=e,r=t[0].equals(t[t.length-1]);r||t.push(t[0]);const n=t.length-1;let i=0;for(let e=0;e<n;e++){const a=t[e].lat.toRadians(),r=t[e+1].lat.toRadians(),n=(t[e+1].lon-t[e].lon).toRadians();i+=2*Math.atan2(Math.tan(n/2)*(Math.tan(a/2)+Math.tan(r/2)),1+Math.tan(a/2)*Math.tan(r/2))}(function(t){let e=0,a=t[0].initialBearingTo(t[1]);for(let r=0;r<t.length-1;r++){const n=t[r].initialBearingTo(t[r+1]),i=t[r].finalBearingTo(t[r+1]);e+=(n-a+540)%360-180,e+=(i-n+540)%360-180,a=i}const r=t[0].initialBearingTo(t[1]);e+=(r-a+540)%360-180;return Math.abs(e)<90})(t)&&(i=Math.abs(i)-2*u);const o=Math.abs(i*a*a);return r||t.pop(),o}equals(t){return t instanceof d||(t=d.parse(t)),!(Math.abs(this.lat-t.lat)>Number.EPSILON)&&!(Math.abs(this.lon-t.lon)>Number.EPSILON)}toGeoJSON(){return{type:"Point",coordinates:[this.lon,this.lat]}}toString(t="d",e=void 0){if(!["d","dm","dms","n"].includes(t))throw new RangeError(`invalid format ‘${t}’`);if("n"==t)return null==e&&(e=4),`${this.lat.toFixed(e)},${this.lon.toFixed(e)}`;return`${h.toLat(this.lat,t,e)}, ${h.toLon(this.lon,t,e)}`}}function p(t,e,a){if(null!==t)for(var r,n,i,o,s,l,c,h,u=0,d=0,g=t.type,f="FeatureCollection"===g,y="Feature"===g,m=f?t.features.length:1,v=0;v<m;v++){s=(h=!!(c=f?t.features[v].geometry:y?t.geometry:t)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var M=0;M<s;M++){var b=0,w=0;if(null!==(o=h?c.geometries[M]:c)){l=o.coordinates;var x=o.type;switch(u=0,x){case null:break;case"Point":if(!1===e(l,d,v,b,w))return!1;d++,b++;break;case"LineString":case"MultiPoint":for(r=0;r<l.length;r++){if(!1===e(l[r],d,v,b,w))return!1;d++,"MultiPoint"===x&&b++}"LineString"===x&&b++;break;case"Polygon":case"MultiLineString":for(r=0;r<l.length;r++){for(n=0;n<l[r].length-u;n++){if(!1===e(l[r][n],d,v,b,w))return!1;d++}"MultiLineString"===x&&b++,"Polygon"===x&&w++}"Polygon"===x&&b++;break;case"MultiPolygon":for(r=0;r<l.length;r++){for(w=0,n=0;n<l[r].length;n++){for(i=0;i<l[r][n].length-u;i++){if(!1===e(l[r][n][i],d,v,b,w))return!1;d++}w++}b++}break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===p(o.geometries[r],e))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}var g=function(t,e={}){if(null!=t.bbox&&!0!==e.recompute)return t.bbox;const a=[1/0,1/0,-1/0,-1/0];return p(t,t=>{a[0]>t[0]&&(a[0]=t[0]),a[1]>t[1]&&(a[1]=t[1]),a[2]<t[0]&&(a[2]=t[0]),a[3]<t[1]&&(a[3]=t[1])}),a},f=(t,e)=>{var[a,r]=t,[n,i]=e,o=new d(r,a),s=new d(i,n);return o.distanceTo(s)},y=t=>{var e=t/1609.344;if(e<.5){var a=Math.round(t),r=1===a?"metre":"metres";return"".concat(a," ").concat(r)}if(e<10){var n=Number.parseFloat(e.toFixed(1)),i=1===n?"mile":"miles";return"".concat(n," ").concat(i)}var o=Math.round(e);return"".concat(o," miles")},m=t=>g(t);function v(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),a.push.apply(a,r)}return a}function M(e){for(var a=1;a<arguments.length;a++){var r=null!=arguments[a]?arguments[a]:{};a%2?v(Object(r),!0).forEach(function(a){t(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var b="highlighted-label";function w(t,e){if("number"==typeof t)return t;if(!Array.isArray(t)||"interpolate"!==t[0])return function(t,e){var{stops:a}=t;if(a.length<2)return a.length>0?a[0][1]:0;for(var r=a[0],n=a[a.length-1],i=1;i<a.length;i++){var o=a[i];if(o[0]>e){n=o,r=a[i-1];break}r=a[i-1],n=o}var[s,l]=r,[c,h]=n;return e<=s?l:e>=c?h:l+(e-s)/(c-s)*(h-l)}(t,e);var[,,a,...r]=t;if("zoom"!==a[0])throw new Error("Only zoom-based expressions supported");for(var n=0;n<r.length-2;n+=2){var i=r[n],o=r[n+1],s=r[n+2],l=r[n+3];if(e<=i)return o;if(e<=s)return o+(e-i)/(s-i)*(l-o)}return r[r.length-1]}function x(t,e,a){return e.flatMap(e=>{var r,n=function(t){var e,a;return"string"==typeof t?null===(e=/^{(.+)}$/.exec(t))||void 0===e?void 0:e[1]:Array.isArray(t)?null===(a=t.find(t=>Array.isArray(t)&&"get"===t[0]))||void 0===a?void 0:a[1]:null}(null===(r=e.layout)||void 0===r?void 0:r["text-field"]);return n?a.filter(t=>{var a;return t.layer.id===e.id&&(null===(a=t.properties)||void 0===a?void 0:a[n])}).map(a=>function(t,e,a,r){var n=function(t){var{type:e,coordinates:a}=t;if("Point"===e)return a;if("MultiPoint"===e)return a[0];if(e.includes("LineString")){var r="LineString"===e?a:a[0];return[(r[0][0]+r[r.length-1][0])/2,(r[0][1]+r[r.length-1][1])/2]}if(e.includes("Polygon")){var n="Polygon"===e?a[0]:a[0][0],i=n.reduce((t,e)=>[t[0]+e[0],t[1]+e[1]],[0,0]);return[i[0]/n.length,i[1]/n.length]}return null}(t.geometry);if(!n)return null;var i=r.project({lng:n[0],lat:n[1]});return{text:t.properties[a],x:i.x,y:i.y,feature:t,layer:e}}(a,e,n,t)).filter(Boolean):[]})}function P(t,e){if(e.highlightLayerId&&t.getLayer(e.highlightLayerId)){try{t.removeLayer(e.highlightLayerId)}catch(t){}e.highlightLayerId=null,e.highlightedExpr=null}}function N(t,e,a){var r;if(null!=e&&null!==(r=e.feature)&&void 0!==r&&r.layer){P(t,a);var{feature:n,layer:i}=e;a.highlightLayerId="highlight-".concat(i.id);var{id:o,type:s,properties:l,geometry:c}=n;t.getSource(b).setData({id:o,type:s,properties:l,geometry:c}),a.highlightedExpr=i.layout["text-size"];var h=t.getZoom(),u=function(t,e,a){return{id:"highlight-".concat(t.id),type:t.type,source:b,layout:M(M({},t.layout),{},{"text-size":e,"text-allow-overlap":!0,"text-ignore-placement":!0,"text-max-angle":90}),paint:M(M({},t.paint),{},{"text-color":a.text,"text-halo-color":a.halo,"text-halo-width":3,"text-halo-blur":1,"text-opacity":1})}}(i,1.5*w(a.highlightedExpr,h),a.isDarkStyle?{text:"#ffffff",halo:"#000000"}:{text:"#000000",halo:"#ffffff"});t.addLayer(u),t.moveLayer(a.highlightLayerId)}}function S(t,e){if(!e.currentPixel)return null;var a=e.labels.map((t,e)=>({pixel:[t.x,t.y],index:e})).filter(t=>t.pixel[0]!==e.currentPixel.x||t.pixel[1]!==e.currentPixel.y);if(!a.length)return null;var r=a.map(t=>t.pixel),n=((t,e,a)=>{var r=(t,e)=>t[0]===e[0]&&t[1]===e[1],n=e.filter(e=>{var n=Math.abs(e[0]-t[0]),i=Math.abs(e[1]-t[1]);return("ArrowUp"===a?e[1]<=t[1]&&i>=n:"ArrowDown"===a?e[1]>t[1]&&i>=n:"ArrowLeft"===a?e[0]<=t[0]&&i<n:"ArrowRight"!==a||e[0]>t[0]&&i<n)&&!r(e,t)});n.length||n.push(t);var i=e=>Math.hypot(t[0]-e[0],t[1]-e[1]),o=n.reduce((t,e)=>i(e)<i(t)?e:t,n[0]);return e.findIndex(t=>r(t,o))})([e.currentPixel.x,e.currentPixel.y],r,t);return(null==n||n<0||n>=a.length)&&(n=0),e.labels[a[n].index]}function E(t){t.getSource(b)||t.addSource(b,{type:"geojson",data:{type:"FeatureCollection",features:[]}})}function L(t){t.getStyle().layers.filter(t=>{var e;return"line"===(null===(e=t.layout)||void 0===e?void 0:e["symbol-placement"])}).forEach(e=>t.setLayoutProperty(e.id,"symbol-placement","line-center"))}var R=t=>t.endsWith(".cold")?"".concat(t.slice(0,-5),".hot"):t.endsWith(".hot")?"".concat(t.slice(0,-4),".cold"):null;function I(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),a.push.apply(a,r)}return a}function O(e){for(var a=1;a<arguments.length;a++){var r=null!=arguments[a]?arguments[a]:{};a%2?I(Object(r),!0).forEach(function(a){t(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var T="icon-image",A="active-highlight",D="active-highlight-inner",_="selected-highlight",j=(t,e)=>{var a,r;return null!==(a=null===(r=t._activeSymbolImageMap)||void 0===r?void 0:r[e])&&void 0!==a?a:null},C=(t,e)=>{var a,r;return null!==(a=null===(r=t._selectedSymbolImageMap)||void 0===r?void 0:r[e])&&void 0!==a?a:null},B=(t,e,a,r)=>{var{featureId:n,idProperty:i,geometry:o}=r,s=t.getLayer(a);s&&(e[a]||(e[a]={ids:new Set,fillIds:new Set,idProperty:i,sourceId:s.source,hasFillGeometry:!1}),!o||"Polygon"!==o.type&&"MultiPolygon"!==o.type||(e[a].hasFillGeometry=!0,e[a].fillIds.add(n)),e[a].ids.add(n))},k=(t,e,a,r)=>{e.forEach(e=>{if(!a.has(e)){var n="".concat(r,"-").concat(e);["".concat(n,"-fill"),"".concat(n,"-line"),"".concat(n,"-symbol")].forEach(e=>{t.getLayer(e)&&t.setFilter(e,["==","id",""])})}})},F=(t,e)=>{var a="_".concat(e.replaceAll("-",""),"Sources");k(t,t[a]||new Set,new Set,e),t[a]=new Set},z=(t,e,a,r,n,i,o)=>{!!t.getLayer(e)||t.addLayer(O(O({id:e,type:a,source:r},n&&{"source-layer":n}),{},{paint:i})),Object.entries(i).forEach(a=>{var[r,n]=a;t.setPaintProperty(e,r,n)}),t.setFilter(e,o),t.moveLayer(e)},W=(t,e,a,r,n,i,o)=>{var s,l=t.getLayoutProperty(n,"icon-offset");t.getLayer(e)||t.addLayer(O(O({id:e,type:"symbol",source:a},r&&{"source-layer":r}),{},{layout:O(O({[T]:i,"icon-anchor":null!==(s=t.getLayoutProperty(n,"icon-anchor"))&&void 0!==s?s:"center"},void 0!==l&&{"icon-offset":l}),{},{"icon-allow-overlap":!0})}));t.setLayoutProperty(e,T,i),void 0!==l&&t.setLayoutProperty(e,"icon-offset",l),t.setFilter(e,o),t.moveLayer(e)},q=(t,e,a,r,n,i)=>{var o,{ids:s,fillIds:l,idProperty:c,sourceId:h,hasFillGeometry:u}=a[e],d=t.getLayer(e),p=null!==(o=r[e])&&void 0!==o?o:r[R(e)];if(d&&p){var g=d.sourceLayer,f=u?"fill":d.type,y="".concat(n,"-").concat(e),{fill:m}=p,v=n===_,M=(t=>t===_||t===D)(n),{lineColor:b,lineWidth:w}=((t,e)=>({lineColor:e?t.selectionStroke:t.stroke,lineWidth:e?t.strokeWidth:t.activeStrokeWidth}))(p,M),x=c?["get",c]:["id"],P=["in",x,["literal",Array.from(s)]];if("fill-extrusion"!==d.type)switch(f){case"fill":((t,e,a,r,n)=>{var{isSelected:i,idExpression:o,fillIds:s,fill:l,lineColor:c,lineWidth:h,filter:u}=n;if(i){var d=[];s.forEach(t=>d.push(t));var p=["in",o,["literal",d]];z(t,"".concat(e,"-fill"),"fill",a,r,{"fill-color":l},p)}z(t,"".concat(e,"-line"),"line",a,r,{"line-color":c,"line-width":h},u)})(t,y,h,g,{isSelected:v,idExpression:x,fillIds:l,fill:m,lineColor:b,lineWidth:w,filter:P});break;case"line":((t,e,a,r,n,i,o)=>{t.getLayer("".concat(e,"-fill"))&&t.setFilter("".concat(e,"-fill"),["==","id",""]),z(t,"".concat(e,"-line"),"line",a,r,{"line-color":n,"line-width":i},o)})(t,y,h,g,b,w,P);break;case"symbol":((t,e,a,r,n,i,o)=>{var s=t.getLayoutProperty(n,T);if(Array.isArray(s)){var l=o===j?"user_symbolActiveImageId":"user_symbolSelectedImageId";W(t,"".concat(e,"-symbol"),a,r,n,["get",l],i)}else{var c=o(t,s);c&&W(t,"".concat(e,"-symbol"),a,r,n,c,i)}})(t,y,h,g,e,P,i)}else((t,e,a,r)=>{var{ids:n,lineColor:i,lineWidth:o,idExpression:s}=r,l=[];n.forEach(t=>l.push(t));var c=["in",s,["literal",l]],{source:h,sourceLayer:u}=t.getLayer(a);z(t,"".concat(e,"-line"),"line",h,u,{"line-color":i,"line-width":o},c)})(t,y,e,{ids:s,lineColor:b,lineWidth:w,idExpression:x})}},$=(t,e,a,r,n)=>{var i=((t,e)=>{var a={};return null==e||e.forEach(e=>{B(t,a,e.layerId,e);var r=R(e.layerId);r&&B(t,a,r,e)}),a})(t,e),o=new Set(Object.keys(i)),s="_".concat(r.replaceAll("-",""),"Sources"),l=t[s]||new Set;return k(t,l,o,r),t[s]=o,o.forEach(e=>q(t,e,i,a,r,n)),i};var Z=(t,e,a)=>{var r=(e.x-a.x)**2+(e.y-a.y)**2;if(0===r)return(t.x-e.x)**2+(t.y-e.y)**2;var n=((t.x-e.x)*(a.x-e.x)+(t.y-e.y)*(a.y-e.y))/r;return n=Math.max(0,Math.min(1,n)),(t.x-(e.x+n*(a.x-e.x)))**2+(t.y-(e.y+n*(a.y-e.y)))**2},G=function(t,e){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{radius:r=10}=a,n=[[e.x-r,e.y-r],[e.x+r,e.y+r]],i=t.queryRenderedFeatures(n);if(0===i.length)return[];var o=new Set(t.queryRenderedFeatures([e.x,e.y]).map(t=>{var e,a=void 0===t.id?JSON.stringify(t.properties):t.id;return"".concat(null===(e=t.layer)||void 0===e?void 0:e.source,":").concat(a)})),s=[];i.forEach(t=>{!1===s.includes(t.layer.id)&&s.push(t.layer.id)});for(var l=new Set,c=[],h=i.length-1;h>=0;h--){var u,d=i[h],p=void 0===d.id?JSON.stringify(d.properties):d.id,g="".concat(null===(u=d.layer)||void 0===u?void 0:u.source,":").concat(p);!1===l.has(g)&&(l.add(g),c.push(d))}var f=t.unproject(e),y=[f.lng,f.lat],m=c.filter(t=>{var e=t.geometry.type;if(e.includes("Polygon"))return("Polygon"===e?[t.geometry.coordinates]:t.geometry.coordinates).some(t=>((t,e)=>{for(var[a,r]=t,n=!1,i=0,o=e.length-1;i<e.length;o=i,i++){var[s,l]=e[i],[c,h]=e[o];l>r!=h>r&&a<(c-s)*(r-l)/(h-l)+s&&(n=!n)}return n})(y,t[0]));if("Point"===e||"MultiPoint"===e){var a,r=void 0===t.id?JSON.stringify(t.properties):t.id;return o.has("".concat(null===(a=t.layer)||void 0===a?void 0:a.source,":").concat(r))}return!0});return m.map(a=>{var r=0,n=a.geometry.type,i=((t,e,a)=>{var{coordinates:r,type:n}=a,i=1/0,o=e=>t.project(e),s=t=>{for(var a=0;a<t.length-1;a++){var r=Z(e,o(t[a]),o(t[a+1]));r<i&&(i=r)}};if("Point"===n){var l=o(r);i=(e.x-l.x)**2+(e.y-l.y)**2}else"LineString"===n||"MultiPoint"===n?"LineString"===n?s(r):r.forEach(t=>{var a=o(t),r=(e.x-a.x)**2+(e.y-a.y)**2;r<i&&(i=r)}):"Polygon"===n||"MultiLineString"===n?r.forEach(s):"MultiPolygon"===n&&r.forEach(t=>t.forEach(s));return i})(t,e,a.geometry);return r+=1e6*s.indexOf(a.layer.id),n.includes("Polygon")&&(r-=5e5),{f:a,score:r+=i}}).sort((t,e)=>t.score-e.score).map(t=>{var{f:e}=t;return e})},H=(t,e,a)=>{var r=t.getCanvas();if(a&&t.off("mousemove",a),null==e||!e.length)return r.style.cursor="",null;var n=a=>{var n=(t=>{var e=new Set(t);return t.forEach(t=>{var a=R(t);a&&e.add(a)}),[...e]})(e).filter(e=>t.getLayer(e));if(0!==n.length){var{lineLayers:i,otherLayers:o}=((t,e)=>{var a=[],r=[];for(var n of e)if("line"===t.getLayer(n).type){var i=n.endsWith("-stroke")?n.slice(0,-7):null;null!==i&&e.includes(i)||a.push(n)}else r.push(n);return{lineLayers:a,otherLayers:r}})(t,n),{x:s,y:l}=a.point,c=[[s-10,l-10],[s+10,l+10]],h=i.length>0&&t.queryRenderedFeatures(c,{layers:i}).length>0,u=o.length>0&&t.queryRenderedFeatures(a.point,{layers:o}).length>0;r.style.cursor=h||u?"pointer":""}else r.style.cursor=""};return t.on("mousemove",n),n},V=function(){var t=a(function*(t,e,r,n){var i,o,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2;e.length&&(null!==(i=t._activeSymbolImageMap)&&void 0!==i||(t._activeSymbolImageMap={}),null!==(o=t._selectedSymbolImageMap)&&void 0!==o||(t._selectedSymbolImageMap={}),yield Promise.all(e.flatMap(e=>{var i=n.getSymbolImageId(e,r,!1,s),o=n.getSymbolImageId(e,r,!0,s);return i&&o&&(t._activeSymbolImageMap[i]=o),["normal","active","selected"].map(function(){var l=a(function*(a){var l="active"===a?o:i;if("selected"===a||l&&!t.hasImage(l)){var c=yield n.rasteriseSymbolImage(e,r,a,s);c&&("selected"===a&&i&&(t._selectedSymbolImageMap[i]=c.imageId),t.hasImage(c.imageId)||t.addImage(c.imageId,c.imageData,{pixelRatio:s}))}});return function(t){return l.apply(this,arguments)}}())})))});return function(e,a,r,n){return t.apply(this,arguments)}}(),J=t=>Math.max(2,2*t),Y=(t,e)=>{if(!t)return null;if("string"==typeof t)return t.trim();if("object"==typeof t){if(e&&t[e])return t[e];var a=Object.values(t)[0];return null!=a?a:null}return null},K=new Map,U=function(){var t=a(function*(t,e,a,r){var n=a.getPatternInnerContent(t);if(!n)return null;var i=a.getPatternImageId(t,e,r);if(!i)return null;var o,s,l=K.get(i);if(!l){var c=Y(t.fillPatternForegroundColor,e)||"black",h=Y(t.fillPatternBackgroundColor,e)||"transparent",u=(o=c,s=h,n.replace(/\{\{foregroundColor\}\}/g,o||"black").replace(/\{\{backgroundColor\}\}/g,s||"transparent")),d='<rect width="16" height="16" fill="'.concat(h,'"/>'),p=J(r),g=Math.round(8*p),f='<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(g,'" height="').concat(g,'" viewBox="0 0 16 16">').concat(d).concat(u,"</svg>");l=yield((t,e,a)=>new Promise((r,n)=>{var i="data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(t)),o=new Image(e,a);o.onload=()=>{var t=document.createElement("canvas");t.width=e,t.height=a;var n=t.getContext("2d");n.drawImage(o,0,0,e,a),r(n.getImageData(0,0,e,a))},o.onerror=()=>{n(new Error("Failed to rasterise SVG: ".concat(t.slice(0,80))))},o.src=i}))(f,g,g),K.set(i,l)}return{imageId:i,imageData:l}});return function(e,a,r,n){return t.apply(this,arguments)}}(),X=function(){var t=a(function*(t,e,r,n,i){if(e.length){var o=J(i),s=e.reduce((e,s)=>{var l=n.getPatternImageId(s,r,i);return!l||e[l]||t.hasImage(l)||(e[l]=a(function*(){var e=yield U(s,r,n,i);e&&!t.hasImage(e.imageId)&&t.addImage(e.imageId,e.imageData,{pixelRatio:o})})),e},{});yield Promise.all(Object.values(s).map(t=>t()))}});return function(e,a,r,n,i){return t.apply(this,arguments)}}(),Q=["container","padding","mapStyle","mapSize","center","zoom","bounds","pixelRatio"];function tt(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),a.push.apply(a,r)}return a}function et(e){for(var a=1;a<arguments.length;a++){var r=null!=arguments[a]?arguments[a]:{};a%2?tt(Object(r),!0).forEach(function(a){t(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tt(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}class at extends r{constructor(t){var{mapFramework:e,mapProviderConfig:a={},events:r,eventBus:n}=t;super(),this.maplibreModule=e,this.events=r,this.eventBus=n,this.capabilities={supportedShortcuts:o,supportsMapSizes:!0},Object.assign(this,a)}get name(){return"MapLibreProvider"}initMap(t){var r=this;return a(function*(){var{container:a,padding:n,mapStyle:i,mapSize:o,center:s,zoom:c,bounds:h,pixelRatio:u}=t,d=e(t,Q);r.mapStyleId=null==i?void 0:i.id,r.mapSize=o;var{Map:p}=r.maplibreModule,{events:g,eventBus:f}=r,y=new p(et(et({},d),{},{container:a,style:null==i?void 0:i.url,pixelRatio:u,padding:n,center:s,zoom:c,fadeDuration:0,attributionControl:!1,dragRotate:!1,doubleClickZoom:!1}));y.touchZoomRotate.disableRotation(),r.map=y,r.map.setPadding(n),h&&y.fitBounds(h,{duration:0}),function(t){var e=Event.prototype.preventDefault;Event.prototype.preventDefault=function(){if(("touchmove"===this.type||"touchstart"===this.type)&&!this.cancelable){var a=t.getCanvas();if(a&&(this.target===a||a.contains(this.target)))return}e.call(this)}}(y),function(t){var e=t.getCanvas();e.removeAttribute("role"),e.setAttribute("tabindex",-1),e.removeAttribute("aria-label"),e.style.display="block",e.addEventListener("focus",t=>{e.blur(),t.relatedTarget&&t.relatedTarget.focus({preventScroll:!0})})}(y),l({map:y,events:g,eventBus:f,getCenter:r.getCenter.bind(r),getZoom:r.getZoom.bind(r),getBounds:r.getBounds.bind(r),getResolution:r.getResolution.bind(r)}),function(t){var{mapProvider:e,map:a,events:r,eventBus:n}=t,i=t=>{a.once("style.load",()=>{n.emit(r.MAP_STYLE_CHANGE,{mapStyleId:t.id})}),a.setStyle(t.url,{diff:!1})},o=t=>{a.setPixelRatio(t)},s=t=>{var{mapSize:a}=t;e.mapSize=a};n.on(r.MAP_SET_STYLE,i),n.on(r.MAP_SET_PIXEL_RATIO,o),n.on(r.MAP_SIZE_CHANGE,s)}({mapProvider:r,map:y,events:g,eventBus:f}),y.on("load",()=>{r.labelNavigator=function(t,e,a,r){var n={isDarkStyle:"dark"===e,labels:[],currentPixel:null,highlightLayerId:null,highlightedExpr:null};function i(){var e=t.getStyle().layers.filter(t=>"symbol"===t.type),a=t.queryRenderedFeatures({layers:e.map(t=>t.id)});n.labels=x(t,e,a)}function o(){if(i(),!n.labels.length)return null;var e=t.project(t.getCenter()),a=function(t,e){var a;return null===(a=t.reduce((t,a)=>{var r=(a.x-e.x)**2+(a.y-e.y)**2;return!t||r<t.dist?{label:a,dist:r}:t},null))||void 0===a?void 0:a.label}(n.labels,e);return n.currentPixel={x:a.x,y:a.y},N(t,a,n),"".concat(a.text," (").concat(a.layer.id,")")}return L(t),E(t),null==r||r.on(a.MAP_SET_STYLE,e=>{t.once("styledata",()=>t.once("idle",()=>{L(t),E(t),n.isDarkStyle="dark"===(null==e?void 0:e.mapColorScheme)}))}),t.on("zoom",()=>{if(n.highlightLayerId&&n.highlightedExpr){var e=w(n.highlightedExpr,t.getZoom());t.setLayoutProperty(n.highlightLayerId,"text-size",1.5*e)}}),function(t){t.getStyle().layers.filter(t=>"symbol"===t.type).forEach(e=>{t.setPaintProperty(e.id,"text-opacity",["case",["boolean",["feature-state","highlighted"],!1],0,1])})}(t),{refreshLabels:i,highlightNextLabel:function(e){if(i(),!n.labels.length)return null;if(!n.currentPixel)return o();var a=S(e,n);return a?(n.currentPixel={x:a.x,y:a.y},N(t,a,n),"".concat(a.text," (").concat(a.layer.id,")")):null},highlightLabelAtCenter:o,clearHighlightedLabel:()=>P(t,n)}}(y,null==i?void 0:i.mapColorScheme,g,f)}),r.eventBus.emit(g.MAP_READY,{map:r.map,mapStyleId:r.mapStyleId,mapSize:r.mapSize,crs:r.crs})})()}isBaseMapReady(){var t;return Boolean(null===(t=this.map)||void 0===t?void 0:t.getStyle())}destroyMap(){var t,e;this.setHoverCursor([]),null===(t=this.mapEvents)||void 0===t||t.remove(),null===(e=this.appEvents)||void 0===e||e.remove(),this.mapEvents=null,this.appEvents=null,this.map.remove()}setHoverCursor(t){this.map&&(this._onHoverMove=H(this.map,t,this._onHoverMove))}setView(t){var{center:e,zoom:a}=t;this.map.flyTo({center:e||this.getCenter(),zoom:a||this.getZoom(),duration:this.map.isStyleLoaded()?n:0})}zoomIn(t){this.map.easeTo({zoom:this.getZoom()+t,duration:n})}zoomOut(t){this.map.easeTo({zoom:this.getZoom()-t,duration:n})}panBy(t){this.map.panBy(t,{duration:n})}fitToBounds(t){var e=Array.isArray(t)?t:m(t),a=this.map.isStyleLoaded()?n:0;this.map.fitBounds(e,{duration:a})}setPadding(t){this.map.setPadding(t)}updateHighlightedFeatures(t,e,a){var{LngLatBounds:r}=this.maplibreModule;return function(t){var{LngLatBounds:e,map:a,selectedFeatures:r,activeFeatures:n,stylesMap:i}=t;if(!a)return null;null!=n&&n.length?($(a,n,i,A,j),$(a,n,i,D,C)):(F(a,A),F(a,D));var o={};null!=r&&r.length?o=$(a,r,i,_,C):F(a,_);var s=[];return Object.entries(o).forEach(t=>{var[e,{ids:r,idProperty:n}]=t;s.push(...a.queryRenderedFeatures({layers:[e]}).filter(t=>{var e;return r.has(n?null===(e=t.properties)||void 0===e?void 0:e[n]:t.id)}))}),((t,e)=>{if(!e.length)return null;var a=new t;return e.forEach(t=>{var e=t=>"number"==typeof t[0]?a.extend(t):t.forEach(e);e(t.geometry.coordinates)}),[a.getWest(),a.getSouth(),a.getEast(),a.getNorth()]})(e,s)}({LngLatBounds:r,map:this.map,selectedFeatures:t,activeFeatures:e,stylesMap:a})}highlightNextLabel(t){var e;return(null===(e=this.labelNavigator)||void 0===e?void 0:e.highlightNextLabel(t))||null}highlightLabelAtCenter(){var t;return(null===(t=this.labelNavigator)||void 0===t?void 0:t.highlightLabelAtCenter())||null}clearHighlightedLabel(){var t;return(null===(t=this.labelNavigator)||void 0===t?void 0:t.clearHighlightedLabel())||null}getCenter(){var t=this.map.getCenter();return[Number(t.lng.toFixed(i)),Number(t.lat.toFixed(i))]}getZoom(){return Number(this.map.getZoom().toFixed(i))}getBounds(){return this.map.getBounds().toArray().flat(1)}getFeaturesAtPoint(t,e){return G(this.map,t,e)}getVisibleFeatures(t){var e=t.filter(t=>this.map.getLayer(t));return e.length?this.map.queryRenderedFeatures(void 0,{layers:e}):[]}addSymbolsToMap(t,e,r){var n=this;return a(function*(){var a=n.map.getPixelRatio()||1;return V(n.map,t,e,r,a)})()}addPatternsToMap(t,e,r){var n=this;return a(function*(){var a=n.map.getPixelRatio()||1;return X(n.map,t,e,r,a)})()}getAreaDimensions(){var{LngLatBounds:t}=this.maplibreModule;return(t=>{var e,a,r,n;if(t&&"function"==typeof t.getWest)e=t.getWest(),a=t.getSouth(),r=t.getEast(),n=t.getNorth();else{if(!Array.isArray(t)||2!==t.length)return"";[[e,a],[r,n]]=t}var i=f([e,a],[r,a]),o=f([e,a],[e,n]),s=y(i),l=y(o);return"".concat(l," by ").concat(s)})(((t,e)=>{var{width:a,height:r}=e.getContainer().getBoundingClientRect(),n=e.getPadding(),i=[n.left,r-n.bottom],o=[a-n.right,n.top];return new t(e.unproject(i),e.unproject(o))})(t,this.map))}getCardinalMove(t,e){return((t,e)=>{var[a,r]=t,[n,i]=e,o=i-r,s=n-a,l=[];if(Math.abs(o)>1e-4){var c=Math.round(f([a,r],[a,i]));l.push("".concat(o>0?"north":"south"," ").concat(y(c)))}if(Math.abs(s)>1e-4){var h=Math.round(f([a,r],[n,r]));l.push("".concat(s>0?"east":"west"," ").concat(y(h)))}return l.join(", ")})(t,e)}getResolution(){return t=this.map.getCenter(),e=this.map.getZoom(),a=t.lat,r=Math.pow(2,e),40075016.686*Math.cos(a*Math.PI/180)/(512*r);var t,e,a,r}mapToScreen(t){return this.map.project(t)}screenToMap(t){var{lng:e,lat:a}=this.map.unproject([t.x,t.y]);return[e,a]}isGeometryObscured(t,e){return((t,e,a)=>{var r=a.getContainer().getBoundingClientRect(),[n,i,o,s]=m(t),l=[a.project([n,i]),a.project([n,s]),a.project([o,i]),a.project([o,s])],c=Math.min(...l.map(t=>t.x)),h=Math.max(...l.map(t=>t.x)),u=Math.min(...l.map(t=>t.y)),d=Math.max(...l.map(t=>t.y)),p=e.left-r.left,g=e.top-r.top,f=e.right-r.left,y=e.bottom-r.top;return c<f&&h>p&&u<y&&d>g})(t,e,this.map)}}export{at as default};
|
|
1
|
+
import t from"@babel/runtime/helpers/defineProperty";import e from"@babel/runtime/helpers/objectWithoutProperties";import a from"@babel/runtime/helpers/asyncToGenerator";class r{isBaseMapReady(){throw new Error(this.name+" must implement isBaseMapReady()")}}var n=400,i=7,o=["showKeyboardHelp","selectControl","moveLarge","nudgeMap","zoomLarge","nudgeZoom","highlightLabelAtCenter","highlightNextLabel"];var s=(t,e)=>{var a=null,r=function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];clearTimeout(a),a=setTimeout(()=>{t(...n)},e)};return r.cancel=()=>{a&&(clearTimeout(a),a=null)},r};function l(t){var{map:e,events:a,eventBus:r,getCenter:n,getZoom:i,getBounds:o,getResolution:l}=t,h=[],u=[],c=()=>{var t=i();return{center:n(),bounds:o(),resolution:l(),zoom:t,isAtMaxZoom:e.getMaxZoom()<=t,isAtMinZoom:e.getMinZoom()>=t}},d=(t,e)=>r.emit(t,e),p=()=>d(a.MAP_LOADED);e.on("load",p),h.push(["load",p]);e.once("idle",()=>d(a.MAP_FIRST_IDLE,c()));var g=()=>d(a.MAP_MOVE_START);e.on("movestart",g),h.push(["movestart",g]);var f=s(()=>{d(a.MAP_MOVE_END,c())},500);e.on("moveend",f),h.push(["moveend",f]);var y,m,v,M=(y=()=>{d(a.MAP_MOVE,c())},m=10,v=0,function(){var t=Date.now();t-v>=m&&(v=t,y(...arguments))});e.on("zoom",M),h.push(["zoom",M]);var b=()=>d(a.MAP_RENDER);e.on("render",b),h.push(["render",b]);var w=s(()=>{d(a.MAP_DATA_CHANGE,c())},500),x=t=>{t.isSourceLoaded&&w()};e.on("styledata",w),e.on("sourcedata",x),h.push(["styledata",w],["sourcedata",x]);var P=()=>d(a.MAP_STYLE_CHANGE);e.on("style.load",P),h.push(["style.load",P]);var N=t=>d(a.MAP_CLICK,{point:t.point,coords:[t.lngLat.lng,t.lngLat.lat]});return e.on("click",N),h.push(["click",N]),u.push(f,M,w),{remove(){u.forEach(t=>t.cancel()),h.forEach(t=>{var[a,r]=t;return e.off(a,r)})}}}let h=" ";class u{static get separator(){return h}static set separator(t){h=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 a=null;switch(e.length){case 3:a=e[0]/1+e[1]/60+e[2]/3600;break;case 2:a=e[0]/1+e[1]/60;break;case 1:a=e[0];break;default:return NaN}return/^-|[WS]$/i.test(t.trim())&&(a=-a),Number(a)}static toDms(t,e="d",a=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===a)switch(e){case"d":case"deg":a=4;break;case"dm":case"deg+min":a=2;break;case"dms":case"deg+min+sec":a=0;break;default:e="d",a=4}t=Math.abs(t);let r=null,n=null,i=null,o=null;switch(e){default:case"d":case"deg":n=t.toFixed(a),n<100&&(n="0"+n),n<10&&(n="0"+n),r=n+"°";break;case"dm":case"deg+min":n=Math.floor(t),i=(60*t%60).toFixed(a),60==i&&(i=(0).toFixed(a),n++),n=("000"+n).slice(-3),i<10&&(i="0"+i),r=n+"°"+u.separator+i+"′";break;case"dms":case"deg+min+sec":n=Math.floor(t),i=Math.floor(3600*t/60)%60,o=(3600*t%60).toFixed(a),60==o&&(o=(0).toFixed(a),i++),60==i&&(i=0,n++),n=("000"+n).slice(-3),i=("00"+i).slice(-2),o<10&&(o="0"+o),r=n+"°"+u.separator+i+"′"+u.separator+o+"″"}return r}static toLat(t,e,a){const r=u.toDms(u.wrap90(t),e,a);return null===r?"–":r.slice(1)+u.separator+(t<0?"S":"N")}static toLon(t,e,a){const r=u.toDms(u.wrap180(t),e,a);return null===r?"–":r+u.separator+(t<0?"W":"E")}static toBrng(t,e,a){const r=u.toDms(u.wrap360(t),e,a);return null===r?"–":r.replace("360","0")}static fromLocale(t){const e=123456.789.toLocaleString(),a={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(a.thousands,"⁜").replace(a.decimal,".").replace("⁜",",")}static toLocale(t){const e=123456.789.toLocaleString(),a={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(/,([0-9])/,"⁜$1").replace(".",a.decimal).replace("⁜",a.thousands)}static compassPoint(t,e=3){if(![1,2,3].includes(Number(e)))throw new RangeError(`invalid precision ‘${e}’`);t=u.wrap360(t);const a=4*2**(e-1);return["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"][Math.round(t*a/360)%a*16/a]}static wrap90(t){if(-90<=t&&t<=90)return t;const e=t,a=360;return 1*Math.abs(((e-90)%a+a)%a-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};const c=Math.PI;class d{constructor(t,e){if(isNaN(t))throw new TypeError(`invalid lat ‘${t}’`);if(isNaN(e))throw new TypeError(`invalid lon ‘${e}’`);this._lat=u.wrap90(Number(t)),this._lon=u.wrap180(Number(e))}get lat(){return this._lat}get latitude(){return this._lat}set lat(t){if(this._lat=isNaN(t)?u.wrap90(u.parse(t)):u.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid lat ‘${t}’`)}set latitude(t){if(this._lat=isNaN(t)?u.wrap90(u.parse(t)):u.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)?u.wrap180(u.parse(t)):u.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lon ‘${t}’`)}set lng(t){if(this._lon=isNaN(t)?u.wrap180(u.parse(t)):u.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lng ‘${t}’`)}set longitude(t){if(this._lon=isNaN(t)?u.wrap180(u.parse(t)):u.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid longitude ‘${t}’`)}static get metresToKm(){return.001}static get metresToMiles(){return 1/1609.344}static get metresToNauticalMiles(){return 1/1852}static parse(...t){if(0==t.length)throw new TypeError("invalid (empty) point");if(null===t[0]||null===t[1])throw new TypeError("invalid (null) point");let e,a;if(2==t.length&&([e,a]=t,e=u.wrap90(u.parse(e)),a=u.wrap180(u.parse(a)),isNaN(e)||isNaN(a)))throw new TypeError(`invalid point ‘${t.toString()}’`);if(1==t.length&&"string"==typeof t[0]&&([e,a]=t[0].split(","),e=u.wrap90(u.parse(e)),a=u.wrap180(u.parse(a)),isNaN(e)||isNaN(a)))throw new TypeError(`invalid point ‘${t[0]}’`);if(1==t.length&&"object"==typeof t[0]){const r=t[0];if("Point"==r.type&&Array.isArray(r.coordinates)?[a,e]=r.coordinates:(null!=r.latitude&&(e=r.latitude),null!=r.lat&&(e=r.lat),null!=r.longitude&&(a=r.longitude),null!=r.lng&&(a=r.lng),null!=r.lon&&(a=r.lon),e=u.wrap90(u.parse(e)),a=u.wrap180(u.parse(a))),isNaN(e)||isNaN(a))throw new TypeError(`invalid point ‘${JSON.stringify(t[0])}’`)}if(isNaN(e)||isNaN(a))throw new TypeError(`invalid point ‘${t.toString()}’`);return new d(e,a)}distanceTo(t,e=6371e3){if(t instanceof d||(t=d.parse(t)),isNaN(e))throw new TypeError(`invalid radius ‘${e}’`);const a=e,r=this.lat.toRadians(),n=this.lon.toRadians(),i=t.lat.toRadians(),o=i-r,s=t.lon.toRadians()-n,l=Math.sin(o/2)*Math.sin(o/2)+Math.cos(r)*Math.cos(i)*Math.sin(s/2)*Math.sin(s/2);return a*(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)))}initialBearingTo(t){if(t instanceof d||(t=d.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),a=t.lat.toRadians(),r=(t.lon-this.lon).toRadians(),n=Math.cos(e)*Math.sin(a)-Math.sin(e)*Math.cos(a)*Math.cos(r),i=Math.sin(r)*Math.cos(a),o=Math.atan2(i,n).toDegrees();return u.wrap360(o)}finalBearingTo(t){t instanceof d||(t=d.parse(t));const e=t.initialBearingTo(this)+180;return u.wrap360(e)}midpointTo(t){t instanceof d||(t=d.parse(t));const e=this.lat.toRadians(),a=this.lon.toRadians(),r=t.lat.toRadians(),n=(t.lon-this.lon).toRadians(),i=Math.cos(e),o=0,s=Math.sin(e),l={x:i+Math.cos(r)*Math.cos(n),y:o+Math.cos(r)*Math.sin(n),z:s+Math.sin(r)},h=Math.atan2(l.z,Math.sqrt(l.x*l.x+l.y*l.y)),u=a+Math.atan2(l.y,l.x),c=h.toDegrees(),p=u.toDegrees();return new d(c,p)}intermediatePointTo(t,e){if(t instanceof d||(t=d.parse(t)),this.equals(t))return new d(this.lat,this.lon);const a=this.lat.toRadians(),r=this.lon.toRadians(),n=t.lat.toRadians(),i=t.lon.toRadians(),o=n-a,s=i-r,l=Math.sin(o/2)*Math.sin(o/2)+Math.cos(a)*Math.cos(n)*Math.sin(s/2)*Math.sin(s/2),h=2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)),u=Math.sin((1-e)*h)/Math.sin(h),c=Math.sin(e*h)/Math.sin(h),p=u*Math.cos(a)*Math.cos(r)+c*Math.cos(n)*Math.cos(i),g=u*Math.cos(a)*Math.sin(r)+c*Math.cos(n)*Math.sin(i),f=u*Math.sin(a)+c*Math.sin(n),y=Math.atan2(f,Math.sqrt(p*p+g*g)),m=Math.atan2(g,p),v=y.toDegrees(),M=m.toDegrees();return new d(v,M)}destinationPoint(t,e,a=6371e3){const r=t/a,n=Number(e).toRadians(),i=this.lat.toRadians(),o=this.lon.toRadians(),s=Math.sin(i)*Math.cos(r)+Math.cos(i)*Math.sin(r)*Math.cos(n),l=Math.asin(s),h=Math.sin(n)*Math.sin(r)*Math.cos(i),u=Math.cos(r)-Math.sin(i)*s,c=o+Math.atan2(h,u),p=l.toDegrees(),g=c.toDegrees();return new d(p,g)}static intersection(t,e,a,r){if(t instanceof d||(t=d.parse(t)),a instanceof d||(a=d.parse(a)),isNaN(e))throw new TypeError(`invalid brng1 ‘${e}’`);if(isNaN(r))throw new TypeError(`invalid brng2 ‘${r}’`);const n=t.lat.toRadians(),i=t.lon.toRadians(),o=a.lat.toRadians(),s=a.lon.toRadians(),l=Number(e).toRadians(),h=Number(r).toRadians(),u=o-n,p=s-i,g=2*Math.asin(Math.sqrt(Math.sin(u/2)*Math.sin(u/2)+Math.cos(n)*Math.cos(o)*Math.sin(p/2)*Math.sin(p/2)));if(Math.abs(g)<Number.EPSILON)return new d(t.lat,t.lon);const f=(Math.sin(o)-Math.sin(n)*Math.cos(g))/(Math.sin(g)*Math.cos(n)),y=(Math.sin(n)-Math.sin(o)*Math.cos(g))/(Math.sin(g)*Math.cos(o)),m=Math.acos(Math.min(Math.max(f,-1),1)),v=Math.acos(Math.min(Math.max(y,-1),1)),M=l-(Math.sin(s-i)>0?m:2*c-m),b=(Math.sin(s-i)>0?2*c-v:v)-h;if(0==Math.sin(M)&&0==Math.sin(b))return null;if(Math.sin(M)*Math.sin(b)<0)return null;const w=-Math.cos(M)*Math.cos(b)+Math.sin(M)*Math.sin(b)*Math.cos(g),x=Math.atan2(Math.sin(g)*Math.sin(M)*Math.sin(b),Math.cos(b)+Math.cos(M)*w),P=Math.asin(Math.min(Math.max(Math.sin(n)*Math.cos(x)+Math.cos(n)*Math.sin(x)*Math.cos(l),-1),1)),N=i+Math.atan2(Math.sin(l)*Math.sin(x)*Math.cos(n),Math.cos(x)-Math.sin(n)*Math.sin(P)),S=P.toDegrees(),E=N.toDegrees();return new d(S,E)}crossTrackDistanceTo(t,e,a=6371e3){t instanceof d||(t=d.parse(t)),e instanceof d||(e=d.parse(e));const r=a;if(this.equals(t))return 0;const n=t.distanceTo(this,r)/r,i=t.initialBearingTo(this).toRadians(),o=t.initialBearingTo(e).toRadians();return Math.asin(Math.sin(n)*Math.sin(i-o))*r}alongTrackDistanceTo(t,e,a=6371e3){t instanceof d||(t=d.parse(t)),e instanceof d||(e=d.parse(e));const r=a;if(this.equals(t))return 0;const n=t.distanceTo(this,r)/r,i=t.initialBearingTo(this).toRadians(),o=t.initialBearingTo(e).toRadians(),s=Math.asin(Math.sin(n)*Math.sin(i-o));return Math.acos(Math.cos(n)/Math.abs(Math.cos(s)))*Math.sign(Math.cos(o-i))*r}maxLatitude(t){const e=Number(t).toRadians(),a=this.lat.toRadians();return Math.acos(Math.abs(Math.sin(e)*Math.cos(a))).toDegrees()}static crossingParallels(t,e,a){if(t.equals(e))return null;const r=Number(a).toRadians(),n=t.lat.toRadians(),i=t.lon.toRadians(),o=e.lat.toRadians(),s=e.lon.toRadians()-i,l=Math.sin(n)*Math.cos(o)*Math.cos(r)*Math.sin(s),h=Math.sin(n)*Math.cos(o)*Math.cos(r)*Math.cos(s)-Math.cos(n)*Math.sin(o)*Math.cos(r),c=Math.cos(n)*Math.cos(o)*Math.sin(r)*Math.sin(s);if(c*c>l*l+h*h)return null;const d=Math.atan2(-h,l),p=Math.acos(c/Math.sqrt(l*l+h*h)),g=i+d+p,f=(i+d-p).toDegrees(),y=g.toDegrees();return{lon1:u.wrap180(f),lon2:u.wrap180(y)}}rhumbDistanceTo(t,e=6371e3){t instanceof d||(t=d.parse(t));const a=e,r=this.lat.toRadians(),n=t.lat.toRadians(),i=n-r;let o=Math.abs(t.lon-this.lon).toRadians();Math.abs(o)>c&&(o=o>0?-(2*c-o):2*c+o);const s=Math.log(Math.tan(n/2+c/4)/Math.tan(r/2+c/4)),l=Math.abs(s)>1e-11?i/s:Math.cos(r);return Math.sqrt(i*i+l*l*o*o)*a}rhumbBearingTo(t){if(t instanceof d||(t=d.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),a=t.lat.toRadians();let r=(t.lon-this.lon).toRadians();Math.abs(r)>c&&(r=r>0?-(2*c-r):2*c+r);const n=Math.log(Math.tan(a/2+c/4)/Math.tan(e/2+c/4)),i=Math.atan2(r,n).toDegrees();return u.wrap360(i)}rhumbDestinationPoint(t,e,a=6371e3){const r=this.lat.toRadians(),n=this.lon.toRadians(),i=Number(e).toRadians(),o=t/a,s=o*Math.cos(i);let l=r+s;Math.abs(l)>c/2&&(l=l>0?c-l:-c-l);const h=Math.log(Math.tan(l/2+c/4)/Math.tan(r/2+c/4)),u=Math.abs(h)>1e-11?s/h:Math.cos(r),p=n+o*Math.sin(i)/u,g=l.toDegrees(),f=p.toDegrees();return new d(g,f)}rhumbMidpointTo(t){t instanceof d||(t=d.parse(t));const e=this.lat.toRadians();let a=this.lon.toRadians();const r=t.lat.toRadians(),n=t.lon.toRadians();Math.abs(n-a)>c&&(a+=2*c);const i=(e+r)/2,o=Math.tan(c/4+e/2),s=Math.tan(c/4+r/2),l=Math.tan(c/4+i/2);let h=((n-a)*Math.log(l)+a*Math.log(s)-n*Math.log(o))/Math.log(s/o);isFinite(h)||(h=(a+n)/2);const u=i.toDegrees(),p=h.toDegrees();return new d(u,p)}static areaOf(t,e=6371e3){const a=e,r=t[0].equals(t[t.length-1]);r||t.push(t[0]);const n=t.length-1;let i=0;for(let e=0;e<n;e++){const a=t[e].lat.toRadians(),r=t[e+1].lat.toRadians(),n=(t[e+1].lon-t[e].lon).toRadians();i+=2*Math.atan2(Math.tan(n/2)*(Math.tan(a/2)+Math.tan(r/2)),1+Math.tan(a/2)*Math.tan(r/2))}(function(t){let e=0,a=t[0].initialBearingTo(t[1]);for(let r=0;r<t.length-1;r++){const n=t[r].initialBearingTo(t[r+1]),i=t[r].finalBearingTo(t[r+1]);e+=(n-a+540)%360-180,e+=(i-n+540)%360-180,a=i}const r=t[0].initialBearingTo(t[1]);e+=(r-a+540)%360-180;return Math.abs(e)<90})(t)&&(i=Math.abs(i)-2*c);const o=Math.abs(i*a*a);return r||t.pop(),o}equals(t){return t instanceof d||(t=d.parse(t)),!(Math.abs(this.lat-t.lat)>Number.EPSILON)&&!(Math.abs(this.lon-t.lon)>Number.EPSILON)}toGeoJSON(){return{type:"Point",coordinates:[this.lon,this.lat]}}toString(t="d",e=void 0){if(!["d","dm","dms","n"].includes(t))throw new RangeError(`invalid format ‘${t}’`);if("n"==t)return null==e&&(e=4),`${this.lat.toFixed(e)},${this.lon.toFixed(e)}`;return`${u.toLat(this.lat,t,e)}, ${u.toLon(this.lon,t,e)}`}}function p(t,e,a){if(null!==t)for(var r,n,i,o,s,l,h,u,c=0,d=0,g=t.type,f="FeatureCollection"===g,y="Feature"===g,m=f?t.features.length:1,v=0;v<m;v++){s=(u=!!(h=f?t.features[v].geometry:y?t.geometry:t)&&"GeometryCollection"===h.type)?h.geometries.length:1;for(var M=0;M<s;M++){var b=0,w=0;if(null!==(o=u?h.geometries[M]:h)){l=o.coordinates;var x=o.type;switch(c=0,x){case null:break;case"Point":if(!1===e(l,d,v,b,w))return!1;d++,b++;break;case"LineString":case"MultiPoint":for(r=0;r<l.length;r++){if(!1===e(l[r],d,v,b,w))return!1;d++,"MultiPoint"===x&&b++}"LineString"===x&&b++;break;case"Polygon":case"MultiLineString":for(r=0;r<l.length;r++){for(n=0;n<l[r].length-c;n++){if(!1===e(l[r][n],d,v,b,w))return!1;d++}"MultiLineString"===x&&b++,"Polygon"===x&&w++}"Polygon"===x&&b++;break;case"MultiPolygon":for(r=0;r<l.length;r++){for(w=0,n=0;n<l[r].length;n++){for(i=0;i<l[r][n].length-c;i++){if(!1===e(l[r][n][i],d,v,b,w))return!1;d++}w++}b++}break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===p(o.geometries[r],e))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}var g=function(t,e={}){if(null!=t.bbox&&!0!==e.recompute)return t.bbox;const a=[1/0,1/0,-1/0,-1/0];return p(t,t=>{a[0]>t[0]&&(a[0]=t[0]),a[1]>t[1]&&(a[1]=t[1]),a[2]<t[0]&&(a[2]=t[0]),a[3]<t[1]&&(a[3]=t[1])}),a},f=(t,e)=>{var[a,r]=t,[n,i]=e,o=new d(r,a),s=new d(i,n);return o.distanceTo(s)},y=t=>{var e=t/1609.344;if(e<.5){var a=Math.round(t),r=1===a?"metre":"metres";return"".concat(a," ").concat(r)}if(e<10){var n=Number.parseFloat(e.toFixed(1)),i=1===n?"mile":"miles";return"".concat(n," ").concat(i)}var o=Math.round(e);return"".concat(o," miles")},m=t=>g(t);function v(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),a.push.apply(a,r)}return a}function M(e){for(var a=1;a<arguments.length;a++){var r=null!=arguments[a]?arguments[a]:{};a%2?v(Object(r),!0).forEach(function(a){t(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var b="highlighted-label";function w(t,e){if("number"==typeof t)return t;if(!Array.isArray(t)||"interpolate"!==t[0])return function(t,e){var{stops:a}=t;if(a.length<2)return a.length>0?a[0][1]:0;for(var r=a[0],n=a[a.length-1],i=1;i<a.length;i++){var o=a[i];if(o[0]>e){n=o,r=a[i-1];break}r=a[i-1],n=o}var[s,l]=r,[h,u]=n;return e<=s?l:e>=h?u:l+(e-s)/(h-s)*(u-l)}(t,e);var[,,a,...r]=t;if("zoom"!==a[0])throw new Error("Only zoom-based expressions supported");for(var n=0;n<r.length-2;n+=2){var i=r[n],o=r[n+1],s=r[n+2],l=r[n+3];if(e<=i)return o;if(e<=s)return o+(e-i)/(s-i)*(l-o)}return r[r.length-1]}function x(t,e,a){return e.flatMap(e=>{var r,n=function(t){var e,a;return"string"==typeof t?null===(e=/^{(.+)}$/.exec(t))||void 0===e?void 0:e[1]:Array.isArray(t)?null===(a=t.find(t=>Array.isArray(t)&&"get"===t[0]))||void 0===a?void 0:a[1]:null}(null===(r=e.layout)||void 0===r?void 0:r["text-field"]);return n?a.filter(t=>{var a;return t.layer.id===e.id&&(null===(a=t.properties)||void 0===a?void 0:a[n])}).map(a=>function(t,e,a,r){var n=function(t){var{type:e,coordinates:a}=t;if("Point"===e)return a;if("MultiPoint"===e)return a[0];if(e.includes("LineString")){var r="LineString"===e?a:a[0];return[(r[0][0]+r[r.length-1][0])/2,(r[0][1]+r[r.length-1][1])/2]}if(e.includes("Polygon")){var n="Polygon"===e?a[0]:a[0][0],i=n.reduce((t,e)=>[t[0]+e[0],t[1]+e[1]],[0,0]);return[i[0]/n.length,i[1]/n.length]}return null}(t.geometry);if(!n)return null;var i=r.project({lng:n[0],lat:n[1]});return{text:t.properties[a],x:i.x,y:i.y,feature:t,layer:e}}(a,e,n,t)).filter(Boolean):[]})}function P(t,e){if(e.highlightLayerId&&t.getLayer(e.highlightLayerId)){try{t.removeLayer(e.highlightLayerId)}catch(t){}e.highlightLayerId=null,e.highlightedExpr=null}}function N(t,e,a){var r;if(null!=e&&null!==(r=e.feature)&&void 0!==r&&r.layer){P(t,a);var{feature:n,layer:i}=e;a.highlightLayerId="highlight-".concat(i.id);var{id:o,type:s,properties:l,geometry:h}=n;t.getSource(b).setData({id:o,type:s,properties:l,geometry:h}),a.highlightedExpr=i.layout["text-size"];var u=t.getZoom(),c=function(t,e,a){return{id:"highlight-".concat(t.id),type:t.type,source:b,layout:M(M({},t.layout),{},{"text-size":e,"text-allow-overlap":!0,"text-ignore-placement":!0,"text-max-angle":90}),paint:M(M({},t.paint),{},{"text-color":a.text,"text-halo-color":a.halo,"text-halo-width":3,"text-halo-blur":1,"text-opacity":1})}}(i,1.5*w(a.highlightedExpr,u),a.isDarkStyle?{text:"#ffffff",halo:"#000000"}:{text:"#000000",halo:"#ffffff"});t.addLayer(c),t.moveLayer(a.highlightLayerId)}}function S(t,e){if(!e.currentPixel)return null;var a=e.labels.map((t,e)=>({pixel:[t.x,t.y],index:e})).filter(t=>t.pixel[0]!==e.currentPixel.x||t.pixel[1]!==e.currentPixel.y);if(!a.length)return null;var r=a.map(t=>t.pixel),n=((t,e,a)=>{var r=(t,e)=>t[0]===e[0]&&t[1]===e[1],n=e.filter(e=>{var n=Math.abs(e[0]-t[0]),i=Math.abs(e[1]-t[1]);return("ArrowUp"===a?e[1]<=t[1]&&i>=n:"ArrowDown"===a?e[1]>t[1]&&i>=n:"ArrowLeft"===a?e[0]<=t[0]&&i<n:"ArrowRight"!==a||e[0]>t[0]&&i<n)&&!r(e,t)});n.length||n.push(t);var i=e=>Math.hypot(t[0]-e[0],t[1]-e[1]),o=n.reduce((t,e)=>i(e)<i(t)?e:t,n[0]);return e.findIndex(t=>r(t,o))})([e.currentPixel.x,e.currentPixel.y],r,t);return(null==n||n<0||n>=a.length)&&(n=0),e.labels[a[n].index]}function E(t){t.getSource(b)||t.addSource(b,{type:"geojson",data:{type:"FeatureCollection",features:[]}})}function L(t){t.getStyle().layers.filter(t=>{var e;return"line"===(null===(e=t.layout)||void 0===e?void 0:e["symbol-placement"])}).forEach(e=>t.setLayoutProperty(e.id,"symbol-placement","line-center"))}var R=t=>t.endsWith(".cold")?"".concat(t.slice(0,-5),".hot"):t.endsWith(".hot")?"".concat(t.slice(0,-4),".cold"):null;function I(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),a.push.apply(a,r)}return a}function O(e){for(var a=1;a<arguments.length;a++){var r=null!=arguments[a]?arguments[a]:{};a%2?I(Object(r),!0).forEach(function(a){t(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var T="icon-image",A="active-highlight",D="active-highlight-inner",_="selected-highlight",j=(t,e)=>{var a,r;return null!==(a=null===(r=t._activeSymbolImageMap)||void 0===r?void 0:r[e])&&void 0!==a?a:null},C=(t,e)=>{var a,r;return null!==(a=null===(r=t._selectedSymbolImageMap)||void 0===r?void 0:r[e])&&void 0!==a?a:null},B=(t,e,a,r)=>{var{featureId:n,idProperty:i,geometry:o}=r,s=t.getLayer(a);s&&(e[a]||(e[a]={ids:new Set,fillIds:new Set,idProperty:i,sourceId:s.source,hasFillGeometry:!1}),!o||"Polygon"!==o.type&&"MultiPolygon"!==o.type||(e[a].hasFillGeometry=!0,e[a].fillIds.add(n)),e[a].ids.add(n))},k=(t,e,a,r)=>{e.forEach(e=>{if(!a.has(e)){var n="".concat(r,"-").concat(e);["".concat(n,"-fill"),"".concat(n,"-line"),"".concat(n,"-symbol")].forEach(e=>{t.getLayer(e)&&t.setFilter(e,["==","id",""])})}})},F=(t,e)=>{var a="_".concat(e.replaceAll("-",""),"Sources");k(t,t[a]||new Set,new Set,e),t[a]=new Set},z=(t,e,a,r,n,i,o)=>{!!t.getLayer(e)||t.addLayer(O(O({id:e,type:a,source:r},n&&{"source-layer":n}),{},{paint:i})),Object.entries(i).forEach(a=>{var[r,n]=a;t.setPaintProperty(e,r,n)}),t.setFilter(e,o),t.moveLayer(e)},W=(t,e,a,r,n,i,o)=>{var s,l=t.getLayoutProperty(n,"icon-offset");t.getLayer(e)||t.addLayer(O(O({id:e,type:"symbol",source:a},r&&{"source-layer":r}),{},{layout:O(O({[T]:i,"icon-anchor":null!==(s=t.getLayoutProperty(n,"icon-anchor"))&&void 0!==s?s:"center"},void 0!==l&&{"icon-offset":l}),{},{"icon-allow-overlap":!0})}));t.setLayoutProperty(e,T,i),void 0!==l&&t.setLayoutProperty(e,"icon-offset",l),t.setFilter(e,o),t.moveLayer(e)},q=(t,e,a,r,n,i)=>{var o,{ids:s,fillIds:l,idProperty:h,sourceId:u,hasFillGeometry:c}=a[e],d=t.getLayer(e),p=null!==(o=r[e])&&void 0!==o?o:r[R(e)];if(d&&p){var g=d.sourceLayer,f=c?"fill":d.type,y="".concat(n,"-").concat(e),{fill:m}=p,v=n===_,M=(t=>t===_||t===D)(n),{lineColor:b,lineWidth:w}=((t,e)=>({lineColor:e?t.selectionStroke:t.stroke,lineWidth:e?t.strokeWidth:t.activeStrokeWidth}))(p,M),x=h?["get",h]:["id"],P=["in",x,["literal",Array.from(s)]];if("fill-extrusion"!==d.type)switch(f){case"fill":((t,e,a,r,n)=>{var{isSelected:i,idExpression:o,fillIds:s,fill:l,lineColor:h,lineWidth:u,filter:c}=n;if(i){var d=[];s.forEach(t=>d.push(t));var p=["in",o,["literal",d]];z(t,"".concat(e,"-fill"),"fill",a,r,{"fill-color":l},p)}z(t,"".concat(e,"-line"),"line",a,r,{"line-color":h,"line-width":u},c)})(t,y,u,g,{isSelected:v,idExpression:x,fillIds:l,fill:m,lineColor:b,lineWidth:w,filter:P});break;case"line":((t,e,a,r,n,i,o)=>{t.getLayer("".concat(e,"-fill"))&&t.setFilter("".concat(e,"-fill"),["==","id",""]),z(t,"".concat(e,"-line"),"line",a,r,{"line-color":n,"line-width":i},o)})(t,y,u,g,b,w,P);break;case"symbol":((t,e,a,r,n,i,o)=>{var s=t.getLayoutProperty(n,T);if(Array.isArray(s)){var l=o===j?"user_symbolActiveImageId":"user_symbolSelectedImageId";W(t,"".concat(e,"-symbol"),a,r,n,["get",l],i)}else{var h=o(t,s);h&&W(t,"".concat(e,"-symbol"),a,r,n,h,i)}})(t,y,u,g,e,P,i)}else((t,e,a,r)=>{var{ids:n,lineColor:i,lineWidth:o,idExpression:s}=r,l=[];n.forEach(t=>l.push(t));var h=["in",s,["literal",l]],{source:u,sourceLayer:c}=t.getLayer(a);z(t,"".concat(e,"-line"),"line",u,c,{"line-color":i,"line-width":o},h)})(t,y,e,{ids:s,lineColor:b,lineWidth:w,idExpression:x})}},$=(t,e,a,r,n)=>{var i=((t,e)=>{var a={};return null==e||e.forEach(e=>{B(t,a,e.layerId,e);var r=R(e.layerId);r&&B(t,a,r,e)}),a})(t,e),o=new Set(Object.keys(i)),s="_".concat(r.replaceAll("-",""),"Sources"),l=t[s]||new Set;return k(t,l,o,r),t[s]=o,o.forEach(e=>q(t,e,i,a,r,n)),i};var Z=(t,e,a)=>{var r=(e.x-a.x)**2+(e.y-a.y)**2;if(0===r)return(t.x-e.x)**2+(t.y-e.y)**2;var n=((t.x-e.x)*(a.x-e.x)+(t.y-e.y)*(a.y-e.y))/r;return n=Math.max(0,Math.min(1,n)),(t.x-(e.x+n*(a.x-e.x)))**2+(t.y-(e.y+n*(a.y-e.y)))**2},G=function(t,e){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{radius:r=10}=a,n=[[e.x-r,e.y-r],[e.x+r,e.y+r]],i=t.queryRenderedFeatures(n);if(0===i.length)return[];var o=new Set(t.queryRenderedFeatures([e.x,e.y]).map(t=>{var e,a=void 0===t.id?JSON.stringify(t.properties):t.id;return"".concat(null===(e=t.layer)||void 0===e?void 0:e.source,":").concat(a)})),s=[];i.forEach(t=>{!1===s.includes(t.layer.id)&&s.push(t.layer.id)});for(var l=new Set,h=[],u=i.length-1;u>=0;u--){var c,d=i[u],p=void 0===d.id?JSON.stringify(d.properties):d.id,g="".concat(null===(c=d.layer)||void 0===c?void 0:c.source,":").concat(p);!1===l.has(g)&&(l.add(g),h.push(d))}var f=t.unproject(e),y=[f.lng,f.lat],m=h.filter(t=>{var e=t.geometry.type;if(e.includes("Polygon"))return("Polygon"===e?[t.geometry.coordinates]:t.geometry.coordinates).some(t=>((t,e)=>{for(var[a,r]=t,n=!1,i=0,o=e.length-1;i<e.length;o=i,i++){var[s,l]=e[i],[h,u]=e[o];l>r!=u>r&&a<(h-s)*(r-l)/(u-l)+s&&(n=!n)}return n})(y,t[0]));if("Point"===e||"MultiPoint"===e){var a,r=void 0===t.id?JSON.stringify(t.properties):t.id;return o.has("".concat(null===(a=t.layer)||void 0===a?void 0:a.source,":").concat(r))}return!0});return m.map(a=>{var r=0,n=a.geometry.type,i=((t,e,a)=>{var{coordinates:r,type:n}=a,i=1/0,o=e=>t.project(e),s=t=>{for(var a=0;a<t.length-1;a++){var r=Z(e,o(t[a]),o(t[a+1]));r<i&&(i=r)}};if("Point"===n){var l=o(r);i=(e.x-l.x)**2+(e.y-l.y)**2}else"LineString"===n||"MultiPoint"===n?"LineString"===n?s(r):r.forEach(t=>{var a=o(t),r=(e.x-a.x)**2+(e.y-a.y)**2;r<i&&(i=r)}):"Polygon"===n||"MultiLineString"===n?r.forEach(s):"MultiPolygon"===n&&r.forEach(t=>t.forEach(s));return i})(t,e,a.geometry);return r+=1e6*s.indexOf(a.layer.id),n.includes("Polygon")&&(r-=5e5),{f:a,score:r+=i}}).sort((t,e)=>t.score-e.score).map(t=>{var{f:e}=t;return e})},H=(t,e,a)=>{var r=t.getCanvas();if(a&&t.off("mousemove",a),null==e||!e.length)return r.style.cursor="",null;var n=a=>{var n=(t=>{var e=new Set(t);return t.forEach(t=>{var a=R(t);a&&e.add(a)}),[...e]})(e).filter(e=>t.getLayer(e));if(0!==n.length){var{lineLayers:i,otherLayers:o}=((t,e)=>{var a=[],r=[];for(var n of e)if("line"===t.getLayer(n).type){var i=n.endsWith("-stroke")?n.slice(0,-7):null;null!==i&&e.includes(i)||a.push(n)}else r.push(n);return{lineLayers:a,otherLayers:r}})(t,n),{x:s,y:l}=a.point,h=[[s-10,l-10],[s+10,l+10]],u=i.length>0&&t.queryRenderedFeatures(h,{layers:i}).length>0,c=o.length>0&&t.queryRenderedFeatures(a.point,{layers:o}).length>0;r.style.cursor=u||c?"pointer":""}else r.style.cursor=""};return t.on("mousemove",n),n},V=function(){var t=a(function*(t,e,r,n){var i,o,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2;e.length&&(null!==(i=t._activeSymbolImageMap)&&void 0!==i||(t._activeSymbolImageMap={}),null!==(o=t._selectedSymbolImageMap)&&void 0!==o||(t._selectedSymbolImageMap={}),yield Promise.all(e.flatMap(e=>{var i=n.getSymbolImageId(e,r,!1,s),o=n.getSymbolImageId(e,r,!0,s);return i&&o&&(t._activeSymbolImageMap[i]=o),["normal","active","selected"].map(function(){var l=a(function*(a){var l="active"===a?o:i;if("selected"===a||l&&!t.hasImage(l)){var h=yield n.rasteriseSymbolImage(e,r,a,s);h&&("selected"===a&&i&&(t._selectedSymbolImageMap[i]=h.imageId),t.hasImage(h.imageId)||t.addImage(h.imageId,h.imageData,{pixelRatio:s}))}});return function(t){return l.apply(this,arguments)}}())})))});return function(e,a,r,n){return t.apply(this,arguments)}}(),J=t=>Math.max(2,2*t),Y=(t,e)=>{if(!t)return null;if("string"==typeof t)return t.trim();if("object"==typeof t){if(e&&t[e])return t[e];var a=Object.values(t)[0];return null!=a?a:null}return null},K=new Map,U=function(){var t=a(function*(t,e,a,r){var n=a.getPatternInnerContent(t);if(!n)return null;var i=a.getPatternImageId(t,e,r);if(!i)return null;var o,s,l=K.get(i);if(!l){var h=Y(t.fillPatternForegroundColor,e)||"black",u=Y(t.fillPatternBackgroundColor,e)||"transparent",c=(o=h,s=u,n.replace(/\{\{foregroundColor\}\}/g,o||"black").replace(/\{\{backgroundColor\}\}/g,s||"transparent")),d='<rect width="16" height="16" fill="'.concat(u,'"/>'),p=J(r),g=Math.round(8*p),f='<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(g,'" height="').concat(g,'" viewBox="0 0 16 16">').concat(d).concat(c,"</svg>");l=yield((t,e,a)=>new Promise((r,n)=>{var i="data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(t)),o=new Image(e,a);o.onload=()=>{var t=document.createElement("canvas");t.width=e,t.height=a;var n=t.getContext("2d");n.drawImage(o,0,0,e,a),r(n.getImageData(0,0,e,a))},o.onerror=()=>{n(new Error("Failed to rasterise SVG: ".concat(t.slice(0,80))))},o.src=i}))(f,g,g),K.set(i,l)}return{imageId:i,imageData:l}});return function(e,a,r,n){return t.apply(this,arguments)}}(),X=function(){var t=a(function*(t,e,r,n,i){if(e.length){var o=J(i),s=e.reduce((e,s)=>{var l=n.getPatternImageId(s,r,i);return!l||e[l]||t.hasImage(l)||(e[l]=a(function*(){var e=yield U(s,r,n,i);e&&!t.hasImage(e.imageId)&&t.addImage(e.imageId,e.imageData,{pixelRatio:o})})),e},{});yield Promise.all(Object.values(s).map(t=>t()))}});return function(e,a,r,n,i){return t.apply(this,arguments)}}(),Q=["container","padding","mapStyle","mapSize","center","zoom","bounds","pixelRatio"];function tt(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),a.push.apply(a,r)}return a}function et(e){for(var a=1;a<arguments.length;a++){var r=null!=arguments[a]?arguments[a]:{};a%2?tt(Object(r),!0).forEach(function(a){t(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tt(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}class at extends r{constructor(t){var{mapFramework:e,mapProviderConfig:a={},events:r,eventBus:n}=t;super(),this.maplibreModule=e,this.events=r,this.eventBus=n,this.capabilities={supportedShortcuts:o,supportsMapSizes:!0},Object.assign(this,a)}get name(){return"MapLibreProvider"}initMap(t){var r=this;return a(function*(){var{container:a,padding:n,mapStyle:i,mapSize:o,center:s,zoom:h,bounds:u,pixelRatio:c}=t,d=e(t,Q);r.mapStyleId=null==i?void 0:i.id,r.mapSize=o;var{Map:p}=r.maplibreModule,{events:g,eventBus:f}=r,y=new p(et(et({},d),{},{container:a,style:null==i?void 0:i.url,pixelRatio:c,padding:n,center:s,zoom:h,fadeDuration:0,attributionControl:!1,dragRotate:!1,doubleClickZoom:!1}));y.touchZoomRotate.disableRotation(),r.map=y,r.map.setPadding(n),u&&y.fitBounds(u,{duration:0}),function(t){var e=Event.prototype.preventDefault;Event.prototype.preventDefault=function(){if(("touchmove"===this.type||"touchstart"===this.type)&&!this.cancelable){var a=t.getCanvas();if(a&&(this.target===a||a.contains(this.target)))return}e.call(this)}}(y),function(t){var e=t.getCanvas();e.removeAttribute("role"),e.setAttribute("tabindex",-1),e.removeAttribute("aria-label"),e.style.display="block",e.addEventListener("focus",t=>{e.blur(),t.relatedTarget&&t.relatedTarget.focus({preventScroll:!0})})}(y),l({map:y,events:g,eventBus:f,getCenter:r.getCenter.bind(r),getZoom:r.getZoom.bind(r),getBounds:r.getBounds.bind(r),getResolution:r.getResolution.bind(r)}),function(t){var{mapProvider:e,map:a,events:r,eventBus:n}=t,i=t=>{a.once("style.load",()=>{n.emit(r.MAP_STYLE_CHANGE,{mapStyleId:t.id})}),a.setStyle(t.url,{diff:!1})},o=t=>{a.setPixelRatio(t)},s=t=>{var{mapSize:a}=t;e.mapSize=a};n.on(r.MAP_SET_STYLE,i),n.on(r.MAP_SET_PIXEL_RATIO,o),n.on(r.MAP_SIZE_CHANGE,s)}({mapProvider:r,map:y,events:g,eventBus:f}),y.on("load",()=>{r.labelNavigator=function(t,e,a,r){var n={isDarkStyle:"dark"===e,labels:[],currentPixel:null,highlightLayerId:null,highlightedExpr:null};function i(){var e=t.getStyle().layers.filter(t=>"symbol"===t.type),a=t.queryRenderedFeatures({layers:e.map(t=>t.id)});n.labels=x(t,e,a)}function o(){if(i(),!n.labels.length)return null;var e=t.project(t.getCenter()),a=function(t,e){var a;return null===(a=t.reduce((t,a)=>{var r=(a.x-e.x)**2+(a.y-e.y)**2;return!t||r<t.dist?{label:a,dist:r}:t},null))||void 0===a?void 0:a.label}(n.labels,e);return n.currentPixel={x:a.x,y:a.y},N(t,a,n),a.text}return L(t),E(t),null==r||r.on(a.MAP_SET_STYLE,e=>{t.once("styledata",()=>t.once("idle",()=>{L(t),E(t),n.isDarkStyle="dark"===(null==e?void 0:e.mapColorScheme)}))}),t.on("zoom",()=>{if(n.highlightLayerId&&n.highlightedExpr){var e=w(n.highlightedExpr,t.getZoom());t.setLayoutProperty(n.highlightLayerId,"text-size",1.5*e)}}),function(t){t.getStyle().layers.filter(t=>"symbol"===t.type).forEach(e=>{t.setPaintProperty(e.id,"text-opacity",["case",["boolean",["feature-state","highlighted"],!1],0,1])})}(t),{refreshLabels:i,highlightNextLabel:function(e){if(i(),!n.labels.length)return null;if(!n.currentPixel)return o();var a=S(e,n);return a?(n.currentPixel={x:a.x,y:a.y},N(t,a,n),a.text):null},highlightLabelAtCenter:o,clearHighlightedLabel:()=>P(t,n)}}(y,null==i?void 0:i.mapColorScheme,g,f)}),r.eventBus.emit(g.MAP_READY,{map:r.map,mapStyleId:r.mapStyleId,mapSize:r.mapSize,crs:r.crs})})()}isBaseMapReady(){var t;return Boolean(null===(t=this.map)||void 0===t?void 0:t.getStyle())}destroyMap(){var t,e;this.setHoverCursor([]),null===(t=this.mapEvents)||void 0===t||t.remove(),null===(e=this.appEvents)||void 0===e||e.remove(),this.mapEvents=null,this.appEvents=null,this.map.remove()}setHoverCursor(t){this.map&&(this._onHoverMove=H(this.map,t,this._onHoverMove))}setView(t){var{center:e,zoom:a}=t;this.map.flyTo({center:e||this.getCenter(),zoom:a||this.getZoom(),duration:this.map.isStyleLoaded()?n:0})}zoomIn(t){this.map.easeTo({zoom:this.getZoom()+t,duration:n})}zoomOut(t){this.map.easeTo({zoom:this.getZoom()-t,duration:n})}panBy(t){this.map.panBy(t,{duration:n})}fitToBounds(t){var e=Array.isArray(t)?t:m(t),a=this.map.isStyleLoaded()?n:0;this.map.fitBounds(e,{duration:a})}setPadding(t){this.map.setPadding(t)}updateHighlightedFeatures(t,e,a){var{LngLatBounds:r}=this.maplibreModule;return function(t){var{LngLatBounds:e,map:a,selectedFeatures:r,activeFeatures:n,stylesMap:i}=t;if(!a)return null;null!=n&&n.length?($(a,n,i,A,j),$(a,n,i,D,C)):(F(a,A),F(a,D));var o={};null!=r&&r.length?o=$(a,r,i,_,C):F(a,_);var s=[];return Object.entries(o).forEach(t=>{var[e,{ids:r,idProperty:n}]=t;s.push(...a.queryRenderedFeatures({layers:[e]}).filter(t=>{var e;return r.has(n?null===(e=t.properties)||void 0===e?void 0:e[n]:t.id)}))}),((t,e)=>{if(!e.length)return null;var a=new t;return e.forEach(t=>{var e=t=>"number"==typeof t[0]?a.extend(t):t.forEach(e);e(t.geometry.coordinates)}),[a.getWest(),a.getSouth(),a.getEast(),a.getNorth()]})(e,s)}({LngLatBounds:r,map:this.map,selectedFeatures:t,activeFeatures:e,stylesMap:a})}highlightNextLabel(t){var e;return(null===(e=this.labelNavigator)||void 0===e?void 0:e.highlightNextLabel(t))||null}highlightLabelAtCenter(){var t;return(null===(t=this.labelNavigator)||void 0===t?void 0:t.highlightLabelAtCenter())||null}clearHighlightedLabel(){var t;return(null===(t=this.labelNavigator)||void 0===t?void 0:t.clearHighlightedLabel())||null}getCenter(){var t=this.map.getCenter();return[Number(t.lng.toFixed(i)),Number(t.lat.toFixed(i))]}getZoom(){return Number(this.map.getZoom().toFixed(i))}getBounds(){return this.map.getBounds().toArray().flat(1)}getFeaturesAtPoint(t,e){return G(this.map,t,e)}getVisibleFeatures(t){var e=t.filter(t=>this.map.getLayer(t));return e.length?this.map.queryRenderedFeatures(void 0,{layers:e}):[]}addSymbolsToMap(t,e,r){var n=this;return a(function*(){var a=n.map.getPixelRatio()||1;return V(n.map,t,e,r,a)})()}addPatternsToMap(t,e,r){var n=this;return a(function*(){var a=n.map.getPixelRatio()||1;return X(n.map,t,e,r,a)})()}getAreaDimensions(){var{LngLatBounds:t}=this.maplibreModule;return(t=>{var e,a,r,n;if(t&&"function"==typeof t.getWest)e=t.getWest(),a=t.getSouth(),r=t.getEast(),n=t.getNorth();else{if(!Array.isArray(t)||2!==t.length)return"";[[e,a],[r,n]]=t}var i=f([e,a],[r,a]),o=f([e,a],[e,n]),s=y(i),l=y(o);return"".concat(l," by ").concat(s)})(((t,e)=>{var{width:a,height:r}=e.getContainer().getBoundingClientRect(),n=e.getPadding(),i=[n.left,r-n.bottom],o=[a-n.right,n.top];return new t(e.unproject(i),e.unproject(o))})(t,this.map))}getCardinalMove(t,e){return((t,e)=>{var[a,r]=t,[n,i]=e,o=i-r,s=n-a,l=[];if(Math.abs(o)>1e-4){var h=Math.round(f([a,r],[a,i]));l.push("".concat(o>0?"north":"south"," ").concat(y(h)))}if(Math.abs(s)>1e-4){var u=Math.round(f([a,r],[n,r]));l.push("".concat(s>0?"east":"west"," ").concat(y(u)))}return l.join(", ")})(t,e)}getResolution(){return t=this.map.getCenter(),e=this.map.getZoom(),a=t.lat,r=Math.pow(2,e),40075016.686*Math.cos(a*Math.PI/180)/(512*r);var t,e,a,r}mapToScreen(t){return this.map.project(t)}screenToMap(t){var{lng:e,lat:a}=this.map.unproject([t.x,t.y]);return[e,a]}isGeometryObscured(t,e){return((t,e,a)=>{var r=a.getContainer().getBoundingClientRect(),[n,i,o,s]=m(t),l=[a.project([n,i]),a.project([n,s]),a.project([o,i]),a.project([o,s])],h=Math.min(...l.map(t=>t.x)),u=Math.max(...l.map(t=>t.x)),c=Math.min(...l.map(t=>t.y)),d=Math.max(...l.map(t=>t.y)),p=e.left-r.left,g=e.top-r.top,f=e.right-r.left,y=e.bottom-r.top;return h<f&&u>p&&c<y&&d>g})(t,e,this.map)}}export{at as default};
|