@loaders.gl/wkt 4.0.0-alpha.4 → 4.0.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.
Files changed (117) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +2 -2
  4. package/dist/dist.min.js +989 -0
  5. package/dist/es5/bundle.js +6 -0
  6. package/dist/es5/bundle.js.map +1 -0
  7. package/dist/es5/index.js +46 -0
  8. package/dist/es5/index.js.map +1 -0
  9. package/dist/es5/lib/encode-wkb.js +373 -0
  10. package/dist/es5/lib/encode-wkb.js.map +1 -0
  11. package/dist/es5/lib/encode-wkt.js +45 -0
  12. package/dist/es5/lib/encode-wkt.js.map +1 -0
  13. package/dist/es5/lib/parse-wkb.js +290 -0
  14. package/dist/es5/lib/parse-wkb.js.map +1 -0
  15. package/dist/es5/lib/parse-wkt.js +176 -0
  16. package/dist/es5/lib/parse-wkt.js.map +1 -0
  17. package/dist/es5/lib/utils/binary-writer.js +161 -0
  18. package/dist/es5/lib/utils/binary-writer.js.map +1 -0
  19. package/dist/es5/lib/utils/version.js +9 -0
  20. package/dist/es5/lib/utils/version.js.map +1 -0
  21. package/dist/es5/wkb-loader.js +54 -0
  22. package/dist/es5/wkb-loader.js.map +1 -0
  23. package/dist/es5/wkb-writer.js +25 -0
  24. package/dist/es5/wkb-writer.js.map +1 -0
  25. package/dist/es5/wkt-loader.js +51 -0
  26. package/dist/es5/wkt-loader.js.map +1 -0
  27. package/dist/es5/wkt-writer.js +22 -0
  28. package/dist/es5/wkt-writer.js.map +1 -0
  29. package/dist/es5/workers/wkb-worker.js +6 -0
  30. package/dist/es5/workers/wkb-worker.js.map +1 -0
  31. package/dist/es5/workers/wkt-worker.js +6 -0
  32. package/dist/es5/workers/wkt-worker.js.map +1 -0
  33. package/dist/esm/bundle.js +4 -0
  34. package/dist/esm/bundle.js.map +1 -0
  35. package/dist/esm/index.js +5 -0
  36. package/dist/esm/index.js.map +1 -0
  37. package/dist/esm/lib/encode-wkb.js +252 -0
  38. package/dist/esm/lib/encode-wkb.js.map +1 -0
  39. package/dist/esm/lib/encode-wkt.js +39 -0
  40. package/dist/esm/lib/encode-wkt.js.map +1 -0
  41. package/dist/esm/lib/parse-wkb.js +255 -0
  42. package/dist/esm/lib/parse-wkb.js.map +1 -0
  43. package/dist/esm/lib/parse-wkt.js +170 -0
  44. package/dist/esm/lib/parse-wkt.js.map +1 -0
  45. package/dist/esm/lib/utils/binary-writer.js +114 -0
  46. package/dist/esm/lib/utils/binary-writer.js.map +1 -0
  47. package/dist/esm/lib/utils/version.js +2 -0
  48. package/dist/esm/lib/utils/version.js.map +1 -0
  49. package/dist/esm/wkb-loader.js +23 -0
  50. package/dist/esm/wkb-loader.js.map +1 -0
  51. package/dist/esm/wkb-writer.js +17 -0
  52. package/dist/esm/wkb-writer.js.map +1 -0
  53. package/dist/esm/wkt-loader.js +22 -0
  54. package/dist/esm/wkt-loader.js.map +1 -0
  55. package/dist/esm/wkt-writer.js +14 -0
  56. package/dist/esm/wkt-writer.js.map +1 -0
  57. package/dist/esm/workers/wkb-worker.js +4 -0
  58. package/dist/esm/workers/wkb-worker.js.map +1 -0
  59. package/dist/esm/workers/wkt-worker.js +4 -0
  60. package/dist/esm/workers/wkt-worker.js.map +1 -0
  61. package/dist/index.d.ts +5 -0
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +13 -4
  64. package/dist/lib/encode-wkb.d.ts +22 -0
  65. package/dist/lib/encode-wkb.d.ts.map +1 -0
  66. package/dist/lib/encode-wkb.js +295 -0
  67. package/dist/lib/encode-wkt.d.ts +8 -0
  68. package/dist/lib/encode-wkt.d.ts.map +1 -0
  69. package/dist/lib/encode-wkt.js +41 -49
  70. package/dist/lib/parse-wkb.d.ts +3 -0
  71. package/dist/lib/parse-wkb.d.ts.map +1 -0
  72. package/dist/lib/parse-wkb.js +208 -276
  73. package/dist/lib/parse-wkt.d.ts +8 -0
  74. package/dist/lib/parse-wkt.d.ts.map +1 -0
  75. package/dist/lib/parse-wkt.js +218 -189
  76. package/dist/lib/utils/binary-writer.d.ts +28 -0
  77. package/dist/lib/utils/binary-writer.d.ts.map +1 -0
  78. package/dist/lib/utils/binary-writer.js +120 -0
  79. package/dist/lib/utils/version.d.ts +2 -0
  80. package/dist/lib/utils/version.d.ts.map +1 -0
  81. package/dist/lib/utils/version.js +7 -2
  82. package/dist/wkb-loader.d.ts +39 -0
  83. package/dist/wkb-loader.d.ts.map +1 -0
  84. package/dist/wkb-loader.js +32 -20
  85. package/dist/wkb-writer.d.ts +6 -0
  86. package/dist/wkb-writer.d.ts.map +1 -0
  87. package/dist/wkb-writer.js +26 -0
  88. package/dist/wkt-loader.d.ts +10 -0
  89. package/dist/wkt-loader.d.ts.map +1 -0
  90. package/dist/wkt-loader.js +31 -19
  91. package/dist/wkt-worker.js +48 -16
  92. package/dist/wkt-writer.d.ts +6 -0
  93. package/dist/wkt-writer.d.ts.map +1 -0
  94. package/dist/wkt-writer.js +22 -13
  95. package/dist/workers/wkb-worker.d.ts +2 -0
  96. package/dist/workers/wkb-worker.d.ts.map +1 -0
  97. package/dist/workers/wkb-worker.js +5 -4
  98. package/dist/workers/wkt-worker.d.ts +2 -0
  99. package/dist/workers/wkt-worker.d.ts.map +1 -0
  100. package/dist/workers/wkt-worker.js +5 -4
  101. package/package.json +9 -9
  102. package/src/index.ts +1 -0
  103. package/src/lib/encode-wkb.ts +397 -0
  104. package/src/lib/encode-wkt.ts +34 -36
  105. package/src/lib/utils/binary-writer.ts +125 -0
  106. package/src/wkb-writer.ts +22 -0
  107. package/dist/bundle.js.map +0 -1
  108. package/dist/index.js.map +0 -1
  109. package/dist/lib/encode-wkt.js.map +0 -1
  110. package/dist/lib/parse-wkb.js.map +0 -1
  111. package/dist/lib/parse-wkt.js.map +0 -1
  112. package/dist/lib/utils/version.js.map +0 -1
  113. package/dist/wkb-loader.js.map +0 -1
  114. package/dist/wkt-loader.js.map +0 -1
  115. package/dist/wkt-writer.js.map +0 -1
  116. package/dist/workers/wkb-worker.js.map +0 -1
  117. package/dist/workers/wkt-worker.js.map +0 -1
