@loaders.gl/wkt 4.2.0-alpha.4 → 4.2.0-alpha.6
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/dist.dev.js +137 -218
- package/dist/dist.min.js +10 -0
- package/dist/hex-wkb-loader.d.ts +1 -1
- package/dist/hex-wkb-loader.d.ts.map +1 -1
- package/dist/hex-wkb-loader.js +44 -28
- package/dist/index.cjs +87 -62
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +14 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/lib/encode-twkb.js +158 -143
- package/dist/lib/encode-wkb.js +247 -211
- package/dist/lib/encode-wkt-crs.d.ts +1 -1
- package/dist/lib/encode-wkt-crs.d.ts.map +1 -1
- package/dist/lib/encode-wkt-crs.js +32 -18
- package/dist/lib/encode-wkt.js +35 -27
- package/dist/lib/parse-hex-wkb.js +1 -2
- package/dist/lib/parse-twkb.js +215 -218
- package/dist/lib/parse-wkb-header.js +124 -95
- package/dist/lib/parse-wkb.d.ts +1 -1
- package/dist/lib/parse-wkb.d.ts.map +1 -1
- package/dist/lib/parse-wkb.js +210 -235
- package/dist/lib/parse-wkt-crs.js +110 -86
- package/dist/lib/parse-wkt.js +251 -185
- package/dist/lib/utils/base64-encoder.js +151 -5
- package/dist/lib/utils/binary-reader.js +67 -64
- package/dist/lib/utils/binary-writer.js +117 -109
- package/dist/lib/utils/hex-encoder.js +46 -32
- package/dist/lib/utils/hex-transcoder.js +40 -24
- package/dist/lib/utils/version.js +7 -2
- package/dist/twkb-loader.js +26 -17
- package/dist/twkb-writer.js +18 -13
- package/dist/wkb-loader.js +26 -17
- package/dist/wkb-writer.js +22 -17
- package/dist/wkt-crs-loader.d.ts +1 -1
- package/dist/wkt-crs-loader.d.ts.map +1 -1
- package/dist/wkt-crs-loader.js +22 -15
- package/dist/wkt-crs-writer.d.ts +2 -2
- package/dist/wkt-crs-writer.d.ts.map +1 -1
- package/dist/wkt-crs-writer.js +23 -15
- package/dist/wkt-loader.js +28 -20
- package/dist/wkt-worker.js +4 -2
- package/dist/wkt-writer.js +19 -14
- package/dist/workers/wkb-worker.js +3 -1
- package/dist/workers/wkt-worker.js +3 -1
- package/package.json +11 -6
- package/src/lib/parse-wkb.ts +2 -2
- package/dist/hex-wkb-loader.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/encode-twkb.js.map +0 -1
- package/dist/lib/encode-wkb.js.map +0 -1
- package/dist/lib/encode-wkt-crs.js.map +0 -1
- package/dist/lib/encode-wkt.js.map +0 -1
- package/dist/lib/parse-hex-wkb.js.map +0 -1
- package/dist/lib/parse-twkb.js.map +0 -1
- package/dist/lib/parse-wkb-header.js.map +0 -1
- package/dist/lib/parse-wkb.js.map +0 -1
- package/dist/lib/parse-wkt-crs.js.map +0 -1
- package/dist/lib/parse-wkt.js.map +0 -1
- package/dist/lib/utils/base64-encoder.js.map +0 -1
- package/dist/lib/utils/binary-reader.js.map +0 -1
- package/dist/lib/utils/binary-writer.js.map +0 -1
- package/dist/lib/utils/hex-encoder.js.map +0 -1
- package/dist/lib/utils/hex-transcoder.js.map +0 -1
- package/dist/lib/utils/version.js.map +0 -1
- package/dist/twkb-loader.js.map +0 -1
- package/dist/twkb-writer.js.map +0 -1
- package/dist/wkb-loader.js.map +0 -1
- package/dist/wkb-writer.js.map +0 -1
- package/dist/wkt-crs-loader.js.map +0 -1
- package/dist/wkt-crs-writer.js.map +0 -1
- package/dist/wkt-loader.js.map +0 -1
- package/dist/wkt-writer.js.map +0 -1
- package/dist/workers/wkb-worker.js.map +0 -1
- package/dist/workers/wkt-worker.js.map +0 -1
package/dist/lib/parse-twkb.js
CHANGED
|
@@ -1,256 +1,253 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
// Forked from https://github.com/cschwarz/wkx under MIT license, Copyright (c) 2013 Christian Schwarz
|
|
1
5
|
import { BinaryReader } from "./utils/binary-reader.js";
|
|
2
6
|
import { WKBGeometryType } from "./parse-wkb-header.js";
|
|
7
|
+
/**
|
|
8
|
+
* Check if an array buffer might be a TWKB array buffer
|
|
9
|
+
* @param arrayBuffer The array buffer to check
|
|
10
|
+
* @returns false if this is definitely not a TWKB array buffer, true if it might be a TWKB array buffer
|
|
11
|
+
*/
|
|
3
12
|
export function isTWKB(arrayBuffer) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
const binaryReader = new BinaryReader(arrayBuffer);
|
|
14
|
+
const type = binaryReader.readUInt8();
|
|
15
|
+
const geometryType = type & 0x0f;
|
|
16
|
+
// Only geometry types 1 to 7 (point to geometry collection are currently defined)
|
|
17
|
+
if (geometryType < 1 || geometryType > 7) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
11
21
|
}
|
|
12
22
|
export function parseTWKBGeometry(arrayBuffer) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
if (context.hasBoundingBox) {
|
|
19
|
-
let dimensions = 2;
|
|
20
|
-
if (context.hasZ) {
|
|
21
|
-
dimensions++;
|
|
22
|
-
}
|
|
23
|
-
if (context.hasM) {
|
|
24
|
-
dimensions++;
|
|
23
|
+
const binaryReader = new BinaryReader(arrayBuffer);
|
|
24
|
+
const context = parseTWKBHeader(binaryReader);
|
|
25
|
+
if (context.hasSizeAttribute) {
|
|
26
|
+
binaryReader.readVarInt();
|
|
25
27
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
if (context.hasBoundingBox) {
|
|
29
|
+
let dimensions = 2;
|
|
30
|
+
if (context.hasZ) {
|
|
31
|
+
dimensions++;
|
|
32
|
+
}
|
|
33
|
+
if (context.hasM) {
|
|
34
|
+
dimensions++;
|
|
35
|
+
}
|
|
36
|
+
// TODO why are we throwing away these datums?
|
|
37
|
+
for (let i = 0; i < dimensions; i++) {
|
|
38
|
+
binaryReader.readVarInt();
|
|
39
|
+
binaryReader.readVarInt();
|
|
40
|
+
}
|
|
29
41
|
}
|
|
30
|
-
|
|
31
|
-
return parseGeometry(binaryReader, context, context.geometryType);
|
|
42
|
+
return parseGeometry(binaryReader, context, context.geometryType);
|
|
32
43
|
}
|
|
33
44
|
function parseTWKBHeader(binaryReader) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
45
|
+
const type = binaryReader.readUInt8();
|
|
46
|
+
const metadataHeader = binaryReader.readUInt8();
|
|
47
|
+
const geometryType = type & 0x0f;
|
|
48
|
+
const precision = zigZagDecode(type >> 4);
|
|
49
|
+
const hasExtendedPrecision = Boolean((metadataHeader >> 3) & 1);
|
|
50
|
+
let hasZ = false;
|
|
51
|
+
let hasM = false;
|
|
52
|
+
let zPrecision = 0;
|
|
53
|
+
let zPrecisionFactor = 1;
|
|
54
|
+
let mPrecision = 0;
|
|
55
|
+
let mPrecisionFactor = 1;
|
|
56
|
+
if (hasExtendedPrecision) {
|
|
57
|
+
const extendedPrecision = binaryReader.readUInt8();
|
|
58
|
+
hasZ = (extendedPrecision & 0x01) === 0x01;
|
|
59
|
+
hasM = (extendedPrecision & 0x02) === 0x02;
|
|
60
|
+
zPrecision = zigZagDecode((extendedPrecision & 0x1c) >> 2);
|
|
61
|
+
zPrecisionFactor = Math.pow(10, zPrecision);
|
|
62
|
+
mPrecision = zigZagDecode((extendedPrecision & 0xe0) >> 5);
|
|
63
|
+
mPrecisionFactor = Math.pow(10, mPrecision);
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
geometryType,
|
|
67
|
+
precision,
|
|
68
|
+
precisionFactor: Math.pow(10, precision),
|
|
69
|
+
hasBoundingBox: Boolean((metadataHeader >> 0) & 1),
|
|
70
|
+
hasSizeAttribute: Boolean((metadataHeader >> 1) & 1),
|
|
71
|
+
hasIdList: Boolean((metadataHeader >> 2) & 1),
|
|
72
|
+
hasExtendedPrecision,
|
|
73
|
+
isEmpty: Boolean((metadataHeader >> 4) & 1),
|
|
74
|
+
hasZ,
|
|
75
|
+
hasM,
|
|
76
|
+
zPrecision,
|
|
77
|
+
zPrecisionFactor,
|
|
78
|
+
mPrecision,
|
|
79
|
+
mPrecisionFactor
|
|
80
|
+
};
|
|
70
81
|
}
|
|
71
82
|
function parseGeometry(binaryReader, context, geometryType) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
switch (geometryType) {
|
|
84
|
+
case WKBGeometryType.Point:
|
|
85
|
+
return parsePoint(binaryReader, context);
|
|
86
|
+
case WKBGeometryType.LineString:
|
|
87
|
+
return parseLineString(binaryReader, context);
|
|
88
|
+
case WKBGeometryType.Polygon:
|
|
89
|
+
return parsePolygon(binaryReader, context);
|
|
90
|
+
case WKBGeometryType.MultiPoint:
|
|
91
|
+
return parseMultiPoint(binaryReader, context);
|
|
92
|
+
case WKBGeometryType.MultiLineString:
|
|
93
|
+
return parseMultiLineString(binaryReader, context);
|
|
94
|
+
case WKBGeometryType.MultiPolygon:
|
|
95
|
+
return parseMultiPolygon(binaryReader, context);
|
|
96
|
+
case WKBGeometryType.GeometryCollection:
|
|
97
|
+
return parseGeometryCollection(binaryReader, context);
|
|
98
|
+
default:
|
|
99
|
+
throw new Error(`GeometryType ${geometryType} not supported`);
|
|
100
|
+
}
|
|
90
101
|
}
|
|
102
|
+
// GEOMETRIES
|
|
91
103
|
function parsePoint(reader, context) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
type: 'Point',
|
|
100
|
-
coordinates: readFirstPoint(reader, context)
|
|
101
|
-
};
|
|
104
|
+
if (context.isEmpty) {
|
|
105
|
+
return { type: 'Point', coordinates: [] };
|
|
106
|
+
}
|
|
107
|
+
return { type: 'Point', coordinates: readFirstPoint(reader, context) };
|
|
102
108
|
}
|
|
103
109
|
function parseLineString(reader, context) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
points.push(parseNextPoint(reader, context, previousPoint));
|
|
115
|
-
}
|
|
116
|
-
return {
|
|
117
|
-
type: 'LineString',
|
|
118
|
-
coordinates: points
|
|
119
|
-
};
|
|
110
|
+
if (context.isEmpty) {
|
|
111
|
+
return { type: 'LineString', coordinates: [] };
|
|
112
|
+
}
|
|
113
|
+
const pointCount = reader.readVarInt();
|
|
114
|
+
const previousPoint = makePreviousPoint(context);
|
|
115
|
+
const points = [];
|
|
116
|
+
for (let i = 0; i < pointCount; i++) {
|
|
117
|
+
points.push(parseNextPoint(reader, context, previousPoint));
|
|
118
|
+
}
|
|
119
|
+
return { type: 'LineString', coordinates: points };
|
|
120
120
|
}
|
|
121
121
|
function parsePolygon(reader, context) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
interiorRing.push(parseNextPoint(reader, context, previousPoint));
|
|
122
|
+
if (context.isEmpty) {
|
|
123
|
+
return { type: 'Polygon', coordinates: [] };
|
|
124
|
+
}
|
|
125
|
+
const ringCount = reader.readVarInt();
|
|
126
|
+
const previousPoint = makePreviousPoint(context);
|
|
127
|
+
const exteriorRingLength = reader.readVarInt();
|
|
128
|
+
const exteriorRing = [];
|
|
129
|
+
for (let i = 0; i < exteriorRingLength; i++) {
|
|
130
|
+
exteriorRing.push(parseNextPoint(reader, context, previousPoint));
|
|
131
|
+
}
|
|
132
|
+
const polygon = [exteriorRing];
|
|
133
|
+
for (let i = 1; i < ringCount; i++) {
|
|
134
|
+
const interiorRingCount = reader.readVarInt();
|
|
135
|
+
const interiorRing = [];
|
|
136
|
+
for (let j = 0; j < interiorRingCount; j++) {
|
|
137
|
+
interiorRing.push(parseNextPoint(reader, context, previousPoint));
|
|
138
|
+
}
|
|
139
|
+
polygon.push(interiorRing);
|
|
141
140
|
}
|
|
142
|
-
polygon
|
|
143
|
-
}
|
|
144
|
-
return {
|
|
145
|
-
type: 'Polygon',
|
|
146
|
-
coordinates: polygon
|
|
147
|
-
};
|
|
141
|
+
return { type: 'Polygon', coordinates: polygon };
|
|
148
142
|
}
|
|
149
143
|
function parseMultiPoint(reader, context) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
coordinates.push(parseNextPoint(reader, context, previousPoint));
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
type: 'MultiPoint',
|
|
164
|
-
coordinates
|
|
165
|
-
};
|
|
144
|
+
if (context.isEmpty) {
|
|
145
|
+
return { type: 'MultiPoint', coordinates: [] };
|
|
146
|
+
}
|
|
147
|
+
const previousPoint = makePreviousPoint(context);
|
|
148
|
+
const pointCount = reader.readVarInt();
|
|
149
|
+
const coordinates = [];
|
|
150
|
+
for (let i = 0; i < pointCount; i++) {
|
|
151
|
+
coordinates.push(parseNextPoint(reader, context, previousPoint));
|
|
152
|
+
}
|
|
153
|
+
return { type: 'MultiPoint', coordinates };
|
|
166
154
|
}
|
|
167
155
|
function parseMultiLineString(reader, context) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
lineString.push(parseNextPoint(reader, context, previousPoint));
|
|
156
|
+
if (context.isEmpty) {
|
|
157
|
+
return { type: 'MultiLineString', coordinates: [] };
|
|
158
|
+
}
|
|
159
|
+
const previousPoint = makePreviousPoint(context);
|
|
160
|
+
const lineStringCount = reader.readVarInt();
|
|
161
|
+
const coordinates = [];
|
|
162
|
+
for (let i = 0; i < lineStringCount; i++) {
|
|
163
|
+
const pointCount = reader.readVarInt();
|
|
164
|
+
const lineString = [];
|
|
165
|
+
for (let j = 0; j < pointCount; j++) {
|
|
166
|
+
lineString.push(parseNextPoint(reader, context, previousPoint));
|
|
167
|
+
}
|
|
168
|
+
coordinates.push(lineString);
|
|
182
169
|
}
|
|
183
|
-
coordinates
|
|
184
|
-
}
|
|
185
|
-
return {
|
|
186
|
-
type: 'MultiLineString',
|
|
187
|
-
coordinates
|
|
188
|
-
};
|
|
170
|
+
return { type: 'MultiLineString', coordinates };
|
|
189
171
|
}
|
|
190
172
|
function parseMultiPolygon(reader, context) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
type: 'MultiPolygon',
|
|
194
|
-
coordinates: []
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
const previousPoint = makePreviousPoint(context);
|
|
198
|
-
const polygonCount = reader.readVarInt();
|
|
199
|
-
const polygons = [];
|
|
200
|
-
for (let i = 0; i < polygonCount; i++) {
|
|
201
|
-
const ringCount = reader.readVarInt();
|
|
202
|
-
const exteriorPointCount = reader.readVarInt();
|
|
203
|
-
const exteriorRing = [];
|
|
204
|
-
for (let j = 0; j < exteriorPointCount; j++) {
|
|
205
|
-
exteriorRing.push(parseNextPoint(reader, context, previousPoint));
|
|
173
|
+
if (context.isEmpty) {
|
|
174
|
+
return { type: 'MultiPolygon', coordinates: [] };
|
|
206
175
|
}
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
176
|
+
const previousPoint = makePreviousPoint(context);
|
|
177
|
+
const polygonCount = reader.readVarInt();
|
|
178
|
+
const polygons = [];
|
|
179
|
+
for (let i = 0; i < polygonCount; i++) {
|
|
180
|
+
const ringCount = reader.readVarInt();
|
|
181
|
+
const exteriorPointCount = reader.readVarInt();
|
|
182
|
+
const exteriorRing = [];
|
|
183
|
+
for (let j = 0; j < exteriorPointCount; j++) {
|
|
184
|
+
exteriorRing.push(parseNextPoint(reader, context, previousPoint));
|
|
185
|
+
}
|
|
186
|
+
const polygon = exteriorRing ? [exteriorRing] : [];
|
|
187
|
+
for (let j = 1; j < ringCount; j++) {
|
|
188
|
+
const interiorRing = [];
|
|
189
|
+
const interiorRingLength = reader.readVarInt();
|
|
190
|
+
for (let k = 0; k < interiorRingLength; k++) {
|
|
191
|
+
interiorRing.push(parseNextPoint(reader, context, previousPoint));
|
|
192
|
+
}
|
|
193
|
+
polygon.push(interiorRing);
|
|
194
|
+
}
|
|
195
|
+
polygons.push(polygon);
|
|
215
196
|
}
|
|
216
|
-
polygons
|
|
217
|
-
}
|
|
218
|
-
return {
|
|
219
|
-
type: 'MultiPolygon',
|
|
220
|
-
coordinates: polygons
|
|
221
|
-
};
|
|
197
|
+
return { type: 'MultiPolygon', coordinates: polygons };
|
|
222
198
|
}
|
|
199
|
+
/** Geometry collection not yet supported */
|
|
223
200
|
function parseGeometryCollection(reader, context) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
201
|
+
return { type: 'GeometryCollection', geometries: [] };
|
|
202
|
+
/**
|
|
203
|
+
if (context.isEmpty) {
|
|
204
|
+
return {type: 'GeometryCollection', geometries: []};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const geometryCount = reader.readVarInt();
|
|
208
|
+
|
|
209
|
+
const geometries: Geometry[] = new Array(geometryCount);
|
|
210
|
+
for (let i = 0; i < geometryCount; i++) {
|
|
211
|
+
const geometry = parseGeometry(reader, context, geometryType);
|
|
212
|
+
geometries.push(geometry);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return {type: 'GeometryCollection', geometries: []};
|
|
216
|
+
*/
|
|
217
|
+
}
|
|
218
|
+
// HELPERS
|
|
219
|
+
/**
|
|
220
|
+
* Maps negative values to positive values while going back and
|
|
221
|
+
forth (0 = 0, -1 = 1, 1 = 2, -2 = 3, 2 = 4, -3 = 5, 3 = 6 ...)
|
|
222
|
+
*/
|
|
229
223
|
function zigZagDecode(value) {
|
|
230
|
-
|
|
224
|
+
return (value >> 1) ^ -(value & 1);
|
|
231
225
|
}
|
|
232
226
|
function makePointCoordinates(x, y, z, m) {
|
|
233
|
-
|
|
227
|
+
return (z !== undefined ? (m !== undefined ? [x, y, z, m] : [x, y, z]) : [x, y]);
|
|
234
228
|
}
|
|
235
229
|
function makePreviousPoint(context) {
|
|
236
|
-
|
|
230
|
+
return makePointCoordinates(0, 0, context.hasZ ? 0 : undefined, context.hasM ? 0 : undefined);
|
|
237
231
|
}
|
|
238
232
|
function readFirstPoint(reader, context) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
233
|
+
const x = zigZagDecode(reader.readVarInt()) / context.precisionFactor;
|
|
234
|
+
const y = zigZagDecode(reader.readVarInt()) / context.precisionFactor;
|
|
235
|
+
const z = context.hasZ ? zigZagDecode(reader.readVarInt()) / context.zPrecisionFactor : undefined;
|
|
236
|
+
const m = context.hasM ? zigZagDecode(reader.readVarInt()) / context.mPrecisionFactor : undefined;
|
|
237
|
+
return makePointCoordinates(x, y, z, m);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Modifies previousPoint
|
|
241
|
+
*/
|
|
245
242
|
function parseNextPoint(reader, context, previousPoint) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
243
|
+
previousPoint[0] += zigZagDecode(reader.readVarInt()) / context.precisionFactor;
|
|
244
|
+
previousPoint[1] += zigZagDecode(reader.readVarInt()) / context.precisionFactor;
|
|
245
|
+
if (context.hasZ) {
|
|
246
|
+
previousPoint[2] += zigZagDecode(reader.readVarInt()) / context.zPrecisionFactor;
|
|
247
|
+
}
|
|
248
|
+
if (context.hasM) {
|
|
249
|
+
previousPoint[3] += zigZagDecode(reader.readVarInt()) / context.mPrecisionFactor;
|
|
250
|
+
}
|
|
251
|
+
// Copy the point
|
|
252
|
+
return previousPoint.slice();
|
|
255
253
|
}
|
|
256
|
-
//# sourceMappingURL=parse-twkb.js.map
|