@loaders.gl/shapefile 4.0.0-alpha.5 → 4.0.0-alpha.7

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 (124) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/dbf-loader.js +29 -20
  3. package/dist/dbf-worker.js +73 -447
  4. package/dist/dist.min.js +130 -489
  5. package/dist/es5/bundle.js +6 -0
  6. package/dist/es5/bundle.js.map +1 -0
  7. package/dist/es5/dbf-loader.js +53 -0
  8. package/dist/es5/dbf-loader.js.map +1 -0
  9. package/dist/es5/index.js +39 -0
  10. package/dist/es5/index.js.map +1 -0
  11. package/dist/es5/lib/parsers/parse-dbf.js +394 -0
  12. package/dist/es5/lib/parsers/parse-dbf.js.map +1 -0
  13. package/dist/es5/lib/parsers/parse-shapefile.js +373 -0
  14. package/dist/es5/lib/parsers/parse-shapefile.js.map +1 -0
  15. package/dist/es5/lib/parsers/parse-shp-geometry.js +220 -0
  16. package/dist/es5/lib/parsers/parse-shp-geometry.js.map +1 -0
  17. package/dist/es5/lib/parsers/parse-shp-header.js +35 -0
  18. package/dist/es5/lib/parsers/parse-shp-header.js.map +1 -0
  19. package/dist/es5/lib/parsers/parse-shp.js +227 -0
  20. package/dist/es5/lib/parsers/parse-shp.js.map +1 -0
  21. package/dist/es5/lib/parsers/parse-shx.js +26 -0
  22. package/dist/es5/lib/parsers/parse-shx.js.map +1 -0
  23. package/dist/es5/lib/parsers/types.js +2 -0
  24. package/dist/es5/lib/parsers/types.js.map +1 -0
  25. package/dist/es5/lib/streaming/binary-chunk-reader.js +178 -0
  26. package/dist/es5/lib/streaming/binary-chunk-reader.js.map +1 -0
  27. package/dist/es5/lib/streaming/binary-reader.js +48 -0
  28. package/dist/es5/lib/streaming/binary-reader.js.map +1 -0
  29. package/dist/es5/lib/streaming/zip-batch-iterators.js +91 -0
  30. package/dist/es5/lib/streaming/zip-batch-iterators.js.map +1 -0
  31. package/dist/es5/shapefile-loader.js +31 -0
  32. package/dist/es5/shapefile-loader.js.map +1 -0
  33. package/dist/es5/shp-loader.js +56 -0
  34. package/dist/es5/shp-loader.js.map +1 -0
  35. package/dist/es5/workers/dbf-worker.js +6 -0
  36. package/dist/es5/workers/dbf-worker.js.map +1 -0
  37. package/dist/es5/workers/shp-worker.js +6 -0
  38. package/dist/es5/workers/shp-worker.js.map +1 -0
  39. package/dist/esm/bundle.js +4 -0
  40. package/dist/esm/bundle.js.map +1 -0
  41. package/dist/esm/dbf-loader.js +24 -0
  42. package/dist/esm/dbf-loader.js.map +1 -0
  43. package/dist/esm/index.js +4 -0
  44. package/dist/esm/index.js.map +1 -0
  45. package/dist/esm/lib/parsers/parse-dbf.js +296 -0
  46. package/dist/esm/lib/parsers/parse-dbf.js.map +1 -0
  47. package/dist/esm/lib/parsers/parse-shapefile.js +187 -0
  48. package/dist/esm/lib/parsers/parse-shapefile.js.map +1 -0
  49. package/dist/esm/lib/parsers/parse-shp-geometry.js +191 -0
  50. package/dist/esm/lib/parsers/parse-shp-geometry.js.map +1 -0
  51. package/dist/esm/lib/parsers/parse-shp-header.js +29 -0
  52. package/dist/esm/lib/parsers/parse-shp-header.js.map +1 -0
  53. package/dist/esm/lib/parsers/parse-shp.js +134 -0
  54. package/dist/esm/lib/parsers/parse-shp.js.map +1 -0
  55. package/dist/esm/lib/parsers/parse-shx.js +20 -0
  56. package/dist/esm/lib/parsers/parse-shx.js.map +1 -0
  57. package/dist/esm/lib/parsers/types.js +2 -0
  58. package/dist/esm/lib/parsers/types.js.map +1 -0
  59. package/dist/esm/lib/streaming/binary-chunk-reader.js +106 -0
  60. package/dist/esm/lib/streaming/binary-chunk-reader.js.map +1 -0
  61. package/dist/esm/lib/streaming/binary-reader.js +27 -0
  62. package/dist/esm/lib/streaming/binary-reader.js.map +1 -0
  63. package/dist/esm/lib/streaming/zip-batch-iterators.js +44 -0
  64. package/dist/esm/lib/streaming/zip-batch-iterators.js.map +1 -0
  65. package/dist/esm/shapefile-loader.js +23 -0
  66. package/dist/esm/shapefile-loader.js.map +1 -0
  67. package/dist/esm/shp-loader.js +26 -0
  68. package/dist/esm/shp-loader.js.map +1 -0
  69. package/dist/esm/workers/dbf-worker.js +4 -0
  70. package/dist/esm/workers/dbf-worker.js.map +1 -0
  71. package/dist/esm/workers/shp-worker.js +4 -0
  72. package/dist/esm/workers/shp-worker.js.map +1 -0
  73. package/dist/index.js +11 -4
  74. package/dist/lib/parsers/parse-dbf.d.ts +4 -18
  75. package/dist/lib/parsers/parse-dbf.d.ts.map +1 -1
  76. package/dist/lib/parsers/parse-dbf.js +309 -264
  77. package/dist/lib/parsers/parse-shapefile.d.ts +3 -8
  78. package/dist/lib/parsers/parse-shapefile.d.ts.map +1 -1
  79. package/dist/lib/parsers/parse-shapefile.js +227 -209
  80. package/dist/lib/parsers/parse-shp-geometry.d.ts +2 -3
  81. package/dist/lib/parsers/parse-shp-geometry.d.ts.map +1 -1
  82. package/dist/lib/parsers/parse-shp-geometry.js +265 -212
  83. package/dist/lib/parsers/parse-shp-header.js +38 -27
  84. package/dist/lib/parsers/parse-shp.d.ts +3 -2
  85. package/dist/lib/parsers/parse-shp.d.ts.map +1 -1
  86. package/dist/lib/parsers/parse-shp.js +160 -136
  87. package/dist/lib/parsers/parse-shx.js +25 -19
  88. package/dist/lib/parsers/types.d.ts +68 -0
  89. package/dist/lib/parsers/types.d.ts.map +1 -0
  90. package/dist/lib/parsers/types.js +2 -0
  91. package/dist/lib/streaming/binary-chunk-reader.d.ts +5 -3
  92. package/dist/lib/streaming/binary-chunk-reader.d.ts.map +1 -1
  93. package/dist/lib/streaming/binary-chunk-reader.js +152 -128
  94. package/dist/lib/streaming/binary-reader.js +50 -33
  95. package/dist/lib/streaming/zip-batch-iterators.js +57 -48
  96. package/dist/shapefile-loader.js +30 -22
  97. package/dist/shp-loader.js +32 -22
  98. package/dist/shp-worker.js +57 -19
  99. package/dist/workers/dbf-worker.js +5 -4
  100. package/dist/workers/shp-worker.js +5 -4
  101. package/package.json +7 -7
  102. package/src/lib/parsers/parse-dbf.ts +41 -67
  103. package/src/lib/parsers/parse-shapefile.ts +3 -6
  104. package/src/lib/parsers/parse-shp-geometry.ts +3 -2
  105. package/src/lib/parsers/parse-shp.ts +26 -12
  106. package/src/lib/parsers/types.ts +79 -0
  107. package/src/lib/streaming/binary-chunk-reader.ts +5 -1
  108. package/src/lib/streaming/zip-batch-iterators.ts +2 -2
  109. package/dist/bundle.js.map +0 -1
  110. package/dist/dbf-loader.js.map +0 -1
  111. package/dist/index.js.map +0 -1
  112. package/dist/lib/parsers/parse-dbf.js.map +0 -1
  113. package/dist/lib/parsers/parse-shapefile.js.map +0 -1
  114. package/dist/lib/parsers/parse-shp-geometry.js.map +0 -1
  115. package/dist/lib/parsers/parse-shp-header.js.map +0 -1
  116. package/dist/lib/parsers/parse-shp.js.map +0 -1
  117. package/dist/lib/parsers/parse-shx.js.map +0 -1
  118. package/dist/lib/streaming/binary-chunk-reader.js.map +0 -1
  119. package/dist/lib/streaming/binary-reader.js.map +0 -1
  120. package/dist/lib/streaming/zip-batch-iterators.js.map +0 -1
  121. package/dist/shapefile-loader.js.map +0 -1
  122. package/dist/shp-loader.js.map +0 -1
  123. package/dist/workers/dbf-worker.js.map +0 -1
  124. package/dist/workers/shp-worker.js.map +0 -1
