@loaders.gl/geopackage 3.1.0-alpha.4 → 3.1.0-beta.3

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.
@@ -0,0 +1,2 @@
1
+ declare const moduleExports: any;
2
+ //# sourceMappingURL=bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,aAAa,KAAqB,CAAC"}
package/dist/bundle.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ const moduleExports = require('./index');
4
+ globalThis.loaders = globalThis.loaders || {};
5
+ module.exports = Object.assign(globalThis.loaders, moduleExports);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var moduleExports = require('./index');
3
+ const moduleExports = require('./index');
4
4
 
5
5
  globalThis.loaders = globalThis.loaders || {};
6
6
  module.exports = Object.assign(globalThis.loaders, moduleExports);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":";;AACA,IAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
1
+ {"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":";;AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
@@ -9,8 +9,8 @@ exports.GeoPackageLoader = void 0;
9
9
 
10
10
  var _parseGeopackage = _interopRequireDefault(require("./lib/parse-geopackage"));
11
11
 
12
- var VERSION = 'latest';
13
- var GeoPackageLoader = {
12
+ const VERSION = 'latest';
13
+ const GeoPackageLoader = {
14
14
  id: 'geopackage',
15
15
  name: 'GeoPackage',
16
16
  module: 'geopackage',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/geopackage-loader.ts"],"names":["VERSION","GeoPackageLoader","id","name","module","version","extensions","mimeTypes","category","parse","parseGeoPackage","options","geopackage","sqlJsCDN"],"mappings":";;;;;;;;;AACA;;AAKA,IAAMA,OAAO,GAAG,QAAhB;AAcO,IAAMC,gBAAkC,GAAG;AAChDC,EAAAA,EAAE,EAAE,YAD4C;AAEhDC,EAAAA,IAAI,EAAE,YAF0C;AAGhDC,EAAAA,MAAM,EAAE,YAHwC;AAIhDC,EAAAA,OAAO,EAAEL,OAJuC;AAKhDM,EAAAA,UAAU,EAAE,CAAC,MAAD,CALoC;AAMhDC,EAAAA,SAAS,EAAE,CAAC,gCAAD,CANqC;AAOhDC,EAAAA,QAAQ,EAAE,UAPsC;AAQhDC,EAAAA,KAAK,EAAEC,wBARyC;AAShDC,EAAAA,OAAO,EAAE;AACPC,IAAAA,UAAU,EAAE;AACVC,MAAAA,QAAQ,EAAE;AADA;AADL;AATuC,CAA3C","sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport parseGeoPackage from './lib/parse-geopackage';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\n// const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\nconst VERSION = 'latest';\n\nexport type GeoPackageLoaderOptions = LoaderOptions & {\n geopackage?: {\n // Use null in Node\n sqlJsCDN: string | null;\n };\n gis?: {\n reproject?: boolean;\n _targetCrs?: string;\n };\n};\n\n/** Geopackage loader */\nexport const GeoPackageLoader: LoaderWithParser = {\n id: 'geopackage',\n name: 'GeoPackage',\n module: 'geopackage',\n version: VERSION,\n extensions: ['gpkg'],\n mimeTypes: ['application/geopackage+sqlite3'],\n category: 'geometry',\n parse: parseGeoPackage,\n options: {\n geopackage: {\n sqlJsCDN: 'https://sql.js.org/dist/'\n }\n }\n};\n"],"file":"geopackage-loader.js"}
1
+ {"version":3,"sources":["../../src/geopackage-loader.ts"],"names":["VERSION","GeoPackageLoader","id","name","module","version","extensions","mimeTypes","category","parse","parseGeoPackage","options","geopackage","sqlJsCDN"],"mappings":";;;;;;;;;AACA;;AAKA,MAAMA,OAAO,GAAG,QAAhB;AAcO,MAAMC,gBAAkC,GAAG;AAChDC,EAAAA,EAAE,EAAE,YAD4C;AAEhDC,EAAAA,IAAI,EAAE,YAF0C;AAGhDC,EAAAA,MAAM,EAAE,YAHwC;AAIhDC,EAAAA,OAAO,EAAEL,OAJuC;AAKhDM,EAAAA,UAAU,EAAE,CAAC,MAAD,CALoC;AAMhDC,EAAAA,SAAS,EAAE,CAAC,gCAAD,CANqC;AAOhDC,EAAAA,QAAQ,EAAE,UAPsC;AAQhDC,EAAAA,KAAK,EAAEC,wBARyC;AAShDC,EAAAA,OAAO,EAAE;AACPC,IAAAA,UAAU,EAAE;AACVC,MAAAA,QAAQ,EAAE;AADA;AADL;AATuC,CAA3C","sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport parseGeoPackage from './lib/parse-geopackage';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\n// const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\nconst VERSION = 'latest';\n\nexport type GeoPackageLoaderOptions = LoaderOptions & {\n geopackage?: {\n // Use null in Node\n sqlJsCDN: string | null;\n };\n gis?: {\n reproject?: boolean;\n _targetCrs?: string;\n };\n};\n\n/** Geopackage loader */\nexport const GeoPackageLoader: LoaderWithParser = {\n id: 'geopackage',\n name: 'GeoPackage',\n module: 'geopackage',\n version: VERSION,\n extensions: ['gpkg'],\n mimeTypes: ['application/geopackage+sqlite3'],\n category: 'geometry',\n parse: parseGeoPackage,\n options: {\n geopackage: {\n sqlJsCDN: 'https://sql.js.org/dist/'\n }\n }\n};\n"],"file":"geopackage-loader.js"}
package/dist/es5/index.js CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "GeoPackageLoader", {
7
7
  enumerable: true,
8
- get: function get() {
8
+ get: function () {
9
9
  return _geopackageLoader.GeoPackageLoader;
10
10
  }
11
11
  });
@@ -7,12 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = parseGeoPackage;
9
9
 
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
-
14
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
-
16
10
  var _sql = _interopRequireDefault(require("sql.js"));
17
11
 
18
12
  var _wkt = require("@loaders.gl/wkt");
@@ -23,13 +17,7 @@ var _gis = require("@loaders.gl/gis");
23
17
 
24
18
  var _proj = require("@math.gl/proj4");
25
19
 
26
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
27
-
28
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
29
-
30
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
31
-
32
- var ENVELOPE_BYTE_LENGTHS = {
20
+ const ENVELOPE_BYTE_LENGTHS = {
33
21
  0: 0,
34
22
  1: 32,
35
23
  2: 48,
@@ -39,7 +27,7 @@ var ENVELOPE_BYTE_LENGTHS = {
39
27
  6: 0,
40
28
  7: 0
41
29
  };
42
- var SQL_TYPE_MAPPING = {
30
+ const SQL_TYPE_MAPPING = {
43
31
  BOOLEAN: _schema.Bool,
44
32
  TINYINT: _schema.Int8,
45
33
  SMALLINT: _schema.Int16,
@@ -56,176 +44,111 @@ var SQL_TYPE_MAPPING = {
56
44
  GEOMETRY: _schema.Binary
57
45
  };
58
46
 
59
- function parseGeoPackage(_x, _x2) {
60
- return _parseGeoPackage.apply(this, arguments);
61
- }
47
+ async function parseGeoPackage(arrayBuffer, options) {
48
+ const {
49
+ sqlJsCDN = 'https://sql.js.org/dist/'
50
+ } = (options === null || options === void 0 ? void 0 : options.geopackage) || {};
51
+ const {
52
+ reproject = false,
53
+ _targetCrs = 'WGS84'
54
+ } = (options === null || options === void 0 ? void 0 : options.gis) || {};
55
+ const db = await loadDatabase(arrayBuffer, sqlJsCDN);
56
+ const tables = listVectorTables(db);
57
+ const projections = getProjections(db);
58
+ const result = {};
59
+
60
+ for (const table of tables) {
61
+ const {
62
+ table_name: tableName
63
+ } = table;
64
+ result[tableName] = getVectorTable(db, tableName, projections, {
65
+ reproject,
66
+ _targetCrs
67
+ });
68
+ }
62
69
 
63
- function _parseGeoPackage() {
64
- _parseGeoPackage = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(arrayBuffer, options) {
65
- var _ref2, _ref2$sqlJsCDN, sqlJsCDN, _ref3, _ref3$reproject, reproject, _ref3$_targetCrs, _targetCrs, db, tables, projections, result, _iterator2, _step2, table, tableName;
66
-
67
- return _regenerator.default.wrap(function _callee$(_context) {
68
- while (1) {
69
- switch (_context.prev = _context.next) {
70
- case 0:
71
- _ref2 = (options === null || options === void 0 ? void 0 : options.geopackage) || {}, _ref2$sqlJsCDN = _ref2.sqlJsCDN, sqlJsCDN = _ref2$sqlJsCDN === void 0 ? 'https://sql.js.org/dist/' : _ref2$sqlJsCDN;
72
- _ref3 = (options === null || options === void 0 ? void 0 : options.gis) || {}, _ref3$reproject = _ref3.reproject, reproject = _ref3$reproject === void 0 ? false : _ref3$reproject, _ref3$_targetCrs = _ref3._targetCrs, _targetCrs = _ref3$_targetCrs === void 0 ? 'WGS84' : _ref3$_targetCrs;
73
- _context.next = 4;
74
- return loadDatabase(arrayBuffer, sqlJsCDN);
75
-
76
- case 4:
77
- db = _context.sent;
78
- tables = listVectorTables(db);
79
- projections = getProjections(db);
80
- result = {};
81
- _iterator2 = _createForOfIteratorHelper(tables);
82
-
83
- try {
84
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
85
- table = _step2.value;
86
- tableName = table.table_name;
87
- result[tableName] = getVectorTable(db, tableName, projections, {
88
- reproject: reproject,
89
- _targetCrs: _targetCrs
90
- });
91
- }
92
- } catch (err) {
93
- _iterator2.e(err);
94
- } finally {
95
- _iterator2.f();
96
- }
97
-
98
- return _context.abrupt("return", result);
99
-
100
- case 11:
101
- case "end":
102
- return _context.stop();
103
- }
104
- }
105
- }, _callee);
106
- }));
107
- return _parseGeoPackage.apply(this, arguments);
70
+ return result;
108
71
  }
109
72
 
110
- function loadDatabase(_x3, _x4) {
111
- return _loadDatabase.apply(this, arguments);
112
- }
73
+ async function loadDatabase(arrayBuffer, sqlJsCDN) {
74
+ let SQL;
113
75
 
114
- function _loadDatabase() {
115
- _loadDatabase = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(arrayBuffer, sqlJsCDN) {
116
- var SQL;
117
- return _regenerator.default.wrap(function _callee2$(_context2) {
118
- while (1) {
119
- switch (_context2.prev = _context2.next) {
120
- case 0:
121
- if (!sqlJsCDN) {
122
- _context2.next = 6;
123
- break;
124
- }
125
-
126
- _context2.next = 3;
127
- return (0, _sql.default)({
128
- locateFile: function locateFile(file) {
129
- return "".concat(sqlJsCDN).concat(file);
130
- }
131
- });
132
-
133
- case 3:
134
- SQL = _context2.sent;
135
- _context2.next = 9;
136
- break;
137
-
138
- case 6:
139
- _context2.next = 8;
140
- return (0, _sql.default)();
141
-
142
- case 8:
143
- SQL = _context2.sent;
144
-
145
- case 9:
146
- return _context2.abrupt("return", new SQL.Database(new Uint8Array(arrayBuffer)));
147
-
148
- case 10:
149
- case "end":
150
- return _context2.stop();
151
- }
152
- }
153
- }, _callee2);
154
- }));
155
- return _loadDatabase.apply(this, arguments);
76
+ if (sqlJsCDN) {
77
+ SQL = await (0, _sql.default)({
78
+ locateFile: file => "".concat(sqlJsCDN).concat(file)
79
+ });
80
+ } else {
81
+ SQL = await (0, _sql.default)();
82
+ }
83
+
84
+ return new SQL.Database(new Uint8Array(arrayBuffer));
156
85
  }
157
86
 
158
87
  function listVectorTables(db) {
159
- var stmt = db.prepare("SELECT * FROM gpkg_contents WHERE data_type='features';");
160
- var vectorTablesInfo = [];
88
+ const stmt = db.prepare("SELECT * FROM gpkg_contents WHERE data_type='features';");
89
+ const vectorTablesInfo = [];
161
90
 
162
91
  while (stmt.step()) {
163
- var vectorTableInfo = stmt.getAsObject();
92
+ const vectorTableInfo = stmt.getAsObject();
164
93
  vectorTablesInfo.push(vectorTableInfo);
165
94
  }
166
95
 
167
96
  return vectorTablesInfo;
168
97
  }
169
98
 
170
- function getVectorTable(db, tableName, projections, _ref) {
171
- var reproject = _ref.reproject,
172
- _targetCrs = _ref._targetCrs;
173
- var dataColumns = getDataColumns(db, tableName);
174
- var geomColumn = getGeometryColumn(db, tableName);
175
- var featureIdColumn = getFeatureIdName(db, tableName);
176
- var _db$exec$ = db.exec("SELECT * FROM `".concat(tableName, "`;"))[0],
177
- columns = _db$exec$.columns,
178
- values = _db$exec$.values;
179
- var projection;
99
+ function getVectorTable(db, tableName, projections, {
100
+ reproject,
101
+ _targetCrs
102
+ }) {
103
+ const dataColumns = getDataColumns(db, tableName);
104
+ const geomColumn = getGeometryColumn(db, tableName);
105
+ const featureIdColumn = getFeatureIdName(db, tableName);
106
+ const {
107
+ columns,
108
+ values
109
+ } = db.exec("SELECT * FROM `".concat(tableName, "`;"))[0];
110
+ let projection;
180
111
 
181
112
  if (reproject) {
182
- var geomColumnProjStr = projections[geomColumn.srs_id];
113
+ const geomColumnProjStr = projections[geomColumn.srs_id];
183
114
  projection = new _proj.Proj4Projection({
184
115
  from: geomColumnProjStr,
185
116
  to: _targetCrs
186
117
  });
187
118
  }
188
119
 
189
- var geojsonFeatures = [];
120
+ const geojsonFeatures = [];
190
121
 
191
- var _iterator = _createForOfIteratorHelper(values),
192
- _step;
193
-
194
- try {
195
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
196
- var row = _step.value;
197
- var geojsonFeature = constructGeoJsonFeature(columns, row, geomColumn, dataColumns, featureIdColumn);
198
- geojsonFeatures.push(geojsonFeature);
199
- }
200
- } catch (err) {
201
- _iterator.e(err);
202
- } finally {
203
- _iterator.f();
122
+ for (const row of values) {
123
+ const geojsonFeature = constructGeoJsonFeature(columns, row, geomColumn, dataColumns, featureIdColumn);
124
+ geojsonFeatures.push(geojsonFeature);
204
125
  }
205
126
 
206
- var schema = getArrowSchema(db, tableName);
127
+ const schema = getArrowSchema(db, tableName);
207
128
 
208
129
  if (projection) {
209
130
  return {
210
131
  geojsonFeatures: (0, _gis.transformGeoJsonCoords)(geojsonFeatures, projection.project),
211
- schema: schema
132
+ schema
212
133
  };
213
134
  }
214
135
 
215
136
  return {
216
- geojsonFeatures: geojsonFeatures,
217
- schema: schema
137
+ geojsonFeatures,
138
+ schema
218
139
  };
219
140
  }
220
141
 
221
142
  function getProjections(db) {
222
- var stmt = db.prepare('SELECT * FROM gpkg_spatial_ref_sys;');
223
- var projectionMapping = {};
143
+ const stmt = db.prepare('SELECT * FROM gpkg_spatial_ref_sys;');
144
+ const projectionMapping = {};
224
145
 
225
146
  while (stmt.step()) {
226
- var srsInfo = stmt.getAsObject();
227
- var srs_id = srsInfo.srs_id,
228
- definition = srsInfo.definition;
147
+ const srsInfo = stmt.getAsObject();
148
+ const {
149
+ srs_id,
150
+ definition
151
+ } = srsInfo;
229
152
  projectionMapping[srs_id] = definition;
230
153
  }
231
154
 
@@ -233,48 +156,44 @@ function getProjections(db) {
233
156
  }
234
157
 
235
158
  function constructGeoJsonFeature(columns, row, geomColumn, dataColumns, featureIdColumn) {
236
- var idIdx = columns.indexOf(featureIdColumn);
237
- var id = row[idIdx];
238
- var geomColumnIdx = columns.indexOf(geomColumn.column_name);
239
- var geometry = parseGeometry(row[geomColumnIdx].buffer);
240
- var properties = {};
159
+ const idIdx = columns.indexOf(featureIdColumn);
160
+ const id = row[idIdx];
161
+ const geomColumnIdx = columns.indexOf(geomColumn.column_name);
162
+ const geometry = parseGeometry(row[geomColumnIdx].buffer);
163
+ const properties = {};
241
164
 
242
165
  if (dataColumns) {
243
- for (var _i = 0, _Object$entries = Object.entries(dataColumns); _i < _Object$entries.length; _i++) {
244
- var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),
245
- key = _Object$entries$_i[0],
246
- value = _Object$entries$_i[1];
247
-
248
- var idx = columns.indexOf(key);
166
+ for (const [key, value] of Object.entries(dataColumns)) {
167
+ const idx = columns.indexOf(key);
249
168
  properties[value] = row[idx];
250
169
  }
251
170
  } else {
252
- for (var i = 0; i < columns.length; i++) {
171
+ for (let i = 0; i < columns.length; i++) {
253
172
  if (i === idIdx || i === geomColumnIdx) {
254
173
  continue;
255
174
  }
256
175
 
257
- var columnName = columns[i];
176
+ const columnName = columns[i];
258
177
  properties[columnName] = row[i];
259
178
  }
260
179
  }
261
180
 
262
181
  return {
263
- id: id,
182
+ id,
264
183
  type: 'Feature',
265
- geometry: geometry,
266
- properties: properties
184
+ geometry,
185
+ properties
267
186
  };
268
187
  }
269
188
 
270
189
  function getGeopackageVersion(db) {
271
- var textDecoder = new TextDecoder();
272
- var applicationIdQuery = db.exec('PRAGMA application_id;')[0];
273
- var applicationId = applicationIdQuery.values[0][0];
274
- var buffer = new ArrayBuffer(4);
275
- var view = new DataView(buffer);
190
+ const textDecoder = new TextDecoder();
191
+ const applicationIdQuery = db.exec('PRAGMA application_id;')[0];
192
+ const applicationId = applicationIdQuery.values[0][0];
193
+ const buffer = new ArrayBuffer(4);
194
+ const view = new DataView(buffer);
276
195
  view.setInt32(0, Number(applicationId));
277
- var versionString = textDecoder.decode(buffer);
196
+ const versionString = textDecoder.decode(buffer);
278
197
 
279
198
  if (versionString === 'GP10') {
280
199
  return '1.0';
@@ -284,8 +203,8 @@ function getGeopackageVersion(db) {
284
203
  return '1.1';
285
204
  }
286
205
 
287
- var userVersionQuery = db.exec('PRAGMA user_version;')[0];
288
- var userVersionInt = userVersionQuery.values[0][0];
206
+ const userVersionQuery = db.exec('PRAGMA user_version;')[0];
207
+ const userVersionInt = userVersionQuery.values[0][0];
289
208
 
290
209
  if (userVersionInt && userVersionInt < 10300) {
291
210
  return '1.2';
@@ -295,12 +214,14 @@ function getGeopackageVersion(db) {
295
214
  }
296
215
 
297
216
  function getFeatureIdName(db, tableName) {
298
- var stmt = db.prepare("PRAGMA table_info(`".concat(tableName, "`)"));
217
+ const stmt = db.prepare("PRAGMA table_info(`".concat(tableName, "`)"));
299
218
 
300
219
  while (stmt.step()) {
301
- var pragmaTableInfo = stmt.getAsObject();
302
- var name = pragmaTableInfo.name,
303
- pk = pragmaTableInfo.pk;
220
+ const pragmaTableInfo = stmt.getAsObject();
221
+ const {
222
+ name,
223
+ pk
224
+ } = pragmaTableInfo;
304
225
 
305
226
  if (pk) {
306
227
  return name;
@@ -311,46 +232,46 @@ function getFeatureIdName(db, tableName) {
311
232
  }
312
233
 
313
234
  function parseGeometry(arrayBuffer) {
314
- var view = new DataView(arrayBuffer);
315
-
316
- var _parseGeometryBitFlag = parseGeometryBitFlags(view.getUint8(3)),
317
- envelopeLength = _parseGeometryBitFlag.envelopeLength,
318
- emptyGeometry = _parseGeometryBitFlag.emptyGeometry;
235
+ const view = new DataView(arrayBuffer);
236
+ const {
237
+ envelopeLength,
238
+ emptyGeometry
239
+ } = parseGeometryBitFlags(view.getUint8(3));
319
240
 
320
241
  if (emptyGeometry) {
321
242
  return null;
322
243
  }
323
244
 
324
- var wkbOffset = 8 + envelopeLength;
245
+ const wkbOffset = 8 + envelopeLength;
325
246
 
326
- var binaryGeometry = _wkt.WKBLoader.parseSync(arrayBuffer.slice(wkbOffset));
247
+ const binaryGeometry = _wkt.WKBLoader.parseSync(arrayBuffer.slice(wkbOffset));
327
248
 
328
249
  return (0, _gis.binaryToGeometry)(binaryGeometry);
329
250
  }
330
251
 
331
252
  function parseGeometryBitFlags(byte) {
332
- var envelopeValue = (byte & 14) / 2;
333
- var envelopeLength = ENVELOPE_BYTE_LENGTHS[envelopeValue];
253
+ const envelopeValue = (byte & 0b00001110) / 2;
254
+ const envelopeLength = ENVELOPE_BYTE_LENGTHS[envelopeValue];
334
255
  return {
335
- littleEndian: Boolean(byte & 1),
336
- envelopeLength: envelopeLength,
337
- emptyGeometry: Boolean(byte & 16),
338
- extendedGeometryType: Boolean(byte & 32)
256
+ littleEndian: Boolean(byte & 0b00000001),
257
+ envelopeLength,
258
+ emptyGeometry: Boolean(byte & 0b00010000),
259
+ extendedGeometryType: Boolean(byte & 0b00100000)
339
260
  };
340
261
  }
341
262
 
342
263
  function getGeometryColumn(db, tableName) {
343
- var stmt = db.prepare('SELECT * FROM gpkg_geometry_columns WHERE table_name=:tableName;');
264
+ const stmt = db.prepare('SELECT * FROM gpkg_geometry_columns WHERE table_name=:tableName;');
344
265
  stmt.bind({
345
266
  ':tableName': tableName
346
267
  });
347
268
  stmt.step();
348
- var geometryColumn = stmt.getAsObject();
269
+ const geometryColumn = stmt.getAsObject();
349
270
  return geometryColumn;
350
271
  }
351
272
 
352
273
  function getDataColumns(db, tableName) {
353
- var stmt;
274
+ let stmt;
354
275
 
355
276
  try {
356
277
  stmt = db.prepare('SELECT * FROM gpkg_data_columns WHERE table_name=:tableName;');
@@ -365,12 +286,14 @@ function getDataColumns(db, tableName) {
365
286
  stmt.bind({
366
287
  ':tableName': tableName
367
288
  });
368
- var result = {};
289
+ const result = {};
369
290
 
370
291
  while (stmt.step()) {
371
- var column = stmt.getAsObject();
372
- var column_name = column.column_name,
373
- name = column.name;
292
+ const column = stmt.getAsObject();
293
+ const {
294
+ column_name,
295
+ name
296
+ } = column;
374
297
  result[column_name] = name || null;
375
298
  }
376
299
 
@@ -378,15 +301,17 @@ function getDataColumns(db, tableName) {
378
301
  }
379
302
 
380
303
  function getArrowSchema(db, tableName) {
381
- var stmt = db.prepare("PRAGMA table_info(`".concat(tableName, "`)"));
382
- var fields = [];
304
+ const stmt = db.prepare("PRAGMA table_info(`".concat(tableName, "`)"));
305
+ const fields = [];
383
306
 
384
307
  while (stmt.step()) {
385
- var pragmaTableInfo = stmt.getAsObject();
386
- var name = pragmaTableInfo.name,
387
- type = pragmaTableInfo.type,
388
- notnull = pragmaTableInfo.notnull;
389
- var field = new _schema.Field(name, new SQL_TYPE_MAPPING[type](), !notnull);
308
+ const pragmaTableInfo = stmt.getAsObject();
309
+ const {
310
+ name,
311
+ type,
312
+ notnull
313
+ } = pragmaTableInfo;
314
+ const field = new _schema.Field(name, new SQL_TYPE_MAPPING[type](), !notnull);
390
315
  fields.push(field);
391
316
  }
392
317