@xyo-network/quadkey 2.81.7 → 2.82.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/Quadkey.d.cts +13 -40
- package/dist/browser/Quadkey.d.cts.map +1 -1
- package/dist/browser/Quadkey.d.mts +13 -40
- package/dist/browser/Quadkey.d.mts.map +1 -1
- package/dist/browser/Quadkey.d.ts +13 -40
- package/dist/browser/Quadkey.d.ts.map +1 -1
- package/dist/browser/index.cjs +46 -158
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +46 -158
- package/dist/browser/index.js.map +1 -1
- package/dist/node/Quadkey.d.cts +13 -40
- package/dist/node/Quadkey.d.cts.map +1 -1
- package/dist/node/Quadkey.d.mts +13 -40
- package/dist/node/Quadkey.d.mts.map +1 -1
- package/dist/node/Quadkey.d.ts +13 -40
- package/dist/node/Quadkey.d.ts.map +1 -1
- package/dist/node/index.cjs +47 -163
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +46 -159
- package/dist/node/index.js.map +1 -1
- package/package.json +6 -6
- package/src/Quadkey.ts +48 -132
- package/dist/browser/utils.d.cts +0 -6
- package/dist/browser/utils.d.cts.map +0 -1
- package/dist/browser/utils.d.mts +0 -6
- package/dist/browser/utils.d.mts.map +0 -1
- package/dist/browser/utils.d.ts +0 -6
- package/dist/browser/utils.d.ts.map +0 -1
- package/dist/node/utils.d.cts +0 -6
- package/dist/node/utils.d.cts.map +0 -1
- package/dist/node/utils.d.mts +0 -6
- package/dist/node/utils.d.mts.map +0 -1
- package/dist/node/utils.d.ts +0 -6
- package/dist/node/utils.d.ts.map +0 -1
- package/src/utils.ts +0 -40
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { BigNumber } from '@xylabs/bignumber';
|
|
3
|
-
import { Buffer } from '@xylabs/buffer';
|
|
4
1
|
import { GeoJson, MercatorBoundingBox, MercatorTile } from '@xyo-network/sdk-geo';
|
|
5
2
|
import { LngLat, LngLatLike } from 'mapbox-gl';
|
|
6
|
-
export * from './utils';
|
|
7
3
|
export declare const isQuadkey: (obj: {
|
|
8
4
|
type: string;
|
|
9
5
|
}) => boolean;
|
|
10
6
|
export declare class Quadkey {
|
|
7
|
+
private key;
|
|
11
8
|
static Zero: Quadkey;
|
|
12
9
|
static root: Quadkey;
|
|
13
10
|
static type: string;
|
|
14
11
|
type: string;
|
|
15
12
|
private _geoJson?;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
get base10String(): string;
|
|
13
|
+
constructor(key?: bigint);
|
|
14
|
+
get base16String(): string;
|
|
19
15
|
get base4Hash(): string;
|
|
20
16
|
get base4HashLabel(): string;
|
|
21
|
-
get bigNumber(): BigNumber;
|
|
22
17
|
get boundingBox(): MercatorBoundingBox;
|
|
23
|
-
get buffer():
|
|
18
|
+
get buffer(): bigint;
|
|
24
19
|
get center(): LngLat;
|
|
25
20
|
get children(): Quadkey[];
|
|
26
21
|
get gridLocation(): {
|
|
@@ -28,25 +23,22 @@ export declare class Quadkey {
|
|
|
28
23
|
row: number;
|
|
29
24
|
zoom: number;
|
|
30
25
|
};
|
|
31
|
-
get
|
|
32
|
-
get id(): Buffer;
|
|
26
|
+
get id(): bigint;
|
|
33
27
|
get parent(): Quadkey | undefined;
|
|
34
28
|
get siblings(): Quadkey[];
|
|
35
29
|
get tile(): MercatorTile;
|
|
36
30
|
get valid(): boolean;
|
|
37
31
|
get zoom(): number;
|
|
38
|
-
static from(zoom: number, id:
|
|
39
|
-
static
|
|
32
|
+
static from(zoom: number, id: bigint): Quadkey;
|
|
33
|
+
static fromArrayBuffer(zoom: number, id: ArrayBuffer): Quadkey;
|
|
40
34
|
static fromBase16String(value: string): Quadkey;
|
|
41
|
-
static fromBase4String(value?: string): Quadkey
|
|
35
|
+
static fromBase4String(value?: string): Quadkey;
|
|
42
36
|
static fromBoundingBox(boundingBox: MercatorBoundingBox, zoom: number): Quadkey[];
|
|
43
|
-
static
|
|
44
|
-
static fromLngLat(point: LngLatLike, zoom: number): Quadkey | undefined;
|
|
37
|
+
static fromLngLat(point: LngLatLike, zoom: number): Quadkey;
|
|
45
38
|
static fromString(zoom: number, id: string, base?: number): Quadkey;
|
|
46
|
-
static fromTile(tile: MercatorTile): Quadkey
|
|
39
|
+
static fromTile(tile: MercatorTile): Quadkey;
|
|
47
40
|
childrenByZoom(zoom: number): Quadkey[];
|
|
48
41
|
clone(): Quadkey;
|
|
49
|
-
compareTo(quadkey: Quadkey): 0 | 1 | -1;
|
|
50
42
|
equals(obj: Quadkey): boolean;
|
|
51
43
|
geoJson(): GeoJson;
|
|
52
44
|
getGridBoundingBox(size: number): {
|
|
@@ -62,31 +54,12 @@ export declare class Quadkey {
|
|
|
62
54
|
zoom: number;
|
|
63
55
|
};
|
|
64
56
|
isInBoundingBox(boundingBox: MercatorBoundingBox): boolean;
|
|
65
|
-
relative(direction: string): Quadkey
|
|
66
|
-
setId(id:
|
|
67
|
-
setKey(zoom: number,
|
|
57
|
+
relative(direction: string): Quadkey;
|
|
58
|
+
setId(id: bigint): this;
|
|
59
|
+
setKey(zoom: number, key: bigint): this;
|
|
68
60
|
setZoom(zoom: number): this;
|
|
69
|
-
/** @deprecated use .base10String*/
|
|
70
|
-
toBase10String(): string;
|
|
71
|
-
/** @deprecated use .base4Hash */
|
|
72
|
-
toBase4Hash(): string;
|
|
73
|
-
/** @deprecated use .base4HashLabel */
|
|
74
|
-
toBase4HashLabel(): string;
|
|
75
|
-
/** @deprecated use .bigNumber */
|
|
76
|
-
toBigNumber(): BigNumber;
|
|
77
|
-
/** @deprecated use .boundingBox */
|
|
78
|
-
toBoundingBox(): MercatorBoundingBox;
|
|
79
|
-
/** @deprecated use .buffer */
|
|
80
|
-
toBuffer(): Buffer;
|
|
81
|
-
/** @deprecated use .center */
|
|
82
|
-
toCenter(): LngLat;
|
|
83
|
-
/** @deprecated use .hex instead */
|
|
84
|
-
toHex(): string;
|
|
85
61
|
toJSON(): string;
|
|
86
|
-
toShortString(): string;
|
|
87
62
|
toString(): string;
|
|
88
|
-
/** @deprecated use .tile instead */
|
|
89
|
-
toTile(): MercatorTile;
|
|
90
63
|
protected guessZoom(): void;
|
|
91
64
|
}
|
|
92
65
|
//# sourceMappingURL=Quadkey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Quadkey.d.ts","sourceRoot":"","sources":["../../src/Quadkey.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Quadkey.d.ts","sourceRoot":"","sources":["../../src/Quadkey.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,OAAO,EACP,mBAAmB,EACnB,YAAY,EAMb,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAM9C,eAAO,MAAM,SAAS,QAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,YAA+B,CAAA;AAU9E,qBAAa,OAAO;IASN,OAAO,CAAC,GAAG;IARvB,MAAM,CAAC,IAAI,UAAsB;IACjC,MAAM,CAAC,IAAI,UAAgB;IAC3B,MAAM,CAAC,IAAI,SAAY;IAEvB,IAAI,SAAe;IAEnB,OAAO,CAAC,QAAQ,CAAC,CAAS;gBAEN,GAAG,SAAK;IAK5B,IAAI,YAAY,WAEf;IAED,IAAI,SAAS,WAEZ;IAED,IAAI,cAAc,WAGjB;IAED,IAAI,WAAW,IAAI,mBAAmB,CAErC;IAED,IAAI,MAAM,WAET;IAED,IAAI,MAAM,WAGT;IAED,IAAI,QAAQ,cAQX;IAED,IAAI,YAAY;;;;MAQf;IAED,IAAI,EAAE,WAEL;IAED,IAAI,MAAM,IAAI,OAAO,GAAG,SAAS,CAIhC;IAED,IAAI,QAAQ,cAKX;IAED,IAAI,IAAI,IAAI,YAAY,CAEvB;IAED,IAAI,KAAK,YAGR;IAED,IAAI,IAAI,WAGP;IAED,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAIpC,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW;IAIpD,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM;IAIrC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM;IAarC,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM;IAUrE,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM;IAMjD,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,SAAK;IASrD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY;IAIlC,cAAc,CAAC,IAAI,EAAE,MAAM;IAc3B,KAAK;IAIL,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO;IAI7B,OAAO;IAKP,kBAAkB,CAAC,IAAI,EAAE,MAAM;;;;;;IAiC/B,4CAA4C;IAC5C,eAAe;;;;;IAIf,eAAe,CAAC,WAAW,EAAE,mBAAmB;IAUhD,QAAQ,CAAC,SAAS,EAAE,MAAM;IAyB1B,KAAK,CAAC,EAAE,EAAE,MAAM;IAMhB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAOhC,OAAO,CAAC,IAAI,EAAE,MAAM;IAMpB,MAAM,IAAI,MAAM;IAIhB,QAAQ;IAIR,SAAS,CAAC,SAAS;CAIpB"}
|
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { BigNumber } from '@xylabs/bignumber';
|
|
3
|
-
import { Buffer } from '@xylabs/buffer';
|
|
4
1
|
import { GeoJson, MercatorBoundingBox, MercatorTile } from '@xyo-network/sdk-geo';
|
|
5
2
|
import { LngLat, LngLatLike } from 'mapbox-gl';
|
|
6
|
-
export * from './utils';
|
|
7
3
|
export declare const isQuadkey: (obj: {
|
|
8
4
|
type: string;
|
|
9
5
|
}) => boolean;
|
|
10
6
|
export declare class Quadkey {
|
|
7
|
+
private key;
|
|
11
8
|
static Zero: Quadkey;
|
|
12
9
|
static root: Quadkey;
|
|
13
10
|
static type: string;
|
|
14
11
|
type: string;
|
|
15
12
|
private _geoJson?;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
get base10String(): string;
|
|
13
|
+
constructor(key?: bigint);
|
|
14
|
+
get base16String(): string;
|
|
19
15
|
get base4Hash(): string;
|
|
20
16
|
get base4HashLabel(): string;
|
|
21
|
-
get bigNumber(): BigNumber;
|
|
22
17
|
get boundingBox(): MercatorBoundingBox;
|
|
23
|
-
get buffer():
|
|
18
|
+
get buffer(): bigint;
|
|
24
19
|
get center(): LngLat;
|
|
25
20
|
get children(): Quadkey[];
|
|
26
21
|
get gridLocation(): {
|
|
@@ -28,25 +23,22 @@ export declare class Quadkey {
|
|
|
28
23
|
row: number;
|
|
29
24
|
zoom: number;
|
|
30
25
|
};
|
|
31
|
-
get
|
|
32
|
-
get id(): Buffer;
|
|
26
|
+
get id(): bigint;
|
|
33
27
|
get parent(): Quadkey | undefined;
|
|
34
28
|
get siblings(): Quadkey[];
|
|
35
29
|
get tile(): MercatorTile;
|
|
36
30
|
get valid(): boolean;
|
|
37
31
|
get zoom(): number;
|
|
38
|
-
static from(zoom: number, id:
|
|
39
|
-
static
|
|
32
|
+
static from(zoom: number, id: bigint): Quadkey;
|
|
33
|
+
static fromArrayBuffer(zoom: number, id: ArrayBuffer): Quadkey;
|
|
40
34
|
static fromBase16String(value: string): Quadkey;
|
|
41
|
-
static fromBase4String(value?: string): Quadkey
|
|
35
|
+
static fromBase4String(value?: string): Quadkey;
|
|
42
36
|
static fromBoundingBox(boundingBox: MercatorBoundingBox, zoom: number): Quadkey[];
|
|
43
|
-
static
|
|
44
|
-
static fromLngLat(point: LngLatLike, zoom: number): Quadkey | undefined;
|
|
37
|
+
static fromLngLat(point: LngLatLike, zoom: number): Quadkey;
|
|
45
38
|
static fromString(zoom: number, id: string, base?: number): Quadkey;
|
|
46
|
-
static fromTile(tile: MercatorTile): Quadkey
|
|
39
|
+
static fromTile(tile: MercatorTile): Quadkey;
|
|
47
40
|
childrenByZoom(zoom: number): Quadkey[];
|
|
48
41
|
clone(): Quadkey;
|
|
49
|
-
compareTo(quadkey: Quadkey): 0 | 1 | -1;
|
|
50
42
|
equals(obj: Quadkey): boolean;
|
|
51
43
|
geoJson(): GeoJson;
|
|
52
44
|
getGridBoundingBox(size: number): {
|
|
@@ -62,31 +54,12 @@ export declare class Quadkey {
|
|
|
62
54
|
zoom: number;
|
|
63
55
|
};
|
|
64
56
|
isInBoundingBox(boundingBox: MercatorBoundingBox): boolean;
|
|
65
|
-
relative(direction: string): Quadkey
|
|
66
|
-
setId(id:
|
|
67
|
-
setKey(zoom: number,
|
|
57
|
+
relative(direction: string): Quadkey;
|
|
58
|
+
setId(id: bigint): this;
|
|
59
|
+
setKey(zoom: number, key: bigint): this;
|
|
68
60
|
setZoom(zoom: number): this;
|
|
69
|
-
/** @deprecated use .base10String*/
|
|
70
|
-
toBase10String(): string;
|
|
71
|
-
/** @deprecated use .base4Hash */
|
|
72
|
-
toBase4Hash(): string;
|
|
73
|
-
/** @deprecated use .base4HashLabel */
|
|
74
|
-
toBase4HashLabel(): string;
|
|
75
|
-
/** @deprecated use .bigNumber */
|
|
76
|
-
toBigNumber(): BigNumber;
|
|
77
|
-
/** @deprecated use .boundingBox */
|
|
78
|
-
toBoundingBox(): MercatorBoundingBox;
|
|
79
|
-
/** @deprecated use .buffer */
|
|
80
|
-
toBuffer(): Buffer;
|
|
81
|
-
/** @deprecated use .center */
|
|
82
|
-
toCenter(): LngLat;
|
|
83
|
-
/** @deprecated use .hex instead */
|
|
84
|
-
toHex(): string;
|
|
85
61
|
toJSON(): string;
|
|
86
|
-
toShortString(): string;
|
|
87
62
|
toString(): string;
|
|
88
|
-
/** @deprecated use .tile instead */
|
|
89
|
-
toTile(): MercatorTile;
|
|
90
63
|
protected guessZoom(): void;
|
|
91
64
|
}
|
|
92
65
|
//# sourceMappingURL=Quadkey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Quadkey.d.ts","sourceRoot":"","sources":["../../src/Quadkey.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Quadkey.d.ts","sourceRoot":"","sources":["../../src/Quadkey.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,OAAO,EACP,mBAAmB,EACnB,YAAY,EAMb,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAM9C,eAAO,MAAM,SAAS,QAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,YAA+B,CAAA;AAU9E,qBAAa,OAAO;IASN,OAAO,CAAC,GAAG;IARvB,MAAM,CAAC,IAAI,UAAsB;IACjC,MAAM,CAAC,IAAI,UAAgB;IAC3B,MAAM,CAAC,IAAI,SAAY;IAEvB,IAAI,SAAe;IAEnB,OAAO,CAAC,QAAQ,CAAC,CAAS;gBAEN,GAAG,SAAK;IAK5B,IAAI,YAAY,WAEf;IAED,IAAI,SAAS,WAEZ;IAED,IAAI,cAAc,WAGjB;IAED,IAAI,WAAW,IAAI,mBAAmB,CAErC;IAED,IAAI,MAAM,WAET;IAED,IAAI,MAAM,WAGT;IAED,IAAI,QAAQ,cAQX;IAED,IAAI,YAAY;;;;MAQf;IAED,IAAI,EAAE,WAEL;IAED,IAAI,MAAM,IAAI,OAAO,GAAG,SAAS,CAIhC;IAED,IAAI,QAAQ,cAKX;IAED,IAAI,IAAI,IAAI,YAAY,CAEvB;IAED,IAAI,KAAK,YAGR;IAED,IAAI,IAAI,WAGP;IAED,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAIpC,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW;IAIpD,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM;IAIrC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM;IAarC,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM;IAUrE,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM;IAMjD,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,SAAK;IASrD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY;IAIlC,cAAc,CAAC,IAAI,EAAE,MAAM;IAc3B,KAAK;IAIL,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO;IAI7B,OAAO;IAKP,kBAAkB,CAAC,IAAI,EAAE,MAAM;;;;;;IAiC/B,4CAA4C;IAC5C,eAAe;;;;;IAIf,eAAe,CAAC,WAAW,EAAE,mBAAmB;IAUhD,QAAQ,CAAC,SAAS,EAAE,MAAM;IAyB1B,KAAK,CAAC,EAAE,EAAE,MAAM;IAMhB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAOhC,OAAO,CAAC,IAAI,EAAE,MAAM;IAMpB,MAAM,IAAI,MAAM;IAIhB,QAAQ;IAIR,SAAS,CAAC,SAAS;CAIpB"}
|
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { BigNumber } from '@xylabs/bignumber';
|
|
3
|
-
import { Buffer } from '@xylabs/buffer';
|
|
4
1
|
import { GeoJson, MercatorBoundingBox, MercatorTile } from '@xyo-network/sdk-geo';
|
|
5
2
|
import { LngLat, LngLatLike } from 'mapbox-gl';
|
|
6
|
-
export * from './utils';
|
|
7
3
|
export declare const isQuadkey: (obj: {
|
|
8
4
|
type: string;
|
|
9
5
|
}) => boolean;
|
|
10
6
|
export declare class Quadkey {
|
|
7
|
+
private key;
|
|
11
8
|
static Zero: Quadkey;
|
|
12
9
|
static root: Quadkey;
|
|
13
10
|
static type: string;
|
|
14
11
|
type: string;
|
|
15
12
|
private _geoJson?;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
get base10String(): string;
|
|
13
|
+
constructor(key?: bigint);
|
|
14
|
+
get base16String(): string;
|
|
19
15
|
get base4Hash(): string;
|
|
20
16
|
get base4HashLabel(): string;
|
|
21
|
-
get bigNumber(): BigNumber;
|
|
22
17
|
get boundingBox(): MercatorBoundingBox;
|
|
23
|
-
get buffer():
|
|
18
|
+
get buffer(): bigint;
|
|
24
19
|
get center(): LngLat;
|
|
25
20
|
get children(): Quadkey[];
|
|
26
21
|
get gridLocation(): {
|
|
@@ -28,25 +23,22 @@ export declare class Quadkey {
|
|
|
28
23
|
row: number;
|
|
29
24
|
zoom: number;
|
|
30
25
|
};
|
|
31
|
-
get
|
|
32
|
-
get id(): Buffer;
|
|
26
|
+
get id(): bigint;
|
|
33
27
|
get parent(): Quadkey | undefined;
|
|
34
28
|
get siblings(): Quadkey[];
|
|
35
29
|
get tile(): MercatorTile;
|
|
36
30
|
get valid(): boolean;
|
|
37
31
|
get zoom(): number;
|
|
38
|
-
static from(zoom: number, id:
|
|
39
|
-
static
|
|
32
|
+
static from(zoom: number, id: bigint): Quadkey;
|
|
33
|
+
static fromArrayBuffer(zoom: number, id: ArrayBuffer): Quadkey;
|
|
40
34
|
static fromBase16String(value: string): Quadkey;
|
|
41
|
-
static fromBase4String(value?: string): Quadkey
|
|
35
|
+
static fromBase4String(value?: string): Quadkey;
|
|
42
36
|
static fromBoundingBox(boundingBox: MercatorBoundingBox, zoom: number): Quadkey[];
|
|
43
|
-
static
|
|
44
|
-
static fromLngLat(point: LngLatLike, zoom: number): Quadkey | undefined;
|
|
37
|
+
static fromLngLat(point: LngLatLike, zoom: number): Quadkey;
|
|
45
38
|
static fromString(zoom: number, id: string, base?: number): Quadkey;
|
|
46
|
-
static fromTile(tile: MercatorTile): Quadkey
|
|
39
|
+
static fromTile(tile: MercatorTile): Quadkey;
|
|
47
40
|
childrenByZoom(zoom: number): Quadkey[];
|
|
48
41
|
clone(): Quadkey;
|
|
49
|
-
compareTo(quadkey: Quadkey): 0 | 1 | -1;
|
|
50
42
|
equals(obj: Quadkey): boolean;
|
|
51
43
|
geoJson(): GeoJson;
|
|
52
44
|
getGridBoundingBox(size: number): {
|
|
@@ -62,31 +54,12 @@ export declare class Quadkey {
|
|
|
62
54
|
zoom: number;
|
|
63
55
|
};
|
|
64
56
|
isInBoundingBox(boundingBox: MercatorBoundingBox): boolean;
|
|
65
|
-
relative(direction: string): Quadkey
|
|
66
|
-
setId(id:
|
|
67
|
-
setKey(zoom: number,
|
|
57
|
+
relative(direction: string): Quadkey;
|
|
58
|
+
setId(id: bigint): this;
|
|
59
|
+
setKey(zoom: number, key: bigint): this;
|
|
68
60
|
setZoom(zoom: number): this;
|
|
69
|
-
/** @deprecated use .base10String*/
|
|
70
|
-
toBase10String(): string;
|
|
71
|
-
/** @deprecated use .base4Hash */
|
|
72
|
-
toBase4Hash(): string;
|
|
73
|
-
/** @deprecated use .base4HashLabel */
|
|
74
|
-
toBase4HashLabel(): string;
|
|
75
|
-
/** @deprecated use .bigNumber */
|
|
76
|
-
toBigNumber(): BigNumber;
|
|
77
|
-
/** @deprecated use .boundingBox */
|
|
78
|
-
toBoundingBox(): MercatorBoundingBox;
|
|
79
|
-
/** @deprecated use .buffer */
|
|
80
|
-
toBuffer(): Buffer;
|
|
81
|
-
/** @deprecated use .center */
|
|
82
|
-
toCenter(): LngLat;
|
|
83
|
-
/** @deprecated use .hex instead */
|
|
84
|
-
toHex(): string;
|
|
85
61
|
toJSON(): string;
|
|
86
|
-
toShortString(): string;
|
|
87
62
|
toString(): string;
|
|
88
|
-
/** @deprecated use .tile instead */
|
|
89
|
-
toTile(): MercatorTile;
|
|
90
63
|
protected guessZoom(): void;
|
|
91
64
|
}
|
|
92
65
|
//# sourceMappingURL=Quadkey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Quadkey.d.ts","sourceRoot":"","sources":["../../src/Quadkey.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Quadkey.d.ts","sourceRoot":"","sources":["../../src/Quadkey.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,OAAO,EACP,mBAAmB,EACnB,YAAY,EAMb,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAM9C,eAAO,MAAM,SAAS,QAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,YAA+B,CAAA;AAU9E,qBAAa,OAAO;IASN,OAAO,CAAC,GAAG;IARvB,MAAM,CAAC,IAAI,UAAsB;IACjC,MAAM,CAAC,IAAI,UAAgB;IAC3B,MAAM,CAAC,IAAI,SAAY;IAEvB,IAAI,SAAe;IAEnB,OAAO,CAAC,QAAQ,CAAC,CAAS;gBAEN,GAAG,SAAK;IAK5B,IAAI,YAAY,WAEf;IAED,IAAI,SAAS,WAEZ;IAED,IAAI,cAAc,WAGjB;IAED,IAAI,WAAW,IAAI,mBAAmB,CAErC;IAED,IAAI,MAAM,WAET;IAED,IAAI,MAAM,WAGT;IAED,IAAI,QAAQ,cAQX;IAED,IAAI,YAAY;;;;MAQf;IAED,IAAI,EAAE,WAEL;IAED,IAAI,MAAM,IAAI,OAAO,GAAG,SAAS,CAIhC;IAED,IAAI,QAAQ,cAKX;IAED,IAAI,IAAI,IAAI,YAAY,CAEvB;IAED,IAAI,KAAK,YAGR;IAED,IAAI,IAAI,WAGP;IAED,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAIpC,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW;IAIpD,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM;IAIrC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM;IAarC,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM;IAUrE,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM;IAMjD,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,SAAK;IASrD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY;IAIlC,cAAc,CAAC,IAAI,EAAE,MAAM;IAc3B,KAAK;IAIL,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO;IAI7B,OAAO;IAKP,kBAAkB,CAAC,IAAI,EAAE,MAAM;;;;;;IAiC/B,4CAA4C;IAC5C,eAAe;;;;;IAIf,eAAe,CAAC,WAAW,EAAE,mBAAmB;IAUhD,QAAQ,CAAC,SAAS,EAAE,MAAM;IAyB1B,KAAK,CAAC,EAAE,EAAE,MAAM;IAMhB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAOhC,OAAO,CAAC,IAAI,EAAE,MAAM;IAMpB,MAAM,IAAI,MAAM;IAIhB,QAAQ;IAIR,SAAS,CAAC,SAAS;CAIpB"}
|
package/dist/browser/index.cjs
CHANGED
|
@@ -21,17 +21,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
Quadkey: () => Quadkey,
|
|
24
|
-
|
|
25
|
-
bitShiftRight: () => bitShiftRight,
|
|
26
|
-
isQuadkey: () => isQuadkey,
|
|
27
|
-
padHex: () => padHex
|
|
24
|
+
isQuadkey: () => isQuadkey
|
|
28
25
|
});
|
|
29
26
|
module.exports = __toCommonJS(src_exports);
|
|
30
27
|
|
|
31
28
|
// src/Quadkey.ts
|
|
32
29
|
var import_assert = require("@xylabs/assert");
|
|
33
|
-
var
|
|
34
|
-
var import_buffer2 = require("@xylabs/buffer");
|
|
30
|
+
var import_hex = require("@xylabs/hex");
|
|
35
31
|
var import_sdk_geo = require("@xyo-network/sdk-geo");
|
|
36
32
|
var import_mapbox_gl = require("mapbox-gl");
|
|
37
33
|
|
|
@@ -43,81 +39,36 @@ var RelativeDirectionConstantLookup = {
|
|
|
43
39
|
w: -1
|
|
44
40
|
};
|
|
45
41
|
|
|
46
|
-
// src/utils.ts
|
|
47
|
-
var import_buffer = require("@xylabs/buffer");
|
|
48
|
-
var padHex = (hex, byteCount) => {
|
|
49
|
-
let result = hex;
|
|
50
|
-
if (hex.length % 2 !== 0) {
|
|
51
|
-
result = `0${hex}`;
|
|
52
|
-
}
|
|
53
|
-
if (byteCount) {
|
|
54
|
-
while (result.length / 2 < byteCount) {
|
|
55
|
-
result = `00${result}`;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return result;
|
|
59
|
-
};
|
|
60
|
-
var bitShiftLeft = (buffer) => {
|
|
61
|
-
const shifted = import_buffer.Buffer.alloc(buffer.length);
|
|
62
|
-
const last = buffer.length - 1;
|
|
63
|
-
for (let index = 0; index < last; index++) {
|
|
64
|
-
shifted[index] = buffer[index] << 1;
|
|
65
|
-
if (buffer[index + 1] & 128) {
|
|
66
|
-
shifted[index] += 1;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
shifted[last] = buffer[last] << 1;
|
|
70
|
-
return shifted;
|
|
71
|
-
};
|
|
72
|
-
var bitShiftRight = (buffer) => {
|
|
73
|
-
const shifted = import_buffer.Buffer.alloc(buffer.length);
|
|
74
|
-
const last = buffer.length - 1;
|
|
75
|
-
for (let index = last; index > 0; index--) {
|
|
76
|
-
shifted[index] = buffer[index] >> 1;
|
|
77
|
-
if (buffer[index - 1] & 1) {
|
|
78
|
-
shifted[index] += 128;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
shifted[0] = buffer[0] >> 1;
|
|
82
|
-
return shifted;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
42
|
// src/Quadkey.ts
|
|
86
43
|
var MAX_ZOOM = 124;
|
|
87
44
|
var isQuadkey = (obj) => obj?.type === Quadkey.type;
|
|
45
|
+
var FULL_MASK = 2n ** 256n - 1n;
|
|
46
|
+
var ZOOM_MASK = 0xffn << 248n;
|
|
47
|
+
var ID_MASK = ZOOM_MASK ^ FULL_MASK;
|
|
48
|
+
var assertMaxBitUint = (value, bits = 256n) => {
|
|
49
|
+
(0, import_assert.assertEx)(value < 2n ** bits && value >= 0, "Not a 256 Bit Uint!");
|
|
50
|
+
};
|
|
88
51
|
var Quadkey = class _Quadkey {
|
|
89
|
-
|
|
52
|
+
constructor(key = 0n) {
|
|
53
|
+
this.key = key;
|
|
54
|
+
assertMaxBitUint(key);
|
|
55
|
+
this.guessZoom();
|
|
56
|
+
}
|
|
57
|
+
static Zero = _Quadkey.from(0, 0n);
|
|
90
58
|
static root = new _Quadkey();
|
|
91
59
|
static type = "Quadkey";
|
|
92
60
|
type = _Quadkey.type;
|
|
93
61
|
_geoJson;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
key.copy(this.key, this.key.length - key.length);
|
|
97
|
-
this.guessZoom();
|
|
98
|
-
}
|
|
99
|
-
get base10String() {
|
|
100
|
-
return this.bigNumber.toString(10);
|
|
62
|
+
get base16String() {
|
|
63
|
+
return this.id.toString(16).padStart(62, "0");
|
|
101
64
|
}
|
|
102
65
|
get base4Hash() {
|
|
103
|
-
|
|
104
|
-
const zoom = this.zoom;
|
|
105
|
-
if (zoom === 0) {
|
|
106
|
-
return "";
|
|
107
|
-
}
|
|
108
|
-
let quadkeySimple = bn.toString(4);
|
|
109
|
-
while (quadkeySimple.length < zoom) {
|
|
110
|
-
quadkeySimple = `0${quadkeySimple}`;
|
|
111
|
-
}
|
|
112
|
-
return quadkeySimple;
|
|
66
|
+
return this.id.toString(4).padStart(this.zoom, "0");
|
|
113
67
|
}
|
|
114
68
|
get base4HashLabel() {
|
|
115
69
|
const hash = this.base4Hash;
|
|
116
70
|
return hash.length === 0 ? "fhr" : hash;
|
|
117
71
|
}
|
|
118
|
-
get bigNumber() {
|
|
119
|
-
return new import_bignumber.BigNumber(`${this.key.toString("hex")}`, "hex");
|
|
120
|
-
}
|
|
121
72
|
get boundingBox() {
|
|
122
73
|
return (0, import_sdk_geo.tileToBoundingBox)(this.tile);
|
|
123
74
|
}
|
|
@@ -131,11 +82,9 @@ var Quadkey = class _Quadkey {
|
|
|
131
82
|
get children() {
|
|
132
83
|
(0, import_assert.assertEx)(this.zoom < MAX_ZOOM - 1, "Can not get children of bottom tiles");
|
|
133
84
|
const result = [];
|
|
134
|
-
const shiftedId =
|
|
135
|
-
for (let i =
|
|
136
|
-
|
|
137
|
-
shiftedId.writeUInt8(currentLastByte & 252 | i, shiftedId.length - 1);
|
|
138
|
-
result.push(new _Quadkey().setId(shiftedId).setZoom(this.zoom + 1));
|
|
85
|
+
const shiftedId = this.id << 2n;
|
|
86
|
+
for (let i = 0n; i < 4n; i++) {
|
|
87
|
+
result.push(new _Quadkey().setId(shiftedId | i).setZoom(this.zoom + 1));
|
|
139
88
|
}
|
|
140
89
|
return result;
|
|
141
90
|
}
|
|
@@ -147,20 +96,17 @@ var Quadkey = class _Quadkey {
|
|
|
147
96
|
zoom: tileData[2]
|
|
148
97
|
};
|
|
149
98
|
}
|
|
150
|
-
get hex() {
|
|
151
|
-
return `0x${this.key.toString("hex")}`;
|
|
152
|
-
}
|
|
153
99
|
get id() {
|
|
154
|
-
return this.
|
|
100
|
+
return this.key & ID_MASK;
|
|
155
101
|
}
|
|
156
102
|
get parent() {
|
|
157
103
|
if (this.zoom > 0) {
|
|
158
|
-
return new _Quadkey().setId(
|
|
104
|
+
return new _Quadkey().setId(this.id >> 2n).setZoom(this.zoom - 1);
|
|
159
105
|
}
|
|
160
106
|
}
|
|
161
107
|
get siblings() {
|
|
162
108
|
const siblings = (0, import_assert.assertEx)(this.parent?.children, `siblings: parentChildren ${this.base4Hash}`);
|
|
163
|
-
const filteredSiblings = siblings.filter((quadkey) =>
|
|
109
|
+
const filteredSiblings = siblings.filter((quadkey) => quadkey.key !== this.key);
|
|
164
110
|
(0, import_assert.assertEx)(filteredSiblings.length === 3, `siblings: expected 3 [${filteredSiblings.length}]`);
|
|
165
111
|
return filteredSiblings;
|
|
166
112
|
}
|
|
@@ -168,39 +114,31 @@ var Quadkey = class _Quadkey {
|
|
|
168
114
|
return (0, import_sdk_geo.tileFromQuadkey)(this.base4Hash);
|
|
169
115
|
}
|
|
170
116
|
get valid() {
|
|
171
|
-
|
|
172
|
-
const shift = (MAX_ZOOM - zoom) * 2;
|
|
173
|
-
const id = this.id;
|
|
174
|
-
let testId = id;
|
|
175
|
-
for (let i = 0; i < shift; i++) {
|
|
176
|
-
testId = bitShiftLeft(testId);
|
|
177
|
-
}
|
|
178
|
-
for (let i = 0; i < shift; i++) {
|
|
179
|
-
testId = bitShiftRight(testId);
|
|
180
|
-
}
|
|
181
|
-
return testId.compare(id) === 0;
|
|
117
|
+
return this.id.toString(4) === this.base4Hash.padStart(64, "0");
|
|
182
118
|
}
|
|
183
119
|
get zoom() {
|
|
184
|
-
return this.
|
|
120
|
+
return Number((this.key & ZOOM_MASK) >> 248n);
|
|
185
121
|
}
|
|
186
122
|
static from(zoom, id) {
|
|
187
123
|
return new _Quadkey().setId(id).setZoom(zoom);
|
|
188
124
|
}
|
|
189
|
-
static
|
|
190
|
-
return new _Quadkey(
|
|
125
|
+
static fromArrayBuffer(zoom, id) {
|
|
126
|
+
return new _Quadkey().setId(BigInt(`0x${(0, import_hex.asHex)(id, 256, true)}`)).setZoom(zoom);
|
|
191
127
|
}
|
|
192
128
|
static fromBase16String(value) {
|
|
193
|
-
|
|
194
|
-
return new _Quadkey(import_buffer2.Buffer.from(padHex(valueToUse), "hex"));
|
|
129
|
+
return new _Quadkey(BigInt(`0x${(0, import_hex.asHex)(value, 256, true)}`));
|
|
195
130
|
}
|
|
196
131
|
static fromBase4String(value) {
|
|
197
|
-
if (value === "fhr" || value === "") {
|
|
132
|
+
if (value === "fhr" || value === "" || value === void 0) {
|
|
198
133
|
return _Quadkey.root;
|
|
199
134
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
135
|
+
let id = 0n;
|
|
136
|
+
for (let i = 0; i < value.length; i++) {
|
|
137
|
+
const nibble = parseInt(value[i]);
|
|
138
|
+
(0, import_assert.assertEx)(nibble < 4 && nibble >= 0, `Invalid Base4 String: ${value}`);
|
|
139
|
+
id = id << 2n | BigInt(nibble);
|
|
203
140
|
}
|
|
141
|
+
return new _Quadkey().setId(id).setZoom(value.length);
|
|
204
142
|
}
|
|
205
143
|
static fromBoundingBox(boundingBox, zoom) {
|
|
206
144
|
const tiles = (0, import_sdk_geo.tilesFromBoundingBox)(boundingBox, Math.floor(zoom));
|
|
@@ -210,18 +148,13 @@ var Quadkey = class _Quadkey {
|
|
|
210
148
|
}
|
|
211
149
|
return result;
|
|
212
150
|
}
|
|
213
|
-
static fromBuffer(value) {
|
|
214
|
-
return _Quadkey.fromBase16String(value.toString("hex"));
|
|
215
|
-
}
|
|
216
151
|
static fromLngLat(point, zoom) {
|
|
217
152
|
const tile = (0, import_sdk_geo.tileFromPoint)(import_mapbox_gl.LngLat.convert(point), zoom);
|
|
218
153
|
const quadkeyString = (0, import_sdk_geo.tileToQuadkey)(tile);
|
|
219
154
|
return _Quadkey.fromBase4String(quadkeyString);
|
|
220
155
|
}
|
|
221
|
-
static fromString(zoom, id, base =
|
|
156
|
+
static fromString(zoom, id, base = 16) {
|
|
222
157
|
switch (base) {
|
|
223
|
-
case 10:
|
|
224
|
-
return _Quadkey.fromBase10String(id)?.setZoom(zoom);
|
|
225
158
|
case 16:
|
|
226
159
|
return _Quadkey.fromBase16String(id).setZoom(zoom);
|
|
227
160
|
default:
|
|
@@ -242,13 +175,10 @@ var Quadkey = class _Quadkey {
|
|
|
242
175
|
return deepResult;
|
|
243
176
|
}
|
|
244
177
|
clone() {
|
|
245
|
-
return _Quadkey
|
|
246
|
-
}
|
|
247
|
-
compareTo(quadkey) {
|
|
248
|
-
return this.bigNumber.cmp(quadkey.bigNumber);
|
|
178
|
+
return new _Quadkey(this.key);
|
|
249
179
|
}
|
|
250
180
|
equals(obj) {
|
|
251
|
-
return obj.
|
|
181
|
+
return obj.key == this.key;
|
|
252
182
|
}
|
|
253
183
|
geoJson() {
|
|
254
184
|
this._geoJson = this._geoJson ?? new import_sdk_geo.GeoJson(this.base4Hash);
|
|
@@ -319,71 +249,29 @@ var Quadkey = class _Quadkey {
|
|
|
319
249
|
return _Quadkey.fromBase4String(quadkey);
|
|
320
250
|
}
|
|
321
251
|
setId(id) {
|
|
252
|
+
assertMaxBitUint(id, 248n);
|
|
322
253
|
this.setKey(this.zoom, id);
|
|
323
254
|
return this;
|
|
324
255
|
}
|
|
325
|
-
setKey(zoom,
|
|
326
|
-
|
|
327
|
-
this.key
|
|
256
|
+
setKey(zoom, key) {
|
|
257
|
+
assertMaxBitUint(key);
|
|
258
|
+
this.key = key;
|
|
259
|
+
this.setZoom(zoom);
|
|
328
260
|
return this;
|
|
329
261
|
}
|
|
330
262
|
setZoom(zoom) {
|
|
331
263
|
(0, import_assert.assertEx)(zoom < MAX_ZOOM, `Invalid zoom [${zoom}] max=${MAX_ZOOM}`);
|
|
332
|
-
this.
|
|
264
|
+
this.key = this.key & ID_MASK | BigInt(zoom) << 248n;
|
|
333
265
|
return this;
|
|
334
266
|
}
|
|
335
|
-
/** @deprecated use .base10String*/
|
|
336
|
-
toBase10String() {
|
|
337
|
-
return this.base10String;
|
|
338
|
-
}
|
|
339
|
-
/** @deprecated use .base4Hash */
|
|
340
|
-
toBase4Hash() {
|
|
341
|
-
return this.base4Hash;
|
|
342
|
-
}
|
|
343
|
-
/** @deprecated use .base4HashLabel */
|
|
344
|
-
toBase4HashLabel() {
|
|
345
|
-
const hash = this.base4HashLabel;
|
|
346
|
-
return hash.length === 0 ? "fhr" : hash;
|
|
347
|
-
}
|
|
348
|
-
/** @deprecated use .bigNumber */
|
|
349
|
-
toBigNumber() {
|
|
350
|
-
return this.bigNumber;
|
|
351
|
-
}
|
|
352
|
-
/** @deprecated use .boundingBox */
|
|
353
|
-
toBoundingBox() {
|
|
354
|
-
return this.boundingBox;
|
|
355
|
-
}
|
|
356
|
-
/** @deprecated use .buffer */
|
|
357
|
-
toBuffer() {
|
|
358
|
-
return this.buffer;
|
|
359
|
-
}
|
|
360
|
-
/** @deprecated use .center */
|
|
361
|
-
toCenter() {
|
|
362
|
-
return this.center;
|
|
363
|
-
}
|
|
364
|
-
/** @deprecated use .hex instead */
|
|
365
|
-
toHex() {
|
|
366
|
-
return this.hex;
|
|
367
|
-
}
|
|
368
267
|
toJSON() {
|
|
369
268
|
return this.base4HashLabel;
|
|
370
269
|
}
|
|
371
|
-
toShortString() {
|
|
372
|
-
const buffer = this.buffer;
|
|
373
|
-
const part1 = buffer.slice(0, 2);
|
|
374
|
-
const part2 = buffer.slice(buffer.length - 2, buffer.length);
|
|
375
|
-
return `${part1.toString("hex")}...${part2.toString("hex")}`;
|
|
376
|
-
}
|
|
377
270
|
toString() {
|
|
378
|
-
return
|
|
379
|
-
}
|
|
380
|
-
/** @deprecated use .tile instead */
|
|
381
|
-
toTile() {
|
|
382
|
-
return this.tile;
|
|
271
|
+
return this.base4Hash;
|
|
383
272
|
}
|
|
384
273
|
guessZoom() {
|
|
385
|
-
const
|
|
386
|
-
const quadkeySimple = bn.toString(4);
|
|
274
|
+
const quadkeySimple = this.id.toString(4);
|
|
387
275
|
this.setZoom(quadkeySimple.length);
|
|
388
276
|
}
|
|
389
277
|
};
|