@@ -1,198 +1,227 @@
1
+ "use strict";
2
+ // Fork of https://github.com/mapbox/wellknown under ISC license (MIT/BSD-2-clause equivalent)
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ /* eslint-disable */
5
+ // @ts-nocheck
1
6
  const numberRegexp = /[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/;
7
+ // Matches sequences like '100 100' or '100 100 100'.
2
8
  const tuples = new RegExp('^' + numberRegexp.source + '(\\s' + numberRegexp.source + '){1,}');
3
- export default function parseWKT(input) {
4
- const parts = input.split(';');
5
-
6
- let _ = parts.pop();
7
-
8
- const srid = (parts.shift() || '').split('=').pop();
9
- let i = 0;
10
-
11
- function $(re) {
12
- const match = _.substring(i).match(re);
13
-
14
- if (!match) return null;else {
15
- i += match[0].length;
16
- return match[0];
9
+ /**
10
+ * Parse WKT and return GeoJSON.
11
+ *
12
+ * @param {string} _ A WKT geometry
13
+ * @return {?Object} A GeoJSON geometry object
14
+ **/
15
+ function parseWKT(input) {
16
+ const parts = input.split(';');
17
+ let _ = parts.pop();
18
+ const srid = (parts.shift() || '').split('=').pop();
19
+ let i = 0;
20
+ function $(re) {
21
+ const match = _.substring(i).match(re);
22
+ if (!match)
23
+ return null;
24
+ else {
25
+ i += match[0].length;
26
+ return match[0];
27
+ }
28
+ }
29
+ function crs(obj) {
30
+ if (obj && srid.match(/\d+/)) {
31
+ obj.crs = {
32
+ type: 'name',
33
+ properties: {
34
+ name: 'urn:ogc:def:crs:EPSG::' + srid
35
+ }
36
+ };
37
+ }
38
+ return obj;
39
+ }
40
+ function white() {
41
+ $(/^\s*/);
42
+ }
43
+ function multicoords() {
44
+ white();
45
+ let depth = 0;
46
+ const rings = [];
47
+ const stack = [rings];
48
+ let pointer = rings;
49
+ let elem;
50
+ while ((elem = $(/^(\()/) || $(/^(\))/) || $(/^(,)/) || $(tuples))) {
51
+ if (elem === '(') {
52
+ stack.push(pointer);
53
+ pointer = [];
54
+ stack[stack.length - 1].push(pointer);
55
+ depth++;
56
+ }
57
+ else if (elem === ')') {
58
+ // For the case: Polygon(), ...
59
+ if (pointer.length === 0)
60
+ return null;
61
+ // @ts-ignore
62
+ pointer = stack.pop();
63
+ // the stack was empty, input was malformed
64
+ if (!pointer)
65
+ return null;
66
+ depth--;
67
+ if (depth === 0)
68
+ break;
69
+ }
70
+ else if (elem === ',') {
71
+ pointer = [];
72
+ stack[stack.length - 1].push(pointer);
73
+ }
74
+ else if (!elem.split(/\s/g).some(isNaN)) {
75
+ Array.prototype.push.apply(pointer, elem.split(/\s/g).map(parseFloat));
76
+ }
77
+ else {
78
+ return null;
79
+ }
80
+ white();
81
+ }
82
+ if (depth !== 0)
83
+ return null;
84
+ return rings;
17
85
  }
18
- }
19
-
20
- function crs(obj) {
21
- if (obj && srid.match(/\d+/)) {
22
- obj.crs = {
23
- type: 'name',
24
- properties: {
25
- name: 'urn:ogc:def:crs:EPSG::' + srid
86
+ function coords() {
87
+ const list = [];
88
+ let item;
89
+ let pt;
90
+ while ((pt = $(tuples) || $(/^(,)/))) {
91
+ if (pt === ',') {
92
+ list.push(item);
93
+ item = [];
94
+ }
95
+ else if (!pt.split(/\s/g).some(isNaN)) {
96
+ if (!item)
97
+ item = [];
98
+ Array.prototype.push.apply(item, pt.split(/\s/g).map(parseFloat));
99
+ }
100
+ white();
26
101
  }
27
- };
102
+ if (item)
103
+ list.push(item);
104
+ else
105
+ return null;
106
+ return list.length ? list : null;
28
107
  }
29
-
30
- return obj;
31
- }
32
-
33
- function white() {
34
- $(/^\s*/);
35
- }
36
-
37
- function multicoords() {
38
- white();
39
- let depth = 0;
40
- const rings = [];
41
- const stack = [rings];
42
- let pointer = rings;
43
- let elem;
44
-
45
- while (elem = $(/^(\()/) || $(/^(\))/) || $(/^(,)/) || $(tuples)) {
46
- if (elem === '(') {
47
- stack.push(pointer);
48
- pointer = [];
49
- stack[stack.length - 1].push(pointer);
50
- depth++;
51
- } else if (elem === ')') {
52
- if (pointer.length === 0) return null;
53
- pointer = stack.pop();
54
- if (!pointer) return null;
55
- depth--;
56
- if (depth === 0) break;
57
- } else if (elem === ',') {
58
- pointer = [];
59
- stack[stack.length - 1].push(pointer);
60
- } else if (!elem.split(/\s/g).some(isNaN)) {
61
- Array.prototype.push.apply(pointer, elem.split(/\s/g).map(parseFloat));
62
- } else {
63
- return null;
64
- }
65
-
66
- white();
108
+ function point() {
109
+ if (!$(/^(point(\sz)?)/i))
110
+ return null;
111
+ white();
112
+ if (!$(/^(\()/))
113
+ return null;
114
+ const c = coords();
115
+ if (!c)
116
+ return null;
117
+ white();
118
+ if (!$(/^(\))/))
119
+ return null;
120
+ return {
121
+ type: 'Point',
122
+ coordinates: c[0]
123
+ };
67
124
  }
68
-
69
- if (depth !== 0) return null;
70
- return rings;
71
- }
72
-
73
- function coords() {
74
- const list = [];
75
- let item;
76
- let pt;
77
-
78
- while (pt = $(tuples) || $(/^(,)/)) {
79
- if (pt === ',') {
80
- list.push(item);
81
- item = [];
82
- } else if (!pt.split(/\s/g).some(isNaN)) {
83
- if (!item) item = [];
84
- Array.prototype.push.apply(item, pt.split(/\s/g).map(parseFloat));
85
- }
86
-
87
- white();
125
+ function multipoint() {
126
+ if (!$(/^(multipoint)/i))
127
+ return null;
128
+ white();
129
+ const newCoordsFormat = _.substring(_.indexOf('(') + 1, _.length - 1)
130
+ .replace(/\(/g, '')
131
+ .replace(/\)/g, '');
132
+ _ = 'MULTIPOINT (' + newCoordsFormat + ')';
133
+ const c = multicoords();
134
+ if (!c)
135
+ return null;
136
+ white();
137
+ return {
138
+ type: 'MultiPoint',
139
+ coordinates: c
140
+ };
141
+ }
142
+ function multilinestring() {
143
+ if (!$(/^(multilinestring)/i))
144
+ return null;
145
+ white();
146
+ const c = multicoords();
147
+ if (!c)
148
+ return null;
149
+ white();
150
+ return {
151
+ type: 'MultiLineString',
152
+ coordinates: c
153
+ };
154
+ }
155
+ function linestring() {
156
+ if (!$(/^(linestring(\sz)?)/i))
157
+ return null;
158
+ white();
159
+ if (!$(/^(\()/))
160
+ return null;
161
+ const c = coords();
162
+ if (!c)
163
+ return null;
164
+ if (!$(/^(\))/))
165
+ return null;
166
+ return {
167
+ type: 'LineString',
168
+ coordinates: c
169
+ };
170
+ }
171
+ function polygon() {
172
+ if (!$(/^(polygon(\sz)?)/i))
173
+ return null;
174
+ white();
175
+ const c = multicoords();
176
+ if (!c)
177
+ return null;
178
+ return {
179
+ type: 'Polygon',
180
+ coordinates: c
181
+ };
182
+ }
183
+ function multipolygon() {
184
+ if (!$(/^(multipolygon)/i))
185
+ return null;
186
+ white();
187
+ const c = multicoords();
188
+ if (!c)
189
+ return null;
190
+ return {
191
+ type: 'MultiPolygon',
192
+ coordinates: c
193
+ };
194
+ }
195
+ function geometrycollection() {
196
+ const geometries = [];
197
+ let geometry;
198
+ if (!$(/^(geometrycollection)/i))
199
+ return null;
200
+ white();
201
+ if (!$(/^(\()/))
202
+ return null;
203
+ while ((geometry = root())) {
204
+ geometries.push(geometry);
205
+ white();
206
+ $(/^(,)/);
207
+ white();
208
+ }
209
+ if (!$(/^(\))/))
210
+ return null;
211
+ return {
212
+ type: 'GeometryCollection',
213
+ geometries: geometries
214
+ };
88
215
  }
89
-
90
- if (item) list.push(item);else return null;
91
- return list.length ? list : null;
92
- }
93
-
94
- function point() {
95
- if (!$(/^(point(\sz)?)/i)) return null;
96
- white();
97
- if (!$(/^(\()/)) return null;
98
- const c = coords();
99
- if (!c) return null;
100
- white();
101
- if (!$(/^(\))/)) return null;
102
- return {
103
- type: 'Point',
104
- coordinates: c[0]
105
- };
106
- }
107
-
108
- function multipoint() {
109
- if (!$(/^(multipoint)/i)) return null;
110
- white();
111
-
112
- const newCoordsFormat = _.substring(_.indexOf('(') + 1, _.length - 1).replace(/\(/g, '').replace(/\)/g, '');
113
-
114
- _ = 'MULTIPOINT (' + newCoordsFormat + ')';
115
- const c = multicoords();
116
- if (!c) return null;
117
- white();
118
- return {
119
- type: 'MultiPoint',
120
- coordinates: c
121
- };
122
- }
123
-
124
- function multilinestring() {
125
- if (!$(/^(multilinestring)/i)) return null;
126
- white();
127
- const c = multicoords();
128
- if (!c) return null;
129
- white();
130
- return {
131
- type: 'MultiLineString',
132
- coordinates: c
133
- };
134
- }
135
-
136
- function linestring() {
137
- if (!$(/^(linestring(\sz)?)/i)) return null;
138
- white();
139
- if (!$(/^(\()/)) return null;
140
- const c = coords();
141
- if (!c) return null;
142
- if (!$(/^(\))/)) return null;
143
- return {
144
- type: 'LineString',
145
- coordinates: c
146
- };
147
- }
148
-
149
- function polygon() {
150
- if (!$(/^(polygon(\sz)?)/i)) return null;
151
- white();
152
- const c = multicoords();
153
- if (!c) return null;
154
- return {
155
- type: 'Polygon',
156
- coordinates: c
157
- };
158
- }
159
-
160
- function multipolygon() {
161
- if (!$(/^(multipolygon)/i)) return null;
162
- white();
163
- const c = multicoords();
164
- if (!c) return null;
165
- return {
166
- type: 'MultiPolygon',
167
- coordinates: c
168
- };
169
- }
170
-
171
- function geometrycollection() {
172
- const geometries = [];
173
- let geometry;
174
- if (!$(/^(geometrycollection)/i)) return null;
175
- white();
176
- if (!$(/^(\()/)) return null;
177
-
178
- while (geometry = root()) {
179
- geometries.push(geometry);
180
- white();
181
- $(/^(,)/);
182
- white();
216
+ function root() {
217
+ return (point() ||
218
+ linestring() ||
219
+ polygon() ||
220
+ multipoint() ||
221
+ multilinestring() ||
222
+ multipolygon() ||
223
+ geometrycollection());
183
224
  }
184
-
185
- if (!$(/^(\))/)) return null;
186
- return {
187
- type: 'GeometryCollection',
188
- geometries: geometries
189
- };
190
- }
191
-
192
- function root() {
193
- return point() || linestring() || polygon() || multipoint() || multilinestring() || multipolygon() || geometrycollection();
194
- }
195
-
196
- return crs(root());
225
+ return crs(root());
197
226
  }
198
- //# sourceMappingURL=parse-wkt.js.map
227
+ exports.default = parseWKT;
@@ -0,0 +1,28 @@
1
+ export default class BinaryWriter {
2
+ arrayBuffer: ArrayBuffer;
3
+ dataView: DataView;
4
+ byteOffset: number;
5
+ allowResize: boolean;
6
+ constructor(size: number, allowResize?: boolean);
7
+ writeUInt8(value: number): void;
8
+ writeUInt16LE(value: number): void;
9
+ writeUInt16BE(value: number): void;
10
+ writeUInt32LE(value: number): void;
11
+ writeUInt32BE(value: number): void;
12
+ writeInt8(value: number): void;
13
+ writeInt16LE(value: number): void;
14
+ writeInt16BE(value: number): void;
15
+ writeInt32LE(value: number): void;
16
+ writeInt32BE(value: number): void;
17
+ writeFloatLE(value: number): void;
18
+ writeFloatBE(value: number): void;
19
+ writeDoubleLE(value: number): void;
20
+ writeDoubleBE(value: number): void;
21
+ /** A varint uses a variable number of bytes */
22
+ writeVarInt(value: number): number;
23
+ /** Append another ArrayBuffer to this ArrayBuffer */
24
+ writeBuffer(arrayBuffer: ArrayBuffer): void;
25
+ /** Resizes this.arrayBuffer if not enough space */
26
+ _ensureSize(size: number): void;
27
+ }
28
+ //# sourceMappingURL=binary-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary-writer.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/binary-writer.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,MAAM,CAAK;IACvB,WAAW,EAAE,OAAO,CAAS;gBAEjB,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO;IAO/C,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK/B,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKlC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKlC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKlC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKlC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK9B,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKjC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKjC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKjC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKjC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKjC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKjC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKlC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAMlC,+CAA+C;IAC/C,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAYlC,qDAAqD;IACrD,WAAW,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAO3C,mDAAmD;IACnD,WAAW,CAAC,IAAI,EAAE,MAAM;CAYzB"}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ // loaders.gl, MIT license
3
+ // Forked from https://github.com/cschwarz/wkx under MIT license, Copyright (c) 2013 Christian Schwarz
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ const LE = true;
6
+ const BE = false;
7
+ class BinaryWriter {
8
+ constructor(size, allowResize) {
9
+ this.byteOffset = 0;
10
+ this.allowResize = false;
11
+ this.arrayBuffer = new ArrayBuffer(size);
12
+ this.dataView = new DataView(this.arrayBuffer);
13
+ this.byteOffset = 0;
14
+ this.allowResize = allowResize || false;
15
+ }
16
+ writeUInt8(value) {
17
+ this._ensureSize(1);
18
+ this.dataView.setUint8(this.byteOffset, value);
19
+ this.byteOffset += 1;
20
+ }
21
+ writeUInt16LE(value) {
22
+ this._ensureSize(2);
23
+ this.dataView.setUint16(this.byteOffset, value, LE);
24
+ this.byteOffset += 2;
25
+ }
26
+ writeUInt16BE(value) {
27
+ this._ensureSize(2);
28
+ this.dataView.setUint16(this.byteOffset, value, BE);
29
+ this.byteOffset += 2;
30
+ }
31
+ writeUInt32LE(value) {
32
+ this._ensureSize(4);
33
+ this.dataView.setUint32(this.byteOffset, value, LE);
34
+ this.byteOffset += 4;
35
+ }
36
+ writeUInt32BE(value) {
37
+ this._ensureSize(4);
38
+ this.dataView.setUint32(this.byteOffset, value, BE);
39
+ this.byteOffset += 4;
40
+ }
41
+ writeInt8(value) {
42
+ this._ensureSize(1);
43
+ this.dataView.setInt8(this.byteOffset, value);
44
+ this.byteOffset += 1;
45
+ }
46
+ writeInt16LE(value) {
47
+ this._ensureSize(2);
48
+ this.dataView.setInt16(this.byteOffset, value, LE);
49
+ this.byteOffset += 2;
50
+ }
51
+ writeInt16BE(value) {
52
+ this._ensureSize(2);
53
+ this.dataView.setInt16(this.byteOffset, value, BE);
54
+ this.byteOffset += 2;
55
+ }
56
+ writeInt32LE(value) {
57
+ this._ensureSize(4);
58
+ this.dataView.setInt32(this.byteOffset, value, LE);
59
+ this.byteOffset += 4;
60
+ }
61
+ writeInt32BE(value) {
62
+ this._ensureSize(4);
63
+ this.dataView.setInt32(this.byteOffset, value, BE);
64
+ this.byteOffset += 4;
65
+ }
66
+ writeFloatLE(value) {
67
+ this._ensureSize(4);
68
+ this.dataView.setFloat32(this.byteOffset, value, LE);
69
+ this.byteOffset += 4;
70
+ }
71
+ writeFloatBE(value) {
72
+ this._ensureSize(4);
73
+ this.dataView.setFloat32(this.byteOffset, value, BE);
74
+ this.byteOffset += 4;
75
+ }
76
+ writeDoubleLE(value) {
77
+ this._ensureSize(8);
78
+ this.dataView.setFloat64(this.byteOffset, value, LE);
79
+ this.byteOffset += 8;
80
+ }
81
+ writeDoubleBE(value) {
82
+ this._ensureSize(8);
83
+ this.dataView.setFloat64(this.byteOffset, value, BE);
84
+ this.byteOffset += 8;
85
+ }
86
+ /** A varint uses a variable number of bytes */
87
+ writeVarInt(value) {
88
+ // TODO - ensure size?
89
+ let length = 1;
90
+ while ((value & 0xffffff80) !== 0) {
91
+ this.writeUInt8((value & 0x7f) | 0x80);
92
+ value >>>= 7;
93
+ length++;
94
+ }
95
+ this.writeUInt8(value & 0x7f);
96
+ return length;
97
+ }
98
+ /** Append another ArrayBuffer to this ArrayBuffer */
99
+ writeBuffer(arrayBuffer) {
100
+ this._ensureSize(arrayBuffer.byteLength);
101
+ const tempArray = new Uint8Array(this.arrayBuffer);
102
+ tempArray.set(new Uint8Array(arrayBuffer), this.byteOffset);
103
+ this.byteOffset += arrayBuffer.byteLength;
104
+ }
105
+ /** Resizes this.arrayBuffer if not enough space */
106
+ _ensureSize(size) {
107
+ if (this.arrayBuffer.byteLength < this.byteOffset + size) {
108
+ if (this.allowResize) {
109
+ const newArrayBuffer = new ArrayBuffer(this.byteOffset + size);
110
+ const tempArray = new Uint8Array(newArrayBuffer);
111
+ tempArray.set(new Uint8Array(this.arrayBuffer));
112
+ this.arrayBuffer = newArrayBuffer;
113
+ }
114
+ else {
115
+ throw new Error('BinaryWriter overflow');
116
+ }
117
+ }
118
+ }
119
+ }
120
+ exports.default = BinaryWriter;
@@ -0,0 +1,2 @@
1
+ export declare const VERSION: any;
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/version.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,KAA8D,CAAC"}
@@ -1,2 +1,7 @@
1
- export const VERSION = typeof "4.0.0-alpha.4" !== 'undefined' ? "4.0.0-alpha.4" : 'latest';
2
- //# sourceMappingURL=version.js.map
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VERSION = void 0;
4
+ // Version constant cannot be imported, it needs to correspond to the build version of **this** module.
5
+ // __VERSION__ is injected by babel-plugin-version-inline
6
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
+ exports.VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
@@ -0,0 +1,39 @@
1
+ import type { Loader, LoaderWithParser } from '@loaders.gl/loader-utils';
2
+ import parseWKB from './lib/parse-wkb';
3
+ /**
4
+ * Worker loader for WKB (Well-Known Binary)
5
+ */
6
+ export declare const WKBWorkerLoader: {
7
+ name: string;
8
+ id: string;
9
+ module: string;
10
+ version: any;
11
+ worker: boolean;
12
+ category: string;
13
+ extensions: string[];
14
+ mimeTypes: never[];
15
+ options: {
16
+ wkb: {};
17
+ };
18
+ };
19
+ /**
20
+ * Loader for WKB (Well-Known Binary)
21
+ */
22
+ export declare const WKBLoader: {
23
+ parse: (arrayBuffer: ArrayBuffer) => Promise<import("@loaders.gl/schema").BinaryGeometry>;
24
+ parseSync: typeof parseWKB;
25
+ name: string;
26
+ id: string;
27
+ module: string;
28
+ version: any;
29
+ worker: boolean;
30
+ category: string;
31
+ extensions: string[];
32
+ mimeTypes: never[];
33
+ options: {
34
+ wkb: {};
35
+ };
36
+ };
37
+ export declare const _typecheckWKBWorkerLoader: Loader;
38
+ export declare const _typecheckWKBLoader: LoaderWithParser;
39
+ //# sourceMappingURL=wkb-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wkb-loader.d.ts","sourceRoot":"","sources":["../src/wkb-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAEvE,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;CAY3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS;yBAEO,WAAW;;;;;;;;;;;;;CAEvC,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,MAAwB,CAAC;AACjE,eAAO,MAAM,mBAAmB,EAAE,gBAA4B,CAAC"}
@@ -1,22 +1,34 @@
1
- import { VERSION } from './lib/utils/version';
2
- import parseWKB from './lib/parse-wkb';
3
- export const WKBWorkerLoader = {
4
- name: 'WKB',
5
- id: 'wkb',
6
- module: 'wkt',
7
- version: VERSION,
8
- worker: true,
9
- category: 'geometry',
10
- extensions: ['wkb'],
11
- mimeTypes: [],
12
- options: {
13
- wkb: {}
14
- }
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
4
  };
16
- export const WKBLoader = { ...WKBWorkerLoader,
17
- parse: async arrayBuffer => parseWKB(arrayBuffer),
18
- parseSync: parseWKB
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports._typecheckWKBLoader = exports._typecheckWKBWorkerLoader = exports.WKBLoader = exports.WKBWorkerLoader = void 0;
7
+ const version_1 = require("./lib/utils/version");
8
+ const parse_wkb_1 = __importDefault(require("./lib/parse-wkb"));
9
+ /**
10
+ * Worker loader for WKB (Well-Known Binary)
11
+ */
12
+ exports.WKBWorkerLoader = {
13
+ name: 'WKB',
14
+ id: 'wkb',
15
+ module: 'wkt',
16
+ version: version_1.VERSION,
17
+ worker: true,
18
+ category: 'geometry',
19
+ extensions: ['wkb'],
20
+ mimeTypes: [],
21
+ options: {
22
+ wkb: {}
23
+ }
19
24
  };
20
- export const _typecheckWKBWorkerLoader = WKBWorkerLoader;
21
- export const _typecheckWKBLoader = WKBLoader;
22
- //# sourceMappingURL=wkb-loader.js.map
25
+ /**
26
+ * Loader for WKB (Well-Known Binary)
27
+ */
28
+ exports.WKBLoader = {
29
+ ...exports.WKBWorkerLoader,
30
+ parse: async (arrayBuffer) => (0, parse_wkb_1.default)(arrayBuffer),
31
+ parseSync: parse_wkb_1.default
32
+ };
33
+ exports._typecheckWKBWorkerLoader = exports.WKBWorkerLoader;
34
+ exports._typecheckWKBLoader = exports.WKBLoader;