@xyo-network/quadkey 2.36.10

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/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
package/README.md ADDED
@@ -0,0 +1,80 @@
1
+ [![logo][]](https://xyo.network)
2
+
3
+ # sdk-xyo-client-js
4
+
5
+ [![main-build][]][main-build-link]
6
+ [![beta-build][]][beta-build-link]
7
+ [![npm-badge][]][npm-link]
8
+ [![bch-badge][]][bch-link]
9
+ [![codacy-badge][]][codacy-link]
10
+ [![codeclimate-badge][]][codeclimate-link]
11
+ [![snyk-badge][]][snyk-link]
12
+
13
+ > The XYO Foundation provides this source code available in our efforts to
14
+ > advance the understanding of the XYO Protocol and its possible uses.
15
+ > We continue to maintain this software in the interest of developer education.
16
+ > Usage of this source code is not intended for production.
17
+
18
+ ## Table of Contents
19
+ - [Title](#sdk-xyo-client-js)
20
+ - [Table of Contents](#table-of-contents)
21
+ - [Description](#description)
22
+ - [Install](#install)
23
+ - [Maintainers](#maintainers)
24
+ - [License](#license)
25
+ - [Credits](#credits)
26
+
27
+ ## Description
28
+
29
+ > Quadkey Class
30
+
31
+ ## Install
32
+
33
+ Using npm:
34
+
35
+ ```sh
36
+ npm i --save @xyo-network/sdk-xyo-client-js
37
+ ```
38
+
39
+ Using yarn:
40
+
41
+ ```sh
42
+ yarn add @xyo-network/sdk-xyo-client-js
43
+ ```
44
+
45
+ ## Maintainers
46
+
47
+ - [Arie Trouw](https://github.com/arietrouw) [(arietrouw.com)](https://arietrouw.com)
48
+ - [Matt Jones](https://github.com/jonesmac)
49
+ - [Joel Carter](https://github.com/JoelBCarter)
50
+
51
+ ## License
52
+
53
+ > See the [LICENSE](LICENSE) file for license details
54
+
55
+ ## Credits
56
+
57
+ [Made with 🔥 and ❄️ by XYO](https://xyo.network)
58
+
59
+ [logo]: https://cdn.xy.company/img/brand/XYO_full_colored.png
60
+
61
+ [main-build]: https://github.com/XYOracleNetwork/sdk-xyo-client-js/actions/workflows/build-main.yml/badge.svg
62
+ [main-build-link]: https://github.com/XYOracleNetwork/sdk-xyo-client-js/actions/workflows/build-main.yml
63
+
64
+ [beta-build]: https://github.com/XYOracleNetwork/sdk-xyo-client-js/actions/workflows/build-beta.yml/badge.svg
65
+ [beta-build-link]: https://github.com/XYOracleNetwork/sdk-xyo-client-js/actions/workflows/build-beta.yml
66
+
67
+ [npm-badge]: https://img.shields.io/npm/v/@xyo-network/sdk-xyo-client-js.svg
68
+ [npm-link]: https://www.npmjs.com/package/@xyo-network/sdk-xyo-client-js
69
+
70
+ [bch-badge]: https://bettercodehub.com/edge/badge/XYOracleNetwork/sdk-xyo-client-js?branch=main
71
+ [bch-link]: https://bettercodehub.com/results/XYOracleNetwork/sdk-xyo-client-js
72
+
73
+ [codacy-badge]: https://app.codacy.com/project/badge/Grade/ba1f344ae34e4bfe999331cf4e27b9f5
74
+ [codacy-link]: https://www.codacy.com/gh/XYOracleNetwork/sdk-xyo-client-js/dashboard?utm_source=github.com&utm_medium=referral&utm_content=XYOracleNetwork/sdk-xyo-client-js&utm_campaign=Badge_Grade
75
+
76
+ [codeclimate-badge]: https://api.codeclimate.com/v1/badges/0e76349c9541f3866948/maintainability
77
+ [codeclimate-link]: https://codeclimate.com/github/XYOracleNetwork/sdk-xyo-client-js/maintainability
78
+
79
+ [snyk-badge]: https://snyk.io/test/github/XYOracleNetwork/sdk-xyo-client-js/badge.svg?targetFile=package.json
80
+ [snyk-link]: https://snyk.io/test/github/XYOracleNetwork/sdk-xyo-client-js?targetFile=package.json
@@ -0,0 +1,66 @@
1
+ /// <reference types="bn.js" />
2
+ import { BigNumber } from '@xylabs/bignumber';
3
+ import { Buffer } from '@xylabs/buffer';
4
+ import { GeoJson, MercatorBoundingBox, MercatorTile } from '@xyo-network/sdk-xyo-js';
5
+ import { LngLatLike } from 'mapbox-gl';
6
+ export * from './utils';
7
+ export declare const isQuadkey: (obj: {
8
+ type: string;
9
+ }) => boolean;
10
+ export declare class Quadkey {
11
+ type: string;
12
+ private key;
13
+ constructor(key?: Buffer);
14
+ equals(obj: Quadkey): boolean;
15
+ static root: Quadkey;
16
+ static type: string;
17
+ static fromBase4String(value?: string): Quadkey | undefined;
18
+ static fromBase10String(value: string): Quadkey;
19
+ static fromBase16String(value: string): Quadkey;
20
+ static fromBuffer(value: Buffer): Quadkey;
21
+ static fromString(zoom: number, id: string, base?: number): Quadkey;
22
+ static from(zoom: number, id: Buffer): Quadkey;
23
+ static fromLngLat(point: LngLatLike, zoom: number): Quadkey | undefined;
24
+ static fromTile(tile: MercatorTile): Quadkey | undefined;
25
+ isInBoundingBox(boundingBox: MercatorBoundingBox): boolean;
26
+ static fromBoundingBox(bbox: MercatorBoundingBox, zoom: number): Quadkey[];
27
+ getGridBoundingBox(size: number): {
28
+ height: number;
29
+ left: number;
30
+ top: number;
31
+ width: number;
32
+ };
33
+ setKey(zoom: number, id: Buffer): this;
34
+ setZoom(zoom: number): this;
35
+ parent(): Quadkey | undefined;
36
+ relative(direction: string): Quadkey | undefined;
37
+ childrenByZoom(zoom: number): Quadkey[];
38
+ children(): Quadkey[];
39
+ siblings(): Quadkey[];
40
+ clone(): Quadkey;
41
+ zoom(): number;
42
+ private _geoJson?;
43
+ geoJson(): GeoJson;
44
+ setId(id: Buffer): this;
45
+ toTile(): MercatorTile;
46
+ toBoundingBox(): MercatorBoundingBox;
47
+ getGridLocation(): {
48
+ col: number;
49
+ row: number;
50
+ zoom: number;
51
+ };
52
+ valid(): boolean;
53
+ id(): Buffer;
54
+ toBuffer(): Buffer;
55
+ toBigNumber(): BigNumber;
56
+ toString(): string;
57
+ toJSON(): string;
58
+ toBase10String(): string;
59
+ toBase4HashLabel(): string;
60
+ toBase4Hash(): string;
61
+ toHex(): string;
62
+ toShortString(): string;
63
+ compareTo(quadkey: Quadkey): 0 | 1 | -1;
64
+ static Zero: Quadkey;
65
+ }
66
+ //# sourceMappingURL=Quadkey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Quadkey.d.ts","sourceRoot":"","sources":["../../src/Quadkey.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC,OAAO,EACL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YR,QAAQ;IAOR,KAAK;IAIL,IAAI;IAIX,OAAO,CAAC,QAAQ,CAAC,CAAS;IAEnB,OAAO;IAKP,KAAK,CAAC,EAAE,EAAE,MAAM;IAKhB,MAAM,IAAI,YAAY;IAItB,aAAa,IAAI,mBAAmB;IAIpC,eAAe;;;;;IAUf,KAAK;IAcL,EAAE;IAIF,QAAQ;IAIR,WAAW;IAIX,QAAQ;IAIR,MAAM,IAAI,MAAM;IAIhB,cAAc;IAId,gBAAgB;IAKhB,WAAW;IAaX,KAAK;IAIL,aAAa;IAOb,SAAS,CAAC,OAAO,EAAE,OAAO;IAIjC,OAAc,IAAI,UAAuC;CAC1D"}
@@ -0,0 +1,282 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Quadkey = exports.isQuadkey = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const bignumber_1 = require("@xylabs/bignumber");
6
+ const buffer_1 = require("@xylabs/buffer");
7
+ const sdk_js_1 = require("@xylabs/sdk-js");
8
+ const sdk_xyo_js_1 = require("@xyo-network/sdk-xyo-js");
9
+ const mapbox_gl_1 = require("mapbox-gl");
10
+ const utils_1 = require("./utils");
11
+ tslib_1.__exportStar(require("./utils"), exports);
12
+ const MAX_ZOOM = 124;
13
+ const isQuadkey = (obj) => (obj === null || obj === void 0 ? void 0 : obj.type) === Quadkey.type;
14
+ exports.isQuadkey = isQuadkey;
15
+ const RelativeDirectionConstantLookup = {
16
+ e: 1,
17
+ n: -2,
18
+ s: 2,
19
+ w: -1,
20
+ };
21
+ class Quadkey {
22
+ constructor(key = buffer_1.Buffer.alloc(32)) {
23
+ this.type = Quadkey.type;
24
+ this.key = buffer_1.Buffer.alloc(32);
25
+ key.copy(this.key, this.key.length - key.length);
26
+ }
27
+ equals(obj) {
28
+ return obj.toBase4HashLabel() == this.toBase4HashLabel();
29
+ }
30
+ static fromBase4String(value) {
31
+ if (value === 'fhr' || value === '') {
32
+ return Quadkey.root;
33
+ }
34
+ if (value && value.length && value.length > 0) {
35
+ const quadkey = new Quadkey(buffer_1.Buffer.from((0, utils_1.padHex)(new bignumber_1.BigNumber(value, 4).toString(16)), 'hex')).setZoom(value.length);
36
+ return quadkey.valid() ? quadkey : undefined;
37
+ }
38
+ }
39
+ static fromBase10String(value) {
40
+ return new Quadkey(buffer_1.Buffer.from((0, utils_1.padHex)(new bignumber_1.BigNumber(value, 10).toString(16)), 'hex'));
41
+ }
42
+ static fromBase16String(value) {
43
+ const valueToUse = value.startsWith('0x') ? value.slice(2) : value;
44
+ return new Quadkey(buffer_1.Buffer.from((0, utils_1.padHex)(valueToUse), 'hex'));
45
+ }
46
+ static fromBuffer(value) {
47
+ return Quadkey.fromBase16String(value.toString('hex'));
48
+ }
49
+ static fromString(zoom, id, base = 10) {
50
+ var _a;
51
+ switch (base) {
52
+ case 10:
53
+ return (_a = Quadkey.fromBase10String(id)) === null || _a === void 0 ? void 0 : _a.setZoom(zoom);
54
+ case 16:
55
+ return Quadkey.fromBase16String(id).setZoom(zoom);
56
+ default:
57
+ throw Error(`Invalid base [${base}]`);
58
+ }
59
+ }
60
+ static from(zoom, id) {
61
+ return new Quadkey().setId(id).setZoom(zoom);
62
+ }
63
+ static fromLngLat(point, zoom) {
64
+ const tile = (0, sdk_xyo_js_1.tileFromPoint)(mapbox_gl_1.LngLat.convert(point), zoom);
65
+ const quadkeyString = (0, sdk_xyo_js_1.tileToQuadkey)(tile);
66
+ return Quadkey.fromBase4String(quadkeyString);
67
+ }
68
+ static fromTile(tile) {
69
+ return Quadkey.fromBase4String((0, sdk_xyo_js_1.tileToQuadkey)(tile));
70
+ }
71
+ isInBoundingBox(boundingBox) {
72
+ const tileBoundingBox = (0, sdk_xyo_js_1.tileToBoundingBox)(this.toTile());
73
+ return (boundingBox.contains(tileBoundingBox.getNorthEast()) ||
74
+ boundingBox.contains(tileBoundingBox.getNorthWest()) ||
75
+ boundingBox.contains(tileBoundingBox.getSouthEast()) ||
76
+ boundingBox.contains(tileBoundingBox.getSouthWest()));
77
+ }
78
+ static fromBoundingBox(bbox, zoom) {
79
+ const tiles = (0, sdk_xyo_js_1.tilesFromBoundingBox)(bbox, Math.floor(zoom));
80
+ const result = [];
81
+ for (const tile of tiles) {
82
+ result.push((0, sdk_js_1.assertEx)(Quadkey.fromTile(tile), 'Bad Quadkey'));
83
+ }
84
+ return result;
85
+ }
86
+ getGridBoundingBox(size) {
87
+ const hash = this.toBase4Hash();
88
+ let index = 0;
89
+ let left = 0;
90
+ let top = 0;
91
+ let blockSize = size;
92
+ while (index < hash.length) {
93
+ blockSize >>= 1;
94
+ switch (hash[index]) {
95
+ case '1':
96
+ left += blockSize;
97
+ break;
98
+ case '2':
99
+ top += blockSize;
100
+ break;
101
+ case '3':
102
+ left += blockSize;
103
+ top += blockSize;
104
+ break;
105
+ }
106
+ index++;
107
+ }
108
+ if (blockSize < 2) {
109
+ blockSize = 2;
110
+ }
111
+ return {
112
+ height: blockSize,
113
+ left,
114
+ top,
115
+ width: blockSize,
116
+ };
117
+ }
118
+ setKey(zoom, id) {
119
+ id.copy(this.key, this.key.length - id.length);
120
+ this.key.writeUInt8(zoom, 0);
121
+ return this;
122
+ }
123
+ setZoom(zoom) {
124
+ (0, sdk_js_1.assertEx)(zoom < MAX_ZOOM, `Invalid zoom [${zoom}] max=${MAX_ZOOM}`);
125
+ this.setKey(zoom, this.id());
126
+ return this;
127
+ }
128
+ parent() {
129
+ if (this.zoom() > 0) {
130
+ return new Quadkey().setId((0, utils_1.bitShiftRight)((0, utils_1.bitShiftRight)(this.id()))).setZoom(this.zoom() - 1);
131
+ }
132
+ }
133
+ relative(direction) {
134
+ const directionConstant = (0, sdk_js_1.assertEx)(RelativeDirectionConstantLookup[direction], 'Invalid direction');
135
+ let quadkey = this.toBase4Hash();
136
+ if (quadkey.length === 0) {
137
+ return this;
138
+ }
139
+ let index = quadkey.length - 1;
140
+ while (index >= 0) {
141
+ let number = parseInt(quadkey.charAt(index));
142
+ number += directionConstant;
143
+ if (number > 3) {
144
+ number -= 4;
145
+ quadkey = quadkey.substring(0, index) + number.toString() + quadkey.substring(index + 1);
146
+ index--;
147
+ }
148
+ else if (number < 0) {
149
+ number += 4;
150
+ quadkey = quadkey.substring(0, index) + number.toString() + quadkey.substring(index + 1);
151
+ index--;
152
+ }
153
+ else {
154
+ index = -1;
155
+ }
156
+ }
157
+ return Quadkey.fromBase4String(quadkey);
158
+ }
159
+ childrenByZoom(zoom) {
160
+ // if we are limiting by zoom, and we are already at that limit, just return this quadkey
161
+ if (zoom && zoom === this.zoom()) {
162
+ return [this];
163
+ }
164
+ // recursively get children
165
+ let deepResult = [];
166
+ for (const quadkey of this.children()) {
167
+ deepResult = deepResult.concat(quadkey.childrenByZoom(zoom));
168
+ }
169
+ return deepResult;
170
+ }
171
+ children() {
172
+ (0, sdk_js_1.assertEx)(this.zoom() < MAX_ZOOM - 1, 'Can not get children of bottom tiles');
173
+ const result = [];
174
+ const shiftedId = (0, utils_1.bitShiftLeft)((0, utils_1.bitShiftLeft)(this.id()));
175
+ for (let i = 0; i < 4; i++) {
176
+ const currentLastByte = shiftedId.readUInt8(shiftedId.length - 1);
177
+ shiftedId.writeUInt8((currentLastByte & 0xfc) | i, shiftedId.length - 1);
178
+ result.push(new Quadkey().setId(shiftedId).setZoom(this.zoom() + 1));
179
+ }
180
+ return result;
181
+ }
182
+ siblings() {
183
+ var _a;
184
+ const siblings = (0, sdk_js_1.assertEx)((_a = this.parent()) === null || _a === void 0 ? void 0 : _a.children(), `siblings: parentChildren ${this.toBase4Hash()}`);
185
+ const filteredeSiblinngs = siblings.filter((quadkey) => this.compareTo(quadkey) !== 0);
186
+ (0, sdk_js_1.assertEx)(filteredeSiblinngs.length === 3, `siblings: expected 3 [${filteredeSiblinngs.length}]`);
187
+ return filteredeSiblinngs;
188
+ }
189
+ clone() {
190
+ return Quadkey.fromBase10String(this.toBase10String());
191
+ }
192
+ zoom() {
193
+ return this.toBuffer().readUInt8(0);
194
+ }
195
+ geoJson() {
196
+ var _a;
197
+ this._geoJson = (_a = this._geoJson) !== null && _a !== void 0 ? _a : new sdk_xyo_js_1.GeoJson(this.toBase4Hash());
198
+ return this._geoJson;
199
+ }
200
+ setId(id) {
201
+ this.setKey(this.zoom(), id);
202
+ return this;
203
+ }
204
+ toTile() {
205
+ return (0, sdk_xyo_js_1.tileFromQuadkey)(this.toBase4Hash());
206
+ }
207
+ toBoundingBox() {
208
+ return (0, sdk_xyo_js_1.tileToBoundingBox)(this.toTile());
209
+ }
210
+ getGridLocation() {
211
+ const tileData = (0, sdk_xyo_js_1.tileFromQuadkey)(this.toBase4Hash());
212
+ return {
213
+ col: Math.pow(2, tileData[2]) - tileData[1] - 1,
214
+ row: tileData[0],
215
+ zoom: tileData[2],
216
+ };
217
+ }
218
+ valid() {
219
+ const zoom = this.zoom();
220
+ const shift = (MAX_ZOOM - zoom) * 2;
221
+ const id = this.id();
222
+ let testId = id;
223
+ for (let i = 0; i < shift; i++) {
224
+ testId = (0, utils_1.bitShiftLeft)(testId);
225
+ }
226
+ for (let i = 0; i < shift; i++) {
227
+ testId = (0, utils_1.bitShiftRight)(testId);
228
+ }
229
+ return testId.compare(id) === 0;
230
+ }
231
+ id() {
232
+ return this.toBuffer().slice(1);
233
+ }
234
+ toBuffer() {
235
+ return this.key;
236
+ }
237
+ toBigNumber() {
238
+ return new bignumber_1.BigNumber(`${this.key.toString('hex')}`, 'hex');
239
+ }
240
+ toString() {
241
+ return `0x${(0, utils_1.padHex)(this.toBigNumber().toString(16))}`;
242
+ }
243
+ toJSON() {
244
+ return this.toBase4HashLabel();
245
+ }
246
+ toBase10String() {
247
+ return this.toBigNumber().toString(10);
248
+ }
249
+ toBase4HashLabel() {
250
+ const hash = this.toBase4Hash();
251
+ return hash.length === 0 ? 'fhr' : hash;
252
+ }
253
+ toBase4Hash() {
254
+ const bn = new bignumber_1.BigNumber(this.id().toString('hex'), 16);
255
+ const zoom = this.zoom();
256
+ if (zoom === 0) {
257
+ return '';
258
+ }
259
+ let quadkeySimple = bn.toString(4);
260
+ while (quadkeySimple.length < zoom) {
261
+ quadkeySimple = `0${quadkeySimple}`;
262
+ }
263
+ return quadkeySimple;
264
+ }
265
+ toHex() {
266
+ return `0x${this.key.toString('hex')}`;
267
+ }
268
+ toShortString() {
269
+ const buffer = this.toBuffer();
270
+ const part1 = buffer.slice(0, 2);
271
+ const part2 = buffer.slice(buffer.length - 2, buffer.length);
272
+ return `${part1.toString('hex')}...${part2.toString('hex')}`;
273
+ }
274
+ compareTo(quadkey) {
275
+ return this.toBigNumber().cmp(quadkey.toBigNumber());
276
+ }
277
+ }
278
+ exports.Quadkey = Quadkey;
279
+ Quadkey.root = new Quadkey();
280
+ Quadkey.type = 'Quadkey';
281
+ Quadkey.Zero = Quadkey.from(0, buffer_1.Buffer.alloc(31, 0));
282
+ //# sourceMappingURL=Quadkey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Quadkey.js","sourceRoot":"","sources":["../../src/Quadkey.ts"],"names":[],"mappings":";;;;AAAA,iDAA6C;AAC7C,2CAAuC;AACvC,2CAAyC;AACzC,wDASgC;AAChC,yCAA8C;AAE9C,mCAA6D;AAE7D,kDAAuB;AAEvB,MAAM,QAAQ,GAAG,GAAG,CAAA;AAEb,MAAM,SAAS,GAAG,CAAC,GAAqB,EAAE,EAAE,CAAC,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,MAAK,OAAO,CAAC,IAAI,CAAA;AAAjE,QAAA,SAAS,aAAwD;AAE9E,MAAM,+BAA+B,GAA2B;IAC9D,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC,CAAC;IACL,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC,CAAC;CACN,CAAA;AAED,MAAa,OAAO;IAKlB,YAAY,GAAG,GAAG,eAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAJ3B,SAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QAElB,QAAG,GAAG,eAAM,CAAC,KAAK,C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C,IAAI,CAAC,CAAC,EAAE,eAAM,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './Quadkey';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./Quadkey"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB"}
@@ -0,0 +1,5 @@
1
+ import { Buffer } from 'buffer/';
2
+ export declare const padHex: (hex: string, byteCount?: number) => string;
3
+ export declare const bitShiftLeft: (buffer: Buffer) => Buffer;
4
+ export declare const bitShiftRight: (buffer: Buffer) => Buffer;
5
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC,eAAO,MAAM,MAAM,QAAS,MAAM,cAAc,MAAM,WAWrD,CAAA;AAED,eAAO,MAAM,YAAY,WAAY,MAAM,WAW1C,CAAA;AAED,eAAO,MAAM,aAAa,WAAY,MAAM,WAW3C,CAAA"}