@@ -1,226 +1,244 @@
1
- import { binaryToGeometry, transformGeoJsonCoords } from '@loaders.gl/gis';
2
- import { Proj4Projection } from '@math.gl/proj4';
3
- import { parseShx } from './parse-shx';
4
- import { zipBatchIterators } from '../streaming/zip-batch-iterators';
5
- import { SHPLoader } from '../../shp-loader';
6
- import { DBFLoader } from '../../dbf-loader';
7
- export async function* parseShapefileInBatches(asyncIterator, options, context) {
8
- const {
9
- reproject = false,
10
- _targetCrs = 'WGS84'
11
- } = (options === null || options === void 0 ? void 0 : options.gis) || {};
12
- const {
13
- shx,
14
- cpg,
15
- prj
16
- } = await loadShapefileSidecarFiles(options, context);
17
- const shapeIterable = await context.parseInBatches(asyncIterator, SHPLoader, options);
18
- let propertyIterable;
19
- const dbfResponse = await context.fetch(replaceExtension((context === null || context === void 0 ? void 0 : context.url) || '', 'dbf'));
20
-
21
- if (dbfResponse.ok) {
22
- propertyIterable = await context.parseInBatches(dbfResponse, DBFLoader, { ...options,
23
- dbf: {
24
- encoding: cpg || 'latin1'
25
- }
26
- });
27
- }
28
-
29
- let shapeHeader = (await shapeIterable.next()).value;
30
-
31
- if (shapeHeader && shapeHeader.batchType === 'metadata') {
32
- shapeHeader = (await shapeIterable.next()).value;
33
- }
34
-
35
- let dbfHeader = {};
36
-
37
- if (propertyIterable) {
38
- dbfHeader = (await propertyIterable.next()).value;
39
-
40
- if (dbfHeader && dbfHeader.batchType === 'metadata') {
41
- dbfHeader = (await propertyIterable.next()).value;
42
- }
43
- }
44
-
45
- let iterator;
46
-
47
- if (propertyIterable) {
48
- iterator = zipBatchIterators(shapeIterable, propertyIterable);
49
- } else {
50
- iterator = shapeIterable;
51
- }
52
-
53
- for await (const item of iterator) {
54
- let geometries;
55
- let properties;
56
-
57
- if (!propertyIterable) {
58
- geometries = item;
59
- } else {
60
- [geometries, properties] = item;
61
- }
62
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.replaceExtension = exports.loadShapefileSidecarFiles = exports.parseShapefile = exports.parseShapefileInBatches = void 0;
4
+ const gis_1 = require("@loaders.gl/gis");
5
+ const proj4_1 = require("@math.gl/proj4");
6
+ const parse_shx_1 = require("./parse-shx");
7
+ const zip_batch_iterators_1 = require("../streaming/zip-batch-iterators");
8
+ const shp_loader_1 = require("../../shp-loader");
9
+ const dbf_loader_1 = require("../../dbf-loader");
10
+ /**
11
+ * Parsing of file in batches
12
+ */
13
+ // eslint-disable-next-line max-statements, complexity
14
+ async function* parseShapefileInBatches(asyncIterator, options, context) {
15
+ const { reproject = false, _targetCrs = 'WGS84' } = options?.gis || {};
16
+ const { shx, cpg, prj } = await loadShapefileSidecarFiles(options, context);
17
+ // parse geometries
18
+ // @ts-ignore context must be defined
19
+ const shapeIterable = await context.parseInBatches(asyncIterator, shp_loader_1.SHPLoader, options);
20
+ // parse properties
21
+ let propertyIterable;
22
+ // @ts-ignore context must be defined
23
+ const dbfResponse = await context.fetch(replaceExtension(context?.url || '', 'dbf'));
24
+ if (dbfResponse.ok) {
25
+ // @ts-ignore context must be defined
26
+ propertyIterable = await context.parseInBatches(dbfResponse, dbf_loader_1.DBFLoader, {
27
+ ...options,
28
+ dbf: { encoding: cpg || 'latin1' }
29
+ });
30
+ }
31
+ // When `options.metadata` is `true`, there's an extra initial `metadata`
32
+ // object before the iterator starts. zipBatchIterators expects to receive
33
+ // batches of Array objects, and will fail with non-iterable batches, so it's
34
+ // important to skip over the first batch.
35
+ let shapeHeader = (await shapeIterable.next()).value;
36
+ if (shapeHeader && shapeHeader.batchType === 'metadata') {
37
+ shapeHeader = (await shapeIterable.next()).value;
38
+ }
39
+ let dbfHeader = {};
40
+ if (propertyIterable) {
41
+ dbfHeader = (await propertyIterable.next()).value;
42
+ if (dbfHeader && dbfHeader.batchType === 'metadata') {
43
+ dbfHeader = (await propertyIterable.next()).value;
44
+ }
45
+ }
46
+ let iterator;
47
+ if (propertyIterable) {
48
+ iterator = (0, zip_batch_iterators_1.zipBatchIterators)(shapeIterable, propertyIterable);
49
+ }
50
+ else {
51
+ iterator = shapeIterable;
52
+ }
53
+ for await (const item of iterator) {
54
+ let geometries;
55
+ let properties;
56
+ if (!propertyIterable) {
57
+ geometries = item;
58
+ }
59
+ else {
60
+ [geometries, properties] = item;
61
+ }
62
+ const geojsonGeometries = parseGeometries(geometries);
63
+ let features = joinProperties(geojsonGeometries, properties);
64
+ if (reproject) {
65
+ // @ts-ignore
66
+ features = reprojectFeatures(features, prj, _targetCrs);
67
+ }
68
+ yield {
69
+ encoding: cpg,
70
+ prj,
71
+ shx,
72
+ header: shapeHeader,
73
+ data: features
74
+ };
75
+ }
76
+ }
77
+ exports.parseShapefileInBatches = parseShapefileInBatches;
78
+ /**
79
+ * Parse shapefile
80
+ *
81
+ * @param arrayBuffer
82
+ * @param options
83
+ * @param context
84
+ * @returns output of shapefile
85
+ */
86
+ async function parseShapefile(arrayBuffer, options, context) {
87
+ const { reproject = false, _targetCrs = 'WGS84' } = options?.gis || {};
88
+ const { shx, cpg, prj } = await loadShapefileSidecarFiles(options, context);
89
+ // parse geometries
90
+ // @ts-ignore context must be defined
91
+ const { header, geometries } = await context.parse(arrayBuffer, shp_loader_1.SHPLoader, options); // {shp: shx}
63
92
  const geojsonGeometries = parseGeometries(geometries);
93
+ // parse properties
94
+ let properties = [];
95
+ // @ts-ignore context must be defined
96
+ const dbfResponse = await context.fetch(replaceExtension(context.url, 'dbf'));
97
+ if (dbfResponse.ok) {
98
+ // @ts-ignore context must be defined
99
+ properties = await context.parse(dbfResponse, dbf_loader_1.DBFLoader, { dbf: { encoding: cpg || 'latin1' } });
100
+ }
64
101
  let features = joinProperties(geojsonGeometries, properties);
65
-
66
102
  if (reproject) {
67
- features = reprojectFeatures(features, prj, _targetCrs);
68
- }
69
-
70
- yield {
71
- encoding: cpg,
72
- prj,
73
- shx,
74
- header: shapeHeader,
75
- data: features
103
+ features = reprojectFeatures(features, prj, _targetCrs);
104
+ }
105
+ return {
106
+ encoding: cpg,
107
+ prj,
108
+ shx,
109
+ header,
110
+ data: features
76
111
  };
77
- }
78
112
  }
79
- export async function parseShapefile(arrayBuffer, options, context) {
80
- const {
81
- reproject = false,
82
- _targetCrs = 'WGS84'
83
- } = (options === null || options === void 0 ? void 0 : options.gis) || {};
84
- const {
85
- shx,
86
- cpg,
87
- prj
88
- } = await loadShapefileSidecarFiles(options, context);
89
- const {
90
- header,
91
- geometries
92
- } = await context.parse(arrayBuffer, SHPLoader, options);
93
- const geojsonGeometries = parseGeometries(geometries);
94
- let properties = [];
95
- const dbfResponse = await context.fetch(replaceExtension(context.url, 'dbf'));
96
-
97
- if (dbfResponse.ok) {
98
- properties = await context.parse(dbfResponse, DBFLoader, {
99
- dbf: {
100
- encoding: cpg || 'latin1'
101
- }
102
- });
103
- }
104
-
105
- let features = joinProperties(geojsonGeometries, properties);
106
-
107
- if (reproject) {
108
- features = reprojectFeatures(features, prj, _targetCrs);
109
- }
110
-
111
- return {
112
- encoding: cpg,
113
- prj,
114
- shx,
115
- header,
116
- data: features
117
- };
118
- }
119
-
113
+ exports.parseShapefile = parseShapefile;
114
+ /**
115
+ * Parse geometries
116
+ *
117
+ * @param geometries
118
+ * @returns geometries as an array
119
+ */
120
120
  function parseGeometries(geometries) {
121
- const geojsonGeometries = [];
122
-
123
- for (const geom of geometries) {
124
- geojsonGeometries.push(binaryToGeometry(geom));
125
- }
126
-
127
- return geojsonGeometries;
121
+ const geojsonGeometries = [];
122
+ for (const geom of geometries) {
123
+ geojsonGeometries.push((0, gis_1.binaryToGeometry)(geom));
124
+ }
125
+ return geojsonGeometries;
128
126
  }
129
-
127
+ /**
128
+ * Join properties and geometries into features
129
+ *
130
+ * @param geometries [description]
131
+ * @param properties [description]
132
+ * @return [description]
133
+ */
130
134
  function joinProperties(geometries, properties) {
131
- const features = [];
132
-
133
- for (let i = 0; i < geometries.length; i++) {
134
- const geometry = geometries[i];
135
- const feature = {
136
- type: 'Feature',
137
- geometry,
138
- properties: properties && properties[i] || {}
139
- };
140
- features.push(feature);
141
- }
142
-
143
- return features;
135
+ const features = [];
136
+ for (let i = 0; i < geometries.length; i++) {
137
+ const geometry = geometries[i];
138
+ const feature = {
139
+ type: 'Feature',
140
+ geometry,
141
+ // properties can be undefined if dbfResponse above was empty
142
+ properties: (properties && properties[i]) || {}
143
+ };
144
+ features.push(feature);
145
+ }
146
+ return features;
144
147
  }
145
-
148
+ /**
149
+ * Reproject GeoJSON features to output CRS
150
+ *
151
+ * @param features parsed GeoJSON features
152
+ * @param sourceCrs source coordinate reference system
153
+ * @param targetCrs †arget coordinate reference system
154
+ * @return Reprojected Features
155
+ */
146
156
  function reprojectFeatures(features, sourceCrs, targetCrs) {
147
- if (!sourceCrs && !targetCrs) {
148
- return features;
149
- }
150
-
151
- const projection = new Proj4Projection({
152
- from: sourceCrs || 'WGS84',
153
- to: targetCrs || 'WGS84'
154
- });
155
- return transformGeoJsonCoords(features, coord => projection.project(coord));
157
+ if (!sourceCrs && !targetCrs) {
158
+ return features;
159
+ }
160
+ const projection = new proj4_1.Proj4Projection({ from: sourceCrs || 'WGS84', to: targetCrs || 'WGS84' });
161
+ return (0, gis_1.transformGeoJsonCoords)(features, (coord) => projection.project(coord));
156
162
  }
157
-
158
- export async function loadShapefileSidecarFiles(options, context) {
159
- const {
160
- url,
161
- fetch
162
- } = context;
163
- const shxPromise = fetch(replaceExtension(url, 'shx'));
164
- const cpgPromise = fetch(replaceExtension(url, 'cpg'));
165
- const prjPromise = fetch(replaceExtension(url, 'prj'));
166
- await Promise.all([shxPromise, cpgPromise, prjPromise]);
167
- let shx;
168
- let cpg;
169
- let prj;
170
- const shxResponse = await shxPromise;
171
-
172
- if (shxResponse.ok) {
173
- const arrayBuffer = await shxResponse.arrayBuffer();
174
- shx = parseShx(arrayBuffer);
175
- }
176
-
177
- const cpgResponse = await cpgPromise;
178
-
179
- if (cpgResponse.ok) {
180
- cpg = await cpgResponse.text();
181
- }
182
-
183
- const prjResponse = await prjPromise;
184
-
185
- if (prjResponse.ok) {
186
- prj = await prjResponse.text();
187
- }
188
-
189
- return {
190
- shx,
191
- cpg,
192
- prj
193
- };
163
+ /**
164
+ *
165
+ * @param options
166
+ * @param context
167
+ * @returns Promise
168
+ */
169
+ // eslint-disable-next-line max-statements
170
+ async function loadShapefileSidecarFiles(options, context) {
171
+ // Attempt a parallel load of the small sidecar files
172
+ // @ts-ignore context must be defined
173
+ const { url, fetch } = context;
174
+ const shxPromise = fetch(replaceExtension(url, 'shx'));
175
+ const cpgPromise = fetch(replaceExtension(url, 'cpg'));
176
+ const prjPromise = fetch(replaceExtension(url, 'prj'));
177
+ await Promise.all([shxPromise, cpgPromise, prjPromise]);
178
+ let shx;
179
+ let cpg;
180
+ let prj;
181
+ const shxResponse = await shxPromise;
182
+ if (shxResponse.ok) {
183
+ const arrayBuffer = await shxResponse.arrayBuffer();
184
+ shx = (0, parse_shx_1.parseShx)(arrayBuffer);
185
+ }
186
+ const cpgResponse = await cpgPromise;
187
+ if (cpgResponse.ok) {
188
+ cpg = await cpgResponse.text();
189
+ }
190
+ const prjResponse = await prjPromise;
191
+ if (prjResponse.ok) {
192
+ prj = await prjResponse.text();
193
+ }
194
+ return {
195
+ shx,
196
+ cpg,
197
+ prj
198
+ };
194
199
  }
195
- export function replaceExtension(url, newExtension) {
196
- const baseName = basename(url);
197
- const extension = extname(url);
198
- const isUpperCase = extension === extension.toUpperCase();
199
-
200
- if (isUpperCase) {
201
- newExtension = newExtension.toUpperCase();
202
- }
203
-
204
- return "".concat(baseName, ".").concat(newExtension);
200
+ exports.loadShapefileSidecarFiles = loadShapefileSidecarFiles;
201
+ /**
202
+ * Replace the extension at the end of a path.
203
+ *
204
+ * Matches the case of new extension with the case of the original file extension,
205
+ * to increase the chance of finding files without firing off a request storm looking for various case combinations
206
+ *
207
+ * NOTE: Extensions can be both lower and uppercase
208
+ * per spec, extensions should be lower case, but that doesn't mean they always are. See:
209
+ * calvinmetcalf/shapefile-js#64, mapserver/mapserver#4712
210
+ * https://trac.osgeo.org/mapserver/ticket/166
211
+ */
212
+ function replaceExtension(url, newExtension) {
213
+ const baseName = basename(url);
214
+ const extension = extname(url);
215
+ const isUpperCase = extension === extension.toUpperCase();
216
+ if (isUpperCase) {
217
+ newExtension = newExtension.toUpperCase();
218
+ }
219
+ return `${baseName}.${newExtension}`;
205
220
  }
206
-
221
+ exports.replaceExtension = replaceExtension;
222
+ // NOTE - this gives the entire path minus extension (i.e. NOT same as path.basename)
223
+ /**
224
+ * @param url
225
+ * @returns string
226
+ */
207
227
  function basename(url) {
208
- const extIndex = url && url.lastIndexOf('.');
209
-
210
- if (typeof extIndex === 'number') {
211
- return extIndex >= 0 ? url.substr(0, extIndex) : '';
212
- }
213
-
214
- return extIndex;
228
+ const extIndex = url && url.lastIndexOf('.');
229
+ if (typeof extIndex === 'number') {
230
+ return extIndex >= 0 ? url.substr(0, extIndex) : '';
231
+ }
232
+ return extIndex;
215
233
  }
216
-
234
+ /**
235
+ * @param url
236
+ * @returns string
237
+ */
217
238
  function extname(url) {
218
- const extIndex = url && url.lastIndexOf('.');
219
-
220
- if (typeof extIndex === 'number') {
221
- return extIndex >= 0 ? url.substr(extIndex + 1) : '';
222
- }
223
-
224
- return extIndex;
239
+ const extIndex = url && url.lastIndexOf('.');
240
+ if (typeof extIndex === 'number') {
241
+ return extIndex >= 0 ? url.substr(extIndex + 1) : '';
242
+ }
243
+ return extIndex;
225
244
  }
226
- //# sourceMappingURL=parse-shapefile.js.map
@@ -1,11 +1,10 @@
1
1
  import { BinaryGeometry } from '@loaders.gl/schema';
2
+ import { SHPLoaderOptions } from './types';
2
3
  /**
3
4
  * Parse individual record
4
5
  *
5
6
  * @param view Record data
6
7
  * @return Binary Geometry Object
7
8
  */
8
- export declare function parseRecord(view: DataView, options?: {
9
- shp?: any;
10
- }): BinaryGeometry | null;
9
+ export declare function parseRecord(view: DataView, options?: SHPLoaderOptions): BinaryGeometry | null;
11
10
  //# sourceMappingURL=parse-shp-geometry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-shp-geometry.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-shp-geometry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAqB,MAAM,oBAAoB,CAAC;AAItE;;;;;GAKG;AAEH,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE;IAAC,GAAG,CAAC,EAAE,GAAG,CAAA;CAAC,GAAG,cAAc,GAAG,IAAI,CAoDxF"}
1
+ {"version":3,"file":"parse-shp-geometry.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-shp-geometry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAqB,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAC,gBAAgB,EAAC,MAAM,SAAS,CAAC;AAIzC;;;;;GAKG;AAEH,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,cAAc,GAAG,IAAI,CAoD7F"}