@loaders.gl/wkt 3.1.0-alpha.5 → 3.1.0-beta.5

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 (50) hide show
  1. package/dist/bundle.d.ts +1 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +596 -0
  4. package/dist/es5/lib/parse-wkb.js +4 -3
  5. package/dist/es5/lib/parse-wkb.js.map +1 -1
  6. package/dist/es5/lib/utils/version.js +1 -1
  7. package/dist/es5/lib/utils/version.js.map +1 -1
  8. package/dist/es5/wkb-loader.js.map +1 -1
  9. package/dist/esm/lib/parse-wkb.js +4 -3
  10. package/dist/esm/lib/parse-wkb.js.map +1 -1
  11. package/dist/esm/lib/utils/version.js +1 -1
  12. package/dist/esm/lib/utils/version.js.map +1 -1
  13. package/dist/esm/wkb-loader.js.map +1 -1
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +11 -0
  17. package/dist/lib/encode-wkt.d.ts +1 -0
  18. package/dist/lib/encode-wkt.d.ts.map +1 -0
  19. package/dist/lib/encode-wkt.js +48 -0
  20. package/dist/lib/parse-wkb.d.ts +2 -1
  21. package/dist/lib/parse-wkb.d.ts.map +1 -0
  22. package/dist/lib/parse-wkb.js +236 -0
  23. package/dist/lib/parse-wkt.d.ts +1 -0
  24. package/dist/lib/parse-wkt.d.ts.map +1 -0
  25. package/dist/lib/parse-wkt.js +227 -0
  26. package/dist/lib/utils/version.d.ts +1 -0
  27. package/dist/lib/utils/version.d.ts.map +1 -0
  28. package/dist/lib/utils/version.js +7 -0
  29. package/dist/wkb-loader.d.ts +2 -1
  30. package/dist/wkb-loader.d.ts.map +1 -0
  31. package/dist/wkb-loader.js +34 -0
  32. package/dist/wkt-loader.d.ts +1 -0
  33. package/dist/wkt-loader.d.ts.map +1 -0
  34. package/dist/wkt-loader.js +33 -0
  35. package/dist/wkt-worker.js +380 -2
  36. package/dist/wkt-writer.d.ts +1 -0
  37. package/dist/wkt-writer.d.ts.map +1 -0
  38. package/dist/wkt-writer.js +23 -0
  39. package/dist/workers/wkb-worker.d.ts +1 -0
  40. package/dist/workers/wkb-worker.d.ts.map +1 -0
  41. package/dist/workers/wkb-worker.js +5 -0
  42. package/dist/workers/wkt-worker.d.ts +1 -0
  43. package/dist/workers/wkt-worker.d.ts.map +1 -0
  44. package/dist/workers/wkt-worker.js +5 -0
  45. package/package.json +6 -7
  46. package/src/lib/parse-wkb.ts +35 -19
  47. package/src/wkb-loader.ts +1 -1
  48. package/dist/dist.min.js +0 -2
  49. package/dist/dist.min.js.map +0 -1
  50. package/dist/wkt-worker.js.map +0 -1
@@ -0,0 +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
6
+ const numberRegexp = /[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/;
7
+ // Matches sequences like '100 100' or '100 100 100'.
8
+ const tuples = new RegExp('^' + numberRegexp.source + '(\\s' + numberRegexp.source + '){1,}');
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;
85
+ }
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();
101
+ }
102
+ if (item)
103
+ list.push(item);
104
+ else
105
+ return null;
106
+ return list.length ? list : null;
107
+ }
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
+ };
124
+ }
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
+ };
215
+ }
216
+ function root() {
217
+ return (point() ||
218
+ linestring() ||
219
+ polygon() ||
220
+ multipoint() ||
221
+ multilinestring() ||
222
+ multipolygon() ||
223
+ geometrycollection());
224
+ }
225
+ return crs(root());
226
+ }
227
+ exports.default = parseWKT;
@@ -1 +1,2 @@
1
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"}
@@ -0,0 +1,7 @@
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';
@@ -20,7 +20,7 @@ export declare const WKBWorkerLoader: {
20
20
  * Loader for WKB (Well-Known Binary)
21
21
  */
22
22
  export declare const WKBLoader: {
23
- parse: (arrayBuffer: any) => Promise<import("modules/schema/dist").BinaryGeometry>;
23
+ parse: (arrayBuffer: ArrayBuffer) => Promise<import("@loaders.gl/schema").BinaryGeometry>;
24
24
  parseSync: typeof parseWKB;
25
25
  name: string;
26
26
  id: string;
@@ -36,3 +36,4 @@ export declare const WKBLoader: {
36
36
  };
37
37
  export declare const _typecheckWKBWorkerLoader: Loader;
38
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"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
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
+ }
24
+ };
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;
@@ -7,3 +7,4 @@ export declare const WKTWorkerLoader: Loader;
7
7
  * Well-Known text loader
8
8
  */
9
9
  export declare const WKTLoader: LoaderWithParser;
10
+ //# sourceMappingURL=wkt-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wkt-loader.d.ts","sourceRoot":"","sources":["../src/wkt-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAIvE;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,MAa7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,gBAIvB,CAAC"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.WKTLoader = exports.WKTWorkerLoader = void 0;
7
+ const version_1 = require("./lib/utils/version");
8
+ const parse_wkt_1 = __importDefault(require("./lib/parse-wkt"));
9
+ /**
10
+ * Well-Known text loader
11
+ */
12
+ exports.WKTWorkerLoader = {
13
+ name: 'WKT (Well-Known Text)',
14
+ id: 'wkt',
15
+ module: 'wkt',
16
+ version: version_1.VERSION,
17
+ worker: true,
18
+ extensions: ['wkt'],
19
+ mimeTypes: ['text/plain'],
20
+ category: 'geometry',
21
+ text: true,
22
+ options: {
23
+ wkt: {}
24
+ }
25
+ };
26
+ /**
27
+ * Well-Known text loader
28
+ */
29
+ exports.WKTLoader = {
30
+ ...exports.WKTWorkerLoader,
31
+ parse: async (arrayBuffer) => (0, parse_wkt_1.default)(new TextDecoder().decode(arrayBuffer)),
32
+ parseTextSync: parse_wkt_1.default
33
+ };