@mapcairn/core 0.1.0-rc.2 → 0.1.0-rc.3
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/README.md +3 -1
- package/dist/contracts/mapAdapter.contract.js +29 -0
- package/dist/contracts/mapAdapter.contract.js.map +1 -1
- package/dist/directions/directions.js +10 -21
- package/dist/directions/directions.js.map +1 -1
- package/dist/fakes/FakeLayerSource.js +3 -3
- package/dist/fakes/FakeLayerSource.js.map +1 -1
- package/dist/fakes/FakeMapAdapter.js +1 -1
- package/dist/fakes/FakeMapAdapter.js.map +1 -1
- package/dist/index.d.ts +78 -10
- package/dist/index.js +4 -3
- package/dist/layers/feed.js +86 -9
- package/dist/layers/feed.js.map +1 -1
- package/dist/layers/query.js +82 -8
- package/dist/layers/query.js.map +1 -1
- package/dist/spatial/boundsOfPaths.js +122 -0
- package/dist/spatial/boundsOfPaths.js.map +1 -0
- package/dist/spatial/boundsOfPoints.js +26 -13
- package/dist/spatial/boundsOfPoints.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directions.js","names":[],"sources":["../../src/directions/directions.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport { formatLatLng } from \"../format/format\";\nimport { geometryArea } from \"../geometry/queries\";\nimport { message } from \"../messages/formatMessage\";\nimport type { RoutingErrorKind } from \"../ports/errors\";\nimport type { Bounds, LatLng } from \"../ports/geometry\";\nimport type { Message } from \"../ports/messages\";\nimport type {\n ReachableAreaFeature,\n RouteLeg,\n TravelMode,\n} from \"../ports/routing\";\n\n/** One place a route passes through. */\nexport interface DirectionStop {\n /** Stable for the life of the stop, so a list keeps its rows when stops move. */\n readonly id: string;\n readonly position: LatLng;\n /** A name for the place, such as a search result's label. Without it the coordinates are shown. */\n readonly label?: string;\n}\n\n/** The most stops a route may have. Services cap the count, and a longer list is hard to use. */\nexport const MAX_DIRECTION_STOPS = 10;\n\n/** The travel times, in minutes, a person can ask a reachable area for. */\nexport const AREA_MINUTES = [5, 10, 15, 30] as const;\n\n/** Every way of travelling, in the order the interface lists them. */\nexport const TRAVEL_MODES: readonly TravelMode[] = [\"drive\", \"walk\", \"cycle\"];\n\nconst MODE_LABEL_MESSAGES = {\n drive: message(\"directions.mode.drive\", {}),\n walk: message(\"directions.mode.walk\", {}),\n cycle: message(\"directions.mode.cycle\", {}),\n} as const satisfies Readonly<Record<TravelMode, Message>>;\n\nconst MODE_PARTICIPLE_MESSAGES = {\n drive: message(\"directions.participle.drive\", {}),\n walk: message(\"directions.participle.walk\", {}),\n cycle: message(\"directions.participle.cycle\", {}),\n} as const satisfies Readonly<Record<TravelMode, Message>>;\n\n/** The short name of a travel mode, as it labels a choice: \"Drive\", \"Walk\" or \"Cycle\", as a message to format. */\nexport function travelModeLabel(mode: TravelMode): Message {\n return MODE_LABEL_MESSAGES[mode];\n}\n\n/** A travel mode as it reads in a sentence: \"driving\", \"walking\" or \"cycling\", as a message to format. */\nexport function travelModeParticiple(mode: TravelMode): Message {\n return MODE_PARTICIPLE_MESSAGES[mode];\n}\n\n/** Whether another stop fits. */\nexport function canAddStop(stops: readonly DirectionStop[]): boolean {\n return stops.length < MAX_DIRECTION_STOPS;\n}\n\n/**\n * The stops with `stop` added at the end. Returns the same list when it is\n * already at {@link MAX_DIRECTION_STOPS}.\n */\nexport function addStop(\n stops: readonly DirectionStop[],\n stop: DirectionStop,\n): readonly DirectionStop[] {\n return canAddStop(stops) ? [...stops, stop] : stops;\n}\n\n/** The stops without the one named by `id`. Returns the same list when there is no such stop. */\nexport function removeStop(\n stops: readonly DirectionStop[],\n id: string,\n): readonly DirectionStop[] {\n const next = stops.filter((stop) => stop.id !== id);\n return next.length === stops.length ? stops : next;\n}\n\n/**\n * The stops with one moved a place earlier (`-1`) or later (`1`). Returns the\n * same list when there is no such stop or it is already at that end.\n */\nexport function moveStop(\n stops: readonly DirectionStop[],\n id: string,\n direction: -1 | 1,\n): readonly DirectionStop[] {\n const from = stops.findIndex((stop) => stop.id === id);\n const to = from + direction;\n const moving = stops[from];\n const other = stops[to];\n if (from < 0 || moving === undefined || other === undefined) {\n return stops;\n }\n const next = [...stops];\n next[from] = other;\n next[to] = moving;\n return next;\n}\n\n/** The letter a stop is known by on the map and in the list: \"A\" for the first stop, \"B\" for the next. */\nexport function stopLetter(index: number): string {\n return String.fromCharCode(65 + index);\n}\n\n/** A stop for a screen reader: \"Stop A, Paris\", or its coordinates when it has no name, as a message to format. */\nexport function describeStop(\n index: number,\n stop: DirectionStop,\n): Message<\"directions.stop\"> {\n return message(\"directions.stop\", {\n letter: stopLetter(index),\n place: stop.label ?? formatLatLng(stop.position),\n });\n}\n\
|
|
1
|
+
{"version":3,"file":"directions.js","names":[],"sources":["../../src/directions/directions.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport { formatLatLng } from \"../format/format\";\nimport { geometryArea } from \"../geometry/queries\";\nimport { message } from \"../messages/formatMessage\";\nimport type { RoutingErrorKind } from \"../ports/errors\";\nimport type { Bounds, LatLng } from \"../ports/geometry\";\nimport type { Message } from \"../ports/messages\";\nimport type {\n ReachableAreaFeature,\n RouteLeg,\n TravelMode,\n} from \"../ports/routing\";\nimport { boundsOfPoints } from \"../spatial/boundsOfPoints\";\n\n/** One place a route passes through. */\nexport interface DirectionStop {\n /** Stable for the life of the stop, so a list keeps its rows when stops move. */\n readonly id: string;\n readonly position: LatLng;\n /** A name for the place, such as a search result's label. Without it the coordinates are shown. */\n readonly label?: string;\n}\n\n/** The most stops a route may have. Services cap the count, and a longer list is hard to use. */\nexport const MAX_DIRECTION_STOPS = 10;\n\n/** The travel times, in minutes, a person can ask a reachable area for. */\nexport const AREA_MINUTES = [5, 10, 15, 30] as const;\n\n/** Every way of travelling, in the order the interface lists them. */\nexport const TRAVEL_MODES: readonly TravelMode[] = [\"drive\", \"walk\", \"cycle\"];\n\nconst MODE_LABEL_MESSAGES = {\n drive: message(\"directions.mode.drive\", {}),\n walk: message(\"directions.mode.walk\", {}),\n cycle: message(\"directions.mode.cycle\", {}),\n} as const satisfies Readonly<Record<TravelMode, Message>>;\n\nconst MODE_PARTICIPLE_MESSAGES = {\n drive: message(\"directions.participle.drive\", {}),\n walk: message(\"directions.participle.walk\", {}),\n cycle: message(\"directions.participle.cycle\", {}),\n} as const satisfies Readonly<Record<TravelMode, Message>>;\n\n/** The short name of a travel mode, as it labels a choice: \"Drive\", \"Walk\" or \"Cycle\", as a message to format. */\nexport function travelModeLabel(mode: TravelMode): Message {\n return MODE_LABEL_MESSAGES[mode];\n}\n\n/** A travel mode as it reads in a sentence: \"driving\", \"walking\" or \"cycling\", as a message to format. */\nexport function travelModeParticiple(mode: TravelMode): Message {\n return MODE_PARTICIPLE_MESSAGES[mode];\n}\n\n/** Whether another stop fits. */\nexport function canAddStop(stops: readonly DirectionStop[]): boolean {\n return stops.length < MAX_DIRECTION_STOPS;\n}\n\n/**\n * The stops with `stop` added at the end. Returns the same list when it is\n * already at {@link MAX_DIRECTION_STOPS}.\n */\nexport function addStop(\n stops: readonly DirectionStop[],\n stop: DirectionStop,\n): readonly DirectionStop[] {\n return canAddStop(stops) ? [...stops, stop] : stops;\n}\n\n/** The stops without the one named by `id`. Returns the same list when there is no such stop. */\nexport function removeStop(\n stops: readonly DirectionStop[],\n id: string,\n): readonly DirectionStop[] {\n const next = stops.filter((stop) => stop.id !== id);\n return next.length === stops.length ? stops : next;\n}\n\n/**\n * The stops with one moved a place earlier (`-1`) or later (`1`). Returns the\n * same list when there is no such stop or it is already at that end.\n */\nexport function moveStop(\n stops: readonly DirectionStop[],\n id: string,\n direction: -1 | 1,\n): readonly DirectionStop[] {\n const from = stops.findIndex((stop) => stop.id === id);\n const to = from + direction;\n const moving = stops[from];\n const other = stops[to];\n if (from < 0 || moving === undefined || other === undefined) {\n return stops;\n }\n const next = [...stops];\n next[from] = other;\n next[to] = moving;\n return next;\n}\n\n/** The letter a stop is known by on the map and in the list: \"A\" for the first stop, \"B\" for the next. */\nexport function stopLetter(index: number): string {\n return String.fromCharCode(65 + index);\n}\n\n/** A stop for a screen reader: \"Stop A, Paris\", or its coordinates when it has no name, as a message to format. */\nexport function describeStop(\n index: number,\n stop: DirectionStop,\n): Message<\"directions.stop\"> {\n return message(\"directions.stop\", {\n letter: stopLetter(index),\n place: stop.label ?? formatLatLng(stop.position),\n });\n}\n\n/**\n * The smallest box that holds every line or ring of the features, or `null`\n * when they hold no position. Takes the short way across the antimeridian, as\n * {@link boundsOfPoints} does. Safe for a route of any length.\n */\nexport function routeBounds(\n features: readonly (RouteLeg | ReachableAreaFeature)[],\n): Bounds | null {\n const positions: LatLng[] = [];\n const visit = (position: readonly number[]) => {\n const [lng, lat] = position;\n if (lng !== undefined && lat !== undefined) {\n positions.push({ lat, lng });\n }\n };\n for (const { geometry } of features) {\n switch (geometry.type) {\n case \"LineString\":\n geometry.coordinates.forEach(visit);\n break;\n case \"Polygon\":\n geometry.coordinates.flat().forEach(visit);\n break;\n case \"MultiPolygon\":\n geometry.coordinates.flat(2).forEach(visit);\n break;\n }\n }\n return boundsOfPoints(positions) ?? null;\n}\n\n/** The ground area of the reachable areas together, in square metres. */\nexport function reachableAreaSize(\n features: readonly ReachableAreaFeature[],\n): number {\n return features.reduce(\n (total, feature) => total + geometryArea(feature.geometry),\n 0,\n );\n}\n\n/** What a routing request was for, which changes how a missing result is worded. */\nexport type RoutingRequestKind = \"route\" | \"area\";\n\n/**\n * The message that tells a person a route or area request failed, saying what\n * happened and what to do next. Not for `aborted`, which is never shown.\n */\nexport function routingErrorMessage(\n kind: Exclude<RoutingErrorKind, \"aborted\">,\n request: RoutingRequestKind,\n): Message {\n switch (kind) {\n case \"network\":\n return message(\"error.routing.network\", {});\n case \"rate-limited\":\n return message(\"error.routing.rateLimited\", {});\n case \"no-route\":\n return request === \"route\"\n ? message(\"error.routing.noRoute\", {})\n : message(\"error.routing.noReachableArea\", {});\n case \"invalid\":\n return message(\"error.routing.invalid\", {});\n case \"unsupported\":\n return message(\"error.routing.unsupported\", {});\n }\n}\n"],"mappings":";;;;;;AAyBA,IAAa,sBAAsB;;AAGnC,IAAa,eAAe;CAAC;CAAG;CAAI;CAAI;AAAE;;AAG1C,IAAa,eAAsC;CAAC;CAAS;CAAQ;AAAO;AAE5E,IAAM,sBAAsB;CAC1B,OAAO,QAAQ,yBAAyB,CAAC,CAAC;CAC1C,MAAM,QAAQ,wBAAwB,CAAC,CAAC;CACxC,OAAO,QAAQ,yBAAyB,CAAC,CAAC;AAC5C;AAEA,IAAM,2BAA2B;CAC/B,OAAO,QAAQ,+BAA+B,CAAC,CAAC;CAChD,MAAM,QAAQ,8BAA8B,CAAC,CAAC;CAC9C,OAAO,QAAQ,+BAA+B,CAAC,CAAC;AAClD;;AAGA,SAAgB,gBAAgB,MAA2B;CACzD,OAAO,oBAAoB;AAC7B;;AAGA,SAAgB,qBAAqB,MAA2B;CAC9D,OAAO,yBAAyB;AAClC;;AAGA,SAAgB,WAAW,OAA0C;CACnE,OAAO,MAAM,SAAA;AACf;;;;;AAMA,SAAgB,QACd,OACA,MAC0B;CAC1B,OAAO,WAAW,KAAK,IAAI,CAAC,GAAG,OAAO,IAAI,IAAI;AAChD;;AAGA,SAAgB,WACd,OACA,IAC0B;CAC1B,MAAM,OAAO,MAAM,QAAQ,SAAS,KAAK,OAAO,EAAE;CAClD,OAAO,KAAK,WAAW,MAAM,SAAS,QAAQ;AAChD;;;;;AAMA,SAAgB,SACd,OACA,IACA,WAC0B;CAC1B,MAAM,OAAO,MAAM,WAAW,SAAS,KAAK,OAAO,EAAE;CACrD,MAAM,KAAK,OAAO;CAClB,MAAM,SAAS,MAAM;CACrB,MAAM,QAAQ,MAAM;CACpB,IAAI,OAAO,KAAK,WAAW,KAAA,KAAa,UAAU,KAAA,GAChD,OAAO;CAET,MAAM,OAAO,CAAC,GAAG,KAAK;CACtB,KAAK,QAAQ;CACb,KAAK,MAAM;CACX,OA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+
import { detailUrl, feedUrls } from "../layers/feed.js";
|
|
2
2
|
import { identifyRequestUrl } from "../layers/identify.js";
|
|
3
3
|
import { LayerError } from "../ports/errors.js";
|
|
4
4
|
// src/fakes/FakeLayerSource.ts
|
|
@@ -112,9 +112,9 @@ var FakeLayerSource = class {
|
|
|
112
112
|
}
|
|
113
113
|
async load(request) {
|
|
114
114
|
const { definition, controls, now, signal, area } = request;
|
|
115
|
-
this.requests.push({
|
|
115
|
+
for (const url of feedUrls(definition, controls, now, area)) this.requests.push({
|
|
116
116
|
...request,
|
|
117
|
-
url
|
|
117
|
+
url
|
|
118
118
|
});
|
|
119
119
|
await this.#wait(signal, this.#held);
|
|
120
120
|
this.#refuseOversize("feed", definition.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FakeLayerSource.js","names":[],"sources":["../../src/fakes/FakeLayerSource.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport { detailUrl, feedUrl } from \"../layers/feed\";\nimport { identifyRequestUrl } from \"../layers/identify\";\nimport { LayerError } from \"../ports/errors\";\nimport type {\n LayerDetailRequest,\n LayerFeature,\n LayerIdentifyRequest,\n LayerLoadRequest,\n LayerSource,\n} from \"../ports/layers\";\n\ntype Outcome =\n | { readonly kind: \"features\"; readonly features: readonly LayerFeature[] }\n | { readonly kind: \"failure\"; readonly error: \"network\" | \"invalid\" };\n\n/** A request the fake received, with the URL a real source would fetch. */\nexport type RecordedLayerRequest<T> = T & { readonly url: string };\n\n/**\n * An in-memory {@link LayerSource}.\n *\n * How to script it, per layer id: `setFeatures` for what `load` returns\n * (none means an `empty` error), `fail` to reject with `network` or\n * `invalid`, `setDetail` for what `loadDetail` returns, and `hold` to make\n * every load wait until the returned function is called. The last call for a\n * layer wins. `requests` and `detailRequests` record what was asked, with the\n * URL the real source would have requested, worked out by the core URL\n * helpers. A detail URL off the definition's declared origins is refused\n * with `invalid`, as the real source does. Aborts are honoured before and\n * after a hold.\n *\n * `identify` is scripted apart from `load`, also per layer id, so a layer\n * can be both loaded and identified without one affecting the other:\n * `setIdentified` for what it finds (a layer it was not told about finds\n * nothing and resolves to an empty list, never `empty`), `failIdentify` to\n * reject with `network` or `invalid`, and `holdIdentify(layerId)` to make\n * that one layer's identifies wait until the returned function is called.\n * `hold` does not hold an identify, and `holdIdentify` does not hold a load.\n * `identifyRequests` records what was asked, with the URL the real source\n * would have requested. A tap that cannot be turned into an `https` URL is\n * refused with `invalid` and not recorded, as a real source refuses it.\n *\n * `setOversizeAnswer` makes the provider's answer to a load or to a detail\n * load larger than the source's limit, so the fake refuses it with `invalid`\n * as a real source does; the other kind of answer is not affected, so\n * features can load while their detail is refused. The fake applies no limit\n * to an identify answer. A second `holdIdentify` for\n * a layer replaces the first, and releasing the first leaves the second in\n * place.\n */\nexport class FakeLayerSource implements LayerSource {\n readonly requests: RecordedLayerRequest<LayerLoadRequest>[] = [];\n readonly detailRequests: RecordedLayerRequest<LayerDetailRequest>[] = [];\n readonly identifyRequests: RecordedLayerRequest<LayerIdentifyRequest>[] = [];\n\n readonly #outcomes = new Map<string, Outcome>();\n readonly #identified = new Map<string, Outcome>();\n readonly #details = new Map<string, readonly LayerFeature[]>();\n readonly #oversize = new Set<string>();\n readonly #heldIdentifies = new Map<string, Promise<void>>();\n #held: Promise<void> | null = null;\n\n /** Makes `load` for a layer return these features. */\n setFeatures(layerId: string, features: readonly LayerFeature[]): void {\n this.#outcomes.set(layerId, { kind: \"features\", features });\n }\n\n /** Makes `load` for a layer reject with a `LayerError` of this kind. */\n fail(layerId: string, error: \"network\" | \"invalid\"): void {\n this.#outcomes.set(layerId, { kind: \"failure\", error });\n }\n\n /** Makes `identify` for a layer find these features. */\n setIdentified(layerId: string, features: readonly LayerFeature[]): void {\n this.#identified.set(layerId, { kind: \"features\", features });\n }\n\n /** Makes `identify` for a layer reject with a `LayerError` of this kind. */\n failIdentify(layerId: string, error: \"network\" | \"invalid\"): void {\n this.#identified.set(layerId, { kind: \"failure\", error });\n }\n\n /**\n * Makes the answer `load` (`\"feed\"`) or `loadDetail` (`\"detail\"`)\n * reads for a layer larger than the source's limit, so it rejects with\n * `invalid`.\n */\n setOversizeAnswer(layerId: string, kind: \"feed\" | \"detail\"): void {\n this.#oversize.add(`${kind}:${layerId}`);\n }\n\n /** Makes `loadDetail` for a layer return these shapes. */\n setDetail(layerId: string, shapes: readonly LayerFeature[]): void {\n this.#details.set(layerId, shapes);\n }\n\n /** Makes every load wait until the returned function is called. */\n hold(): () => void {\n let release!: () => void;\n this.#held = new Promise<void>((resolve) => {\n release = resolve;\n });\n return () => {\n this.#held = null;\n release();\n };\n }\n\n /**\n * Makes every identify of one layer wait until the returned function is\n * called. Other layers' identifies, and every load, are not held.\n */\n holdIdentify(layerId: string): () => void {\n let release!: () => void;\n const held = new Promise<void>((resolve) => {\n release = resolve;\n });\n this.#heldIdentifies.set(layerId, held);\n return () => {\n if (this.#heldIdentifies.get(layerId) === held) {\n this.#heldIdentifies.delete(layerId);\n }\n release();\n };\n }\n\n async load(request: LayerLoadRequest): Promise<readonly LayerFeature[]> {\n const { definition, controls, now, signal, area } = request;\n this.requests.push({\n ...request,\n url: feedUrl(definition, controls, now, area),\n });\n await this.#wait(signal, this.#held);\n this.#refuseOversize(\"feed\", definition.id);\n const outcome = this.#outcomes.get(definition.id);\n if (outcome?.kind === \"failure\") {\n throw new LayerError(outcome.error);\n }\n if (!outcome || outcome.features.length === 0) {\n throw new LayerError(\"empty\");\n }\n return outcome.features;\n }\n\n async loadDetail(\n request: LayerDetailRequest,\n ): Promise<readonly LayerFeature[]> {\n const url = detailUrl(request.definition, request.feature);\n if (url === null) {\n throw new LayerError(\"invalid\", \"The detail URL is not allowed.\");\n }\n this.detailRequests.push({ ...request, url });\n await this.#wait(request.signal, this.#held);\n this.#refuseOversize(\"detail\", request.definition.id);\n const shapes = this.#details.get(request.definition.id) ?? [];\n if (shapes.length === 0) {\n throw new LayerError(\"empty\");\n }\n return shapes;\n }\n\n async identify(\n request: LayerIdentifyRequest,\n ): Promise<readonly LayerFeature[]> {\n const { definition, controls, now, at, signal } = request;\n this.identifyRequests.push({\n ...request,\n url: identifyRequestUrl(definition, controls, now, at),\n });\n await this.#wait(signal, this.#heldIdentifies.get(definition.id) ?? null);\n const outcome = this.#identified.get(definition.id);\n if (outcome?.kind === \"failure\") {\n throw new LayerError(outcome.error);\n }\n return outcome?.features ?? [];\n }\n\n #refuseOversize(kind: \"feed\" | \"detail\", layerId: string): void {\n if (this.#oversize.has(`${kind}:${layerId}`)) {\n throw new LayerError(\"invalid\", \"The response is too large.\");\n }\n }\n\n async #wait(\n signal: AbortSignal | undefined,\n held: Promise<void> | null,\n ): Promise<void> {\n if (signal?.aborted) {\n throw new LayerError(\"aborted\");\n }\n if (held !== null) {\n await held;\n }\n if (signal?.aborted) {\n throw new LayerError(\"aborted\");\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,IAAa,kBAAb,MAAoD;CAClD,WAA8D,CAAC;CAC/D,iBAAsE,CAAC;CACvE,mBAA0E,CAAC;CAE3E,4BAAqB,IAAI,IAAqB;CAC9C,8BAAuB,IAAI,IAAqB;CAChD,2BAAoB,IAAI,IAAqC;CAC7D,4BAAqB,IAAI,IAAY;CACrC,kCAA2B,IAAI,IAA2B;CAC1D,QAA8B;;CAG9B,YAAY,SAAiB,UAAyC;EACpE,KAAK,UAAU,IAAI,SAAS;GAAE,MAAM;GAAY;EAAS,CAAC;CAC5D;;CAGA,KAAK,SAAiB,OAAoC;EACxD,KAAK,UAAU,IAAI,SAAS;GAAE,MAAM;GAAW;EAAM,CAAC;CACxD;;CAGA,cAAc,SAAiB,UAAyC;EACtE,KAAK,YAAY,IAAI,SAAS;GAAE,MAAM;GAAY;EAAS,CAAC;CAC9D;;CAGA,aAAa,SAAiB,OAAoC;EAChE,KAAK,YAAY,IAAI,SAAS;GAAE,MAAM;GAAW;EAAM,CAAC;CAC1D;;;;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KAAK;EAC3C,KAAK,gBAAgB,UAAU,QAAQ,WAAW,EAAE;EACpD,MAAM,SAAS,KAAK,SAAS,IAAI,QAAQ,WAAW,EAAE,KAAK,CAAC;EAC5D,IAAI,OAAO,WAAW,GACpB,MAAM,IAAI,WAAW,OAAO;EAE9B,OAAO;CACT;CAEA,MAAM,SACJ,SACkC;EAClC,MAAM,EAAE,YAAY,UAAU,KAAK,IAAI,WAAW;EAClD,KAAK,iBAAiB,KAAK;GACzB,GAAG;GACH,KAAK,mBAAmB,YAAY,UAAU,KAAK,EAAE;EACvD,CAAC;EACD,MAAM,KAAK,MAAM,QAAQ,KAAK,gBAAgB,IAAI,WAAW,EAAE,KAAK,IAAI;EACxE,MAAM,UAAU,KAAK,YAAY,IAAI,WAAW,EAAE;EAClD,IAAI,SAAS,SAAS,WACpB,MAAM,IAAI,WAAW,QAAQ,KAAK;EAEpC,OAAO,SAAS,YAAY,CAAC;CAC/B;CAEA,gBAAgB,MAAyB,SAAuB;EAC9D,IAAI,KAAK,UAAU,IAAI,GAAG,KAAK,GAAG,SAAS,GACzC,MAAM,IAAI,WAAW,WAAW,4BAA4B;CAEhE;CAEA,MAAM,MACJ,QACA,MACe;EACf,IAAI,QAAQ,SACV,MAAM,IAAI,WAAW,SAAS;EAEhC,IAAI,SAAS,MACX,MAAM;EAER,IAAI,QAAQ,SACV,MAAM,IAAI,WAAW,SAAS;CAElC;AACF"}
|
|
1
|
+
{"version":3,"file":"FakeLayerSource.js","names":[],"sources":["../../src/fakes/FakeLayerSource.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport { detailUrl, feedUrls } from \"../layers/feed\";\nimport { identifyRequestUrl } from \"../layers/identify\";\nimport { LayerError } from \"../ports/errors\";\nimport type {\n LayerDetailRequest,\n LayerFeature,\n LayerIdentifyRequest,\n LayerLoadRequest,\n LayerSource,\n} from \"../ports/layers\";\n\ntype Outcome =\n | { readonly kind: \"features\"; readonly features: readonly LayerFeature[] }\n | { readonly kind: \"failure\"; readonly error: \"network\" | \"invalid\" };\n\n/** A request the fake received, with the URL a real source would fetch. */\nexport type RecordedLayerRequest<T> = T & { readonly url: string };\n\n/**\n * An in-memory {@link LayerSource}.\n *\n * How to script it, per layer id: `setFeatures` for what `load` returns\n * (none means an `empty` error), `fail` to reject with `network` or\n * `invalid`, `setDetail` for what `loadDetail` returns, and `hold` to make\n * every load wait until the returned function is called. The last call for a\n * layer wins. `requests` and `detailRequests` record what was asked, with the\n * URL the real source would have requested, worked out by the core URL\n * helpers. A detail URL off the definition's declared origins is refused\n * with `invalid`, as the real source does. Aborts are honoured before and\n * after a hold.\n *\n * `identify` is scripted apart from `load`, also per layer id, so a layer\n * can be both loaded and identified without one affecting the other:\n * `setIdentified` for what it finds (a layer it was not told about finds\n * nothing and resolves to an empty list, never `empty`), `failIdentify` to\n * reject with `network` or `invalid`, and `holdIdentify(layerId)` to make\n * that one layer's identifies wait until the returned function is called.\n * `hold` does not hold an identify, and `holdIdentify` does not hold a load.\n * `identifyRequests` records what was asked, with the URL the real source\n * would have requested. A tap that cannot be turned into an `https` URL is\n * refused with `invalid` and not recorded, as a real source refuses it.\n *\n * `setOversizeAnswer` makes the provider's answer to a load or to a detail\n * load larger than the source's limit, so the fake refuses it with `invalid`\n * as a real source does; the other kind of answer is not affected, so\n * features can load while their detail is refused. The fake applies no limit\n * to an identify answer. A second `holdIdentify` for\n * a layer replaces the first, and releasing the first leaves the second in\n * place.\n */\nexport class FakeLayerSource implements LayerSource {\n readonly requests: RecordedLayerRequest<LayerLoadRequest>[] = [];\n readonly detailRequests: RecordedLayerRequest<LayerDetailRequest>[] = [];\n readonly identifyRequests: RecordedLayerRequest<LayerIdentifyRequest>[] = [];\n\n readonly #outcomes = new Map<string, Outcome>();\n readonly #identified = new Map<string, Outcome>();\n readonly #details = new Map<string, readonly LayerFeature[]>();\n readonly #oversize = new Set<string>();\n readonly #heldIdentifies = new Map<string, Promise<void>>();\n #held: Promise<void> | null = null;\n\n /** Makes `load` for a layer return these features. */\n setFeatures(layerId: string, features: readonly LayerFeature[]): void {\n this.#outcomes.set(layerId, { kind: \"features\", features });\n }\n\n /** Makes `load` for a layer reject with a `LayerError` of this kind. */\n fail(layerId: string, error: \"network\" | \"invalid\"): void {\n this.#outcomes.set(layerId, { kind: \"failure\", error });\n }\n\n /** Makes `identify` for a layer find these features. */\n setIdentified(layerId: string, features: readonly LayerFeature[]): void {\n this.#identified.set(layerId, { kind: \"features\", features });\n }\n\n /** Makes `identify` for a layer reject with a `LayerError` of this kind. */\n failIdentify(layerId: string, error: \"network\" | \"invalid\"): void {\n this.#identified.set(layerId, { kind: \"failure\", error });\n }\n\n /**\n * Makes the answer `load` (`\"feed\"`) or `loadDetail` (`\"detail\"`)\n * reads for a layer larger than the source's limit, so it rejects with\n * `invalid`.\n */\n setOversizeAnswer(layerId: string, kind: \"feed\" | \"detail\"): void {\n this.#oversize.add(`${kind}:${layerId}`);\n }\n\n /** Makes `loadDetail` for a layer return these shapes. */\n setDetail(layerId: string, shapes: readonly LayerFeature[]): void {\n this.#details.set(layerId, shapes);\n }\n\n /** Makes every load wait until the returned function is called. */\n hold(): () => void {\n let release!: () => void;\n this.#held = new Promise<void>((resolve) => {\n release = resolve;\n });\n return () => {\n this.#held = null;\n release();\n };\n }\n\n /**\n * Makes every identify of one layer wait until the returned function is\n * called. Other layers' identifies, and every load, are not held.\n */\n holdIdentify(layerId: string): () => void {\n let release!: () => void;\n const held = new Promise<void>((resolve) => {\n release = resolve;\n });\n this.#heldIdentifies.set(layerId, held);\n return () => {\n if (this.#heldIdentifies.get(layerId) === held) {\n this.#heldIdentifies.delete(layerId);\n }\n release();\n };\n }\n\n async load(request: LayerLoadRequest): Promise<readonly LayerFeature[]> {\n const { definition, controls, now, signal, area } = request;\n for (const url of feedUrls(definition, controls, now, area)) {\n this.requests.push({ ...request, url });\n }\n await this.#wait(signal, this.#held);\n this.#refuseOversize(\"feed\", definition.id);\n const outcome = this.#outcomes.get(definition.id);\n if (outcome?.kind === \"failure\") {\n throw new LayerError(outcome.error);\n }\n if (!outcome || outcome.features.length === 0) {\n throw new LayerError(\"empty\");\n }\n return outcome.features;\n }\n\n async loadDetail(\n request: LayerDetailRequest,\n ): Promise<readonly LayerFeature[]> {\n const url = detailUrl(request.definition, request.feature);\n if (url === null) {\n throw new LayerError(\"invalid\", \"The detail URL is not allowed.\");\n }\n this.detailRequests.push({ ...request, url });\n await this.#wait(request.signal, this.#held);\n this.#refuseOversize(\"detail\", request.definition.id);\n const shapes = this.#details.get(request.definition.id) ?? [];\n if (shapes.length === 0) {\n throw new LayerError(\"empty\");\n }\n return shapes;\n }\n\n async identify(\n request: LayerIdentifyRequest,\n ): Promise<readonly LayerFeature[]> {\n const { definition, controls, now, at, signal } = request;\n this.identifyRequests.push({\n ...request,\n url: identifyRequestUrl(definition, controls, now, at),\n });\n await this.#wait(signal, this.#heldIdentifies.get(definition.id) ?? null);\n const outcome = this.#identified.get(definition.id);\n if (outcome?.kind === \"failure\") {\n throw new LayerError(outcome.error);\n }\n return outcome?.features ?? [];\n }\n\n #refuseOversize(kind: \"feed\" | \"detail\", layerId: string): void {\n if (this.#oversize.has(`${kind}:${layerId}`)) {\n throw new LayerError(\"invalid\", \"The response is too large.\");\n }\n }\n\n async #wait(\n signal: AbortSignal | undefined,\n held: Promise<void> | null,\n ): Promise<void> {\n if (signal?.aborted) {\n throw new LayerError(\"aborted\");\n }\n if (held !== null) {\n await held;\n }\n if (signal?.aborted) {\n throw new LayerError(\"aborted\");\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,IAAa,kBAAb,MAAoD;CAClD,WAA8D,CAAC;CAC/D,iBAAsE,CAAC;CACvE,mBAA0E,CAAC;CAE3E,4BAAqB,IAAI,IAAqB;CAC9C,8BAAuB,IAAI,IAAqB;CAChD,2BAAoB,IAAI,IAAqC;CAC7D,4BAAqB,IAAI,IAAY;CACrC,kCAA2B,I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S,MACX,MAAM;EAER,IAAI,QAAQ,SACV,MAAM,IAAI,WAAW,SAAS;CAElC;AACF"}
|
|
@@ -200,7 +200,7 @@ var FakeMapAdapter = class {
|
|
|
200
200
|
this.setView({
|
|
201
201
|
center: {
|
|
202
202
|
lat: (bounds.south + bounds.north) / 2,
|
|
203
|
-
lng: (bounds.west + bounds.east) / 2
|
|
203
|
+
lng: wrapLongitude((bounds.west + bounds.east) / 2)
|
|
204
204
|
},
|
|
205
205
|
zoom: Math.min(fitted, options.maxZoom ?? Number.POSITIVE_INFINITY)
|
|
206
206
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FakeMapAdapter.js","names":[],"sources":["../../src/fakes/FakeMapAdapter.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport { distanceMetres, EARTH_RADIUS_METRES } from \"../draw/geo\";\nimport {\n dragHandle,\n type HandleGesture,\n type HandlePointer,\n handleReach,\n pressHandle,\n} from \"../draw/gesture\";\nimport { hitTestHandle, type ProjectedHandle } from \"../draw/hit\";\nimport { wrapLongitude } from \"../globe/longitude\";\nimport { placePoint } from \"../globe/placement\";\nimport { mapMetresPerPixel } from \"../globe/resolution\";\nimport { planRequestedImage, refuseBoxOnGlobe } from \"../imageExport/plan\";\nimport { clamp } from \"../numbers/clamp\";\nimport type { BasemapDefinition } from \"../ports/basemap\";\nimport {\n MapEngineError,\n type MapEngineErrorReason,\n MapImageExportError,\n} from \"../ports/errors\";\nimport type { Bounds, LatLng, PixelPoint, ViewState } from \"../ports/geometry\";\nimport type {\n MapAdapter,\n MapAdapterFactory,\n MapBasemapOptions,\n MapClickEvent,\n MapEditHandle,\n MapEvents,\n MapFeature,\n MapFeatureHit,\n MapFitOptions,\n MapHeatmap,\n MapHostElement,\n MapImageOptions,\n MapMountOptions,\n MapProjection,\n MapShapes,\n MapStyledShapes,\n MapTileOverlay,\n MapVectorTiles,\n} from \"../ports/map\";\nimport {\n clampZoom,\n MAX_MERCATOR_LATITUDE,\n mercatorProject,\n mercatorUnproject,\n} from \"../zoom/zoom\";\nimport { pngHeader } from \"./pngHeader\";\n\n/** The view a {@link FakeMapAdapter} starts with before it is mounted. */\nexport const DEFAULT_FAKE_VIEW: ViewState = Object.freeze({\n center: Object.freeze({ lat: 0, lng: 0 }),\n zoom: 2,\n bearing: 0,\n});\n\n/** Options for {@link FakeMapAdapter}. */\nexport interface FakeMapAdapterOptions {\n /** Makes `mount` reject with a `MapEngineError` of this reason. */\n readonly failMount?: MapEngineErrorReason;\n}\n\n/** A host element double of a fixed size, recording focus calls. */\nexport class FakeMapHost implements MapHostElement {\n readonly focusCalls: ({ preventScroll?: boolean } | undefined)[] = [];\n\n constructor(\n readonly width = 800,\n readonly height = 600,\n ) {}\n\n focus(options?: { preventScroll?: boolean }): void {\n this.focusCalls.push(options);\n }\n\n getBoundingClientRect(): {\n readonly width: number;\n readonly height: number;\n readonly left: number;\n readonly top: number;\n } {\n return { width: this.width, height: this.height, left: 0, top: 0 };\n }\n}\n\ntype Handler = (payload: never) => void;\n\n/** What a deferred basemap swap waits on (see `FakeMapAdapter.deferNextBasemap`). */\ninterface SwapGate {\n readonly promise: Promise<void>;\n}\n\ntype DataLayer =\n | { readonly kind: \"features\"; readonly features: readonly MapFeature[] }\n | { readonly kind: \"tiles\"; readonly overlay: MapTileOverlay }\n | { readonly kind: \"shapes\"; readonly shapes: MapShapes }\n | { readonly kind: \"styled\"; readonly layer: MapStyledShapes }\n | { readonly kind: \"vector\"; readonly layer: MapVectorTiles }\n | { readonly kind: \"heatmap\"; readonly heatmap: MapHeatmap };\n\n/**\n * A data layer as an engine draws it, lowest first, for tests and the map\n * adapter contract to compare adapters by.\n */\nexport type DrawnLayer =\n | {\n readonly id: string;\n readonly kind: \"features\" | \"shapes\";\n readonly count: number;\n }\n | {\n readonly id: string;\n readonly kind: \"tiles\";\n readonly tiles: string;\n readonly opacity: number;\n }\n | {\n readonly id: string;\n readonly kind: \"styled\";\n readonly geometry: \"area\" | \"line\";\n readonly count: number;\n }\n | {\n readonly id: string;\n readonly kind: \"vector\";\n readonly tiles: string;\n readonly sourceLayers: readonly string[];\n }\n | {\n readonly id: string;\n readonly kind: \"heatmap\";\n readonly source: \"points\" | \"vector\";\n /** The points drawn, or 0 for a vector source. */\n readonly count: number;\n };\n\n/** Stacking order, lowest first: imagery, vector tiles, styled shapes, detail shapes, heatmaps, points. */\nconst KIND_ORDER: Readonly<Record<DataLayer[\"kind\"], number>> = {\n tiles: 0,\n vector: 1,\n styled: 2,\n shapes: 3,\n heatmap: 4,\n features: 5,\n};\n\nfunction firstPosition(\n geometry: MapStyledShapes[\"shapes\"][number][\"geometry\"],\n): readonly [number, number] | null {\n switch (geometry.type) {\n case \"Point\":\n return geometry.coordinates;\n case \"LineString\":\n return geometry.coordinates[0] ?? null;\n case \"MultiLineString\":\n case \"Polygon\":\n return geometry.coordinates[0]?.[0] ?? null;\n case \"MultiPolygon\":\n return geometry.coordinates[0]?.[0]?.[0] ?? null;\n }\n}\n\nfunction wrapBearing(degrees: number): number {\n return ((degrees % 360) + 360) % 360;\n}\n\n/**\n * A pure in-memory {@link MapAdapter}: no engine, no DOM, no timers.\n *\n * How to script it:\n * - Pass `failMount: \"webgl-unavailable\"` (or `\"load-failed\"`) to make\n * `mount` reject with a `MapEngineError`.\n * - Mount it into a {@link FakeMapHost}; the host's size (800 by 600 by\n * default) sets the pixel space used by `project` and `unproject`.\n * - Drive events with `simulateClick`, `simulateTileError`,\n * `simulateLoading`, `simulateUserZoom` (a wheel, pinch or double-click)\n * `simulateFatalError` (the engine stopping after it loaded), and\n * `simulatePointerDown`, `simulatePointerMove` and `simulatePointerUp` (a\n * mouse or finger on the map, which drive edit handles). Call\n * `failNextBasemap` to make the next swap fail. `setView`, `zoomIn`, `panBy` and the rest emit real\n * `move`, `zoom`, `rotate` and `moveEnd` events, and only when something\n * changed.\n * - Inspect `mountCount`, `destroyed`, `animationEnabled`, `keyboardEnabled`\n * and `focusCount`.\n *\n * Animation options are accepted and ignored, because every change is\n * immediate. `project` ignores the bearing.\n */\nexport class FakeMapAdapter implements MapAdapter {\n mountCount = 0;\n focusCount = 0;\n animationEnabled = true;\n keyboardEnabled = true;\n /** Whether the last `mount` or `setBasemap` asked for Save data mode. */\n saveData = false;\n /** The shape the map was last asked to draw. */\n projection: MapProjection = \"flat\";\n\n readonly #failMount: MapEngineErrorReason | undefined;\n #failNextBasemap = false;\n /** The next swap waits on this until the test settles it. */\n #nextSwapGate: SwapGate | null = null;\n /** The basemap a swap in flight is loading, until it has loaded or failed. */\n #swapTarget: BasemapDefinition | null = null;\n #view: ViewState = DEFAULT_FAKE_VIEW;\n #basemap: BasemapDefinition | null = null;\n #host: MapHostElement | null = null;\n #hostSize = { width: 800, height: 600 };\n #destroyed = false;\n readonly #listeners = new Map<keyof MapEvents, Set<Handler>>();\n readonly #dataLayers = new Map<string, DataLayer>();\n /** The tiles each tile layer reported as slow or missing, until they load or change. */\n readonly #reportedTiles = new Map<string, string>();\n #hitsAtPointer: readonly MapFeatureHit[] = [];\n #failNextImage = false;\n #stallImageTiles = false;\n /** The options of every `toImage` call, in order. */\n readonly imageRequests: (MapImageOptions | undefined)[] = [];\n #handles: readonly MapEditHandle[] = [];\n #gesture: HandleGesture | null = null;\n #hovered: string | null = null;\n #swallowClick = false;\n\n constructor(options: FakeMapAdapterOptions = {}) {\n this.#failMount = options.failMount;\n }\n\n /** True after `destroy`, until the next successful `mount`. */\n get destroyed(): boolean {\n return this.#destroyed;\n }\n\n async mount(host: MapHostElement, options: MapMountOptions): Promise<void> {\n if (this.#failMount !== undefined) {\n throw new MapEngineError(this.#failMount);\n }\n const { width, height } = host.getBoundingClientRect();\n this.#host = host;\n this.#hostSize = { width, height };\n this.#basemap = options.basemap;\n this.#view = this.#normalise(options.view);\n this.animationEnabled = !options.reducedMotion;\n this.saveData = options.saveData ?? false;\n this.projection = options.projection ?? \"flat\";\n this.#destroyed = false;\n this.mountCount += 1;\n this.#emit(\"load\", undefined);\n }\n\n destroy(): void {\n this.#destroyed = true;\n this.#host = null;\n this.#listeners.clear();\n }\n\n getView(): ViewState {\n return this.#view;\n }\n\n setView(view: Partial<ViewState>): void {\n this.#applyView({ ...this.#view, ...view });\n }\n\n zoomIn(): void {\n this.setView({ zoom: this.#view.zoom + 1 });\n }\n\n zoomOut(): void {\n this.setView({ zoom: this.#view.zoom - 1 });\n }\n\n panBy(dx: number, dy: number): void {\n if (dx === 0 && dy === 0) {\n return;\n }\n const { zoom, center } = this.#view;\n const world = mercatorProject(center, zoom);\n const limit = mercatorProject(\n { lat: -MAX_MERCATOR_LATITUDE, lng: 0 },\n zoom,\n );\n this.setView({\n center: mercatorUnproject(\n { x: world.x + dx, y: clamp(world.y + dy, 0, limit.y) },\n zoom,\n ),\n });\n }\n\n rotateBy(degrees: number): void {\n this.setView({ bearing: this.#view.bearing + degrees });\n }\n\n resetBearing(): void {\n this.setView({ bearing: 0 });\n }\n\n fitBounds(bounds: Bounds, options: MapFitOptions = {}): void {\n const { top = 0, right = 0, bottom = 0, left = 0 } = options.padding ?? {};\n const southWest = mercatorProject(\n { lat: bounds.south, lng: bounds.west },\n 0,\n );\n const northEast = mercatorProject(\n { lat: bounds.north, lng: bounds.east },\n 0,\n );\n const spanX = Math.abs(northEast.x - southWest.x);\n const spanY = Math.abs(southWest.y - northEast.y);\n const availableX = Math.max(1, this.#hostSize.width - left - right);\n const availableY = Math.max(1, this.#hostSize.height - top - bottom);\n const fitted = Math.min(\n Math.log2(availableX / spanX),\n Math.log2(availableY / spanY),\n );\n this.setView({\n center: {\n lat: (bounds.south + bounds.north) / 2,\n lng: (bounds.west + bounds.east) / 2,\n },\n zoom: Math.min(fitted, options.maxZoom ?? Number.POSITIVE_INFINITY),\n });\n }\n\n getMinZoom(): number {\n return this.#basemap?.minZoom ?? 0;\n }\n\n getMaxZoom(): number {\n return this.#basemap?.maxZoom ?? 18;\n }\n\n project(latlng: LatLng): PixelPoint {\n const { center, zoom } = this.#view;\n const world = mercatorProject(latlng, zoom);\n const origin = mercatorProject(center, zoom);\n return {\n x: world.x - origin.x + this.#hostSize.width / 2,\n y: world.y - origin.y + this.#hostSize.height / 2,\n };\n }\n\n /** On a globe, a place more than a quarter of the way round from the centre is out of sight. */\n isVisible(latlng: LatLng): boolean {\n return (\n this.projection === \"flat\" ||\n distanceMetres(this.#view.center, latlng) <=\n (Math.PI / 2) * EARTH_RADIUS_METRES\n );\n }\n\n setProjection(projection: MapProjection): void {\n this.projection = projection;\n }\n\n unproject(point: PixelPoint): LatLng {\n const { center, zoom } = this.#view;\n const origin = mercatorProject(center, zoom);\n const position = mercatorUnproject(\n {\n x: point.x - this.#hostSize.width / 2 + origin.x,\n y: point.y - this.#hostSize.height / 2 + origin.y,\n },\n zoom,\n );\n return { lat: position.lat, lng: wrapLongitude(position.lng) };\n }\n\n metresPerPixel(lat: number = this.#view.center.lat): number {\n const { center, zoom } = this.#view;\n return mapMetresPerPixel(this.projection, lat, center.lat, zoom);\n }\n\n async setBasemap(\n basemap: BasemapDefinition,\n options: MapBasemapOptions = {},\n ): Promise<void> {\n if (this.#failNextBasemap) {\n this.#failNextBasemap = false;\n throw new MapEngineError(\n \"load-failed\",\n \"The fake basemap style could not be loaded.\",\n );\n }\n this.#swapTarget = basemap;\n const gate = this.#nextSwapGate;\n this.#nextSwapGate = null;\n if (gate) {\n try {\n await gate.promise;\n } catch (error) {\n if (this.#swapTarget === basemap) {\n this.#swapTarget = null;\n }\n throw error;\n }\n }\n if (this.#swapTarget !== basemap) {\n // A newer swap took over while this one waited: nothing loaded.\n return;\n }\n this.#swapTarget = null;\n this.#basemap = basemap;\n this.saveData = options.saveData ?? false;\n this.#applyView(this.#view);\n this.#emit(\"load\", undefined);\n }\n\n /**\n * Makes the next `setBasemap` wait, as a real style that is still\n * downloading does, until `resolve` (the swap loads) or `reject` (it fails\n * with a `load-failed` `MapEngineError` and the last basemap stays). While\n * it waits the basemap is the old one, and `toImage` refuses.\n */\n deferNextBasemap(): {\n readonly resolve: () => void;\n readonly reject: () => void;\n } {\n let resolve = () => {};\n let reject = () => {};\n const promise = new Promise<void>((done, fail) => {\n resolve = done;\n reject = () =>\n fail(\n new MapEngineError(\n \"load-failed\",\n \"The fake basemap style could not be loaded.\",\n ),\n );\n });\n // The caller may never settle a deferred swap it no longer needs.\n promise.catch(() => {});\n this.#nextSwapGate = { promise };\n return { resolve, reject };\n }\n\n setAnimationEnabled(enabled: boolean): void {\n this.animationEnabled = enabled;\n }\n\n setKeyboardEnabled(enabled: boolean): void {\n this.keyboardEnabled = enabled;\n }\n\n focus(): void {\n this.focusCount += 1;\n this.#host?.focus({ preventScroll: true });\n }\n\n on<K extends keyof MapEvents>(\n event: K,\n handler: (payload: MapEvents[K]) => void,\n ): () => void {\n const handlers = this.#listeners.get(event) ?? new Set<Handler>();\n handlers.add(handler as Handler);\n this.#listeners.set(event, handlers);\n return () => {\n handlers.delete(handler as Handler);\n };\n }\n\n setFeatureLayer(id: string, features: readonly MapFeature[]): void {\n this.#dataLayers.delete(id);\n this.#dataLayers.set(id, { kind: \"features\", features: [...features] });\n }\n\n setTileLayer(id: string, overlay: MapTileOverlay): void {\n if (this.#reportedTiles.get(id) !== overlay.tiles) {\n this.#reportedTiles.delete(id);\n }\n this.#dataLayers.delete(id);\n this.#dataLayers.set(id, { kind: \"tiles\", overlay });\n }\n\n setShapeLayer(id: string, shapes: MapShapes): void {\n this.#dataLayers.delete(id);\n this.#dataLayers.set(id, { kind: \"shapes\", shapes });\n }\n\n setStyledShapes(id: string, layer: MapStyledShapes): void {\n this.#dataLayers.delete(id);\n this.#dataLayers.set(id, { kind: \"styled\", layer });\n }\n\n setVectorLayer(id: string, layer: MapVectorTiles): void {\n this.#dataLayers.delete(id);\n this.#dataLayers.set(id, { kind: \"vector\", layer });\n }\n\n setHeatmapLayer(id: string, heatmap: MapHeatmap): void {\n this.#dataLayers.delete(id);\n this.#dataLayers.set(id, { kind: \"heatmap\", heatmap });\n }\n\n removeLayer(id: string): void {\n this.#reportedTiles.delete(id);\n this.#dataLayers.delete(id);\n }\n\n /**\n * The features most recently scripted under the pointer with\n * `simulateFeatureHits` or `simulateFeatureTap`, still drawn, in the order\n * scripted. A real engine finds them by position; the fake cannot, so a\n * test says what is there.\n */\n featuresAt(_point: PixelPoint): readonly MapFeatureHit[] {\n return this.#hitsAtPointer.filter((hit) => this.#hasFeature(hit));\n }\n\n getBounds(): Bounds {\n const { width, height } = this.#hostSize;\n const corners = [\n this.unproject({ x: 0, y: 0 }),\n this.unproject({ x: width, y: 0 }),\n this.unproject({ x: 0, y: height }),\n this.unproject({ x: width, y: height }),\n ];\n const lats = corners.map((corner) => corner.lat);\n const lngs = corners.map((corner) => corner.lng);\n return {\n west: Math.min(...lngs),\n south: Math.min(...lats),\n east: Math.max(...lngs),\n north: Math.max(...lats),\n };\n }\n\n async toImage(options?: MapImageOptions): Promise<Blob> {\n this.imageRequests.push(options);\n if (this.#failNextImage) {\n this.#failNextImage = false;\n throw new MapEngineError(\n \"export-failed\",\n \"The fake map could not produce an image.\",\n );\n }\n if (this.#host === null) {\n throw new MapEngineError(\"export-failed\", \"The map is not mounted.\");\n }\n this.#refuseExport();\n // The size of the map on screen as the MapLibre adapter reads it: the\n // layout size, which the DOM's `clientWidth` and `clientHeight` give as\n // whole pixels rounded to the nearest.\n const screen = {\n width: Math.round(this.#hostSize.width),\n height: Math.round(this.#hostSize.height),\n };\n const requested = planRequestedImage(options ?? {}, {\n size: screen,\n view: this.#view,\n });\n if (requested) {\n refuseBoxOnGlobe(requested.view, this.projection);\n }\n // A real engine waits for its tiles here, and a swap can start meanwhile.\n await Promise.resolve();\n this.#refuseExport();\n if (requested && this.#stallImageTiles) {\n this.#stallImageTiles = false;\n throw new MapImageExportError(\n \"timed-out\",\n \"The fake map's tiles did not finish loading.\",\n );\n }\n // A PNG header of the image's size, so the blob is recognisably an image\n // without an encoder and a test can read the size back.\n const { width, height } = requested\n ? { width: requested.pixelWidth, height: requested.pixelHeight }\n : screen;\n return new Blob([pngHeader(width, height)], { type: \"image/png\" });\n }\n\n /** Refuses an image while a swap is loading. */\n #refuseExport(): void {\n if (this.#swapTarget !== null) {\n throw new MapEngineError(\n \"export-failed\",\n \"The basemap is still loading, so the map cannot be saved yet.\",\n );\n }\n }\n\n /** Makes the next `toImage` reject with an `export-failed` `MapEngineError`. */\n failNextImage(): void {\n this.#failNextImage = true;\n }\n\n /**\n * Makes the next `toImage` that asks for a size, a pixel ratio or a view\n * reject with a `timed-out` `MapImageExportError`, as when its tiles never\n * finish loading.\n */\n stallNextImageTiles(): void {\n this.#stallImageTiles = true;\n }\n\n setEditHandles(handles: readonly MapEditHandle[]): void {\n this.#handles = [...handles];\n if (this.#hovered !== null && !this.#hasHandle(this.#hovered)) {\n this.#hovered = null;\n this.#emit(\"handleHover\", null);\n }\n }\n\n /** The edit handles last set. */\n editHandles(): readonly MapEditHandle[] {\n return this.#handles;\n }\n\n /**\n * A mouse or finger going down at a position. On a handle it starts a\n * `handleDrag`; anywhere else it starts nothing.\n */\n simulatePointerDown(latlng: LatLng, pointer: HandlePointer = \"mouse\"): void {\n this.#swallowClick = false;\n const gesture = pressHandle(\n this.#projectedHandles(),\n this.project(latlng),\n pointer,\n );\n this.#gesture = gesture;\n if (gesture) {\n this.#emit(\"handleDrag\", {\n id: gesture.id,\n phase: \"start\",\n latlng,\n moved: false,\n });\n }\n }\n\n /**\n * The pointer moving to a position. During a press on a handle, once it\n * has left the click tolerance, it reports `move`; otherwise a mouse\n * reports `handleHover` as it crosses handles.\n */\n simulatePointerMove(latlng: LatLng, pointer: HandlePointer = \"mouse\"): void {\n const point = this.project(latlng);\n if (this.#gesture) {\n this.#gesture = dragHandle(this.#gesture, point);\n if (this.#gesture.moved) {\n this.#emit(\"handleDrag\", {\n id: this.#gesture.id,\n phase: \"move\",\n latlng,\n moved: true,\n });\n }\n return;\n }\n if (pointer !== \"mouse\") {\n return;\n }\n const hit = hitTestHandle(\n this.#projectedHandles(),\n point,\n handleReach(\"mouse\"),\n );\n const id = hit?.id ?? null;\n if (id !== this.#hovered) {\n this.#hovered = id;\n this.#emit(\"handleHover\", id);\n }\n }\n\n /**\n * The pointer going up at a position. It ends a press on a handle, and the\n * `click` that would follow it is then dropped, as an engine's is.\n */\n simulatePointerUp(latlng: LatLng): void {\n const gesture = this.#gesture;\n this.#gesture = null;\n if (!gesture) {\n return;\n }\n this.#swallowClick = true;\n this.#emit(\"handleDrag\", {\n id: gesture.id,\n phase: \"end\",\n latlng,\n moved: gesture.moved,\n });\n }\n\n #hasHandle(id: string): boolean {\n return this.#handles.some((handle) => handle.id === id);\n }\n\n /** The handles that can be pressed: each where the overlay draws it, none beyond the horizon. */\n #projectedHandles(): ProjectedHandle[] {\n const placement = {\n projection: this.projection,\n view: this.#view,\n project: (position: LatLng) => this.project(position),\n isVisible: (position: LatLng) => this.isVisible(position),\n };\n return this.#handles.flatMap((handle) => {\n const point = placePoint(handle.position, placement);\n return point ? [{ id: handle.id, kind: handle.kind, point }] : [];\n });\n }\n\n /** The data layers drawn, lowest first: imagery, vector tiles, styled shapes, detail shapes, heatmaps, then points. */\n drawnLayers(): DrawnLayer[] {\n return [...this.#dataLayers]\n .sort(([, a], [, b]) => KIND_ORDER[a.kind] - KIND_ORDER[b.kind])\n .map(([id, layer]): DrawnLayer => {\n if (layer.kind === \"features\") {\n return { id, kind: \"features\", count: layer.features.length };\n }\n if (layer.kind === \"shapes\") {\n return { id, kind: \"shapes\", count: layer.shapes.geometries.length };\n }\n if (layer.kind === \"styled\") {\n return {\n id,\n kind: \"styled\",\n geometry: layer.layer.geometry,\n count: layer.layer.shapes.length,\n };\n }\n if (layer.kind === \"vector\") {\n return {\n id,\n kind: \"vector\",\n tiles: layer.layer.source.tiles,\n sourceLayers: layer.layer.layers.map((item) => item.sourceLayer),\n };\n }\n if (layer.kind === \"heatmap\") {\n const { source } = layer.heatmap;\n return {\n id,\n kind: \"heatmap\",\n source: source.kind,\n count: source.kind === \"points\" ? source.points.length : 0,\n };\n }\n return {\n id,\n kind: \"tiles\",\n tiles: layer.overlay.tiles,\n opacity: layer.overlay.opacity,\n };\n });\n }\n\n /** The polygons or lines drawn for a styled layer, or undefined when none is drawn under `id`. */\n styledShapesOf(id: string): MapStyledShapes | undefined {\n const layer = this.#dataLayers.get(id);\n return layer?.kind === \"styled\" ? layer.layer : undefined;\n }\n\n /** The vector tile layer drawn under `id`, or undefined. */\n vectorLayerOf(id: string): MapVectorTiles | undefined {\n const layer = this.#dataLayers.get(id);\n return layer?.kind === \"vector\" ? layer.layer : undefined;\n }\n\n /** The heatmap drawn under `id`, or undefined. */\n heatmapOf(id: string): MapHeatmap | undefined {\n const layer = this.#dataLayers.get(id);\n return layer?.kind === \"heatmap\" ? layer.heatmap : undefined;\n }\n\n #hasFeature(hit: MapFeatureHit): boolean {\n const layer = this.#dataLayers.get(hit.layerId);\n if (layer?.kind === \"features\") {\n return layer.features.some((feature) => feature.id === hit.featureId);\n }\n if (layer?.kind === \"styled\") {\n return layer.layer.shapes.some((shape) => shape.id === hit.featureId);\n }\n return false;\n }\n\n /** The points drawn for a feed layer, or undefined when none is drawn under `id`. */\n featuresOf(id: string): readonly MapFeature[] | undefined {\n const layer = this.#dataLayers.get(id);\n return layer?.kind === \"features\" ? layer.features : undefined;\n }\n\n /**\n * Emits `featureTap` and then `click` for a tap on a drawn point, polygon or\n * line, as an engine does. A feature that is not drawn gets nothing.\n */\n simulateFeatureTap(layerId: string, featureId: string): void {\n this.simulateFeatureHits([{ layerId, featureId }]);\n }\n\n /**\n * Emits `featureTap` for a tap that lands on several features at once,\n * topmost first, and then `click`. Only features that are drawn count, each\n * once; with none drawn nothing is emitted. They are also what\n * `featuresAt` then reports.\n */\n simulateFeatureHits(hits: readonly MapFeatureHit[]): void {\n const seen = new Set<string>();\n const drawn = hits.filter((hit) => {\n const key = `${hit.layerId}\\u0000${hit.featureId}`;\n if (seen.has(key) || !this.#hasFeature(hit)) {\n return false;\n }\n seen.add(key);\n return true;\n });\n this.#hitsAtPointer = drawn;\n const [top] = drawn;\n if (!top) {\n return;\n }\n this.#emit(\"featureTap\", { ...top, hits: drawn });\n this.simulateClick(this.#centreOf(top));\n }\n\n #centreOf(hit: MapFeatureHit): LatLng {\n const layer = this.#dataLayers.get(hit.layerId);\n if (layer?.kind === \"features\") {\n const feature = layer.features.find((f) => f.id === hit.featureId);\n if (feature) {\n return feature.position;\n }\n }\n if (layer?.kind === \"styled\") {\n const shape = layer.layer.shapes.find((s) => s.id === hit.featureId);\n const first = shape ? firstPosition(shape.geometry) : null;\n if (first) {\n return { lng: first[0], lat: first[1] };\n }\n }\n return this.#view.center;\n }\n\n /** Emits a `click` at a position, with the given `features`. */\n simulateClick(\n latlng: LatLng,\n features: MapClickEvent[\"features\"] = [],\n ): void {\n if (this.#swallowClick) {\n this.#swallowClick = false;\n return;\n }\n this.#emit(\"click\", {\n latlng: { lat: latlng.lat, lng: wrapLongitude(latlng.lng) },\n point: this.project(latlng),\n features,\n });\n }\n\n /** Emits a `tileError`. */\n simulateTileError(): void {\n this.#emit(\"tileError\", undefined);\n }\n\n /**\n * Emits `basemapUnavailable` for the basemap it draws, as an engine does\n * when every tile of it failed and none loaded. Before `mount` it does\n * nothing, because nothing is drawn.\n */\n simulateBasemapUnavailable(): void {\n if (this.#basemap) {\n this.#emit(\"basemapUnavailable\", this.#basemap);\n }\n }\n\n /**\n * Emits `tileLayerUnavailable` for the tile layer `layerId` as it is drawn,\n * as an engine does when every tile of it failed and none loaded. A layer\n * that is not a drawn tile layer has no tiles, so nothing is emitted.\n */\n simulateTileLayerFailure(layerId: string): void {\n this.#reportTileLayer(layerId, \"tileLayerUnavailable\");\n }\n\n /**\n * Emits `tileLayerSlow` for the tile layer `layerId` as it is drawn, as an\n * engine does when none of its tiles has loaded for longer than its wait. A\n * layer that is not a drawn tile layer has no tiles, so nothing is emitted,\n * and a layer reports it at most once for the tiles it is set to, and not\n * once it has reported no tiles.\n */\n simulateTileLayerSlow(layerId: string): void {\n const layer = this.#dataLayers.get(layerId);\n if (\n layer?.kind === \"tiles\" &&\n this.#reportedTiles.get(layerId) !== layer.overlay.tiles\n ) {\n this.#reportTileLayer(layerId, \"tileLayerSlow\");\n }\n }\n\n /**\n * Emits `tileLayerRecovered` for the tile layer `layerId`, as an engine does\n * when a tile loads after the layer reported slow tiles or no tiles. A layer\n * that has not reported (or has since been set to other tiles, or removed)\n * emits nothing, and the reports of one drawing are ended by one recovery.\n */\n simulateTileLayerRecovery(layerId: string): void {\n const layer = this.#dataLayers.get(layerId);\n const tiles = this.#reportedTiles.get(layerId);\n if (layer?.kind === \"tiles\" && tiles === layer.overlay.tiles) {\n this.#reportedTiles.delete(layerId);\n this.#emit(\"tileLayerRecovered\", { layerId, tiles });\n }\n }\n\n #reportTileLayer(\n layerId: string,\n event: \"tileLayerSlow\" | \"tileLayerUnavailable\",\n ): void {\n const layer = this.#dataLayers.get(layerId);\n if (layer?.kind === \"tiles\") {\n this.#reportedTiles.set(layerId, layer.overlay.tiles);\n this.#emit(event, { layerId, tiles: layer.overlay.tiles });\n }\n }\n\n /** Emits `loading` with the given state. */\n simulateLoading(loading: boolean): void {\n this.#emit(\"loading\", loading);\n }\n\n /**\n * Zooms to `zoom` the way a gesture the engine handles would: the view\n * events fire as for `setView`, and `userZoom` fires with them.\n */\n simulateUserZoom(zoom: number): void {\n this.#applyView({ ...this.#view, zoom }, true);\n }\n\n /**\n * Makes the next `setBasemap` reject with a `load-failed` `MapEngineError`,\n * leaving the current basemap, its zoom limits and the view as they were,\n * as a real engine does when a new style cannot load.\n */\n failNextBasemap(): void {\n this.#failNextBasemap = true;\n }\n\n /** Emits `fatalError`, as an engine that stopped working after it loaded. */\n simulateFatalError(): void {\n this.#emit(\n \"fatalError\",\n new MapEngineError(\"stopped\", \"The fake map engine stopped working.\"),\n );\n }\n\n #normalise(view: ViewState): ViewState {\n return {\n center: {\n lat: clamp(\n view.center.lat,\n -MAX_MERCATOR_LATITUDE,\n MAX_MERCATOR_LATITUDE,\n ),\n lng: wrapLongitude(view.center.lng),\n },\n zoom: clampZoom(view.zoom, this.getMinZoom(), this.getMaxZoom()),\n bearing: wrapBearing(view.bearing),\n };\n }\n\n #applyView(requested: ViewState, byUser = false): void {\n const previous = this.#view;\n const next = this.#normalise(requested);\n const moved =\n next.center.lat !== previous.center.lat ||\n next.center.lng !== previous.center.lng;\n const zoomed = next.zoom !== previous.zoom;\n const rotated = next.bearing !== previous.bearing;\n if (!moved && !zoomed && !rotated) {\n return;\n }\n this.#view = next;\n this.#emit(\"move\", next);\n if (zoomed) {\n this.#emit(\"zoom\", next);\n if (byUser) {\n this.#emit(\"userZoom\", next);\n }\n }\n if (rotated) {\n this.#emit(\"rotate\", next);\n }\n this.#emit(\"moveEnd\", next);\n }\n\n #emit<K extends keyof MapEvents>(event: K, payload: MapEvents[K]): void {\n for (const handler of [...(this.#listeners.get(event) ?? [])]) {\n (handler as (payload: MapEvents[K]) => void)(payload);\n }\n }\n}\n\n/**\n * Builds a `MapAdapterFactory` of fakes. `onCreate` receives each adapter\n * built, so a test can script it.\n */\nexport function createFakeMapAdapterFactory(\n onCreate?: (adapter: FakeMapAdapter) => void,\n): MapAdapterFactory {\n return () => {\n const adapter = new FakeMapAdapter();\n onCreate?.(adapter);\n return adapter;\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAoDA,IAAa,oBAA+B,OAAO,OAAO;CACxD,QAAQ,OAAO,OAAO;EAAE,KAAK;EAAG,KAAK;CAAE,CAAC;CACxC,MAAM;CACN,SAAS;AACX,CAAC;;AASD,IAAa,cAAb,MAAmD;CAItC;CACA;CAJX,aAAmE,CAAC;CAEpE,YACE,QAAiB,KACjB,SAAkB,KAClB;EAFS,KAAA,QAAA;EACA,KAAA,SAAA;CACR;CAEH,MAAM,SAA6C;EACjD,KAAK,WAAW,KAAK,OAAO;CAC9B;CAEA,wBAKE;EACA,OAAO;GAAE,OAAO,KAAK;GAAO,QAAQ,KAAK;GAAQ,MAAM;GAAG,KAAK;EAAE;CACnE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,MAAM,UAAU,KAAK,MAAM,KAAK,WAAW,GAAG,KAAK,WAAW,CAAC;GAC/D,SAAS,YAAY,KAAK,OAAO;EACnC;CACF;CAEA,WAAW,WAAsB,SAAS,OAAa;EACrD,MAAM,WAAW,KAAK;EACtB,MAAM,OAAO,KAAK,WAAW,SAAS;EACtC,MAAM,QACJ,KAAK,OAAO,QAAQ,SAAS,OAAO,OACpC,KAAK,OAAO,QAAQ,SAAS,OAAO;EACtC,MAAM,SAAS,KAAK,SAAS,SAAS;EACtC,MAAM,UAAU,KAAK,YAAY,SAAS;EAC1C,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,SACxB;EAEF,KAAK,QAAQ;EACb,KAAK,MAAM,QAAQ,IAAI;EACvB,IAAI,QAAQ;GACV,KAAK,MAAM,QAAQ,IAAI;GACvB,IAAI,QACF,KAAK,MAAM,YAAY,IAAI;EAE/B;EACA,IAAI,SACF,KAAK,MAAM,UAAU,IAAI;EAE3B,KAAK,MAAM,WAAW,IAAI;CAC5B;CAEA,MAAiC,OAAU,SAA6B;EACtE,KAAK,MAAM,WAAW,CAAC,GAAI,KAAK,WAAW,IAAI,KAAK,KAAK,CAAC,CAAE,GAC1D,QAA6C,OAAO;CAExD;AACF;;;;;AAMA,SAAgB,4BACd,UACmB;CACnB,aAAa;EACX,MAAM,UAAU,IAAI,eAAe;EACnC,WAAW,OAAO;EAClB,OAAO;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"FakeMapAdapter.js","names":[],"sources":["../../src/fakes/FakeMapAdapter.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport { distanceMetres, EARTH_RADIUS_METRES } from \"../draw/geo\";\nimport {\n dragHandle,\n type HandleGesture,\n type HandlePointer,\n handleReach,\n pressHandle,\n} from \"../draw/gesture\";\nimport { hitTestHandle, type ProjectedHandle } from \"../draw/hit\";\nimport { wrapLongitude } from \"../globe/longitude\";\nimport { placePoint } from \"../globe/placement\";\nimport { mapMetresPerPixel } from \"../globe/resolution\";\nimport { planRequestedImage, refuseBoxOnGlobe } from \"../imageExport/plan\";\nimport { clamp } from \"../numbers/clamp\";\nimport type { BasemapDefinition } from \"../ports/basemap\";\nimport {\n MapEngineError,\n type MapEngineErrorReason,\n MapImageExportError,\n} from \"../ports/errors\";\nimport type { Bounds, LatLng, PixelPoint, ViewState } from \"../ports/geometry\";\nimport type {\n MapAdapter,\n MapAdapterFactory,\n MapBasemapOptions,\n MapClickEvent,\n MapEditHandle,\n MapEvents,\n MapFeature,\n MapFeatureHit,\n MapFitOptions,\n MapHeatmap,\n MapHostElement,\n MapImageOptions,\n MapMountOptions,\n MapProjection,\n MapShapes,\n MapStyledShapes,\n MapTileOverlay,\n MapVectorTiles,\n} from \"../ports/map\";\nimport {\n clampZoom,\n MAX_MERCATOR_LATITUDE,\n mercatorProject,\n mercatorUnproject,\n} from \"../zoom/zoom\";\nimport { pngHeader } from \"./pngHeader\";\n\n/** The view a {@link FakeMapAdapter} starts with before it is mounted. */\nexport const DEFAULT_FAKE_VIEW: ViewState = Object.freeze({\n center: Object.freeze({ lat: 0, lng: 0 }),\n zoom: 2,\n bearing: 0,\n});\n\n/** Options for {@link FakeMapAdapter}. */\nexport interface FakeMapAdapterOptions {\n /** Makes `mount` reject with a `MapEngineError` of this reason. */\n readonly failMount?: MapEngineErrorReason;\n}\n\n/** A host element double of a fixed size, recording focus calls. */\nexport class FakeMapHost implements MapHostElement {\n readonly focusCalls: ({ preventScroll?: boolean } | undefined)[] = [];\n\n constructor(\n readonly width = 800,\n readonly height = 600,\n ) {}\n\n focus(options?: { preventScroll?: boolean }): void {\n this.focusCalls.push(options);\n }\n\n getBoundingClientRect(): {\n readonly width: number;\n readonly height: number;\n readonly left: number;\n readonly top: number;\n } {\n return { width: this.width, height: this.height, left: 0, top: 0 };\n }\n}\n\ntype Handler = (payload: never) => void;\n\n/** What a deferred basemap swap waits on (see `FakeMapAdapter.deferNextBasemap`). */\ninterface SwapGate {\n readonly promise: Promise<void>;\n}\n\ntype DataLayer =\n | { readonly kind: \"features\"; readonly features: readonly MapFeature[] }\n | { readonly kind: \"tiles\"; readonly overlay: MapTileOverlay }\n | { readonly kind: \"shapes\"; readonly shapes: MapShapes }\n | { readonly kind: \"styled\"; readonly layer: MapStyledShapes }\n | { readonly kind: \"vector\"; readonly layer: MapVectorTiles }\n | { readonly kind: \"heatmap\"; readonly heatmap: MapHeatmap };\n\n/**\n * A data layer as an engine draws it, lowest first, for tests and the map\n * adapter contract to compare adapters by.\n */\nexport type DrawnLayer =\n | {\n readonly id: string;\n readonly kind: \"features\" | \"shapes\";\n readonly count: number;\n }\n | {\n readonly id: string;\n readonly kind: \"tiles\";\n readonly tiles: string;\n readonly opacity: number;\n }\n | {\n readonly id: string;\n readonly kind: \"styled\";\n readonly geometry: \"area\" | \"line\";\n readonly count: number;\n }\n | {\n readonly id: string;\n readonly kind: \"vector\";\n readonly tiles: string;\n readonly sourceLayers: readonly string[];\n }\n | {\n readonly id: string;\n readonly kind: \"heatmap\";\n readonly source: \"points\" | \"vector\";\n /** The points drawn, or 0 for a vector source. */\n readonly count: number;\n };\n\n/** Stacking order, lowest first: imagery, vector tiles, styled shapes, detail shapes, heatmaps, points. */\nconst KIND_ORDER: Readonly<Record<DataLayer[\"kind\"], number>> = {\n tiles: 0,\n vector: 1,\n styled: 2,\n shapes: 3,\n heatmap: 4,\n features: 5,\n};\n\nfunction firstPosition(\n geometry: MapStyledShapes[\"shapes\"][number][\"geometry\"],\n): readonly [number, number] | null {\n switch (geometry.type) {\n case \"Point\":\n return geometry.coordinates;\n case \"LineString\":\n return geometry.coordinates[0] ?? null;\n case \"MultiLineString\":\n case \"Polygon\":\n return geometry.coordinates[0]?.[0] ?? null;\n case \"MultiPolygon\":\n return geometry.coordinates[0]?.[0]?.[0] ?? null;\n }\n}\n\nfunction wrapBearing(degrees: number): number {\n return ((degrees % 360) + 360) % 360;\n}\n\n/**\n * A pure in-memory {@link MapAdapter}: no engine, no DOM, no timers.\n *\n * How to script it:\n * - Pass `failMount: \"webgl-unavailable\"` (or `\"load-failed\"`) to make\n * `mount` reject with a `MapEngineError`.\n * - Mount it into a {@link FakeMapHost}; the host's size (800 by 600 by\n * default) sets the pixel space used by `project` and `unproject`.\n * - Drive events with `simulateClick`, `simulateTileError`,\n * `simulateLoading`, `simulateUserZoom` (a wheel, pinch or double-click)\n * `simulateFatalError` (the engine stopping after it loaded), and\n * `simulatePointerDown`, `simulatePointerMove` and `simulatePointerUp` (a\n * mouse or finger on the map, which drive edit handles). Call\n * `failNextBasemap` to make the next swap fail. `setView`, `zoomIn`, `panBy` and the rest emit real\n * `move`, `zoom`, `rotate` and `moveEnd` events, and only when something\n * changed.\n * - Inspect `mountCount`, `destroyed`, `animationEnabled`, `keyboardEnabled`\n * and `focusCount`.\n *\n * Animation options are accepted and ignored, because every change is\n * immediate. `project` ignores the bearing.\n */\nexport class FakeMapAdapter implements MapAdapter {\n mountCount = 0;\n focusCount = 0;\n animationEnabled = true;\n keyboardEnabled = true;\n /** Whether the last `mount` or `setBasemap` asked for Save data mode. */\n saveData = false;\n /** The shape the map was last asked to draw. */\n projection: MapProjection = \"flat\";\n\n readonly #failMount: MapEngineErrorReason | undefined;\n #failNextBasemap = false;\n /** The next swap waits on this until the test settles it. */\n #nextSwapGate: SwapGate | null = null;\n /** The basemap a swap in flight is loading, until it has loaded or failed. */\n #swapTarget: BasemapDefinition | null = null;\n #view: ViewState = DEFAULT_FAKE_VIEW;\n #basemap: BasemapDefinition | null = null;\n #host: MapHostElement | null = null;\n #hostSize = { width: 800, height: 600 };\n #destroyed = false;\n readonly #listeners = new Map<keyof MapEvents, Set<Handler>>();\n readonly #dataLayers = new Map<string, DataLayer>();\n /** The tiles each tile layer reported as slow or missing, until they load or change. */\n readonly #reportedTiles = new Map<string, string>();\n #hitsAtPointer: readonly MapFeatureHit[] = [];\n #failNextImage = false;\n #stallImageTiles = false;\n /** The options of every `toImage` call, in order. */\n readonly imageRequests: (MapImageOptions | undefined)[] = [];\n #handles: readonly MapEditHandle[] = [];\n #gesture: HandleGesture | null = null;\n #hovered: string | null = null;\n #swallowClick = false;\n\n constructor(options: FakeMapAdapterOptions = {}) {\n this.#failMount = options.failMount;\n }\n\n /** True after `destroy`, until the next successful `mount`. */\n get destroyed(): boolean {\n return this.#destroyed;\n }\n\n async mount(host: MapHostElement, options: MapMountOptions): Promise<void> {\n if (this.#failMount !== undefined) {\n throw new MapEngineError(this.#failMount);\n }\n const { width, height } = host.getBoundingClientRect();\n this.#host = host;\n this.#hostSize = { width, height };\n this.#basemap = options.basemap;\n this.#view = this.#normalise(options.view);\n this.animationEnabled = !options.reducedMotion;\n this.saveData = options.saveData ?? false;\n this.projection = options.projection ?? \"flat\";\n this.#destroyed = false;\n this.mountCount += 1;\n this.#emit(\"load\", undefined);\n }\n\n destroy(): void {\n this.#destroyed = true;\n this.#host = null;\n this.#listeners.clear();\n }\n\n getView(): ViewState {\n return this.#view;\n }\n\n setView(view: Partial<ViewState>): void {\n this.#applyView({ ...this.#view, ...view });\n }\n\n zoomIn(): void {\n this.setView({ zoom: this.#view.zoom + 1 });\n }\n\n zoomOut(): void {\n this.setView({ zoom: this.#view.zoom - 1 });\n }\n\n panBy(dx: number, dy: number): void {\n if (dx === 0 && dy === 0) {\n return;\n }\n const { zoom, center } = this.#view;\n const world = mercatorProject(center, zoom);\n const limit = mercatorProject(\n { lat: -MAX_MERCATOR_LATITUDE, lng: 0 },\n zoom,\n );\n this.setView({\n center: mercatorUnproject(\n { x: world.x + dx, y: clamp(world.y + dy, 0, limit.y) },\n zoom,\n ),\n });\n }\n\n rotateBy(degrees: number): void {\n this.setView({ bearing: this.#view.bearing + degrees });\n }\n\n resetBearing(): void {\n this.setView({ bearing: 0 });\n }\n\n fitBounds(bounds: Bounds, options: MapFitOptions = {}): void {\n const { top = 0, right = 0, bottom = 0, left = 0 } = options.padding ?? {};\n const southWest = mercatorProject(\n { lat: bounds.south, lng: bounds.west },\n 0,\n );\n const northEast = mercatorProject(\n { lat: bounds.north, lng: bounds.east },\n 0,\n );\n const spanX = Math.abs(northEast.x - southWest.x);\n const spanY = Math.abs(southWest.y - northEast.y);\n const availableX = Math.max(1, this.#hostSize.width - left - right);\n const availableY = Math.max(1, this.#hostSize.height - top - bottom);\n const fitted = Math.min(\n Math.log2(availableX / spanX),\n Math.log2(availableY / spanY),\n );\n this.setView({\n center: {\n lat: (bounds.south + bounds.north) / 2,\n lng: wrapLongitude((bounds.west + bounds.east) / 2),\n },\n zoom: Math.min(fitted, options.maxZoom ?? Number.POSITIVE_INFINITY),\n });\n }\n\n getMinZoom(): number {\n return this.#basemap?.minZoom ?? 0;\n }\n\n getMaxZoom(): number {\n return this.#basemap?.maxZoom ?? 18;\n }\n\n project(latlng: LatLng): PixelPoint {\n const { center, zoom } = this.#view;\n const world = mercatorProject(latlng, zoom);\n const origin = mercatorProject(center, zoom);\n return {\n x: world.x - origin.x + this.#hostSize.width / 2,\n y: world.y - origin.y + this.#hostSize.height / 2,\n };\n }\n\n /** On a globe, a place more than a quarter of the way round from the centre is out of sight. */\n isVisible(latlng: LatLng): boolean {\n return (\n this.projection === \"flat\" ||\n distanceMetres(this.#view.center, latlng) <=\n (Math.PI / 2) * EARTH_RADIUS_METRES\n );\n }\n\n setProjection(projection: MapProjection): void {\n this.projection = projection;\n }\n\n unproject(point: PixelPoint): LatLng {\n const { center, zoom } = this.#view;\n const origin = mercatorProject(center, zoom);\n const position = mercatorUnproject(\n {\n x: point.x - this.#hostSize.width / 2 + origin.x,\n y: point.y - this.#hostSize.height / 2 + origin.y,\n },\n zoom,\n );\n return { lat: position.lat, lng: wrapLongitude(position.lng) };\n }\n\n metresPerPixel(lat: number = this.#view.center.lat): number {\n const { center, zoom } = this.#view;\n return mapMetresPerPixel(this.projection, lat, center.lat, zoom);\n }\n\n async setBasemap(\n basemap: BasemapDefinition,\n options: MapBasemapOptions = {},\n ): Promise<void> {\n if (this.#failNextBasemap) {\n this.#failNextBasemap = false;\n throw new MapEngineError(\n \"load-failed\",\n \"The fake basemap style could not be loaded.\",\n );\n }\n this.#swapTarget = basemap;\n const gate = this.#nextSwapGate;\n this.#nextSwapGate = null;\n if (gate) {\n try {\n await gate.promise;\n } catch (error) {\n if (this.#swapTarget === basemap) {\n this.#swapTarget = null;\n }\n throw error;\n }\n }\n if (this.#swapTarget !== basemap) {\n // A newer swap took over while this one waited: nothing loaded.\n return;\n }\n this.#swapTarget = null;\n this.#basemap = basemap;\n this.saveData = options.saveData ?? false;\n this.#applyView(this.#view);\n this.#emit(\"load\", undefined);\n }\n\n /**\n * Makes the next `setBasemap` wait, as a real style that is still\n * downloading does, until `resolve` (the swap loads) or `reject` (it fails\n * with a `load-failed` `MapEngineError` and the last basemap stays). While\n * it waits the basemap is the old one, and `toImage` refuses.\n */\n deferNextBasemap(): {\n readonly resolve: () => void;\n readonly reject: () => void;\n } {\n let resolve = () => {};\n let reject = () => {};\n const promise = new Promise<void>((done, fail) => {\n resolve = done;\n reject = () =>\n fail(\n new MapEngineError(\n \"load-failed\",\n \"The fake basemap style could not be loaded.\",\n ),\n );\n });\n // The caller may never settle a deferred swap it no longer needs.\n promise.catch(() => {});\n this.#nextSwapGate = { promise };\n return { resolve, reject };\n }\n\n setAnimationEnabled(enabled: boolean): void {\n this.animationEnabled = enabled;\n }\n\n setKeyboardEnabled(enabled: boolean): void {\n this.keyboardEnabled = enabled;\n }\n\n focus(): void {\n this.focusCount += 1;\n this.#host?.focus({ preventScroll: true });\n }\n\n on<K extends keyof MapEvents>(\n event: K,\n handler: (payload: MapEvents[K]) => void,\n ): () => void {\n const handlers = this.#listeners.get(event) ?? new Set<Handler>();\n handlers.add(handler as Handler);\n this.#listeners.set(event, handlers);\n return () => {\n handlers.delete(handler as Handler);\n };\n }\n\n setFeatureLayer(id: string, features: readonly MapFeature[]): void {\n this.#dataLayers.delete(id);\n this.#dataLayers.set(id, { kind: \"features\", features: [...features] });\n }\n\n setTileLayer(id: string, overlay: MapTileOverlay): void {\n if (this.#reportedTiles.get(id) !== overlay.tiles) {\n this.#reportedTiles.delete(id);\n }\n this.#dataLayers.delete(id);\n this.#dataLayers.set(id, { kind: \"tiles\", overlay });\n }\n\n setShapeLayer(id: string, shapes: MapShapes): void {\n this.#dataLayers.delete(id);\n this.#dataLayers.set(id, { kind: \"shapes\", shapes });\n }\n\n setStyledShapes(id: string, layer: MapStyledShapes): void {\n this.#dataLayers.delete(id);\n this.#dataLayers.set(id, { kind: \"styled\", layer });\n }\n\n setVectorLayer(id: string, layer: MapVectorTiles): void {\n this.#dataLayers.delete(id);\n this.#dataLayers.set(id, { kind: \"vector\", layer });\n }\n\n setHeatmapLayer(id: string, heatmap: MapHeatmap): void {\n this.#dataLayers.delete(id);\n this.#dataLayers.set(id, { kind: \"heatmap\", heatmap });\n }\n\n removeLayer(id: string): void {\n this.#reportedTiles.delete(id);\n this.#dataLayers.delete(id);\n }\n\n /**\n * The features most recently scripted under the pointer with\n * `simulateFeatureHits` or `simulateFeatureTap`, still drawn, in the order\n * scripted. A real engine finds them by position; the fake cannot, so a\n * test says what is there.\n */\n featuresAt(_point: PixelPoint): readonly MapFeatureHit[] {\n return this.#hitsAtPointer.filter((hit) => this.#hasFeature(hit));\n }\n\n getBounds(): Bounds {\n const { width, height } = this.#hostSize;\n const corners = [\n this.unproject({ x: 0, y: 0 }),\n this.unproject({ x: width, y: 0 }),\n this.unproject({ x: 0, y: height }),\n this.unproject({ x: width, y: height }),\n ];\n const lats = corners.map((corner) => corner.lat);\n const lngs = corners.map((corner) => corner.lng);\n return {\n west: Math.min(...lngs),\n south: Math.min(...lats),\n east: Math.max(...lngs),\n north: Math.max(...lats),\n };\n }\n\n async toImage(options?: MapImageOptions): Promise<Blob> {\n this.imageRequests.push(options);\n if (this.#failNextImage) {\n this.#failNextImage = false;\n throw new MapEngineError(\n \"export-failed\",\n \"The fake map could not produce an image.\",\n );\n }\n if (this.#host === null) {\n throw new MapEngineError(\"export-failed\", \"The map is not mounted.\");\n }\n this.#refuseExport();\n // The size of the map on screen as the MapLibre adapter reads it: the\n // layout size, which the DOM's `clientWidth` and `clientHeight` give as\n // whole pixels rounded to the nearest.\n const screen = {\n width: Math.round(this.#hostSize.width),\n height: Math.round(this.#hostSize.height),\n };\n const requested = planRequestedImage(options ?? {}, {\n size: screen,\n view: this.#view,\n });\n if (requested) {\n refuseBoxOnGlobe(requested.view, this.projection);\n }\n // A real engine waits for its tiles here, and a swap can start meanwhile.\n await Promise.resolve();\n this.#refuseExport();\n if (requested && this.#stallImageTiles) {\n this.#stallImageTiles = false;\n throw new MapImageExportError(\n \"timed-out\",\n \"The fake map's tiles did not finish loading.\",\n );\n }\n // A PNG header of the image's size, so the blob is recognisably an image\n // without an encoder and a test can read the size back.\n const { width, height } = requested\n ? { width: requested.pixelWidth, height: requested.pixelHeight }\n : screen;\n return new Blob([pngHeader(width, height)], { type: \"image/png\" });\n }\n\n /** Refuses an image while a swap is loading. */\n #refuseExport(): void {\n if (this.#swapTarget !== null) {\n throw new MapEngineError(\n \"export-failed\",\n \"The basemap is still loading, so the map cannot be saved yet.\",\n );\n }\n }\n\n /** Makes the next `toImage` reject with an `export-failed` `MapEngineError`. */\n failNextImage(): void {\n this.#failNextImage = true;\n }\n\n /**\n * Makes the next `toImage` that asks for a size, a pixel ratio or a view\n * reject with a `timed-out` `MapImageExportError`, as when its tiles never\n * finish loading.\n */\n stallNextImageTiles(): void {\n this.#stallImageTiles = true;\n }\n\n setEditHandles(handles: readonly MapEditHandle[]): void {\n this.#handles = [...handles];\n if (this.#hovered !== null && !this.#hasHandle(this.#hovered)) {\n this.#hovered = null;\n this.#emit(\"handleHover\", null);\n }\n }\n\n /** The edit handles last set. */\n editHandles(): readonly MapEditHandle[] {\n return this.#handles;\n }\n\n /**\n * A mouse or finger going down at a position. On a handle it starts a\n * `handleDrag`; anywhere else it starts nothing.\n */\n simulatePointerDown(latlng: LatLng, pointer: HandlePointer = \"mouse\"): void {\n this.#swallowClick = false;\n const gesture = pressHandle(\n this.#projectedHandles(),\n this.project(latlng),\n pointer,\n );\n this.#gesture = gesture;\n if (gesture) {\n this.#emit(\"handleDrag\", {\n id: gesture.id,\n phase: \"start\",\n latlng,\n moved: false,\n });\n }\n }\n\n /**\n * The pointer moving to a position. During a press on a handle, once it\n * has left the click tolerance, it reports `move`; otherwise a mouse\n * reports `handleHover` as it crosses handles.\n */\n simulatePointerMove(latlng: LatLng, pointer: HandlePointer = \"mouse\"): void {\n const point = this.project(latlng);\n if (this.#gesture) {\n this.#gesture = dragHandle(this.#gesture, point);\n if (this.#gesture.moved) {\n this.#emit(\"handleDrag\", {\n id: this.#gesture.id,\n phase: \"move\",\n latlng,\n moved: true,\n });\n }\n return;\n }\n if (pointer !== \"mouse\") {\n return;\n }\n const hit = hitTestHandle(\n this.#projectedHandles(),\n point,\n handleReach(\"mouse\"),\n );\n const id = hit?.id ?? null;\n if (id !== this.#hovered) {\n this.#hovered = id;\n this.#emit(\"handleHover\", id);\n }\n }\n\n /**\n * The pointer going up at a position. It ends a press on a handle, and the\n * `click` that would follow it is then dropped, as an engine's is.\n */\n simulatePointerUp(latlng: LatLng): void {\n const gesture = this.#gesture;\n this.#gesture = null;\n if (!gesture) {\n return;\n }\n this.#swallowClick = true;\n this.#emit(\"handleDrag\", {\n id: gesture.id,\n phase: \"end\",\n latlng,\n moved: gesture.moved,\n });\n }\n\n #hasHandle(id: string): boolean {\n return this.#handles.some((handle) => handle.id === id);\n }\n\n /** The handles that can be pressed: each where the overlay draws it, none beyond the horizon. */\n #projectedHandles(): ProjectedHandle[] {\n const placement = {\n projection: this.projection,\n view: this.#view,\n project: (position: LatLng) => this.project(position),\n isVisible: (position: LatLng) => this.isVisible(position),\n };\n return this.#handles.flatMap((handle) => {\n const point = placePoint(handle.position, placement);\n return point ? [{ id: handle.id, kind: handle.kind, point }] : [];\n });\n }\n\n /** The data layers drawn, lowest first: imagery, vector tiles, styled shapes, detail shapes, heatmaps, then points. */\n drawnLayers(): DrawnLayer[] {\n return [...this.#dataLayers]\n .sort(([, a], [, b]) => KIND_ORDER[a.kind] - KIND_ORDER[b.kind])\n .map(([id, layer]): DrawnLayer => {\n if (layer.kind === \"features\") {\n return { id, kind: \"features\", count: layer.features.length };\n }\n if (layer.kind === \"shapes\") {\n return { id, kind: \"shapes\", count: layer.shapes.geometries.length };\n }\n if (layer.kind === \"styled\") {\n return {\n id,\n kind: \"styled\",\n geometry: layer.layer.geometry,\n count: layer.layer.shapes.length,\n };\n }\n if (layer.kind === \"vector\") {\n return {\n id,\n kind: \"vector\",\n tiles: layer.layer.source.tiles,\n sourceLayers: layer.layer.layers.map((item) => item.sourceLayer),\n };\n }\n if (layer.kind === \"heatmap\") {\n const { source } = layer.heatmap;\n return {\n id,\n kind: \"heatmap\",\n source: source.kind,\n count: source.kind === \"points\" ? source.points.length : 0,\n };\n }\n return {\n id,\n kind: \"tiles\",\n tiles: layer.overlay.tiles,\n opacity: layer.overlay.opacity,\n };\n });\n }\n\n /** The polygons or lines drawn for a styled layer, or undefined when none is drawn under `id`. */\n styledShapesOf(id: string): MapStyledShapes | undefined {\n const layer = this.#dataLayers.get(id);\n return layer?.kind === \"styled\" ? layer.layer : undefined;\n }\n\n /** The vector tile layer drawn under `id`, or undefined. */\n vectorLayerOf(id: string): MapVectorTiles | undefined {\n const layer = this.#dataLayers.get(id);\n return layer?.kind === \"vector\" ? layer.layer : undefined;\n }\n\n /** The heatmap drawn under `id`, or undefined. */\n heatmapOf(id: string): MapHeatmap | undefined {\n const layer = this.#dataLayers.get(id);\n return layer?.kind === \"heatmap\" ? layer.heatmap : undefined;\n }\n\n #hasFeature(hit: MapFeatureHit): boolean {\n const layer = this.#dataLayers.get(hit.layerId);\n if (layer?.kind === \"features\") {\n return layer.features.some((feature) => feature.id === hit.featureId);\n }\n if (layer?.kind === \"styled\") {\n return layer.layer.shapes.some((shape) => shape.id === hit.featureId);\n }\n return false;\n }\n\n /** The points drawn for a feed layer, or undefined when none is drawn under `id`. */\n featuresOf(id: string): readonly MapFeature[] | undefined {\n const layer = this.#dataLayers.get(id);\n return layer?.kind === \"features\" ? layer.features : undefined;\n }\n\n /**\n * Emits `featureTap` and then `click` for a tap on a drawn point, polygon or\n * line, as an engine does. A feature that is not drawn gets nothing.\n */\n simulateFeatureTap(layerId: string, featureId: string): void {\n this.simulateFeatureHits([{ layerId, featureId }]);\n }\n\n /**\n * Emits `featureTap` for a tap that lands on several features at once,\n * topmost first, and then `click`. Only features that are drawn count, each\n * once; with none drawn nothing is emitted. They are also what\n * `featuresAt` then reports.\n */\n simulateFeatureHits(hits: readonly MapFeatureHit[]): void {\n const seen = new Set<string>();\n const drawn = hits.filter((hit) => {\n const key = `${hit.layerId}\\u0000${hit.featureId}`;\n if (seen.has(key) || !this.#hasFeature(hit)) {\n return false;\n }\n seen.add(key);\n return true;\n });\n this.#hitsAtPointer = drawn;\n const [top] = drawn;\n if (!top) {\n return;\n }\n this.#emit(\"featureTap\", { ...top, hits: drawn });\n this.simulateClick(this.#centreOf(top));\n }\n\n #centreOf(hit: MapFeatureHit): LatLng {\n const layer = this.#dataLayers.get(hit.layerId);\n if (layer?.kind === \"features\") {\n const feature = layer.features.find((f) => f.id === hit.featureId);\n if (feature) {\n return feature.position;\n }\n }\n if (layer?.kind === \"styled\") {\n const shape = layer.layer.shapes.find((s) => s.id === hit.featureId);\n const first = shape ? firstPosition(shape.geometry) : null;\n if (first) {\n return { lng: first[0], lat: first[1] };\n }\n }\n return this.#view.center;\n }\n\n /** Emits a `click` at a position, with the given `features`. */\n simulateClick(\n latlng: LatLng,\n features: MapClickEvent[\"features\"] = [],\n ): void {\n if (this.#swallowClick) {\n this.#swallowClick = false;\n return;\n }\n this.#emit(\"click\", {\n latlng: { lat: latlng.lat, lng: wrapLongitude(latlng.lng) },\n point: this.project(latlng),\n features,\n });\n }\n\n /** Emits a `tileError`. */\n simulateTileError(): void {\n this.#emit(\"tileError\", undefined);\n }\n\n /**\n * Emits `basemapUnavailable` for the basemap it draws, as an engine does\n * when every tile of it failed and none loaded. Before `mount` it does\n * nothing, because nothing is drawn.\n */\n simulateBasemapUnavailable(): void {\n if (this.#basemap) {\n this.#emit(\"basemapUnavailable\", this.#basemap);\n }\n }\n\n /**\n * Emits `tileLayerUnavailable` for the tile layer `layerId` as it is drawn,\n * as an engine does when every tile of it failed and none loaded. A layer\n * that is not a drawn tile layer has no tiles, so nothing is emitted.\n */\n simulateTileLayerFailure(layerId: string): void {\n this.#reportTileLayer(layerId, \"tileLayerUnavailable\");\n }\n\n /**\n * Emits `tileLayerSlow` for the tile layer `layerId` as it is drawn, as an\n * engine does when none of its tiles has loaded for longer than its wait. A\n * layer that is not a drawn tile layer has no tiles, so nothing is emitted,\n * and a layer reports it at most once for the tiles it is set to, and not\n * once it has reported no tiles.\n */\n simulateTileLayerSlow(layerId: string): void {\n const layer = this.#dataLayers.get(layerId);\n if (\n layer?.kind === \"tiles\" &&\n this.#reportedTiles.get(layerId) !== layer.overlay.tiles\n ) {\n this.#reportTileLayer(layerId, \"tileLayerSlow\");\n }\n }\n\n /**\n * Emits `tileLayerRecovered` for the tile layer `layerId`, as an engine does\n * when a tile loads after the layer reported slow tiles or no tiles. A layer\n * that has not reported (or has since been set to other tiles, or removed)\n * emits nothing, and the reports of one drawing are ended by one recovery.\n */\n simulateTileLayerRecovery(layerId: string): void {\n const layer = this.#dataLayers.get(layerId);\n const tiles = this.#reportedTiles.get(layerId);\n if (layer?.kind === \"tiles\" && tiles === layer.overlay.tiles) {\n this.#reportedTiles.delete(layerId);\n this.#emit(\"tileLayerRecovered\", { layerId, tiles });\n }\n }\n\n #reportTileLayer(\n layerId: string,\n event: \"tileLayerSlow\" | \"tileLayerUnavailable\",\n ): void {\n const layer = this.#dataLayers.get(layerId);\n if (layer?.kind === \"tiles\") {\n this.#reportedTiles.set(layerId, layer.overlay.tiles);\n this.#emit(event, { layerId, tiles: layer.overlay.tiles });\n }\n }\n\n /** Emits `loading` with the given state. */\n simulateLoading(loading: boolean): void {\n this.#emit(\"loading\", loading);\n }\n\n /**\n * Zooms to `zoom` the way a gesture the engine handles would: the view\n * events fire as for `setView`, and `userZoom` fires with them.\n */\n simulateUserZoom(zoom: number): void {\n this.#applyView({ ...this.#view, zoom }, true);\n }\n\n /**\n * Makes the next `setBasemap` reject with a `load-failed` `MapEngineError`,\n * leaving the current basemap, its zoom limits and the view as they were,\n * as a real engine does when a new style cannot load.\n */\n failNextBasemap(): void {\n this.#failNextBasemap = true;\n }\n\n /** Emits `fatalError`, as an engine that stopped working after it loaded. */\n simulateFatalError(): void {\n this.#emit(\n \"fatalError\",\n new MapEngineError(\"stopped\", \"The fake map engine stopped working.\"),\n );\n }\n\n #normalise(view: ViewState): ViewState {\n return {\n center: {\n lat: clamp(\n view.center.lat,\n -MAX_MERCATOR_LATITUDE,\n MAX_MERCATOR_LATITUDE,\n ),\n lng: wrapLongitude(view.center.lng),\n },\n zoom: clampZoom(view.zoom, this.getMinZoom(), this.getMaxZoom()),\n bearing: wrapBearing(view.bearing),\n };\n }\n\n #applyView(requested: ViewState, byUser = false): void {\n const previous = this.#view;\n const next = this.#normalise(requested);\n const moved =\n next.center.lat !== previous.center.lat ||\n next.center.lng !== previous.center.lng;\n const zoomed = next.zoom !== previous.zoom;\n const rotated = next.bearing !== previous.bearing;\n if (!moved && !zoomed && !rotated) {\n return;\n }\n this.#view = next;\n this.#emit(\"move\", next);\n if (zoomed) {\n this.#emit(\"zoom\", next);\n if (byUser) {\n this.#emit(\"userZoom\", next);\n }\n }\n if (rotated) {\n this.#emit(\"rotate\", next);\n }\n this.#emit(\"moveEnd\", next);\n }\n\n #emit<K extends keyof MapEvents>(event: K, payload: MapEvents[K]): void {\n for (const handler of [...(this.#listeners.get(event) ?? [])]) {\n (handler as (payload: MapEvents[K]) => void)(payload);\n }\n }\n}\n\n/**\n * Builds a `MapAdapterFactory` of fakes. `onCreate` receives each adapter\n * built, so a test can script it.\n */\nexport function createFakeMapAdapterFactory(\n onCreate?: (adapter: FakeMapAdapter) => void,\n): MapAdapterFactory {\n return () => {\n const adapter = new FakeMapAdapter();\n onCreate?.(adapter);\n return adapter;\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAoDA,IAAa,oBAA+B,OAAO,OAAO;CACxD,QAAQ,OAAO,OAAO;EAAE,KAAK;EAAG,KAAK;CAAE,CAAC;CACxC,MAAM;CACN,SAAS;AACX,CAAC;;AASD,IAAa,cAAb,MAAmD;CAItC;CACA;CAJX,aAAmE,CAAC;CAEpE,YACE,QAAiB,KACjB,SAAkB,KAClB;EAFS,KAAA,QAAA;EACA,KAAA,SAAA;CACR;CAEH,MAAM,SAA6C;EACjD,KAAK,WAAW,KAAK,OAAO;CAC9B;CAEA,wBAKE;EACA,OAAO;GAAE,OAAO,KAAK;GAAO,QAAQ,KAAK;GAAQ,MAAM;GAAG,KAAK;EAAE;CACnE;AACF;;AAsDA,IAAM,aAA0D;CAC9D,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,UAAU;AACZ;AAEA,SAAS,cACP,UACkC;CAClC,QAAQ,SAAS,MAAjB;EACE,KAAK,SACH,OAAO,SAAS;EAClB,KAAK,cACH,OAAO,SAAS,YAAY,MAAM;EACpC,KAAK;EACL,KAAK,WACH,OAAO,SAAS,YAAY,EAAE,GAAG,MAAM;EACzC,KAAK,gBACH,OAAO,SAAS,YAAY,EAAE,GAAG,EAAE,GAAG,MAAM;CAChD;AACF;AAEA,SAAS,YAAY,SAAyB;CAC5C,QAAS,UAAU,MAAO,OAAO;AACnC;;;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAa,iBAAb,MAAkD;CAChD,aAAa;CACb,aAAa;CACb,mBAAmB;CACnB,kBAAkB;;CAElB,WAAW;;CAEX,aAA4B;CAE5B;CACA,mBAAmB;;CAEnB,gBAAiC;;CAEjC,cAAwC;CACxC,QAAmB;CACnB,WAAqC;CACrC,QAA+B;CAC/B,YAAY;EAAE,OAAO;EAAK,QAAQ;CAAI;CACtC,aAAa;CACb,6BAAsB,IAAI,IA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AK,CAAC,CAAE,GAC1D,QAA6C,OAAO;CAExD;AACF;;;;;AAMA,SAAgB,4BACd,UACmB;CACnB,aAAa;EACX,MAAM,UAAU,IAAI,eAAe;EACnC,WAAW,OAAO;EAClB,OAAO;CACT;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -475,13 +475,41 @@ export declare interface Bounds {
|
|
|
475
475
|
export declare function boundsAroundPoint(centre: LatLng, radiusMetres: number): Bounds;
|
|
476
476
|
|
|
477
477
|
/**
|
|
478
|
-
* The smallest latitude and longitude box holding every
|
|
479
|
-
*
|
|
480
|
-
*
|
|
478
|
+
* The smallest latitude and longitude box holding every vertex of every path
|
|
479
|
+
* and every edge between neighbouring vertices of one path, each edge taken
|
|
480
|
+
* the short way round the globe (the way a path is drawn and measured). Used
|
|
481
|
+
* to fit the map to a polygon, a line or a feature with several parts.
|
|
482
|
+
* @param paths The rings and lines of a shape. A ring repeats its first
|
|
483
|
+
* vertex at the end, as GeoJSON does; no edge joins two paths.
|
|
481
484
|
* @returns `undefined` when no point has finite coordinates.
|
|
482
|
-
* @remarks
|
|
483
|
-
*
|
|
484
|
-
*
|
|
485
|
+
* @remarks Longitude is a circle, so the box is the circle less its widest
|
|
486
|
+
* gap that no vertex or edge covers. A shape wider than half the globe with
|
|
487
|
+
* few vertices is therefore boxed on the side its edges cover, which
|
|
488
|
+
* {@link boundsOfPoints} cannot know from vertices alone. A shape that
|
|
489
|
+
* covers the whole circle, such as a ring round a pole, gives a `west` of
|
|
490
|
+
* -180 and an `east` of 180. Otherwise the box has the form of
|
|
491
|
+
* {@link boundsOfPoints}: `west` inside [-180, 180) and `east` not before it,
|
|
492
|
+
* past 180 across the antimeridian. An edge of exactly half the globe has
|
|
493
|
+
* no short way and is taken eastward, as it is drawn and measured. Latitudes are clamped to valid
|
|
494
|
+
* coordinates, and an edge is a straight step in latitude.
|
|
495
|
+
*/
|
|
496
|
+
export declare function boundsOfPaths(paths: readonly (readonly LatLng[])[]): Bounds | undefined;
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* The smallest latitude and longitude box holding every point, with its
|
|
500
|
+
* latitudes clamped to valid coordinates. Used to fit the map to a feature.
|
|
501
|
+
* @returns `undefined` when no point has finite coordinates.
|
|
502
|
+
* @remarks The box takes the short way round the globe. Points on both sides
|
|
503
|
+
* of the antimeridian give a `west` inside [-180, 180) and an `east` past
|
|
504
|
+
* 180 (179 and -179 give 179 to 181), the form `shapeInputBounds` and
|
|
505
|
+
* {@link shortestLongitudeSpan} already use, so `west` is never greater than
|
|
506
|
+
* `east` and a caller that reads width as `east - west` stays correct. A box
|
|
507
|
+
* that does not cross the line keeps both edges inside [-180, 180]. Take the
|
|
508
|
+
* middle with `wrapLongitude((west + east) / 2)`. The engine's `fitBounds`
|
|
509
|
+
* accepts the unwrapped `east`. A set of points wider than half the globe
|
|
510
|
+
* with a wide gap in it may be boxed on the other side of the gap, because
|
|
511
|
+
* points say nothing about what lies between them. For a polygon or a line,
|
|
512
|
+
* use {@link boundsOfPaths}, which also holds every edge.
|
|
485
513
|
*/
|
|
486
514
|
export declare function boundsOfPoints(points: readonly LatLng[]): Bounds | undefined;
|
|
487
515
|
|
|
@@ -1144,6 +1172,20 @@ export declare function decodeDetail(definition: LayerDefinition, raw: unknown,
|
|
|
1144
1172
|
*/
|
|
1145
1173
|
export declare function decodeFeed(definition: LayerDefinition, raw: unknown, decoders: DecoderRegistry): LayerFeature[];
|
|
1146
1174
|
|
|
1175
|
+
/**
|
|
1176
|
+
* Decodes the responses to the requests `feedUrls` lists, as `decodeFeed`
|
|
1177
|
+
* does for one, and joins them in the order they came. A feature that more
|
|
1178
|
+
* than one response holds (one on the antimeridian can be in the box on each
|
|
1179
|
+
* side) is kept once, when its id and geometry are the same; a different
|
|
1180
|
+
* feature with the same id is kept under a new id. Each response is capped
|
|
1181
|
+
* at one more than a query layer's `maxFeatures` before they are joined, and
|
|
1182
|
+
* the cap applies to the whole again.
|
|
1183
|
+
*
|
|
1184
|
+
* @throws `LayerError` `invalid` when any response cannot be decoded, and
|
|
1185
|
+
* `empty` when no feature is left in any of them.
|
|
1186
|
+
*/
|
|
1187
|
+
export declare function decodeFeeds(definition: LayerDefinition, raws: readonly unknown[], decoders: DecoderRegistry): LayerFeature[];
|
|
1188
|
+
|
|
1147
1189
|
/**
|
|
1148
1190
|
* Decodes a service's answer to a tap into features, keeping at most
|
|
1149
1191
|
* {@link MAX_IDENTIFIED_FEATURES}. Nothing found is an empty list, not an
|
|
@@ -2840,9 +2882,21 @@ export declare interface FeedSource {
|
|
|
2840
2882
|
* The URL for a feed or query layer's controls. Missing or invalid values use
|
|
2841
2883
|
* their defaults. A query layer needs the `area` of the map it asks for
|
|
2842
2884
|
* (see `queryWindow`), which fills its box and its limit.
|
|
2885
|
+
*
|
|
2886
|
+
* @throws when the `area` crosses the antimeridian, which takes two
|
|
2887
|
+
* requests: use `feedUrls`. It once gave one URL with the box clamped to
|
|
2888
|
+
* the edge of the world, which asked for the wrong area.
|
|
2843
2889
|
*/
|
|
2844
2890
|
export declare function feedUrl(definition: LayerDefinition, controls: ControlValues, now: number, area?: Bounds): string;
|
|
2845
2891
|
|
|
2892
|
+
/**
|
|
2893
|
+
* The URLs to ask for a feed or query layer's controls: one, except for a
|
|
2894
|
+
* query layer whose `area` crosses the antimeridian, which gets one for each
|
|
2895
|
+
* side of the line (`queryBoxes`), because a provider takes a box inside
|
|
2896
|
+
* -180 to 180. Join the answers with `decodeFeeds`.
|
|
2897
|
+
*/
|
|
2898
|
+
export declare function feedUrls(definition: LayerDefinition, controls: ControlValues, now: number, area?: Bounds): string[];
|
|
2899
|
+
|
|
2846
2900
|
/** Converts international feet to metres. */
|
|
2847
2901
|
export declare function feetToMetres(feet: number): number;
|
|
2848
2902
|
|
|
@@ -3802,7 +3856,9 @@ export declare interface LayerLoadRequest {
|
|
|
3802
3856
|
readonly definition: LayerDefinition;
|
|
3803
3857
|
/**
|
|
3804
3858
|
* The box of the map a query layer asks for (see `queryWindow`). Required
|
|
3805
|
-
* for a query layer and ignored for any other.
|
|
3859
|
+
* for a query layer and ignored for any other. A box across the
|
|
3860
|
+
* antimeridian has `east` past 180, and the source asks for each side of
|
|
3861
|
+
* the line (see `feedUrls`).
|
|
3806
3862
|
*/
|
|
3807
3863
|
readonly area?: Bounds;
|
|
3808
3864
|
/** Every control's value, already resolved (see `resolveControlValues`). */
|
|
@@ -6400,6 +6456,14 @@ export declare interface QueryArea {
|
|
|
6400
6456
|
readonly coordinates: number[][][];
|
|
6401
6457
|
}
|
|
6402
6458
|
|
|
6459
|
+
/**
|
|
6460
|
+
* The boxes to ask a provider for `window`, each inside -180 to 180: the
|
|
6461
|
+
* window itself, or when it crosses the antimeridian (`east` past 180) the
|
|
6462
|
+
* part from `west` to 180 and then the part from -180 to the rest. The
|
|
6463
|
+
* boxes meet at the line and cover the window exactly.
|
|
6464
|
+
*/
|
|
6465
|
+
export declare function queryBoxes(window: Bounds): Bounds[];
|
|
6466
|
+
|
|
6403
6467
|
/** A layer whose features come from a query for the current view. */
|
|
6404
6468
|
export declare type QueryLayerDefinition = (FeedLayerDefinition | HeatmapLayerDefinition) & {
|
|
6405
6469
|
readonly source: QuerySource;
|
|
@@ -6432,7 +6496,11 @@ export declare interface QuerySource {
|
|
|
6432
6496
|
* margin, snapped outward to a grid in proportion to its size. A few pixels
|
|
6433
6497
|
* of panning give the same window, so they send the same request (and the
|
|
6434
6498
|
* same cache entry), and a small pan stays inside the window and needs none.
|
|
6435
|
-
* Latitudes
|
|
6499
|
+
* Latitudes are kept within what a map shows, and longitudes within -180 to
|
|
6500
|
+
* 180, except that a view across the antimeridian gets a window across it:
|
|
6501
|
+
* the short box, with `west` inside -180 to 180 and `east` past 180 (see
|
|
6502
|
+
* `queryBoxes` for the boxes to ask a provider). A view that does not cross
|
|
6503
|
+
* the line gets a window that stops at it, margin or not.
|
|
6436
6504
|
*/
|
|
6437
6505
|
export declare function queryWindow(view: Bounds): Bounds;
|
|
6438
6506
|
|
|
@@ -6723,8 +6791,8 @@ export declare function roundForLookup(position: LatLng): LatLng;
|
|
|
6723
6791
|
|
|
6724
6792
|
/**
|
|
6725
6793
|
* The smallest box that holds every line or ring of the features, or `null`
|
|
6726
|
-
* when they hold no position.
|
|
6727
|
-
*
|
|
6794
|
+
* when they hold no position. Takes the short way across the antimeridian, as
|
|
6795
|
+
* {@link boundsOfPoints} does. Safe for a route of any length.
|
|
6728
6796
|
*/
|
|
6729
6797
|
export declare function routeBounds(features: readonly (RouteLeg | ReachableAreaFeature)[]): Bounds | null;
|
|
6730
6798
|
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { appendMessages, formatMessage, joinMessages, message } from "./messages
|
|
|
10
10
|
import { GeometryError } from "./geometry/errors.js";
|
|
11
11
|
import { MAX_COLLECTION_DEPTH, isEmptyGeometry, validateGeometry } from "./geometry/validate.js";
|
|
12
12
|
import { boundingBox, boundingBoxToBounds, centroid, geometryArea, geometryLength, pointInPolygon } from "./geometry/queries.js";
|
|
13
|
+
import { boundsOfPaths } from "./spatial/boundsOfPaths.js";
|
|
13
14
|
import { AREA_MINUTES, MAX_DIRECTION_STOPS, TRAVEL_MODES, addStop, canAddStop, describeStop, moveStop, reachableAreaSize, removeStop, routeBounds, routingErrorMessage, stopLetter, travelModeLabel, travelModeParticiple } from "./directions/directions.js";
|
|
14
15
|
import { MAX_MINUTES_AGO, MINUTES_PER_DAY, dateTimeRange, defaultSlot, describeDay, describeSlot, describeSlotStart, isSlotValue, resolveSlot, slotInstant, slotTime, slotValue, slotsOnDay } from "./layers/dateTime.js";
|
|
15
16
|
import { describeDuration, formatDuration } from "./units/duration.js";
|
|
@@ -52,8 +53,9 @@ import { createNamedRegistry } from "./layers/registry.js";
|
|
|
52
53
|
import { createDecoderRegistry, decodeWith, geojsonDecoder } from "./layers/decoders.js";
|
|
53
54
|
import { cardOf, hasCard, isFeedLayer, isHeatmapLayer, isIdentifiable, isQueryLayer, isRasterTileLayer, isShapeStyle, isVectorTileLayer, loadsFeatures } from "./layers/definition.js";
|
|
54
55
|
import { matchesFilter } from "./layers/filter.js";
|
|
56
|
+
import { nextQueryWindow, queryBoxes, queryWindow } from "./layers/query.js";
|
|
55
57
|
import { ENGINE_PLACEHOLDERS, QUERY_BOX, QUERY_PLACEHOLDERS, fillUrlTemplate, formatTemplate, parseTemplate, resolveLayerTemplate } from "./layers/template.js";
|
|
56
|
-
import { decodeDetail, decodeFeed, detailUrl, feedUrl, tileUrl } from "./layers/feed.js";
|
|
58
|
+
import { decodeDetail, decodeFeed, decodeFeeds, detailUrl, feedUrl, feedUrls, tileUrl } from "./layers/feed.js";
|
|
57
59
|
import { CATEGORICAL_SLOTS, ORDINAL_SLOTS, PALETTE_SLOTS, isCategoricalSlot, isOrdinalSlot, isPaletteSlot } from "./layers/palette.js";
|
|
58
60
|
import { DEFAULT_IDENTIFY_TOLERANCE_PX, IDENTIFY_VARIABLES, MAX_IDENTIFIED_FEATURES, MAX_IDENTIFY_TOLERANCE_PX, MIN_IDENTIFY_TOLERANCE_PX, decodeIdentify, identifyRequestUrl, identifyUrl } from "./layers/identify.js";
|
|
59
61
|
import { FakeLayerSource } from "./fakes/FakeLayerSource.js";
|
|
@@ -80,7 +82,6 @@ import { BUILT_IN_FORMATTERS, createFormatterRegistry, parseTime } from "./layer
|
|
|
80
82
|
import { DEFAULT_HEATMAP_OPACITY, heatmapOpacity, heatmapSettings } from "./layers/heatmap.js";
|
|
81
83
|
import { assertValidDefinitions, validateLayerDefinition } from "./layers/validate.js";
|
|
82
84
|
import { partitionDefinitions } from "./layers/partitionDefinitions.js";
|
|
83
|
-
import { nextQueryWindow, queryWindow } from "./layers/query.js";
|
|
84
85
|
import { SharedResponseCache, maxAgeFromCacheControl } from "./layers/responseCache.js";
|
|
85
86
|
import { createRuntimeLayerCatalogue } from "./layers/runtimeLayerCatalogue.js";
|
|
86
87
|
import { DEFAULT_AREA_WIDTH, DEFAULT_FILL_OPACITY, DEFAULT_LINE_WIDTH, evaluateShapeStyle, shapeAppearances, shapeClasses, shapeEvaluator } from "./layers/shapeStyle.js";
|
|
@@ -102,4 +103,4 @@ import { parseThemeChoice, resolveTheme } from "./theme/theme.js";
|
|
|
102
103
|
import { LANGUAGE_STORAGE_KEY, MAP_SHAPE_ATTRIBUTE, PROJECTION_STORAGE_KEY, THEME_ATTRIBUTE, THEME_COLOR_META, THEME_COLOR_META_NAME, THEME_STORAGE_KEY } from "./theme/themeConstants.js";
|
|
103
104
|
import { buildThemeBootstrapScript } from "./theme/themeBootstrap.js";
|
|
104
105
|
import { initialTourState, shouldOfferTour, stepDone, tourReducer } from "./tour/tour.js";
|
|
105
|
-
export { AREA_MINUTES, BASEMAPS, BUILT_IN_BASEMAP_CATALOGUE, BUILT_IN_FORMATTERS, CATEGORICAL_SLOTS, CIRCLE_EXPORT_STEPS, DEFAULT_AREA_WIDTH, DEFAULT_BASEMAP_BACKGROUND, DEFAULT_BASEMAP_ID, DEFAULT_FAKE_FIX, DEFAULT_FAKE_SETTINGS, DEFAULT_FAKE_VIEW, DEFAULT_FILL_OPACITY, DEFAULT_HEATMAP_OPACITY, DEFAULT_IDENTIFY_TOLERANCE_PX, DEFAULT_IMAGE_PIXEL_RATIO, DEFAULT_LINE_WIDTH, DEFAULT_MARKER_RADIUS, DEFAULT_SELECTION_LIMIT, DRAW_HISTORY_LIMIT, DRAW_ISSUE_MESSAGES, DRAW_KEY_HELP, DRAW_NUDGE_PX, DRAW_NUDGE_PX_LARGE, EARTH_RADIUS_METRES, ENGINE_PLACEHOLDERS, ENGINE_ZOOM_OFFSET, EN_GB_CATALOGUE, EQUATOR_METRES_PER_PIXEL_AT_ZOOM_0, FAKE_HYBRID_BASEMAP, FAKE_RASTER_BASEMAP, FAKE_VECTOR_BASEMAP, FakeClipboard, FakeDevicePreferences, FakeFeatureQuery, FakeFileOpener, FakeFileSaver, FakeLayerCatalogue, FakeLayerSource, FakeLocationProvider, FakeMapAdapter, FakeMapHost, FakeMessageCatalogue, FakeRoutingProvider, FakeSearchProvider, FakeSuggestionProvider, FakeThemeSource, FeatureQueryError, FileOpenError, GLOBE_CHORD_TOLERANCE_PX, GeometryError, HANDLE_CLICK_TOLERANCE_PX, HANDLE_HIT_RADIUS_MOUSE_PX, HANDLE_HIT_RADIUS_TOUCH_PX, IDENTIFY_VARIABLES, LANGUAGE_STORAGE_KEY, LOOKUP_DECIMAL_PLACES, LayerError, LocationError, MAPLIBRE_CREDIT, MAP_KEY_HELP, MAP_SHAPE_ATTRIBUTE, MAX_AXIS_SCAN_CHARACTERS, MAX_CIRCLE_RADIUS_METRES, MAX_COLLECTION_DEPTH, MAX_COORDINATE_TEXT_LENGTH, MAX_DIRECTION_STOPS, MAX_DRAWING_SHAPES, MAX_GREAT_CIRCLE_STEPS, MAX_IDENTIFIED_FEATURES, MAX_IDENTIFY_TOLERANCE_PX, MAX_IMAGE_PIXELS, MAX_IMAGE_SIDE_PX, MAX_IMPORT_BYTES, MAX_IMPORT_DEPTH, MAX_IMPORT_POINTS, MAX_IMPORT_SHAPES, MAX_IMPORT_SHAPE_POINTS, MAX_MERCATOR_LATITUDE, MAX_MINUTES_AGO, MAX_SHARE_LENGTH, MAX_SHARE_SHAPES, MINUTES_PER_DAY, MIN_IDENTIFY_TOLERANCE_PX, MapEngineError, MapImageExportError, MemoryFeatureSelection, MemorySettingsStore, MemoryUrlState, NORMALISED_TILE_SIZE, ORDINAL_SLOTS, PALETTE_SLOTS, PANEL_MAX_HEIGHT_EXCLUSIVE, PANEL_MIN_WIDTH, PROJECTION_STORAGE_KEY, PortAbortError, QUERY_BOX, QUERY_PLACEHOLDERS, RoutingError, SAMPLE_ALERT_LAYER, SAMPLE_AREA_LAYER, SAMPLE_FEED_LAYER, SAMPLE_HEATMAP_LAYER, SAMPLE_IDENTIFY_LAYER, SAMPLE_LAYERS, SAMPLE_LINE_LAYER, SAMPLE_QUERY_LAYER, SAMPLE_TILE_LAYER, SAMPLE_TIME_LAYER, SAMPLE_VECTOR_LAYER, SHAPES_CSV_HEADER, SHAPE_FILE_TYPES, SHARE_PATTERN, SHEET_DETENTS, SHEET_FLING_VELOCITY, SUPPORTED_WKT_SRID, SearchError, SharedResponseCache, THEME_ATTRIBUTE, THEME_COLOR_META, THEME_COLOR_META_NAME, THEME_STORAGE_KEY, TRAVEL_MODES, UnsupportedSridError, WEB_MERCATOR_HALF_WORLD, addStop, announceAddressError, announceAddressFound, announceAddressNotFound, announceAreaFound, announceBasemap, announceCatalogueChange, announceCoordinateResult, announceCopied, announceDetailError, announceDetailShown, announceDetent, announceDirectionsCleared, announceDrawEvent, announceFeatureDeselected, announceFeatureSelected, announceFeaturesDeselected, announceFeaturesFound, announceFeaturesSelected, announceIdentified, announceImageFailed, announceImageSaved, announceLayerCapped, announceLayerEmpty, announceLayerError, announceLayerLoaded, announceLayerOffline, announceLayerOn, announceLayerZoomIn, announceLayerZoomOut, announceLayersTurnedBackOn, announceLayersTurnedOff, announceLocationError, announceLocationFound, announceMeasureTotal, announceNoFeaturesHere, announceNoResults, announceNoSuggestions, announceOffline, announcePinCleared, announcePinDropped, announceProjection, announceRouteFound, announceRoutingCancelled, announceRoutingError, announceSearchError, announceSearchResults, announceSelectionCleared, announceSelectionFull, announceShowingFeature, announceStopAdded, announceStopLimit, announceStopMoved, announceStopRemoved, announceSuggestions, announceSuggestionsUnavailable, announceSurfaceClosed, announceSurfaceOpened, announceTileError, announceTilesRecovered, announceTilesSlow, announceTilesUnavailable, announceTimeMoved, announceTourSkipped, announceZoom, appendMessages, assertValidDefinitions, blurSearch, boundingBox, boundingBoxToBounds, boundsAroundPoint, boundsOfPoints, buffer, buildAttribution, buildThemeBootstrapScript, canAddStop, cardOf, centralAngle, centroid, checkDefinitionTexts, checkMessageCatalogue, chooseLayout, circleArea, circleCircumference, circleRing, clampHeight, clampZoom, clearPin, clearsInlineEnd, closeSurface, computeBottomSlotLayout, computeDetentHeights, computeEndStackMaxHeight, computeScaleBar, coordinateSearchResult, coordinateWordsFor, createBasemapCatalogue, createDecoderRegistry, createDrawReducer, createFakeMapAdapterFactory, createFakeServices, createFormatterRegistry, createLanguageCatalogue, createMessageCatalogue, createNamedRegistry, createRuntimeLayerCatalogue, createStaticLayerCatalogue, creditsLine, cycleDetent, dateTimeRange, decodeDetail, decodeFeed, decodeIdentify, decodeShapes, decodeWith, defaultControlValues, defaultSlot, densifyAlongGreatCircles, describeArea, describeAxisSuggestion, describeChosenTime, describeDay, describeDistance, describeDistanceReading, describeDuration, describeLayersLoadFailed, describeLayersLoading, describeLayersRefreshFailed, describeLayersSkipped, describeNoLayers, describeShapeImport, describeShapeMeasure, describeSlot, describeSlotStart, describeStop, describeTilesSlow, describeTilesUnavailable, describeZoomIn, describeZoomOut, destinationPoint, detailUrl, difference, distanceMetres, draftOf, dragHandle, drawKeyCommand, drawReducer, dropPin, editHandlesFor, emptyLayerCatalogue, encodeShapes, escapeAction, evaluatePointStyle, evaluateShapeStyle, exportableShapes, featureRefKey, feedUrl, feetToMetres, fillUrlTemplate, formatArea, formatDay, formatDistance, formatDuration, formatFixed, formatLatLng, formatLatitude, formatLocale, formatLongitude, formatMessage, formatNumber, formatShapeMeasure, formatTemplate, formatWkt, formatZoom, geojsonDecoder, geometryArea, geometryLength, getBasemap, globeRadiusPixels, greatCircleInterpolate, greatCircleMidpoint, greatCirclePoints, greatCircleStepRadians, handleReach, hasCard, hasZoomWindow, heatmapOpacity, heatmapSettings, hemispheresFor, hintFor, hitTestHandle, identifyRequestUrl, identifyUrl, imageMarksFor, initialDrawState, initialSurfaceState, initialTourState, inlineDistanceToFarEdge, intersect, isCategoricalSlot, isCompactViewport, isControlEnabled, isEmptyGeometry, isFeedLayer, isHeatmapLayer, isIdentifiable, isIsoDate, isMessageKey, isOrdinalSlot, isPaletteSlot, isQueryLayer, isRasterTileLayer, isSettingsSection, isShapeStyle, isSlotValue, isVectorTileLayer, isolate, joinMessages, kilometresToMetres, languageDirection, layerZoomLimit, legendFor, loadsFeatures, mapKeyAction, mapMetresPerPixel, matchesFilter, maxAgeFromCacheControl, measureLineDistance, measurePolygonArea, measureShape, mercatorProject, mercatorUnproject, message, metresPerPixel, metresToFeet, metresToKilometres, metresToMiles, milesToMetres, moveStop, nearestLongitude, nextDetent, nextQueryWindow, omittedLayers, openSearch, openSheet, parseCoordinates, parseHandleId, parseShapeFile, parseTemplate, parseThemeChoice, parseTime, parseUrlHash, parseWkt, partitionDefinitions, pickShape, placePath, placePoint, planRequestedImage, pngHeader, pointInPolygon, polygonSelfIntersects, pressEscape, pressHandle, queryWindow, reachableAreaSize, readArea, readDistance, readPath, readPngSize, readWktRecovering, readWktSequence, readyLayers, refuseBoxOnGlobe, removeStop, resolveControlValues, resolveDateBound, resolveLanguage, resolveLayerTemplate, resolveSlot, resolveSnap, resolveText, resolveTheme, ringSignedArea, roundForLookup, routeBounds, routingErrorMessage, rubberBand, sampleArea, sampleLine, samplePoint, selectedShape, serialiseUrlHash, setDetent, shapeAppearances, shapeClasses, shapeEvaluator, shapeGeometry, shapeInputBounds, shapeLabel, shapeRing, shapesToCsv, shapesToGeoJson, shapesToGeoJsonText, shapesToWkt, shortestLongitudeSpan, shouldOfferTour, shouldShowZoomButtons, simplify, slotInstant, slotTime, slotValue, slotsOnDay, squareMetresToAcres, squareMetresToHectares, squareMetresToSquareFeet, squareMetresToSquareKilometres, squareMetresToSquareMiles, startDirections, startDraw, startMeasure, startsLikeWkt, stepDone, stopDirections, stopDraw, stopLetter, stopMeasure, suggestWktAxisOrder, surfaceReducer, templateValues, textOrMessage, tileUrl, toEngineZoom, toNormalisedZoom, tourReducer, travelModeLabel, travelModeParticiple, union, unsharableShapes, unwrapLongitudes, usesMoreData, validateGeometry, validateLayerDefinition, validateShape, verticesCollinear, visibleRuns, webMercatorToWgs84, wgs84ToWebMercator, wrapLongitude };
|
|
106
|
+
export { AREA_MINUTES, BASEMAPS, BUILT_IN_BASEMAP_CATALOGUE, BUILT_IN_FORMATTERS, CATEGORICAL_SLOTS, CIRCLE_EXPORT_STEPS, DEFAULT_AREA_WIDTH, DEFAULT_BASEMAP_BACKGROUND, DEFAULT_BASEMAP_ID, DEFAULT_FAKE_FIX, DEFAULT_FAKE_SETTINGS, DEFAULT_FAKE_VIEW, DEFAULT_FILL_OPACITY, DEFAULT_HEATMAP_OPACITY, DEFAULT_IDENTIFY_TOLERANCE_PX, DEFAULT_IMAGE_PIXEL_RATIO, DEFAULT_LINE_WIDTH, DEFAULT_MARKER_RADIUS, DEFAULT_SELECTION_LIMIT, DRAW_HISTORY_LIMIT, DRAW_ISSUE_MESSAGES, DRAW_KEY_HELP, DRAW_NUDGE_PX, DRAW_NUDGE_PX_LARGE, EARTH_RADIUS_METRES, ENGINE_PLACEHOLDERS, ENGINE_ZOOM_OFFSET, EN_GB_CATALOGUE, EQUATOR_METRES_PER_PIXEL_AT_ZOOM_0, FAKE_HYBRID_BASEMAP, FAKE_RASTER_BASEMAP, FAKE_VECTOR_BASEMAP, FakeClipboard, FakeDevicePreferences, FakeFeatureQuery, FakeFileOpener, FakeFileSaver, FakeLayerCatalogue, FakeLayerSource, FakeLocationProvider, FakeMapAdapter, FakeMapHost, FakeMessageCatalogue, FakeRoutingProvider, FakeSearchProvider, FakeSuggestionProvider, FakeThemeSource, FeatureQueryError, FileOpenError, GLOBE_CHORD_TOLERANCE_PX, GeometryError, HANDLE_CLICK_TOLERANCE_PX, HANDLE_HIT_RADIUS_MOUSE_PX, HANDLE_HIT_RADIUS_TOUCH_PX, IDENTIFY_VARIABLES, LANGUAGE_STORAGE_KEY, LOOKUP_DECIMAL_PLACES, LayerError, LocationError, MAPLIBRE_CREDIT, MAP_KEY_HELP, MAP_SHAPE_ATTRIBUTE, MAX_AXIS_SCAN_CHARACTERS, MAX_CIRCLE_RADIUS_METRES, MAX_COLLECTION_DEPTH, MAX_COORDINATE_TEXT_LENGTH, MAX_DIRECTION_STOPS, MAX_DRAWING_SHAPES, MAX_GREAT_CIRCLE_STEPS, MAX_IDENTIFIED_FEATURES, MAX_IDENTIFY_TOLERANCE_PX, MAX_IMAGE_PIXELS, MAX_IMAGE_SIDE_PX, MAX_IMPORT_BYTES, MAX_IMPORT_DEPTH, MAX_IMPORT_POINTS, MAX_IMPORT_SHAPES, MAX_IMPORT_SHAPE_POINTS, MAX_MERCATOR_LATITUDE, MAX_MINUTES_AGO, MAX_SHARE_LENGTH, MAX_SHARE_SHAPES, MINUTES_PER_DAY, MIN_IDENTIFY_TOLERANCE_PX, MapEngineError, MapImageExportError, MemoryFeatureSelection, MemorySettingsStore, MemoryUrlState, NORMALISED_TILE_SIZE, ORDINAL_SLOTS, PALETTE_SLOTS, PANEL_MAX_HEIGHT_EXCLUSIVE, PANEL_MIN_WIDTH, PROJECTION_STORAGE_KEY, PortAbortError, QUERY_BOX, QUERY_PLACEHOLDERS, RoutingError, SAMPLE_ALERT_LAYER, SAMPLE_AREA_LAYER, SAMPLE_FEED_LAYER, SAMPLE_HEATMAP_LAYER, SAMPLE_IDENTIFY_LAYER, SAMPLE_LAYERS, SAMPLE_LINE_LAYER, SAMPLE_QUERY_LAYER, SAMPLE_TILE_LAYER, SAMPLE_TIME_LAYER, SAMPLE_VECTOR_LAYER, SHAPES_CSV_HEADER, SHAPE_FILE_TYPES, SHARE_PATTERN, SHEET_DETENTS, SHEET_FLING_VELOCITY, SUPPORTED_WKT_SRID, SearchError, SharedResponseCache, THEME_ATTRIBUTE, THEME_COLOR_META, THEME_COLOR_META_NAME, THEME_STORAGE_KEY, TRAVEL_MODES, UnsupportedSridError, WEB_MERCATOR_HALF_WORLD, addStop, announceAddressError, announceAddressFound, announceAddressNotFound, announceAreaFound, announceBasemap, announceCatalogueChange, announceCoordinateResult, announceCopied, announceDetailError, announceDetailShown, announceDetent, announceDirectionsCleared, announceDrawEvent, announceFeatureDeselected, announceFeatureSelected, announceFeaturesDeselected, announceFeaturesFound, announceFeaturesSelected, announceIdentified, announceImageFailed, announceImageSaved, announceLayerCapped, announceLayerEmpty, announceLayerError, announceLayerLoaded, announceLayerOffline, announceLayerOn, announceLayerZoomIn, announceLayerZoomOut, announceLayersTurnedBackOn, announceLayersTurnedOff, announceLocationError, announceLocationFound, announceMeasureTotal, announceNoFeaturesHere, announceNoResults, announceNoSuggestions, announceOffline, announcePinCleared, announcePinDropped, announceProjection, announceRouteFound, announceRoutingCancelled, announceRoutingError, announceSearchError, announceSearchResults, announceSelectionCleared, announceSelectionFull, announceShowingFeature, announceStopAdded, announceStopLimit, announceStopMoved, announceStopRemoved, announceSuggestions, announceSuggestionsUnavailable, announceSurfaceClosed, announceSurfaceOpened, announceTileError, announceTilesRecovered, announceTilesSlow, announceTilesUnavailable, announceTimeMoved, announceTourSkipped, announceZoom, appendMessages, assertValidDefinitions, blurSearch, boundingBox, boundingBoxToBounds, boundsAroundPoint, boundsOfPaths, boundsOfPoints, buffer, buildAttribution, buildThemeBootstrapScript, canAddStop, cardOf, centralAngle, centroid, checkDefinitionTexts, checkMessageCatalogue, chooseLayout, circleArea, circleCircumference, circleRing, clampHeight, clampZoom, clearPin, clearsInlineEnd, closeSurface, computeBottomSlotLayout, computeDetentHeights, computeEndStackMaxHeight, computeScaleBar, coordinateSearchResult, coordinateWordsFor, createBasemapCatalogue, createDecoderRegistry, createDrawReducer, createFakeMapAdapterFactory, createFakeServices, createFormatterRegistry, createLanguageCatalogue, createMessageCatalogue, createNamedRegistry, createRuntimeLayerCatalogue, createStaticLayerCatalogue, creditsLine, cycleDetent, dateTimeRange, decodeDetail, decodeFeed, decodeFeeds, decodeIdentify, decodeShapes, decodeWith, defaultControlValues, defaultSlot, densifyAlongGreatCircles, describeArea, describeAxisSuggestion, describeChosenTime, describeDay, describeDistance, describeDistanceReading, describeDuration, describeLayersLoadFailed, describeLayersLoading, describeLayersRefreshFailed, describeLayersSkipped, describeNoLayers, describeShapeImport, describeShapeMeasure, describeSlot, describeSlotStart, describeStop, describeTilesSlow, describeTilesUnavailable, describeZoomIn, describeZoomOut, destinationPoint, detailUrl, difference, distanceMetres, draftOf, dragHandle, drawKeyCommand, drawReducer, dropPin, editHandlesFor, emptyLayerCatalogue, encodeShapes, escapeAction, evaluatePointStyle, evaluateShapeStyle, exportableShapes, featureRefKey, feedUrl, feedUrls, feetToMetres, fillUrlTemplate, formatArea, formatDay, formatDistance, formatDuration, formatFixed, formatLatLng, formatLatitude, formatLocale, formatLongitude, formatMessage, formatNumber, formatShapeMeasure, formatTemplate, formatWkt, formatZoom, geojsonDecoder, geometryArea, geometryLength, getBasemap, globeRadiusPixels, greatCircleInterpolate, greatCircleMidpoint, greatCirclePoints, greatCircleStepRadians, handleReach, hasCard, hasZoomWindow, heatmapOpacity, heatmapSettings, hemispheresFor, hintFor, hitTestHandle, identifyRequestUrl, identifyUrl, imageMarksFor, initialDrawState, initialSurfaceState, initialTourState, inlineDistanceToFarEdge, intersect, isCategoricalSlot, isCompactViewport, isControlEnabled, isEmptyGeometry, isFeedLayer, isHeatmapLayer, isIdentifiable, isIsoDate, isMessageKey, isOrdinalSlot, isPaletteSlot, isQueryLayer, isRasterTileLayer, isSettingsSection, isShapeStyle, isSlotValue, isVectorTileLayer, isolate, joinMessages, kilometresToMetres, languageDirection, layerZoomLimit, legendFor, loadsFeatures, mapKeyAction, mapMetresPerPixel, matchesFilter, maxAgeFromCacheControl, measureLineDistance, measurePolygonArea, measureShape, mercatorProject, mercatorUnproject, message, metresPerPixel, metresToFeet, metresToKilometres, metresToMiles, milesToMetres, moveStop, nearestLongitude, nextDetent, nextQueryWindow, omittedLayers, openSearch, openSheet, parseCoordinates, parseHandleId, parseShapeFile, parseTemplate, parseThemeChoice, parseTime, parseUrlHash, parseWkt, partitionDefinitions, pickShape, placePath, placePoint, planRequestedImage, pngHeader, pointInPolygon, polygonSelfIntersects, pressEscape, pressHandle, queryBoxes, queryWindow, reachableAreaSize, readArea, readDistance, readPath, readPngSize, readWktRecovering, readWktSequence, readyLayers, refuseBoxOnGlobe, removeStop, resolveControlValues, resolveDateBound, resolveLanguage, resolveLayerTemplate, resolveSlot, resolveSnap, resolveText, resolveTheme, ringSignedArea, roundForLookup, routeBounds, routingErrorMessage, rubberBand, sampleArea, sampleLine, samplePoint, selectedShape, serialiseUrlHash, setDetent, shapeAppearances, shapeClasses, shapeEvaluator, shapeGeometry, shapeInputBounds, shapeLabel, shapeRing, shapesToCsv, shapesToGeoJson, shapesToGeoJsonText, shapesToWkt, shortestLongitudeSpan, shouldOfferTour, shouldShowZoomButtons, simplify, slotInstant, slotTime, slotValue, slotsOnDay, squareMetresToAcres, squareMetresToHectares, squareMetresToSquareFeet, squareMetresToSquareKilometres, squareMetresToSquareMiles, startDirections, startDraw, startMeasure, startsLikeWkt, stepDone, stopDirections, stopDraw, stopLetter, stopMeasure, suggestWktAxisOrder, surfaceReducer, templateValues, textOrMessage, tileUrl, toEngineZoom, toNormalisedZoom, tourReducer, travelModeLabel, travelModeParticiple, union, unsharableShapes, unwrapLongitudes, usesMoreData, validateGeometry, validateLayerDefinition, validateShape, verticesCollinear, visibleRuns, webMercatorToWgs84, wgs84ToWebMercator, wrapLongitude };
|