@osmix/shared 0.0.6 → 0.0.7
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/CHANGELOG.md +6 -0
- package/dist/assert.d.ts +24 -0
- package/dist/assert.d.ts.map +1 -0
- package/dist/assert.js +28 -0
- package/dist/assert.js.map +1 -0
- package/dist/bbox-intersects.d.ts +15 -0
- package/dist/bbox-intersects.d.ts.map +1 -0
- package/dist/bbox-intersects.js +24 -0
- package/dist/bbox-intersects.js.map +1 -0
- package/dist/bytes-to-stream.d.ts +18 -0
- package/dist/bytes-to-stream.d.ts.map +1 -0
- package/dist/bytes-to-stream.js +25 -0
- package/dist/bytes-to-stream.js.map +1 -0
- package/dist/color.d.ts +4 -0
- package/dist/color.d.ts.map +1 -0
- package/dist/color.js +33 -0
- package/dist/color.js.map +1 -0
- package/dist/concat-bytes.d.ts +5 -0
- package/dist/concat-bytes.d.ts.map +1 -0
- package/dist/concat-bytes.js +14 -0
- package/dist/concat-bytes.js.map +1 -0
- package/dist/coordinates.d.ts +28 -0
- package/dist/coordinates.d.ts.map +1 -0
- package/dist/coordinates.js +38 -0
- package/dist/coordinates.js.map +1 -0
- package/dist/haversine-distance.d.ts +16 -0
- package/dist/haversine-distance.d.ts.map +1 -0
- package/dist/haversine-distance.js +26 -0
- package/dist/haversine-distance.js.map +1 -0
- package/dist/lineclip.d.ts +2 -0
- package/dist/lineclip.d.ts.map +1 -0
- package/dist/lineclip.js +3 -0
- package/dist/lineclip.js.map +1 -0
- package/dist/progress.d.ts +42 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +53 -0
- package/dist/progress.js.map +1 -0
- package/dist/relation-kind.d.ts +69 -0
- package/dist/relation-kind.d.ts.map +1 -0
- package/dist/relation-kind.js +375 -0
- package/dist/relation-kind.js.map +1 -0
- package/dist/relation-multipolygon.d.ts +43 -0
- package/dist/relation-multipolygon.d.ts.map +1 -0
- package/dist/relation-multipolygon.js +195 -0
- package/dist/relation-multipolygon.js.map +1 -0
- package/dist/src/color.d.ts +4 -0
- package/dist/src/color.d.ts.map +1 -0
- package/dist/src/color.js +33 -0
- package/dist/src/color.js.map +1 -0
- package/dist/src/progress.d.ts +4 -2
- package/dist/src/progress.d.ts.map +1 -1
- package/dist/src/progress.js +17 -4
- package/dist/src/progress.js.map +1 -1
- package/dist/src/test/fixtures.d.ts.map +1 -1
- package/dist/src/test/fixtures.js +3 -0
- package/dist/src/test/fixtures.js.map +1 -1
- package/dist/stream-to-bytes.d.ts +18 -0
- package/dist/stream-to-bytes.d.ts.map +1 -0
- package/dist/stream-to-bytes.js +30 -0
- package/dist/stream-to-bytes.js.map +1 -0
- package/dist/test/fixtures.d.ts +36 -0
- package/dist/test/fixtures.d.ts.map +1 -0
- package/dist/test/fixtures.js +175 -0
- package/dist/test/fixtures.js.map +1 -0
- package/dist/throttle.d.ts +25 -0
- package/dist/throttle.d.ts.map +1 -0
- package/dist/throttle.js +34 -0
- package/dist/throttle.js.map +1 -0
- package/dist/tile.d.ts +34 -0
- package/dist/tile.d.ts.map +1 -0
- package/dist/tile.js +72 -0
- package/dist/tile.js.map +1 -0
- package/dist/transform-bytes.d.ts +24 -0
- package/dist/transform-bytes.d.ts.map +1 -0
- package/dist/transform-bytes.js +28 -0
- package/dist/transform-bytes.js.map +1 -0
- package/dist/types.d.ts +99 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +30 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +70 -0
- package/dist/utils.js.map +1 -0
- package/dist/way-is-area.d.ts +24 -0
- package/dist/way-is-area.d.ts.map +1 -0
- package/dist/way-is-area.js +104 -0
- package/dist/way-is-area.js.map +1 -0
- package/dist/zigzag.d.ts +33 -0
- package/dist/zigzag.d.ts.map +1 -0
- package/dist/zigzag.js +40 -0
- package/dist/zigzag.js.map +1 -0
- package/package.json +8 -7
- package/src/color.ts +37 -0
- package/src/progress.ts +23 -4
- package/src/test/fixtures.ts +3 -0
- package/tsconfig.build.json +5 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const hexPattern = /^[0-9a-fA-F]+$/;
|
|
2
|
+
export function normalizeHexColor(value) {
|
|
3
|
+
if (value === null || value === undefined)
|
|
4
|
+
return;
|
|
5
|
+
const raw = String(value).trim();
|
|
6
|
+
if (!raw)
|
|
7
|
+
return;
|
|
8
|
+
let hex = raw.startsWith("#") ? raw.slice(1) : raw;
|
|
9
|
+
if (!hexPattern.test(hex))
|
|
10
|
+
return;
|
|
11
|
+
if (hex.length === 3 || hex.length === 4) {
|
|
12
|
+
hex = hex
|
|
13
|
+
.split("")
|
|
14
|
+
.map((char) => `${char}${char}`)
|
|
15
|
+
.join("");
|
|
16
|
+
}
|
|
17
|
+
else if (hex.length !== 6 && hex.length !== 8) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
return `#${hex.toUpperCase()}`;
|
|
21
|
+
}
|
|
22
|
+
export function hexColorToRgba(value) {
|
|
23
|
+
const normalized = normalizeHexColor(value);
|
|
24
|
+
if (!normalized)
|
|
25
|
+
return;
|
|
26
|
+
const hex = normalized.slice(1);
|
|
27
|
+
const r = Number.parseInt(hex.slice(0, 2), 16);
|
|
28
|
+
const g = Number.parseInt(hex.slice(2, 4), 16);
|
|
29
|
+
const b = Number.parseInt(hex.slice(4, 6), 16);
|
|
30
|
+
const a = hex.length === 8 ? Number.parseInt(hex.slice(6, 8), 16) : 255;
|
|
31
|
+
return [r, g, b, a];
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=color.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.js","sourceRoot":"","sources":["../../src/color.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG,gBAAgB,CAAA;AAEnC,MAAM,UAAU,iBAAiB,CAChC,KAAyC;IAEzC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,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AAA;IAC9C,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAC9C,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IACvE,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;AACpB,CAAC"}
|
package/dist/src/progress.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
+
export type ProgressLevel = "info" | "warn" | "error";
|
|
9
10
|
/**
|
|
10
11
|
* Progress payload containing a message and timestamp.
|
|
11
12
|
* Planned expansion to include percentage completion.
|
|
@@ -13,6 +14,7 @@
|
|
|
13
14
|
export type Progress = {
|
|
14
15
|
msg: string;
|
|
15
16
|
timestamp: number;
|
|
17
|
+
level: ProgressLevel;
|
|
16
18
|
};
|
|
17
19
|
/** CustomEvent carrying progress details. */
|
|
18
20
|
export interface ProgressEvent extends CustomEvent<Progress> {
|
|
@@ -21,12 +23,12 @@ export interface ProgressEvent extends CustomEvent<Progress> {
|
|
|
21
23
|
* Create a Progress payload with current timestamp.
|
|
22
24
|
* @param msg - The progress message.
|
|
23
25
|
*/
|
|
24
|
-
export declare function progress(msg: string): Progress;
|
|
26
|
+
export declare function progress(msg: string, level?: ProgressLevel): Progress;
|
|
25
27
|
/**
|
|
26
28
|
* Create a ProgressEvent with the given message.
|
|
27
29
|
* @param msg - The progress message.
|
|
28
30
|
*/
|
|
29
|
-
export declare function progressEvent(msg: string): ProgressEvent;
|
|
31
|
+
export declare function progressEvent(msg: string, level?: ProgressLevel): ProgressEvent;
|
|
30
32
|
/**
|
|
31
33
|
* Extract the message string from a progress event.
|
|
32
34
|
* @param event - The event to extract from.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../src/progress.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../src/progress.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAErD;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,aAAa,CAAA;CACpB,CAAA;AAED,6CAA6C;AAC7C,MAAM,WAAW,aAAc,SAAQ,WAAW,CAAC,QAAQ,CAAC;CAAG;AAE/D;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,aAAsB,GAAG,QAAQ,CAM7E;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC5B,GAAG,EAAE,MAAM,EACX,KAAK,GAAE,aAAsB,GAC3B,aAAa,CAEf;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAEzD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,aAAa,QAclD"}
|
package/dist/src/progress.js
CHANGED
|
@@ -10,18 +10,19 @@
|
|
|
10
10
|
* Create a Progress payload with current timestamp.
|
|
11
11
|
* @param msg - The progress message.
|
|
12
12
|
*/
|
|
13
|
-
export function progress(msg) {
|
|
13
|
+
export function progress(msg, level = "info") {
|
|
14
14
|
return {
|
|
15
15
|
msg,
|
|
16
16
|
timestamp: Date.now(),
|
|
17
|
+
level,
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
21
|
* Create a ProgressEvent with the given message.
|
|
21
22
|
* @param msg - The progress message.
|
|
22
23
|
*/
|
|
23
|
-
export function progressEvent(msg) {
|
|
24
|
-
return new CustomEvent("progress", { detail: progress(msg) });
|
|
24
|
+
export function progressEvent(msg, level = "info") {
|
|
25
|
+
return new CustomEvent("progress", { detail: progress(msg, level) });
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
27
28
|
* Extract the message string from a progress event.
|
|
@@ -35,6 +36,18 @@ export function progressEventMessage(event) {
|
|
|
35
36
|
* @param progress - The progress event to log.
|
|
36
37
|
*/
|
|
37
38
|
export function logProgress(progress) {
|
|
38
|
-
|
|
39
|
+
const level = progress.detail.level;
|
|
40
|
+
const message = progressEventMessage(progress);
|
|
41
|
+
switch (level) {
|
|
42
|
+
case "info":
|
|
43
|
+
console.log(message);
|
|
44
|
+
break;
|
|
45
|
+
case "warn":
|
|
46
|
+
console.warn(message);
|
|
47
|
+
break;
|
|
48
|
+
case "error":
|
|
49
|
+
console.error(message);
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
39
52
|
}
|
|
40
53
|
//# sourceMappingURL=progress.js.map
|
package/dist/src/progress.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../../src/progress.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../../src/progress.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiBH;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAW,EAAE,QAAuB,MAAM;IAClE,OAAO;QACN,GAAG;QACH,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,KAAK;KACL,CAAA;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC5B,GAAW,EACX,QAAuB,MAAM;IAE7B,OAAO,IAAI,WAAW,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,CAAA;AACrE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAY;IAChD,OAAQ,KAAuB,CAAC,MAAM,CAAC,GAAG,CAAA;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,QAAuB;IAClD,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAA;IACnC,MAAM,OAAO,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;IAC9C,QAAQ,KAAK,EAAE,CAAC;QACf,KAAK,MAAM;YACV,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACpB,MAAK;QACN,KAAK,MAAM;YACV,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YACrB,MAAK;QACN,KAAK,OAAO;YACX,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;YACtB,MAAK;IACP,CAAC;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../../src/test/fixtures.ts"],"names":[],"mappings":"AAOA,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,UAOzC;AAED;;GAEG;AACH,wBAAsB,cAAc,CACnC,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../../src/test/fixtures.ts"],"names":[],"mappings":"AAOA,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,UAOzC;AAED;;GAEG;AACH,wBAAsB,cAAc,CACnC,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAetC;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,2CAEnD;AAED,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,+CAUpD;AAED,MAAM,MAAM,UAAU,GAAG;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE;QACL,MAAM,EAAE,MAAM,CAAA;QACd,GAAG,EAAE,MAAM,CAAA;QACX,IAAI,EAAE,MAAM,CAAA;QACZ,KAAK,EAAE,MAAM,CAAA;KACb,CAAA;IACD,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE;QACN,GAAG,EAAE,MAAM,CAAA;QACX,GAAG,EAAE,MAAM,CAAA;QACX,EAAE,EAAE,MAAM,CAAA;KACV,CAAA;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;CACvB,CAAA;AAiCD,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CA0FrC,CAAA;AAEV;;;GAGG;AACH,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAgC,CAAA"}
|
|
@@ -22,6 +22,9 @@ export async function getFixtureFile(url) {
|
|
|
22
22
|
return new Uint8Array(file);
|
|
23
23
|
}
|
|
24
24
|
catch (_error) {
|
|
25
|
+
if (process.env["CI"]) {
|
|
26
|
+
throw Error(`Do not download fixtures in CI: ${url} not found`);
|
|
27
|
+
}
|
|
25
28
|
const response = await fetch(url);
|
|
26
29
|
const buffer = await response.arrayBuffer();
|
|
27
30
|
const data = new Uint8Array(buffer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../../src/test/fixtures.ts"],"names":[],"mappings":"AAAA,OA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GAAG,EAAE,CAAC,WAAW;YACjB,EAAE,EAAE,QAAQ;SACZ;QACD,IAAI,EAAE,GAAG;QACT,SAAS,EAAE,GAAG;QACd,aAAa,EAAE,OAAO;QACtB,eAAe,EAAE,MAAM;KACvB;CACQ,CAAA;AAEV;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAA+B,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stream to byte array conversion.
|
|
3
|
+
*
|
|
4
|
+
* Consumes a ReadableStream and concatenates all chunks into a single Uint8Array.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Consume a ReadableStream and return all data as a single Uint8Array.
|
|
10
|
+
*
|
|
11
|
+
* Reads all chunks from the stream and concatenates them.
|
|
12
|
+
* The stream will be fully consumed after this function returns.
|
|
13
|
+
*
|
|
14
|
+
* @param stream - The stream to consume.
|
|
15
|
+
* @returns A Promise resolving to the concatenated bytes.
|
|
16
|
+
*/
|
|
17
|
+
export declare function streamToBytes(stream: ReadableStream<Uint8Array<ArrayBuffer>>): Promise<Uint8Array<ArrayBuffer>>;
|
|
18
|
+
//# sourceMappingURL=stream-to-bytes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-to-bytes.d.ts","sourceRoot":"","sources":["../src/stream-to-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAClC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,GAC7C,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAelC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stream to byte array conversion.
|
|
3
|
+
*
|
|
4
|
+
* Consumes a ReadableStream and concatenates all chunks into a single Uint8Array.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { concatBytes } from "./concat-bytes";
|
|
9
|
+
/**
|
|
10
|
+
* Consume a ReadableStream and return all data as a single Uint8Array.
|
|
11
|
+
*
|
|
12
|
+
* Reads all chunks from the stream and concatenates them.
|
|
13
|
+
* The stream will be fully consumed after this function returns.
|
|
14
|
+
*
|
|
15
|
+
* @param stream - The stream to consume.
|
|
16
|
+
* @returns A Promise resolving to the concatenated bytes.
|
|
17
|
+
*/
|
|
18
|
+
export async function streamToBytes(stream) {
|
|
19
|
+
const reader = stream.getReader();
|
|
20
|
+
const chunks = [];
|
|
21
|
+
while (true) {
|
|
22
|
+
const { done, value } = await reader.read();
|
|
23
|
+
if (done) {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
chunks.push(value);
|
|
27
|
+
}
|
|
28
|
+
return concatBytes(chunks);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=stream-to-bytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-to-bytes.js","sourceRoot":"","sources":["../src/stream-to-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAClC,MAA+C;IAE/C,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAA;IACjC,MAAM,MAAM,GAA8B,EAAE,CAAA;IAE5C,OAAO,IAAI,EAAE,CAAC;QACb,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAA;QAE3C,IAAI,IAAI,EAAE,CAAC;YACV,MAAK;QACN,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACnB,CAAC;IAED,OAAO,WAAW,CAAC,MAAM,CAAC,CAAA;AAC3B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare function getFixturePath(url: string): string;
|
|
2
|
+
/**
|
|
3
|
+
* Get file from the cache folder or download it from the URL
|
|
4
|
+
*/
|
|
5
|
+
export declare function getFixtureFile(url: string): Promise<Uint8Array<ArrayBufferLike>>;
|
|
6
|
+
export declare function getFixtureFileReadStream(url: string): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
7
|
+
export declare function getFixtureFileWriteStream(url: string): WritableStream<Uint8Array<ArrayBufferLike>>;
|
|
8
|
+
export type PbfFixture = {
|
|
9
|
+
url: string;
|
|
10
|
+
bbox: {
|
|
11
|
+
bottom: number;
|
|
12
|
+
top: number;
|
|
13
|
+
left: number;
|
|
14
|
+
right: number;
|
|
15
|
+
};
|
|
16
|
+
nodesWithTags: number;
|
|
17
|
+
nodes: number;
|
|
18
|
+
ways: number;
|
|
19
|
+
relations: number;
|
|
20
|
+
node0: {
|
|
21
|
+
lat: number;
|
|
22
|
+
lon: number;
|
|
23
|
+
id: number;
|
|
24
|
+
};
|
|
25
|
+
way0: number;
|
|
26
|
+
relation0: number;
|
|
27
|
+
uniqueStrings: number;
|
|
28
|
+
primitiveGroups: number;
|
|
29
|
+
};
|
|
30
|
+
export declare const AllPBFs: Record<string, PbfFixture>;
|
|
31
|
+
/**
|
|
32
|
+
* A subset of the PBFs that we want to use for current tests. Do not check in changes to this list as it will cause CI to
|
|
33
|
+
* attempt to download PBFs that are not checked into the repository.
|
|
34
|
+
*/
|
|
35
|
+
export declare const PBFs: Record<string, PbfFixture>;
|
|
36
|
+
//# sourceMappingURL=fixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/test/fixtures.ts"],"names":[],"mappings":"AAOA,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,UAOzC;AAED;;GAEG;AACH,wBAAsB,cAAc,CACnC,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAetC;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,2CAEnD;AAED,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,+CAUpD;AAED,MAAM,MAAM,UAAU,GAAG;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE;QACL,MAAM,EAAE,MAAM,CAAA;QACd,GAAG,EAAE,MAAM,CAAA;QACX,IAAI,EAAE,MAAM,CAAA;QACZ,KAAK,EAAE,MAAM,CAAA;KACb,CAAA;IACD,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE;QACN,GAAG,EAAE,MAAM,CAAA;QACX,GAAG,EAAE,MAAM,CAAA;QACX,EAAE,EAAE,MAAM,CAAA;KACV,CAAA;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;CACvB,CAAA;AAiCD,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CA0FrC,CAAA;AAEV;;;GAGG;AACH,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAgC,CAAA"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { dirname, join, resolve } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
4
|
+
const ROOT_DIR = resolve(__dirname, "../../../../");
|
|
5
|
+
const FIXTURES_DIR = resolve(ROOT_DIR, "fixtures");
|
|
6
|
+
export function getFixturePath(url) {
|
|
7
|
+
if (url.startsWith("http")) {
|
|
8
|
+
const fileName = url.split("/").pop();
|
|
9
|
+
if (!fileName)
|
|
10
|
+
throw new Error("Invalid URL");
|
|
11
|
+
return join(FIXTURES_DIR, fileName);
|
|
12
|
+
}
|
|
13
|
+
return join(FIXTURES_DIR, url);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get file from the cache folder or download it from the URL
|
|
17
|
+
*/
|
|
18
|
+
export async function getFixtureFile(url) {
|
|
19
|
+
const filePath = getFixturePath(url);
|
|
20
|
+
try {
|
|
21
|
+
const file = await Bun.file(filePath).arrayBuffer();
|
|
22
|
+
return new Uint8Array(file);
|
|
23
|
+
}
|
|
24
|
+
catch (_error) {
|
|
25
|
+
if (process.env["CI"]) {
|
|
26
|
+
throw Error(`Do not download fixtures in CI: ${url} not found`);
|
|
27
|
+
}
|
|
28
|
+
const response = await fetch(url);
|
|
29
|
+
const buffer = await response.arrayBuffer();
|
|
30
|
+
const data = new Uint8Array(buffer);
|
|
31
|
+
await Bun.write(filePath, data);
|
|
32
|
+
return data;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function getFixtureFileReadStream(url) {
|
|
36
|
+
return Bun.file(getFixturePath(url)).stream();
|
|
37
|
+
}
|
|
38
|
+
export function getFixtureFileWriteStream(url) {
|
|
39
|
+
const incrementalWriter = Bun.file(getFixturePath(url)).writer();
|
|
40
|
+
return new WritableStream({
|
|
41
|
+
write: (chunk) => {
|
|
42
|
+
incrementalWriter.write(chunk);
|
|
43
|
+
},
|
|
44
|
+
close: () => {
|
|
45
|
+
incrementalWriter.end();
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* List of PBFs and their metadata used for testing. Cached locally in the top level fixtures directory so they can
|
|
51
|
+
* be used across packages and apps.
|
|
52
|
+
*
|
|
53
|
+
* `monaco.pbf` is checked into the repository so it can be used in CI without causing repeated downloads.
|
|
54
|
+
*
|
|
55
|
+
* Below, we export a subset of the PBFs that we want to use for current tests.
|
|
56
|
+
*/
|
|
57
|
+
const monacoPbfFixture = {
|
|
58
|
+
url: "monaco.pbf",
|
|
59
|
+
bbox: {
|
|
60
|
+
bottom: 43.7232244,
|
|
61
|
+
top: 43.7543687,
|
|
62
|
+
left: 7.4053929,
|
|
63
|
+
right: 7.4447259,
|
|
64
|
+
},
|
|
65
|
+
nodesWithTags: 1_254,
|
|
66
|
+
nodes: 14_286,
|
|
67
|
+
ways: 3_346,
|
|
68
|
+
relations: 46,
|
|
69
|
+
node0: {
|
|
70
|
+
lat: 43.7371175,
|
|
71
|
+
lon: 7.4229093,
|
|
72
|
+
id: 21911883,
|
|
73
|
+
},
|
|
74
|
+
way0: 4097656,
|
|
75
|
+
relation0: 3410831,
|
|
76
|
+
uniqueStrings: 1_060,
|
|
77
|
+
primitiveGroups: 7,
|
|
78
|
+
};
|
|
79
|
+
export const AllPBFs = {
|
|
80
|
+
monaco: monacoPbfFixture,
|
|
81
|
+
montenegro: {
|
|
82
|
+
url: "https://download.geofabrik.de/europe/montenegro-250101.osm.pbf",
|
|
83
|
+
bbox: {
|
|
84
|
+
bottom: 41.61621,
|
|
85
|
+
top: 43.562169,
|
|
86
|
+
left: 18.17282,
|
|
87
|
+
right: 20.358827,
|
|
88
|
+
},
|
|
89
|
+
nodesWithTags: 63_321,
|
|
90
|
+
nodes: 3_915_383,
|
|
91
|
+
ways: 321_330,
|
|
92
|
+
relations: 5_501,
|
|
93
|
+
node0: {
|
|
94
|
+
lat: 42.1982436,
|
|
95
|
+
lon: 18.9656482,
|
|
96
|
+
id: 26860768,
|
|
97
|
+
},
|
|
98
|
+
way0: 123,
|
|
99
|
+
relation0: 123,
|
|
100
|
+
uniqueStrings: 55_071,
|
|
101
|
+
primitiveGroups: 532,
|
|
102
|
+
},
|
|
103
|
+
croatia: {
|
|
104
|
+
url: "https://download.geofabrik.de/europe/croatia-250101.osm.pbf",
|
|
105
|
+
bbox: {
|
|
106
|
+
bottom: 42.16483,
|
|
107
|
+
top: 46.557562,
|
|
108
|
+
left: 13.08916,
|
|
109
|
+
right: 19.459968,
|
|
110
|
+
},
|
|
111
|
+
nodesWithTags: 481_613,
|
|
112
|
+
nodes: 23_063_621,
|
|
113
|
+
ways: 2_315_247,
|
|
114
|
+
relations: 39_098,
|
|
115
|
+
primitiveGroups: 3_178,
|
|
116
|
+
node0: {
|
|
117
|
+
lat: 42.9738772,
|
|
118
|
+
lon: 17.021989,
|
|
119
|
+
id: 4_511_653,
|
|
120
|
+
},
|
|
121
|
+
way0: 123,
|
|
122
|
+
relation0: 123,
|
|
123
|
+
uniqueStrings: 269_315,
|
|
124
|
+
},
|
|
125
|
+
italy: {
|
|
126
|
+
url: "https://download.geofabrik.de/europe/italy-250101.osm.pbf",
|
|
127
|
+
bbox: {
|
|
128
|
+
bottom: 35.07638,
|
|
129
|
+
left: 6.602696,
|
|
130
|
+
right: 19.12499,
|
|
131
|
+
top: 47.100045,
|
|
132
|
+
},
|
|
133
|
+
nodesWithTags: 1_513_303,
|
|
134
|
+
nodes: 250_818_620,
|
|
135
|
+
ways: 27_837_987,
|
|
136
|
+
relations: 100_000,
|
|
137
|
+
primitiveGroups: 34_901,
|
|
138
|
+
node0: {
|
|
139
|
+
lat: 41.9033,
|
|
140
|
+
lon: 12.4534,
|
|
141
|
+
id: 1,
|
|
142
|
+
},
|
|
143
|
+
way0: 123,
|
|
144
|
+
relation0: 123,
|
|
145
|
+
uniqueStrings: 3190,
|
|
146
|
+
},
|
|
147
|
+
washington: {
|
|
148
|
+
url: "https://download.geofabrik.de/north-america/us/washington-250101.osm.pbf",
|
|
149
|
+
bbox: {
|
|
150
|
+
bottom: 45.53882,
|
|
151
|
+
top: 49.00708,
|
|
152
|
+
left: -126.7423,
|
|
153
|
+
right: -116.911526,
|
|
154
|
+
},
|
|
155
|
+
nodesWithTags: 1_513_303,
|
|
156
|
+
nodes: 43_032_447,
|
|
157
|
+
ways: 4_541_651,
|
|
158
|
+
relations: 44_373,
|
|
159
|
+
node0: {
|
|
160
|
+
lat: 47.64248,
|
|
161
|
+
lon: -122.3196898,
|
|
162
|
+
id: 29445653,
|
|
163
|
+
},
|
|
164
|
+
way0: 123,
|
|
165
|
+
relation0: 123,
|
|
166
|
+
uniqueStrings: 598_993,
|
|
167
|
+
primitiveGroups: 34_901,
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* A subset of the PBFs that we want to use for current tests. Do not check in changes to this list as it will cause CI to
|
|
172
|
+
* attempt to download PBFs that are not checked into the repository.
|
|
173
|
+
*/
|
|
174
|
+
export const PBFs = { monaco: monacoPbfFixture };
|
|
175
|
+
//# sourceMappingURL=fixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../src/test/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AACzD,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;AACnD,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;AAElD,MAAM,UAAU,cAAc,CAAC,GAAW;IACzC,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAA;QACrC,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;QAC7C,OAAO,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;IACpC,CAAC;IACD,OAAO,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAA;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,CAAC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}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throttling utilities for rate-limiting function calls.
|
|
3
|
+
*
|
|
4
|
+
* Useful for limiting progress updates from workers or other high-frequency
|
|
5
|
+
* operations to avoid overwhelming the UI or logging.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Create a throttled version of a function that only executes at most
|
|
11
|
+
* once per `timeFrame` milliseconds.
|
|
12
|
+
*
|
|
13
|
+
* @param func - The function to throttle.
|
|
14
|
+
* @param timeFrame - Minimum time between calls in milliseconds.
|
|
15
|
+
* @returns A throttled version of the function.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const logThrottled = throttle((msg) => console.log(msg), 1000)
|
|
20
|
+
* // Only logs at most once per second
|
|
21
|
+
* for (let i = 0; i < 1000; i++) logThrottled(`Progress: ${i}`)
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function throttle<T extends unknown[]>(func: (...args: T) => void, timeFrame: number): (...args: T) => void;
|
|
25
|
+
//# sourceMappingURL=throttle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../src/throttle.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,OAAO,EAAE,EAC3C,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,EAC1B,SAAS,EAAE,MAAM,IAGT,GAAG,MAAM,CAAC,UAOlB"}
|
package/dist/throttle.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throttling utilities for rate-limiting function calls.
|
|
3
|
+
*
|
|
4
|
+
* Useful for limiting progress updates from workers or other high-frequency
|
|
5
|
+
* operations to avoid overwhelming the UI or logging.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Create a throttled version of a function that only executes at most
|
|
11
|
+
* once per `timeFrame` milliseconds.
|
|
12
|
+
*
|
|
13
|
+
* @param func - The function to throttle.
|
|
14
|
+
* @param timeFrame - Minimum time between calls in milliseconds.
|
|
15
|
+
* @returns A throttled version of the function.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const logThrottled = throttle((msg) => console.log(msg), 1000)
|
|
20
|
+
* // Only logs at most once per second
|
|
21
|
+
* for (let i = 0; i < 1000; i++) logThrottled(`Progress: ${i}`)
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export function throttle(func, timeFrame) {
|
|
25
|
+
let lastTime = 0;
|
|
26
|
+
return (...args) => {
|
|
27
|
+
const now = Date.now();
|
|
28
|
+
if (now - lastTime >= timeFrame) {
|
|
29
|
+
func(...args);
|
|
30
|
+
lastTime = now;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=throttle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throttle.js","sourceRoot":"","sources":["../src/throttle.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,QAAQ,CACvB,IAA0B,EAC1B,SAAiB;IAEjB,IAAI,QAAQ,GAAG,CAAC,CAAA;IAChB,OAAO,CAAC,GAAG,IAAO,EAAE,EAAE;QACrB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACtB,IAAI,GAAG,GAAG,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;YACb,QAAQ,GAAG,GAAG,CAAA;QACf,CAAC;IACF,CAAC,CAAA;AACF,CAAC"}
|
package/dist/tile.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XYZ tile coordinate utilities.
|
|
3
|
+
*
|
|
4
|
+
* Provides conversions between geographic coordinates (lon/lat) and
|
|
5
|
+
* tile pixel coordinates for XYZ tiled map systems. Supports various
|
|
6
|
+
* tile sizes and zoom levels.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import type { GeoBbox2D, LonLat, Tile, TilePxBbox, XY } from "./types";
|
|
11
|
+
/**
|
|
12
|
+
* Get the geographic bounding box of a tile.
|
|
13
|
+
* Returns [west, south, east, north].
|
|
14
|
+
*/
|
|
15
|
+
export declare function tileToBbox(tile: Tile): GeoBbox2D;
|
|
16
|
+
/**
|
|
17
|
+
* Convert a bounding box from geographic coordinates to tile pixel coordinates.
|
|
18
|
+
*/
|
|
19
|
+
export declare function bboxToTilePx(bbox: GeoBbox2D, tile: Tile, tileSize?: number): TilePxBbox;
|
|
20
|
+
/**
|
|
21
|
+
* Convert a geographic coordinate to tile pixel coordinates.
|
|
22
|
+
* Returns [x, y] in pixels relative to the top-left of the tile.
|
|
23
|
+
*/
|
|
24
|
+
export declare function llToTilePx(ll: LonLat, tile: Tile, tileSize?: number): XY;
|
|
25
|
+
/**
|
|
26
|
+
* Convert tile pixel coordinates to geographic coordinates.
|
|
27
|
+
*/
|
|
28
|
+
export declare function tilePxToLonLat(px: XY, tile: Tile, tileSize?: number): LonLat;
|
|
29
|
+
/**
|
|
30
|
+
* Clamp a pixel coordinate to the tile bounds and round to the nearest integer. Useful for converting a floating point pixel
|
|
31
|
+
* coordinate to a the exact tile pixel it is contained by.
|
|
32
|
+
*/
|
|
33
|
+
export declare function clampAndRoundPx(px: XY, tileSizeOrBbox: number | GeoBbox2D): XY;
|
|
34
|
+
//# sourceMappingURL=tile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tile.d.ts","sourceRoot":"","sources":["../src/tile.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAatE;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,CAOhD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC3B,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,IAAI,EACV,QAAQ,SAAM,GACZ,UAAU,CAIZ;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,SAAM,GAAG,EAAE,CAMrE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,SAAM,GAAG,MAAM,CAKzE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC9B,EAAE,EAAE,EAAE,EACN,cAAc,EAAE,MAAM,GAAG,SAAS,GAChC,EAAE,CASJ"}
|
package/dist/tile.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XYZ tile coordinate utilities.
|
|
3
|
+
*
|
|
4
|
+
* Provides conversions between geographic coordinates (lon/lat) and
|
|
5
|
+
* tile pixel coordinates for XYZ tiled map systems. Supports various
|
|
6
|
+
* tile sizes and zoom levels.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { pointToTileFraction } from "@mapbox/tilebelt";
|
|
11
|
+
const RADIANS_TO_DEGREES = 180 / Math.PI;
|
|
12
|
+
function tile2lon(x, z) {
|
|
13
|
+
return (x / 2 ** z) * 360 - 180;
|
|
14
|
+
}
|
|
15
|
+
function tile2lat(y, z) {
|
|
16
|
+
const n = Math.PI - (2 * Math.PI * y) / 2 ** z;
|
|
17
|
+
return RADIANS_TO_DEGREES * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get the geographic bounding box of a tile.
|
|
21
|
+
* Returns [west, south, east, north].
|
|
22
|
+
*/
|
|
23
|
+
export function tileToBbox(tile) {
|
|
24
|
+
const [tx, ty, tz] = tile;
|
|
25
|
+
const n = tile2lat(ty, tz);
|
|
26
|
+
const s = tile2lat(ty + 1, tz);
|
|
27
|
+
const e = tile2lon(tx + 1, tz);
|
|
28
|
+
const w = tile2lon(tx, tz);
|
|
29
|
+
return [w, s, e, n];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Convert a bounding box from geographic coordinates to tile pixel coordinates.
|
|
33
|
+
*/
|
|
34
|
+
export function bboxToTilePx(bbox, tile, tileSize = 256) {
|
|
35
|
+
const [minX, minY] = llToTilePx([bbox[0], bbox[3]], tile, tileSize);
|
|
36
|
+
const [maxX, maxY] = llToTilePx([bbox[2], bbox[1]], tile, tileSize);
|
|
37
|
+
return [minX, minY, maxX, maxY];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Convert a geographic coordinate to tile pixel coordinates.
|
|
41
|
+
* Returns [x, y] in pixels relative to the top-left of the tile.
|
|
42
|
+
*/
|
|
43
|
+
export function llToTilePx(ll, tile, tileSize = 256) {
|
|
44
|
+
const [tx, ty, tz] = tile;
|
|
45
|
+
const tf = pointToTileFraction(ll[0], ll[1], tz);
|
|
46
|
+
const x = (tf[0] - tx) * tileSize;
|
|
47
|
+
const y = (tf[1] - ty) * tileSize;
|
|
48
|
+
return [x, y];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Convert tile pixel coordinates to geographic coordinates.
|
|
52
|
+
*/
|
|
53
|
+
export function tilePxToLonLat(px, tile, tileSize = 256) {
|
|
54
|
+
const [tx, ty, tz] = tile;
|
|
55
|
+
const lon = tile2lon(px[0] / tileSize + tx, tz);
|
|
56
|
+
const lat = tile2lat(px[1] / tileSize + ty, tz);
|
|
57
|
+
return [lon, lat];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Clamp a pixel coordinate to the tile bounds and round to the nearest integer. Useful for converting a floating point pixel
|
|
61
|
+
* coordinate to a the exact tile pixel it is contained by.
|
|
62
|
+
*/
|
|
63
|
+
export function clampAndRoundPx(px, tileSizeOrBbox) {
|
|
64
|
+
const [minX, minY, maxX, maxY] = typeof tileSizeOrBbox === "number"
|
|
65
|
+
? [0, 0, tileSizeOrBbox, tileSizeOrBbox]
|
|
66
|
+
: tileSizeOrBbox;
|
|
67
|
+
return [
|
|
68
|
+
Math.max(minX, Math.min(maxX, Math.round(px[0]))),
|
|
69
|
+
Math.max(minY, Math.min(maxY, Math.round(px[1]))),
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=tile.js.map
|
package/dist/tile.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tile.js","sourceRoot":"","sources":["../src/tile.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAGtD,MAAM,kBAAkB,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,CAAA;AAExC,SAAS,QAAQ,CAAC,CAAS,EAAE,CAAS;IACrC,OAAO,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,CAAA;AAChC,CAAC;AAED,SAAS,QAAQ,CAAC,CAAS,EAAE,CAAS;IACrC,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC9C,OAAO,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAA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