@loaders.gl/gis 3.4.0-alpha.1 → 3.4.0-alpha.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.
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/binary-to-geojson.js +1 -19
- package/dist/es5/lib/binary-to-geojson.js.map +1 -1
- package/dist/es5/lib/extract-geometry-info.js +1 -3
- package/dist/es5/lib/extract-geometry-info.js.map +1 -1
- package/dist/es5/lib/flat-geojson-to-binary.js +2 -26
- package/dist/es5/lib/flat-geojson-to-binary.js.map +1 -1
- package/dist/es5/lib/geojson-to-binary.js.map +1 -1
- package/dist/es5/lib/geojson-to-flat-geojson.js +1 -8
- package/dist/es5/lib/geojson-to-flat-geojson.js.map +1 -1
- package/dist/es5/lib/transform.js +1 -3
- package/dist/es5/lib/transform.js.map +1 -1
- package/dist/esm/bundle.js +0 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/binary-to-geojson.js +0 -19
- package/dist/esm/lib/binary-to-geojson.js.map +1 -1
- package/dist/esm/lib/extract-geometry-info.js +0 -3
- package/dist/esm/lib/extract-geometry-info.js.map +1 -1
- package/dist/esm/lib/flat-geojson-to-binary.js +1 -26
- package/dist/esm/lib/flat-geojson-to-binary.js.map +1 -1
- package/dist/esm/lib/geojson-to-binary.js +0 -1
- package/dist/esm/lib/geojson-to-binary.js.map +1 -1
- package/dist/esm/lib/geojson-to-flat-geojson.js +0 -7
- package/dist/esm/lib/geojson-to-flat-geojson.js.map +1 -1
- package/dist/esm/lib/transform.js +0 -3
- package/dist/esm/lib/transform.js.map +1 -1
- package/package.json +4 -4
package/dist/es5/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["// Types from `@loaders.gl/schema`\n\n// Functions\nexport {flatGeojsonToBinary} from './lib/flat-geojson-to-binary';\nexport {geojsonToBinary} from './lib/geojson-to-binary';\nexport {geojsonToFlatGeojson} from './lib/geojson-to-flat-geojson';\nexport {binaryToGeojson, binaryToGeoJson, binaryToGeometry} from './lib/binary-to-geojson';\nexport {transformBinaryCoords, transformGeoJsonCoords} from './lib/transform';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;AACA;AACA;AACA;AACA"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_flatGeojsonToBinary","require","_geojsonToBinary","_geojsonToFlatGeojson","_binaryToGeojson","_transform"],"sources":["../../src/index.ts"],"sourcesContent":["// Types from `@loaders.gl/schema`\n\n// Functions\nexport {flatGeojsonToBinary} from './lib/flat-geojson-to-binary';\nexport {geojsonToBinary} from './lib/geojson-to-binary';\nexport {geojsonToFlatGeojson} from './lib/geojson-to-flat-geojson';\nexport {binaryToGeojson, binaryToGeoJson, binaryToGeometry} from './lib/binary-to-geojson';\nexport {transformBinaryCoords, transformGeoJsonCoords} from './lib/transform';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,oBAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA"}
|
|
@@ -12,8 +12,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
12
12
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
13
|
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; } } }; }
|
|
14
14
|
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); }
|
|
15
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
16
|
-
|
|
15
|
+
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; }
|
|
17
16
|
function binaryToGeojson(data, options) {
|
|
18
17
|
var globalFeatureId = options === null || options === void 0 ? void 0 : options.globalFeatureId;
|
|
19
18
|
if (globalFeatureId !== undefined) {
|
|
@@ -21,7 +20,6 @@ function binaryToGeojson(data, options) {
|
|
|
21
20
|
}
|
|
22
21
|
return parseFeatures(data, options === null || options === void 0 ? void 0 : options.type);
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
function binaryToGeoJson(data, type) {
|
|
26
24
|
var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'feature';
|
|
27
25
|
switch (format) {
|
|
@@ -33,7 +31,6 @@ function binaryToGeoJson(data, type) {
|
|
|
33
31
|
throw new Error(format);
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
|
-
|
|
37
34
|
function getSingleFeature(data, globalFeatureId) {
|
|
38
35
|
var dataArray = normalizeInput(data);
|
|
39
36
|
var _iterator = _createForOfIteratorHelper(dataArray),
|
|
@@ -43,7 +40,6 @@ function getSingleFeature(data, globalFeatureId) {
|
|
|
43
40
|
var _data = _step.value;
|
|
44
41
|
var lastIndex = 0;
|
|
45
42
|
var lastValue = _data.featureIds.value[0];
|
|
46
|
-
|
|
47
43
|
for (var i = 0; i < _data.featureIds.value.length; i++) {
|
|
48
44
|
var currValue = _data.featureIds.value[i];
|
|
49
45
|
if (currValue === lastValue) {
|
|
@@ -70,7 +66,6 @@ function parseFeatures(data, type) {
|
|
|
70
66
|
var dataArray = normalizeInput(data, type);
|
|
71
67
|
return parseFeatureCollection(dataArray);
|
|
72
68
|
}
|
|
73
|
-
|
|
74
69
|
function binaryToGeometry(data, startIndex, endIndex) {
|
|
75
70
|
switch (data.type) {
|
|
76
71
|
case 'Point':
|
|
@@ -105,7 +100,6 @@ function normalizeInput(data, type) {
|
|
|
105
100
|
}
|
|
106
101
|
return features;
|
|
107
102
|
}
|
|
108
|
-
|
|
109
103
|
function parseFeatureCollection(dataArray) {
|
|
110
104
|
var features = [];
|
|
111
105
|
var _iterator2 = _createForOfIteratorHelper(dataArray),
|
|
@@ -118,7 +112,6 @@ function parseFeatureCollection(dataArray) {
|
|
|
118
112
|
}
|
|
119
113
|
var lastIndex = 0;
|
|
120
114
|
var lastValue = data.featureIds.value[0];
|
|
121
|
-
|
|
122
115
|
for (var i = 0; i < data.featureIds.value.length; i++) {
|
|
123
116
|
var currValue = data.featureIds.value[i];
|
|
124
117
|
if (currValue === lastValue) {
|
|
@@ -128,7 +121,6 @@ function parseFeatureCollection(dataArray) {
|
|
|
128
121
|
lastIndex = i;
|
|
129
122
|
lastValue = currValue;
|
|
130
123
|
}
|
|
131
|
-
|
|
132
124
|
features.push(parseFeature(data, lastIndex, data.featureIds.value.length));
|
|
133
125
|
}
|
|
134
126
|
} catch (err) {
|
|
@@ -138,7 +130,6 @@ function parseFeatureCollection(dataArray) {
|
|
|
138
130
|
}
|
|
139
131
|
return features;
|
|
140
132
|
}
|
|
141
|
-
|
|
142
133
|
function parseFeature(data, startIndex, endIndex) {
|
|
143
134
|
var geometry = binaryToGeometry(data, startIndex, endIndex);
|
|
144
135
|
var properties = parseProperties(data, startIndex, endIndex);
|
|
@@ -149,13 +140,11 @@ function parseFeature(data, startIndex, endIndex) {
|
|
|
149
140
|
properties: properties
|
|
150
141
|
}, fields);
|
|
151
142
|
}
|
|
152
|
-
|
|
153
143
|
function parseFields(data) {
|
|
154
144
|
var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
155
145
|
var endIndex = arguments.length > 2 ? arguments[2] : undefined;
|
|
156
146
|
return data.fields && data.fields[data.featureIds.value[startIndex]];
|
|
157
147
|
}
|
|
158
|
-
|
|
159
148
|
function parseProperties(data) {
|
|
160
149
|
var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
161
150
|
var endIndex = arguments.length > 2 ? arguments[2] : undefined;
|
|
@@ -165,7 +154,6 @@ function parseProperties(data) {
|
|
|
165
154
|
}
|
|
166
155
|
return properties;
|
|
167
156
|
}
|
|
168
|
-
|
|
169
157
|
function polygonToGeoJson(data) {
|
|
170
158
|
var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -Infinity;
|
|
171
159
|
var endIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity;
|
|
@@ -177,7 +165,6 @@ function polygonToGeoJson(data) {
|
|
|
177
165
|
return x >= startIndex && x <= endIndex;
|
|
178
166
|
});
|
|
179
167
|
var multi = polygonIndices.length > 2;
|
|
180
|
-
|
|
181
168
|
if (!multi) {
|
|
182
169
|
var _coordinates = [];
|
|
183
170
|
for (var i = 0; i < primitivePolygonIndices.length - 1; i++) {
|
|
@@ -191,7 +178,6 @@ function polygonToGeoJson(data) {
|
|
|
191
178
|
coordinates: _coordinates
|
|
192
179
|
};
|
|
193
180
|
}
|
|
194
|
-
|
|
195
181
|
var coordinates = [];
|
|
196
182
|
for (var _i = 0; _i < polygonIndices.length - 1; _i++) {
|
|
197
183
|
var startPolygonIndex = polygonIndices[_i];
|
|
@@ -204,7 +190,6 @@ function polygonToGeoJson(data) {
|
|
|
204
190
|
coordinates: coordinates
|
|
205
191
|
};
|
|
206
192
|
}
|
|
207
|
-
|
|
208
193
|
function lineStringToGeoJson(data) {
|
|
209
194
|
var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -Infinity;
|
|
210
195
|
var endIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity;
|
|
@@ -230,7 +215,6 @@ function lineStringToGeoJson(data) {
|
|
|
230
215
|
coordinates: coordinates
|
|
231
216
|
};
|
|
232
217
|
}
|
|
233
|
-
|
|
234
218
|
function pointToGeoJson(data, startIndex, endIndex) {
|
|
235
219
|
var positions = data.positions;
|
|
236
220
|
var coordinates = ringToGeoJson(positions, startIndex, endIndex);
|
|
@@ -246,7 +230,6 @@ function pointToGeoJson(data, startIndex, endIndex) {
|
|
|
246
230
|
coordinates: coordinates[0]
|
|
247
231
|
};
|
|
248
232
|
}
|
|
249
|
-
|
|
250
233
|
function ringToGeoJson(positions, startIndex, endIndex) {
|
|
251
234
|
startIndex = startIndex || 0;
|
|
252
235
|
endIndex = endIndex || positions.value.length / positions.size;
|
|
@@ -260,7 +243,6 @@ function ringToGeoJson(positions, startIndex, endIndex) {
|
|
|
260
243
|
}
|
|
261
244
|
return ringCoordinates;
|
|
262
245
|
}
|
|
263
|
-
|
|
264
246
|
function parseType(data) {
|
|
265
247
|
if (data.pathIndices) {
|
|
266
248
|
return 'LineString';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binary-to-geojson.js","names":["binaryToGeojson","data","options","globalFeatureId","undefined","getSingleFeature","parseFeatures","type","binaryToGeoJson","format","binaryToGeometry","Error","dataArray","normalizeInput","lastIndex","lastValue","featureIds","value","i","length","currValue","globalFeatureIds","parseFeature","parseFeatureCollection","startIndex","endIndex","pointToGeoJson","lineStringToGeoJson","polygonToGeoJson","unexpectedInput","isHeterogeneousType","Boolean","points","lines","polygons","parseType","features","push","geometry","properties","parseProperties","fields","parseFields","Object","assign","key","numericProps","Infinity","positions","polygonIndices","filter","x","primitivePolygonIndices","multi","coordinates","startRingIndex","endRingIndex","ringCoordinates","ringToGeoJson","startPolygonIndex","endPolygonIndex","polygonCoordinates","pathIndices","size","j","coord","Array","k","Number"],"sources":["../../../src/lib/binary-to-geojson.ts"],"sourcesContent":["import type {\n BinaryGeometry,\n BinaryFeatures,\n BinaryGeometryType,\n BinaryPointFeatures,\n BinaryLineFeatures,\n BinaryPolygonFeatures,\n BinaryAttribute\n} from '@loaders.gl/schema';\nimport type {Feature, Geometry, Position, GeoJsonProperties} from '@loaders.gl/schema';\nimport type {\n Point,\n MultiPoint,\n LineString,\n MultiLineString,\n Polygon,\n MultiPolygon\n} from '@loaders.gl/schema';\n\n// Note:L We do not handle GeometryCollection, define a limited Geometry type that always has coordinates.\n// type FeatureGeometry = Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon;\n\ntype BinaryToGeoJsonOptions = {\n type?: BinaryGeometryType;\n globalFeatureId?: number;\n};\n\n/**\n * Convert binary geometry representation to GeoJSON\n * @param data geometry data in binary representation\n * @param options\n * @param options.type Input data type: Point, LineString, or Polygon\n * @param options.featureId Global feature id. If specified, only a single feature is extracted\n * @return GeoJSON objects\n */\nexport function binaryToGeojson(\n data: BinaryFeatures,\n options?: BinaryToGeoJsonOptions\n): Feature[] | Feature {\n const globalFeatureId = options?.globalFeatureId;\n if (globalFeatureId !== undefined) {\n return getSingleFeature(data, globalFeatureId);\n }\n return parseFeatures(data, options?.type);\n}\n\n/** @deprecated use `binaryToGeojson` or `binaryToGeometry` instead */\nexport function binaryToGeoJson(\n data: BinaryGeometry | BinaryFeatures,\n type?: BinaryGeometryType,\n format: 'feature' | 'geometry' = 'feature'\n): Geometry | Feature[] {\n switch (format) {\n case 'feature':\n return parseFeatures(data as BinaryFeatures, type);\n case 'geometry':\n return binaryToGeometry(data as BinaryGeometry);\n default:\n throw new Error(format);\n }\n}\n\n/**\n * Return a single feature from a binary geometry representation as GeoJSON\n * @param data geometry data in binary representation\n * @return GeoJSON feature\n */\nfunction getSingleFeature(data: BinaryFeatures, globalFeatureId: number): Feature {\n const dataArray = normalizeInput(data);\n for (const data of dataArray) {\n let lastIndex = 0;\n let lastValue = data.featureIds.value[0];\n\n // Scan through data until we find matching feature\n for (let i = 0; i < data.featureIds.value.length; i++) {\n const currValue = data.featureIds.value[i];\n if (currValue === lastValue) {\n // eslint-disable-next-line no-continue\n continue;\n }\n if (globalFeatureId === data.globalFeatureIds.value[lastIndex]) {\n return parseFeature(data, lastIndex, i);\n }\n lastIndex = i;\n lastValue = currValue;\n }\n\n if (globalFeatureId === data.globalFeatureIds.value[lastIndex]) {\n return parseFeature(data, lastIndex, data.featureIds.value.length);\n }\n }\n\n throw new Error(`featureId:${globalFeatureId} not found`);\n}\n\nfunction parseFeatures(data: BinaryFeatures, type?: BinaryGeometryType): Feature[] {\n const dataArray = normalizeInput(data, type);\n return parseFeatureCollection(dataArray);\n}\n\n/** Parse input binary data and return a valid GeoJSON geometry object */\nexport function binaryToGeometry(\n data: BinaryGeometry,\n startIndex?: number,\n endIndex?: number\n): Geometry {\n switch (data.type) {\n case 'Point':\n return pointToGeoJson(data, startIndex, endIndex);\n case 'LineString':\n return lineStringToGeoJson(data, startIndex, endIndex);\n case 'Polygon':\n return polygonToGeoJson(data, startIndex, endIndex);\n default:\n const unexpectedInput: never = data;\n throw new Error(`Unsupported geometry type: ${(unexpectedInput as any)?.type}`);\n }\n}\n\ntype BinaryFeature = BinaryPointFeatures | BinaryLineFeatures | BinaryPolygonFeatures;\ntype BinaryFeaturesArray = BinaryFeature[];\n\n// Normalize features\n// Return an array of data objects, each of which have a type key\nfunction normalizeInput(data: BinaryFeatures, type?: BinaryGeometryType): BinaryFeaturesArray {\n const isHeterogeneousType = Boolean(data.points || data.lines || data.polygons);\n\n if (!isHeterogeneousType) {\n // @ts-expect-error This is a legacy check which allowed `data` to be an instance of the values\n // here. Aka the new data.points, data.lines, or data.polygons.\n data.type = type || parseType(data);\n return [data] as BinaryFeaturesArray;\n }\n\n const features: BinaryFeaturesArray = [];\n if (data.points) {\n data.points.type = 'Point';\n features.push(data.points);\n }\n if (data.lines) {\n data.lines.type = 'LineString';\n features.push(data.lines);\n }\n if (data.polygons) {\n data.polygons.type = 'Polygon';\n features.push(data.polygons);\n }\n\n return features;\n}\n\n/** Parse input binary data and return an array of GeoJSON Features */\nfunction parseFeatureCollection(dataArray): Feature[] {\n const features: Feature[] = [];\n for (const data of dataArray) {\n if (data.featureIds.value.length === 0) {\n // eslint-disable-next-line no-continue\n continue;\n }\n let lastIndex = 0;\n let lastValue = data.featureIds.value[0];\n\n // Need to deduce start, end indices of each feature\n for (let i = 0; i < data.featureIds.value.length; i++) {\n const currValue = data.featureIds.value[i];\n if (currValue === lastValue) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n features.push(parseFeature(data, lastIndex, i));\n lastIndex = i;\n lastValue = currValue;\n }\n\n // Last feature\n features.push(parseFeature(data, lastIndex, data.featureIds.value.length));\n }\n return features;\n}\n\n/** Parse input binary data and return a single GeoJSON Feature */\nfunction parseFeature(data, startIndex?: number, endIndex?: number): Feature {\n const geometry = binaryToGeometry(data, startIndex, endIndex);\n const properties = parseProperties(data, startIndex, endIndex);\n const fields = parseFields(data, startIndex, endIndex);\n return {type: 'Feature', geometry, properties, ...fields};\n}\n\n/** Parse input binary data and return an object of fields */\nfunction parseFields(data, startIndex: number = 0, endIndex?: number): GeoJsonProperties {\n return data.fields && data.fields[data.featureIds.value[startIndex]];\n}\n\n/** Parse input binary data and return an object of properties */\nfunction parseProperties(data, startIndex: number = 0, endIndex?: number): GeoJsonProperties {\n const properties = Object.assign({}, data.properties[data.featureIds.value[startIndex]]);\n for (const key in data.numericProps) {\n properties[key] = data.numericProps[key].value[startIndex];\n }\n return properties;\n}\n\n/** Parse binary data of type Polygon */\nfunction polygonToGeoJson(\n data,\n startIndex: number = -Infinity,\n endIndex: number = Infinity\n): Polygon | MultiPolygon {\n const {positions} = data;\n const polygonIndices = data.polygonIndices.value.filter((x) => x >= startIndex && x <= endIndex);\n const primitivePolygonIndices = data.primitivePolygonIndices.value.filter(\n (x) => x >= startIndex && x <= endIndex\n );\n const multi = polygonIndices.length > 2;\n\n // Polygon\n if (!multi) {\n const coordinates: Position[][] = [];\n for (let i = 0; i < primitivePolygonIndices.length - 1; i++) {\n const startRingIndex = primitivePolygonIndices[i];\n const endRingIndex = primitivePolygonIndices[i + 1];\n const ringCoordinates = ringToGeoJson(positions, startRingIndex, endRingIndex);\n coordinates.push(ringCoordinates);\n }\n\n return {type: 'Polygon', coordinates};\n }\n\n // MultiPolygon\n const coordinates: Position[][][] = [];\n for (let i = 0; i < polygonIndices.length - 1; i++) {\n const startPolygonIndex = polygonIndices[i];\n const endPolygonIndex = polygonIndices[i + 1];\n const polygonCoordinates = polygonToGeoJson(\n data,\n startPolygonIndex,\n endPolygonIndex\n ).coordinates;\n coordinates.push(polygonCoordinates as Position[][]);\n }\n\n return {type: 'MultiPolygon', coordinates};\n}\n\n/** Parse binary data of type LineString */\nfunction lineStringToGeoJson(\n data,\n startIndex: number = -Infinity,\n endIndex: number = Infinity\n): LineString | MultiLineString {\n const {positions} = data;\n const pathIndices = data.pathIndices.value.filter((x) => x >= startIndex && x <= endIndex);\n const multi = pathIndices.length > 2;\n\n if (!multi) {\n const coordinates = ringToGeoJson(positions, pathIndices[0], pathIndices[1]);\n return {type: 'LineString', coordinates};\n }\n\n const coordinates: Position[][] = [];\n for (let i = 0; i < pathIndices.length - 1; i++) {\n const ringCoordinates = ringToGeoJson(positions, pathIndices[i], pathIndices[i + 1]);\n coordinates.push(ringCoordinates);\n }\n\n return {type: 'MultiLineString', coordinates};\n}\n\n/** Parse binary data of type Point */\nfunction pointToGeoJson(data, startIndex, endIndex): Point | MultiPoint {\n const {positions} = data;\n const coordinates = ringToGeoJson(positions, startIndex, endIndex);\n const multi = coordinates.length > 1;\n\n if (multi) {\n return {type: 'MultiPoint', coordinates};\n }\n\n return {type: 'Point', coordinates: coordinates[0]};\n}\n\n/**\n * Parse a linear ring of positions to a GeoJSON linear ring\n *\n * @param positions Positions TypedArray\n * @param startIndex Start index to include in ring\n * @param endIndex End index to include in ring\n * @returns GeoJSON ring\n */\nfunction ringToGeoJson(\n positions: BinaryAttribute,\n startIndex?: number,\n endIndex?: number\n): Position[] {\n startIndex = startIndex || 0;\n endIndex = endIndex || positions.value.length / positions.size;\n\n const ringCoordinates: Position[] = [];\n for (let j = startIndex; j < endIndex; j++) {\n const coord = Array<number>();\n for (let k = j * positions.size; k < (j + 1) * positions.size; k++) {\n coord.push(Number(positions.value[k]));\n }\n ringCoordinates.push(coord);\n }\n return ringCoordinates;\n}\n\n// Deduce geometry type of data object\nfunction parseType(data) {\n if (data.pathIndices) {\n return 'LineString';\n }\n\n if (data.polygonIndices) {\n return 'Polygon';\n }\n\n return 'Point';\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmCO,SAASA,eAAe,CAC7BC,IAAoB,EACpBC,OAAgC,EACX;EACrB,IAAMC,eAAe,GAAGD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,eAAe;EAChD,IAAIA,eAAe,KAAKC,SAAS,EAAE;IACjC,OAAOC,gBAAgB,CAACJ,IAAI,EAAEE,eAAe,CAAC;EAChD;EACA,OAAOG,aAAa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e,IAAI,EAAEI,CAAC,EAAE,EAAE;MAClEF,KAAK,CAAC5B,IAAI,CAAC+B,MAAM,CAACpB,SAAS,CAAC/B,KAAK,CAACkD,CAAC,CAAC,CAAC,CAAC;IACxC;IACAV,eAAe,CAACpB,IAAI,CAAC4B,KAAK,CAAC;EAC7B;EACA,OAAOR,eAAe;AACxB;;AAGA,SAAStB,SAAS,CAAClC,IAAI,EAAE;EACvB,IAAIA,IAAI,CAAC6D,WAAW,EAAE;IACpB,OAAO,YAAY;EACrB;EAEA,IAAI7D,IAAI,CAACgD,cAAc,EAAE;IACvB,OAAO,SAAS;EAClB;EAEA,OAAO,OAAO;AAChB"}
|
|
1
|
+
{"version":3,"file":"binary-to-geojson.js","names":["binaryToGeojson","data","options","globalFeatureId","undefined","getSingleFeature","parseFeatures","type","binaryToGeoJson","format","arguments","length","binaryToGeometry","Error","dataArray","normalizeInput","_iterator","_createForOfIteratorHelper","_step","s","n","done","value","lastIndex","lastValue","featureIds","i","currValue","globalFeatureIds","parseFeature","err","e","f","concat","parseFeatureCollection","startIndex","endIndex","pointToGeoJson","lineStringToGeoJson","polygonToGeoJson","unexpectedInput","isHeterogeneousType","Boolean","points","lines","polygons","parseType","features","push","_iterator2","_step2","geometry","properties","parseProperties","fields","parseFields","_objectSpread","Object","assign","key","numericProps","Infinity","positions","polygonIndices","filter","x","primitivePolygonIndices","multi","coordinates","startRingIndex","endRingIndex","ringCoordinates","ringToGeoJson","startPolygonIndex","endPolygonIndex","polygonCoordinates","pathIndices","size","j","coord","Array","k","Number"],"sources":["../../../src/lib/binary-to-geojson.ts"],"sourcesContent":["import type {\n BinaryGeometry,\n BinaryFeatures,\n BinaryGeometryType,\n BinaryPointFeatures,\n BinaryLineFeatures,\n BinaryPolygonFeatures,\n BinaryAttribute\n} from '@loaders.gl/schema';\nimport type {Feature, Geometry, Position, GeoJsonProperties} from '@loaders.gl/schema';\nimport type {\n Point,\n MultiPoint,\n LineString,\n MultiLineString,\n Polygon,\n MultiPolygon\n} from '@loaders.gl/schema';\n\n// Note:L We do not handle GeometryCollection, define a limited Geometry type that always has coordinates.\n// type FeatureGeometry = Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon;\n\ntype BinaryToGeoJsonOptions = {\n type?: BinaryGeometryType;\n globalFeatureId?: number;\n};\n\n/**\n * Convert binary geometry representation to GeoJSON\n * @param data geometry data in binary representation\n * @param options\n * @param options.type Input data type: Point, LineString, or Polygon\n * @param options.featureId Global feature id. If specified, only a single feature is extracted\n * @return GeoJSON objects\n */\nexport function binaryToGeojson(\n data: BinaryFeatures,\n options?: BinaryToGeoJsonOptions\n): Feature[] | Feature {\n const globalFeatureId = options?.globalFeatureId;\n if (globalFeatureId !== undefined) {\n return getSingleFeature(data, globalFeatureId);\n }\n return parseFeatures(data, options?.type);\n}\n\n/** @deprecated use `binaryToGeojson` or `binaryToGeometry` instead */\nexport function binaryToGeoJson(\n data: BinaryGeometry | BinaryFeatures,\n type?: BinaryGeometryType,\n format: 'feature' | 'geometry' = 'feature'\n): Geometry | Feature[] {\n switch (format) {\n case 'feature':\n return parseFeatures(data as BinaryFeatures, type);\n case 'geometry':\n return binaryToGeometry(data as BinaryGeometry);\n default:\n throw new Error(format);\n }\n}\n\n/**\n * Return a single feature from a binary geometry representation as GeoJSON\n * @param data geometry data in binary representation\n * @return GeoJSON feature\n */\nfunction getSingleFeature(data: BinaryFeatures, globalFeatureId: number): Feature {\n const dataArray = normalizeInput(data);\n for (const data of dataArray) {\n let lastIndex = 0;\n let lastValue = data.featureIds.value[0];\n\n // Scan through data until we find matching feature\n for (let i = 0; i < data.featureIds.value.length; i++) {\n const currValue = data.featureIds.value[i];\n if (currValue === lastValue) {\n // eslint-disable-next-line no-continue\n continue;\n }\n if (globalFeatureId === data.globalFeatureIds.value[lastIndex]) {\n return parseFeature(data, lastIndex, i);\n }\n lastIndex = i;\n lastValue = currValue;\n }\n\n if (globalFeatureId === data.globalFeatureIds.value[lastIndex]) {\n return parseFeature(data, lastIndex, data.featureIds.value.length);\n }\n }\n\n throw new Error(`featureId:${globalFeatureId} not found`);\n}\n\nfunction parseFeatures(data: BinaryFeatures, type?: BinaryGeometryType): Feature[] {\n const dataArray = normalizeInput(data, type);\n return parseFeatureCollection(dataArray);\n}\n\n/** Parse input binary data and return a valid GeoJSON geometry object */\nexport function binaryToGeometry(\n data: BinaryGeometry,\n startIndex?: number,\n endIndex?: number\n): Geometry {\n switch (data.type) {\n case 'Point':\n return pointToGeoJson(data, startIndex, endIndex);\n case 'LineString':\n return lineStringToGeoJson(data, startIndex, endIndex);\n case 'Polygon':\n return polygonToGeoJson(data, startIndex, endIndex);\n default:\n const unexpectedInput: never = data;\n throw new Error(`Unsupported geometry type: ${(unexpectedInput as any)?.type}`);\n }\n}\n\ntype BinaryFeature = BinaryPointFeatures | BinaryLineFeatures | BinaryPolygonFeatures;\ntype BinaryFeaturesArray = BinaryFeature[];\n\n// Normalize features\n// Return an array of data objects, each of which have a type key\nfunction normalizeInput(data: BinaryFeatures, type?: BinaryGeometryType): BinaryFeaturesArray {\n const isHeterogeneousType = Boolean(data.points || data.lines || data.polygons);\n\n if (!isHeterogeneousType) {\n // @ts-expect-error This is a legacy check which allowed `data` to be an instance of the values\n // here. Aka the new data.points, data.lines, or data.polygons.\n data.type = type || parseType(data);\n return [data] as BinaryFeaturesArray;\n }\n\n const features: BinaryFeaturesArray = [];\n if (data.points) {\n data.points.type = 'Point';\n features.push(data.points);\n }\n if (data.lines) {\n data.lines.type = 'LineString';\n features.push(data.lines);\n }\n if (data.polygons) {\n data.polygons.type = 'Polygon';\n features.push(data.polygons);\n }\n\n return features;\n}\n\n/** Parse input binary data and return an array of GeoJSON Features */\nfunction parseFeatureCollection(dataArray): Feature[] {\n const features: Feature[] = [];\n for (const data of dataArray) {\n if (data.featureIds.value.length === 0) {\n // eslint-disable-next-line no-continue\n continue;\n }\n let lastIndex = 0;\n let lastValue = data.featureIds.value[0];\n\n // Need to deduce start, end indices of each feature\n for (let i = 0; i < data.featureIds.value.length; i++) {\n const currValue = data.featureIds.value[i];\n if (currValue === lastValue) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n features.push(parseFeature(data, lastIndex, i));\n lastIndex = i;\n lastValue = currValue;\n }\n\n // Last feature\n features.push(parseFeature(data, lastIndex, data.featureIds.value.length));\n }\n return features;\n}\n\n/** Parse input binary data and return a single GeoJSON Feature */\nfunction parseFeature(data, startIndex?: number, endIndex?: number): Feature {\n const geometry = binaryToGeometry(data, startIndex, endIndex);\n const properties = parseProperties(data, startIndex, endIndex);\n const fields = parseFields(data, startIndex, endIndex);\n return {type: 'Feature', geometry, properties, ...fields};\n}\n\n/** Parse input binary data and return an object of fields */\nfunction parseFields(data, startIndex: number = 0, endIndex?: number): GeoJsonProperties {\n return data.fields && data.fields[data.featureIds.value[startIndex]];\n}\n\n/** Parse input binary data and return an object of properties */\nfunction parseProperties(data, startIndex: number = 0, endIndex?: number): GeoJsonProperties {\n const properties = Object.assign({}, data.properties[data.featureIds.value[startIndex]]);\n for (const key in data.numericProps) {\n properties[key] = data.numericProps[key].value[startIndex];\n }\n return properties;\n}\n\n/** Parse binary data of type Polygon */\nfunction polygonToGeoJson(\n data,\n startIndex: number = -Infinity,\n endIndex: number = Infinity\n): Polygon | MultiPolygon {\n const {positions} = data;\n const polygonIndices = data.polygonIndices.value.filter((x) => x >= startIndex && x <= endIndex);\n const primitivePolygonIndices = data.primitivePolygonIndices.value.filter(\n (x) => x >= startIndex && x <= endIndex\n );\n const multi = polygonIndices.length > 2;\n\n // Polygon\n if (!multi) {\n const coordinates: Position[][] = [];\n for (let i = 0; i < primitivePolygonIndices.length - 1; i++) {\n const startRingIndex = primitivePolygonIndices[i];\n const endRingIndex = primitivePolygonIndices[i + 1];\n const ringCoordinates = ringToGeoJson(positions, startRingIndex, endRingIndex);\n coordinates.push(ringCoordinates);\n }\n\n return {type: 'Polygon', coordinates};\n }\n\n // MultiPolygon\n const coordinates: Position[][][] = [];\n for (let i = 0; i < polygonIndices.length - 1; i++) {\n const startPolygonIndex = polygonIndices[i];\n const endPolygonIndex = polygonIndices[i + 1];\n const polygonCoordinates = polygonToGeoJson(\n data,\n startPolygonIndex,\n endPolygonIndex\n ).coordinates;\n coordinates.push(polygonCoordinates as Position[][]);\n }\n\n return {type: 'MultiPolygon', coordinates};\n}\n\n/** Parse binary data of type LineString */\nfunction lineStringToGeoJson(\n data,\n startIndex: number = -Infinity,\n endIndex: number = Infinity\n): LineString | MultiLineString {\n const {positions} = data;\n const pathIndices = data.pathIndices.value.filter((x) => x >= startIndex && x <= endIndex);\n const multi = pathIndices.length > 2;\n\n if (!multi) {\n const coordinates = ringToGeoJson(positions, pathIndices[0], pathIndices[1]);\n return {type: 'LineString', coordinates};\n }\n\n const coordinates: Position[][] = [];\n for (let i = 0; i < pathIndices.length - 1; i++) {\n const ringCoordinates = ringToGeoJson(positions, pathIndices[i], pathIndices[i + 1]);\n coordinates.push(ringCoordinates);\n }\n\n return {type: 'MultiLineString', coordinates};\n}\n\n/** Parse binary data of type Point */\nfunction pointToGeoJson(data, startIndex, endIndex): Point | MultiPoint {\n const {positions} = data;\n const coordinates = ringToGeoJson(positions, startIndex, endIndex);\n const multi = coordinates.length > 1;\n\n if (multi) {\n return {type: 'MultiPoint', coordinates};\n }\n\n return {type: 'Point', coordinates: coordinates[0]};\n}\n\n/**\n * Parse a linear ring of positions to a GeoJSON linear ring\n *\n * @param positions Positions TypedArray\n * @param startIndex Start index to include in ring\n * @param endIndex End index to include in ring\n * @returns GeoJSON ring\n */\nfunction ringToGeoJson(\n positions: BinaryAttribute,\n startIndex?: number,\n endIndex?: number\n): Position[] {\n startIndex = startIndex || 0;\n endIndex = endIndex || positions.value.length / positions.size;\n\n const ringCoordinates: Position[] = [];\n for (let j = startIndex; j < endIndex; j++) {\n const coord = Array<number>();\n for (let k = j * positions.size; k < (j + 1) * positions.size; k++) {\n coord.push(Number(positions.value[k]));\n }\n ringCoordinates.push(coord);\n }\n return ringCoordinates;\n}\n\n// Deduce geometry type of data object\nfunction parseType(data) {\n if (data.pathIndices) {\n return 'LineString';\n }\n\n if (data.polygonIndices) {\n return 'Polygon';\n }\n\n return 'Point';\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmCO,SAASA,eAAeA,CAC7BC,IAAoB,EACpBC,OAAgC,EACX;EACrB,IAAMC,eAAe,GAAGD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,eAAe;EAChD,IAAIA,eAAe,KAAKC,SAAS,EAAE;IACjC,OAAOC,gBAAgB,CAACJ,IAAI,EAAEE,eAAe,CAAC;EAChD;EACA,OAAOG,aAAa,CAACL,IAAI,EAAEC,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEK,IAAI,CAAC;AAC3C;AAGO,SAASC,eAAeA,CAC7BP,IAAqC,EACrCM,IAAyB,EAEH;EAAA,IADtBE,MAA8B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAN,SAAA,GAAAM,SAAA,MAAG,SAAS;EAE1C,QAAQD,MAAM;IACZ,KAAK,SAAS;MACZ,OAAOH,aAAa,CAACL,IAAI,EAAoBM,IAAI,CAAC;IACpD,KAAK,UAAU;MACb,OAAOK,gBAAgB,CAACX,IAAI,CAAmB;IACjD;MACE,MAAM,IAAIY,KAAK,CAACJ,MAAM,CAAC;EAAC;AAE9B;AAOA,SAASJ,gBAAgBA,CAACJ,IAAoB,EAAEE,eAAuB,EAAW;EAChF,IAAMW,SAAS,GAAGC,cAAc,CAACd,IAAI,CAAC;EAAC,IAAAe,SAAA,GAAAC,0BAAA,CACpBH,SAAS;IAAAI,KAAA;EAAA;IAA5B,KAAAF,SAAA,CAAAG,CAAA,MAAAD,KAAA,GAAAF,SAAA,CAAAI,CAAA,IAAAC,IAAA,GAA8B;MAAA,IAAnBpB,KAAI,GAAAiB,KAAA,CAAAI,KAAA;MACb,IAAIC,SAAS,GAAG,CAAC;MACjB,IAAIC,SAAS,GAAGvB,KAAI,CAACwB,UAAU,CAACH,KAAK,CA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AAU,EAAE2C,CAAC,GAAG1C,QAAQ,EAAE0C,CAAC,EAAE,EAAE;IAC1C,IAAMC,KAAK,GAAGC,KAAK,EAAU;IAC7B,KAAK,IAAIC,CAAC,GAAGH,CAAC,GAAGhB,SAAS,CAACe,IAAI,EAAEI,CAAC,GAAG,CAACH,CAAC,GAAG,CAAC,IAAIhB,SAAS,CAACe,IAAI,EAAEI,CAAC,EAAE,EAAE;MAClEF,KAAK,CAAC/B,IAAI,CAACkC,MAAM,CAACpB,SAAS,CAACxC,KAAK,CAAC2D,CAAC,CAAC,CAAC,CAAC;IACxC;IACAV,eAAe,CAACvB,IAAI,CAAC+B,KAAK,CAAC;EAC7B;EACA,OAAOR,eAAe;AACxB;AAGA,SAASzB,SAASA,CAAC7C,IAAI,EAAE;EACvB,IAAIA,IAAI,CAAC2E,WAAW,EAAE;IACpB,OAAO,YAAY;EACrB;EAEA,IAAI3E,IAAI,CAAC8D,cAAc,EAAE;IACvB,OAAO,SAAS;EAClB;EAEA,OAAO,OAAO;AAChB"}
|
|
@@ -8,7 +8,7 @@ exports.extractGeometryInfo = extractGeometryInfo;
|
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
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; } } }; }
|
|
10
10
|
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); }
|
|
11
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
11
|
+
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; }
|
|
12
12
|
function extractGeometryInfo(features) {
|
|
13
13
|
var pointPositionsCount = 0;
|
|
14
14
|
var pointFeaturesCount = 0;
|
|
@@ -74,7 +74,6 @@ function extractGeometryInfo(features) {
|
|
|
74
74
|
var line = _step4.value;
|
|
75
75
|
linePositionsCount += line.length;
|
|
76
76
|
linePathsCount++;
|
|
77
|
-
|
|
78
77
|
var _iterator5 = _createForOfIteratorHelper(line),
|
|
79
78
|
_step5;
|
|
80
79
|
try {
|
|
@@ -124,7 +123,6 @@ function extractGeometryInfo(features) {
|
|
|
124
123
|
polygonRingsCount += polygon.length;
|
|
125
124
|
var _flattened = polygon.flat();
|
|
126
125
|
polygonPositionsCount += _flattened.length;
|
|
127
|
-
|
|
128
126
|
var _iterator8 = _createForOfIteratorHelper(_flattened),
|
|
129
127
|
_step8;
|
|
130
128
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-geometry-info.js","names":["extractGeometryInfo","features","pointPositionsCount","pointFeaturesCount","linePositionsCount","linePathsCount","lineFeaturesCount","polygonPositionsCount","polygonObjectsCount","polygonRingsCount","polygonFeaturesCount","coordLengths","Set","feature","geometry","type","add","coordinates","length","point","coord","line","flattened","flat","polygon","Error","coordLength","size","Math","max"],"sources":["../../../src/lib/extract-geometry-info.ts"],"sourcesContent":["import {Feature, GeojsonGeometryInfo} from '@loaders.gl/schema';\n\n/**\n * Initial scan over GeoJSON features\n * Counts number of coordinates of each geometry type and\n * keeps track of the max coordinate dimensions\n */\n// eslint-disable-next-line complexity, max-statements\nexport function extractGeometryInfo(features: Feature[]): GeojsonGeometryInfo {\n // Counts the number of _positions_, so [x, y, z] counts as one\n let pointPositionsCount = 0;\n let pointFeaturesCount = 0;\n let linePositionsCount = 0;\n let linePathsCount = 0;\n let lineFeaturesCount = 0;\n let polygonPositionsCount = 0;\n let polygonObjectsCount = 0;\n let polygonRingsCount = 0;\n let polygonFeaturesCount = 0;\n const coordLengths = new Set<number>();\n\n for (const feature of features) {\n const geometry = feature.geometry;\n switch (geometry.type) {\n case 'Point':\n pointFeaturesCount++;\n pointPositionsCount++;\n coordLengths.add(geometry.coordinates.length);\n break;\n case 'MultiPoint':\n pointFeaturesCount++;\n pointPositionsCount += geometry.coordinates.length;\n for (const point of geometry.coordinates) {\n coordLengths.add(point.length);\n }\n break;\n case 'LineString':\n lineFeaturesCount++;\n linePositionsCount += geometry.coordinates.length;\n linePathsCount++;\n\n for (const coord of geometry.coordinates) {\n coordLengths.add(coord.length);\n }\n break;\n case 'MultiLineString':\n lineFeaturesCount++;\n for (const line of geometry.coordinates) {\n linePositionsCount += line.length;\n linePathsCount++;\n\n // eslint-disable-next-line max-depth\n for (const coord of line) {\n coordLengths.add(coord.length);\n }\n }\n break;\n case 'Polygon':\n polygonFeaturesCount++;\n polygonObjectsCount++;\n polygonRingsCount += geometry.coordinates.length;\n const flattened = geometry.coordinates.flat();\n polygonPositionsCount += flattened.length;\n\n for (const coord of flattened) {\n coordLengths.add(coord.length);\n }\n break;\n case 'MultiPolygon':\n polygonFeaturesCount++;\n for (const polygon of geometry.coordinates) {\n polygonObjectsCount++;\n polygonRingsCount += polygon.length;\n const flattened = polygon.flat();\n polygonPositionsCount += flattened.length;\n\n // eslint-disable-next-line max-depth\n for (const coord of flattened) {\n coordLengths.add(coord.length);\n }\n }\n break;\n default:\n throw new Error(`Unsupported geometry type: ${geometry.type}`);\n }\n }\n\n return {\n coordLength: coordLengths.size > 0 ? Math.max(...coordLengths) : 2,\n\n pointPositionsCount,\n pointFeaturesCount,\n linePositionsCount,\n linePathsCount,\n lineFeaturesCount,\n polygonPositionsCount,\n polygonObjectsCount,\n polygonRingsCount,\n polygonFeaturesCount\n };\n}\n"],"mappings":";;;;;;;;;;;AAQO,SAASA,
|
|
1
|
+
{"version":3,"file":"extract-geometry-info.js","names":["extractGeometryInfo","features","pointPositionsCount","pointFeaturesCount","linePositionsCount","linePathsCount","lineFeaturesCount","polygonPositionsCount","polygonObjectsCount","polygonRingsCount","polygonFeaturesCount","coordLengths","Set","_iterator","_createForOfIteratorHelper","_step","s","n","done","feature","value","geometry","type","add","coordinates","length","_iterator2","_step2","point","err","e","f","_iterator3","_step3","coord","_iterator4","_step4","line","_iterator5","_step5","flattened","flat","_iterator6","_step6","_iterator7","_step7","polygon","_iterator8","_step8","Error","concat","coordLength","size","Math","max","apply","_toConsumableArray2","default"],"sources":["../../../src/lib/extract-geometry-info.ts"],"sourcesContent":["import {Feature, GeojsonGeometryInfo} from '@loaders.gl/schema';\n\n/**\n * Initial scan over GeoJSON features\n * Counts number of coordinates of each geometry type and\n * keeps track of the max coordinate dimensions\n */\n// eslint-disable-next-line complexity, max-statements\nexport function extractGeometryInfo(features: Feature[]): GeojsonGeometryInfo {\n // Counts the number of _positions_, so [x, y, z] counts as one\n let pointPositionsCount = 0;\n let pointFeaturesCount = 0;\n let linePositionsCount = 0;\n let linePathsCount = 0;\n let lineFeaturesCount = 0;\n let polygonPositionsCount = 0;\n let polygonObjectsCount = 0;\n let polygonRingsCount = 0;\n let polygonFeaturesCount = 0;\n const coordLengths = new Set<number>();\n\n for (const feature of features) {\n const geometry = feature.geometry;\n switch (geometry.type) {\n case 'Point':\n pointFeaturesCount++;\n pointPositionsCount++;\n coordLengths.add(geometry.coordinates.length);\n break;\n case 'MultiPoint':\n pointFeaturesCount++;\n pointPositionsCount += geometry.coordinates.length;\n for (const point of geometry.coordinates) {\n coordLengths.add(point.length);\n }\n break;\n case 'LineString':\n lineFeaturesCount++;\n linePositionsCount += geometry.coordinates.length;\n linePathsCount++;\n\n for (const coord of geometry.coordinates) {\n coordLengths.add(coord.length);\n }\n break;\n case 'MultiLineString':\n lineFeaturesCount++;\n for (const line of geometry.coordinates) {\n linePositionsCount += line.length;\n linePathsCount++;\n\n // eslint-disable-next-line max-depth\n for (const coord of line) {\n coordLengths.add(coord.length);\n }\n }\n break;\n case 'Polygon':\n polygonFeaturesCount++;\n polygonObjectsCount++;\n polygonRingsCount += geometry.coordinates.length;\n const flattened = geometry.coordinates.flat();\n polygonPositionsCount += flattened.length;\n\n for (const coord of flattened) {\n coordLengths.add(coord.length);\n }\n break;\n case 'MultiPolygon':\n polygonFeaturesCount++;\n for (const polygon of geometry.coordinates) {\n polygonObjectsCount++;\n polygonRingsCount += polygon.length;\n const flattened = polygon.flat();\n polygonPositionsCount += flattened.length;\n\n // eslint-disable-next-line max-depth\n for (const coord of flattened) {\n coordLengths.add(coord.length);\n }\n }\n break;\n default:\n throw new Error(`Unsupported geometry type: ${geometry.type}`);\n }\n }\n\n return {\n coordLength: coordLengths.size > 0 ? Math.max(...coordLengths) : 2,\n\n pointPositionsCount,\n pointFeaturesCount,\n linePositionsCount,\n linePathsCount,\n lineFeaturesCount,\n polygonPositionsCount,\n polygonObjectsCount,\n polygonRingsCount,\n polygonFeaturesCount\n };\n}\n"],"mappings":";;;;;;;;;;;AAQO,SAASA,mBAAmBA,CAACC,QAAmB,EAAuB;EAE5E,IAAIC,mBAAmB,GAAG,CAAC;EAC3B,IAAIC,kBAAkB,GAAG,CAAC;EAC1B,IAAIC,kBAAkB,GAAG,CAAC;EAC1B,IAAIC,cAAc,GAAG,CAAC;EACtB,IAAIC,iBAAiB,GA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,CAACW,OAAK,CAACT,MAAM,CAAC;gBAChC;cAAC,SAAAI,GAAA;gBAAAkB,UAAA,CAAAjB,CAAA,CAAAD,GAAA;cAAA;gBAAAkB,UAAA,CAAAhB,CAAA;cAAA;YACH;UAAC,SAAAF,GAAA;YAAAe,UAAA,CAAAd,CAAA,CAAAD,GAAA;UAAA;YAAAe,UAAA,CAAAb,CAAA;UAAA;UACD;QACF;UACE,MAAM,IAAIkB,KAAK,+BAAAC,MAAA,CAA+B7B,QAAQ,CAACC,IAAI,EAAG;MAAC;IAErE;EAAC,SAAAO,GAAA;IAAAhB,SAAA,CAAAiB,CAAA,CAAAD,GAAA;EAAA;IAAAhB,SAAA,CAAAkB,CAAA;EAAA;EAED,OAAO;IACLoB,WAAW,EAAExC,YAAY,CAACyC,IAAI,GAAG,CAAC,GAAGC,IAAI,CAACC,GAAG,CAAAC,KAAA,CAARF,IAAI,MAAAG,mBAAA,CAAAC,OAAA,EAAQ9C,YAAY,EAAC,GAAG,CAAC;IAElET,mBAAmB,EAAnBA,mBAAmB;IACnBC,kBAAkB,EAAlBA,kBAAkB;IAClBC,kBAAkB,EAAlBA,kBAAkB;IAClBC,cAAc,EAAdA,cAAc;IACdC,iBAAiB,EAAjBA,iBAAiB;IACjBC,qBAAqB,EAArBA,qBAAqB;IACrBC,mBAAmB,EAAnBA,mBAAmB;IACnBC,iBAAiB,EAAjBA,iBAAiB;IACjBC,oBAAoB,EAApBA;EACF,CAAC;AACH"}
|
|
@@ -10,7 +10,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
10
10
|
var _polygon = require("@math.gl/polygon");
|
|
11
11
|
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; } } }; }
|
|
12
12
|
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); }
|
|
13
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
13
|
+
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; }
|
|
14
14
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
15
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
16
|
function flatGeojsonToBinary(features, geometryInfo, options) {
|
|
@@ -25,11 +25,9 @@ function flatGeojsonToBinary(features, geometryInfo, options) {
|
|
|
25
25
|
PositionDataType: options ? options.PositionDataType : Float32Array
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
|
|
29
28
|
var TEST_EXPORTS = {
|
|
30
29
|
extractNumericPropTypes: extractNumericPropTypes
|
|
31
30
|
};
|
|
32
|
-
|
|
33
31
|
exports.TEST_EXPORTS = TEST_EXPORTS;
|
|
34
32
|
function extractNumericPropTypes(features) {
|
|
35
33
|
var propArrayTypes = {};
|
|
@@ -52,7 +50,6 @@ function extractNumericPropTypes(features) {
|
|
|
52
50
|
}
|
|
53
51
|
return propArrayTypes;
|
|
54
52
|
}
|
|
55
|
-
|
|
56
53
|
function fillArrays(features, geometryInfo, options) {
|
|
57
54
|
var pointPositionsCount = geometryInfo.pointPositionsCount,
|
|
58
55
|
pointFeaturesCount = geometryInfo.pointFeaturesCount,
|
|
@@ -102,7 +99,6 @@ function fillArrays(features, geometryInfo, options) {
|
|
|
102
99
|
properties: [],
|
|
103
100
|
fields: []
|
|
104
101
|
};
|
|
105
|
-
|
|
106
102
|
for (var _i = 0, _arr = [points, lines, polygons]; _i < _arr.length; _i++) {
|
|
107
103
|
var object = _arr[_i];
|
|
108
104
|
var _iterator2 = _createForOfIteratorHelper(numericPropKeys),
|
|
@@ -119,7 +115,6 @@ function fillArrays(features, geometryInfo, options) {
|
|
|
119
115
|
_iterator2.f();
|
|
120
116
|
}
|
|
121
117
|
}
|
|
122
|
-
|
|
123
118
|
lines.pathIndices[linePathsCount] = linePositionsCount;
|
|
124
119
|
polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;
|
|
125
120
|
polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;
|
|
@@ -178,7 +173,6 @@ function fillArrays(features, geometryInfo, options) {
|
|
|
178
173
|
}
|
|
179
174
|
indexMap.feature++;
|
|
180
175
|
}
|
|
181
|
-
|
|
182
176
|
} catch (err) {
|
|
183
177
|
_iterator3.e(err);
|
|
184
178
|
} finally {
|
|
@@ -186,7 +180,6 @@ function fillArrays(features, geometryInfo, options) {
|
|
|
186
180
|
}
|
|
187
181
|
return makeAccessorObjects(points, lines, polygons, coordLength);
|
|
188
182
|
}
|
|
189
|
-
|
|
190
183
|
function handlePoint(geometry, points, indexMap, coordLength, properties) {
|
|
191
184
|
points.positions.set(geometry.data, indexMap.pointPosition * coordLength);
|
|
192
185
|
var nPositions = geometry.data.length / coordLength;
|
|
@@ -195,7 +188,6 @@ function handlePoint(geometry, points, indexMap, coordLength, properties) {
|
|
|
195
188
|
points.featureIds.fill(indexMap.pointFeature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
|
|
196
189
|
indexMap.pointPosition += nPositions;
|
|
197
190
|
}
|
|
198
|
-
|
|
199
191
|
function handleLineString(geometry, lines, indexMap, coordLength, properties) {
|
|
200
192
|
lines.positions.set(geometry.data, indexMap.linePosition * coordLength);
|
|
201
193
|
var nPositions = geometry.data.length / coordLength;
|
|
@@ -205,19 +197,16 @@ function handleLineString(geometry, lines, indexMap, coordLength, properties) {
|
|
|
205
197
|
for (var i = 0, il = geometry.indices.length; i < il; ++i) {
|
|
206
198
|
var start = geometry.indices[i];
|
|
207
199
|
var end = i === il - 1 ? geometry.data.length : geometry.indices[i + 1];
|
|
208
|
-
|
|
209
200
|
lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;
|
|
210
201
|
indexMap.linePosition += (end - start) / coordLength;
|
|
211
202
|
}
|
|
212
203
|
}
|
|
213
|
-
|
|
214
204
|
function handlePolygon(geometry, polygons, indexMap, coordLength, properties) {
|
|
215
205
|
polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);
|
|
216
206
|
var nPositions = geometry.data.length / coordLength;
|
|
217
207
|
fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);
|
|
218
208
|
polygons.globalFeatureIds.fill(indexMap.feature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
|
|
219
209
|
polygons.featureIds.fill(indexMap.polygonFeature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
|
|
220
|
-
|
|
221
210
|
for (var l = 0, ll = geometry.indices.length; l < ll; ++l) {
|
|
222
211
|
var startPosition = indexMap.polygonPosition;
|
|
223
212
|
polygons.polygonIndices[indexMap.polygonObject++] = startPosition;
|
|
@@ -226,9 +215,7 @@ function handlePolygon(geometry, polygons, indexMap, coordLength, properties) {
|
|
|
226
215
|
var nextIndices = geometry.indices[l + 1];
|
|
227
216
|
for (var i = 0, il = indices.length; i < il; ++i) {
|
|
228
217
|
var start = indices[i];
|
|
229
|
-
var end = i === il - 1 ?
|
|
230
|
-
nextIndices === undefined ? geometry.data.length : nextIndices[0] : indices[i + 1];
|
|
231
|
-
|
|
218
|
+
var end = i === il - 1 ? nextIndices === undefined ? geometry.data.length : nextIndices[0] : indices[i + 1];
|
|
232
219
|
polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
|
|
233
220
|
indexMap.polygonPosition += (end - start) / coordLength;
|
|
234
221
|
}
|
|
@@ -240,28 +227,22 @@ function handlePolygon(geometry, polygons, indexMap, coordLength, properties) {
|
|
|
240
227
|
});
|
|
241
228
|
}
|
|
242
229
|
}
|
|
243
|
-
|
|
244
230
|
function triangulatePolygon(polygons, areas, indices, _ref) {
|
|
245
231
|
var startPosition = _ref.startPosition,
|
|
246
232
|
endPosition = _ref.endPosition,
|
|
247
233
|
coordLength = _ref.coordLength;
|
|
248
234
|
var start = startPosition * coordLength;
|
|
249
235
|
var end = endPosition * coordLength;
|
|
250
|
-
|
|
251
236
|
var polygonPositions = polygons.positions.subarray(start, end);
|
|
252
|
-
|
|
253
237
|
var offset = indices[0];
|
|
254
238
|
var holes = indices.slice(1).map(function (n) {
|
|
255
239
|
return (n - offset) / coordLength;
|
|
256
240
|
});
|
|
257
|
-
|
|
258
241
|
var triangles = (0, _polygon.earcut)(polygonPositions, holes, coordLength, areas);
|
|
259
|
-
|
|
260
242
|
for (var t = 0, tl = triangles.length; t < tl; ++t) {
|
|
261
243
|
polygons.triangles.push(startPosition + triangles[t]);
|
|
262
244
|
}
|
|
263
245
|
}
|
|
264
|
-
|
|
265
246
|
function wrapProps(obj, size) {
|
|
266
247
|
var returnObj = {};
|
|
267
248
|
for (var _key2 in obj) {
|
|
@@ -272,7 +253,6 @@ function wrapProps(obj, size) {
|
|
|
272
253
|
}
|
|
273
254
|
return returnObj;
|
|
274
255
|
}
|
|
275
|
-
|
|
276
256
|
function makeAccessorObjects(points, lines, polygons, coordLength) {
|
|
277
257
|
return {
|
|
278
258
|
points: _objectSpread(_objectSpread({}, points), {}, {
|
|
@@ -338,7 +318,6 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
|
|
|
338
318
|
})
|
|
339
319
|
};
|
|
340
320
|
}
|
|
341
|
-
|
|
342
321
|
function fillNumericProperties(object, properties, index, length) {
|
|
343
322
|
for (var numericPropName in object.numericProps) {
|
|
344
323
|
if (numericPropName in properties) {
|
|
@@ -347,7 +326,6 @@ function fillNumericProperties(object, properties, index, length) {
|
|
|
347
326
|
}
|
|
348
327
|
}
|
|
349
328
|
}
|
|
350
|
-
|
|
351
329
|
function keepStringProperties(properties, numericKeys) {
|
|
352
330
|
var props = {};
|
|
353
331
|
for (var _key3 in properties) {
|
|
@@ -357,12 +335,10 @@ function keepStringProperties(properties, numericKeys) {
|
|
|
357
335
|
}
|
|
358
336
|
return props;
|
|
359
337
|
}
|
|
360
|
-
|
|
361
338
|
function deduceArrayType(x, constructor) {
|
|
362
339
|
if (constructor === Array || !Number.isFinite(x)) {
|
|
363
340
|
return Array;
|
|
364
341
|
}
|
|
365
|
-
|
|
366
342
|
return constructor === Float64Array || Math.fround(x) !== x ? Float64Array : Float32Array;
|
|
367
343
|
}
|
|
368
344
|
//# sourceMappingURL=flat-geojson-to-binary.js.map
|