@loaders.gl/gis 4.0.0-alpha.4 → 4.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +2 -2
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/index.js +59 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/binary-to-geojson.js +255 -0
- package/dist/es5/lib/binary-to-geojson.js.map +1 -0
- package/dist/es5/lib/extract-geometry-info.js +167 -0
- package/dist/es5/lib/extract-geometry-info.js.map +1 -0
- package/dist/es5/lib/flat-geojson-to-binary-types.js +2 -0
- package/dist/es5/lib/flat-geojson-to-binary-types.js.map +1 -0
- package/dist/es5/lib/flat-geojson-to-binary.js +344 -0
- package/dist/es5/lib/flat-geojson-to-binary.js.map +1 -0
- package/dist/es5/lib/geojson-to-binary.js +26 -0
- package/dist/es5/lib/geojson-to-binary.js.map +1 -0
- package/dist/es5/lib/geojson-to-flat-geojson.js +136 -0
- package/dist/es5/lib/geojson-to-flat-geojson.js.map +1 -0
- package/dist/es5/lib/transform.js +57 -0
- package/dist/es5/lib/transform.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/binary-to-geojson.js +223 -0
- package/dist/esm/lib/binary-to-geojson.js.map +1 -0
- package/dist/esm/lib/extract-geometry-info.js +84 -0
- package/dist/esm/lib/extract-geometry-info.js.map +1 -0
- package/dist/esm/lib/flat-geojson-to-binary-types.js +2 -0
- package/dist/esm/lib/flat-geojson-to-binary-types.js.map +1 -0
- package/dist/esm/lib/flat-geojson-to-binary.js +305 -0
- package/dist/esm/lib/flat-geojson-to-binary.js.map +1 -0
- package/dist/esm/lib/geojson-to-binary.js +22 -0
- package/dist/esm/lib/geojson-to-binary.js.map +1 -0
- package/dist/esm/lib/geojson-to-flat-geojson.js +97 -0
- package/dist/esm/lib/geojson-to-flat-geojson.js.map +1 -0
- package/dist/esm/lib/transform.js +40 -0
- package/dist/esm/lib/transform.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -4
- package/dist/lib/binary-to-geojson.d.ts +21 -0
- package/dist/lib/binary-to-geojson.d.ts.map +1 -0
- package/dist/lib/binary-to-geojson.js +201 -242
- package/dist/lib/extract-geometry-info.d.ts +8 -0
- package/dist/lib/extract-geometry-info.d.ts.map +1 -0
- package/dist/lib/extract-geometry-info.js +96 -0
- package/dist/lib/flat-geojson-to-binary-types.d.ts +58 -0
- package/dist/lib/flat-geojson-to-binary-types.d.ts.map +1 -0
- package/dist/lib/flat-geojson-to-binary-types.js +2 -0
- package/dist/lib/flat-geojson-to-binary.d.ts +37 -0
- package/dist/lib/flat-geojson-to-binary.d.ts.map +1 -0
- package/dist/lib/flat-geojson-to-binary.js +376 -0
- package/dist/lib/geojson-to-binary.d.ts +19 -0
- package/dist/lib/geojson-to-binary.d.ts.map +1 -0
- package/dist/lib/geojson-to-binary.js +24 -407
- package/dist/lib/geojson-to-flat-geojson.d.ts +17 -0
- package/dist/lib/geojson-to-flat-geojson.d.ts.map +1 -0
- package/dist/lib/geojson-to-flat-geojson.js +128 -0
- package/dist/lib/transform.d.ts +19 -0
- package/dist/lib/transform.d.ts.map +1 -0
- package/dist/lib/transform.js +51 -42
- package/package.json +8 -7
- package/src/index.ts +2 -0
- package/src/lib/extract-geometry-info.ts +101 -0
- package/src/lib/flat-geojson-to-binary-types.ts +58 -0
- package/src/lib/flat-geojson-to-binary.ts +565 -0
- package/src/lib/geojson-to-binary.ts +24 -450
- package/src/lib/geojson-to-flat-geojson.ts +171 -0
- package/dist/bundle.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/binary-to-geojson.js.map +0 -1
- package/dist/lib/geojson-to-binary.js.map +0 -1
- package/dist/lib/transform.js.map +0 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.transformBinaryCoords = transformBinaryCoords;
|
|
7
|
+
exports.transformGeoJsonCoords = transformGeoJsonCoords;
|
|
8
|
+
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; } } }; }
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
function transformBinaryCoords(binaryFeatures, transformCoordinate) {
|
|
12
|
+
if (binaryFeatures.points) {
|
|
13
|
+
transformBinaryGeometryPositions(binaryFeatures.points, transformCoordinate);
|
|
14
|
+
}
|
|
15
|
+
if (binaryFeatures.lines) {
|
|
16
|
+
transformBinaryGeometryPositions(binaryFeatures.lines, transformCoordinate);
|
|
17
|
+
}
|
|
18
|
+
if (binaryFeatures.polygons) {
|
|
19
|
+
transformBinaryGeometryPositions(binaryFeatures.polygons, transformCoordinate);
|
|
20
|
+
}
|
|
21
|
+
return binaryFeatures;
|
|
22
|
+
}
|
|
23
|
+
function transformBinaryGeometryPositions(binaryGeometry, fn) {
|
|
24
|
+
var positions = binaryGeometry.positions;
|
|
25
|
+
for (var i = 0; i < positions.value.length; i += positions.size) {
|
|
26
|
+
var _coord = Array.from(positions.value.subarray(i, i + positions.size));
|
|
27
|
+
var transformedCoord = fn(_coord);
|
|
28
|
+
positions.value.set(transformedCoord, i);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function transformGeoJsonCoords(features, fn) {
|
|
32
|
+
var _iterator = _createForOfIteratorHelper(features),
|
|
33
|
+
_step;
|
|
34
|
+
try {
|
|
35
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
36
|
+
var feature = _step.value;
|
|
37
|
+
feature.geometry.coordinates = coordMap(feature.geometry.coordinates, fn);
|
|
38
|
+
}
|
|
39
|
+
} catch (err) {
|
|
40
|
+
_iterator.e(err);
|
|
41
|
+
} finally {
|
|
42
|
+
_iterator.f();
|
|
43
|
+
}
|
|
44
|
+
return features;
|
|
45
|
+
}
|
|
46
|
+
function coordMap(array, fn) {
|
|
47
|
+
if (isCoord(array)) {
|
|
48
|
+
return fn(array);
|
|
49
|
+
}
|
|
50
|
+
return array.map(function (item) {
|
|
51
|
+
return coordMap(item, fn);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function isCoord(array) {
|
|
55
|
+
return Number.isFinite(array[0]) && Number.isFinite(array[1]);
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.js","names":["transformBinaryCoords","binaryFeatures","transformCoordinate","points","transformBinaryGeometryPositions","lines","polygons","binaryGeometry","fn","positions","i","value","length","size","coord","Array","from","subarray","transformedCoord","set","transformGeoJsonCoords","features","_iterator","_createForOfIteratorHelper","_step","s","n","done","feature","geometry","coordinates","coordMap","err","e","f","array","isCoord","map","item","Number","isFinite"],"sources":["../../../src/lib/transform.ts"],"sourcesContent":["import type {BinaryFeatures, BinaryGeometry} from '@loaders.gl/schema';\n\ntype TransformCoordinate = (coord: number[]) => number[];\n\n/**\n * Apply transformation to every coordinate of binary features\n * @param binaryFeatures binary features\n * @param transformCoordinate Function to call on each coordinate\n * @return Transformed binary features\n */\nexport function transformBinaryCoords(\n binaryFeatures: BinaryFeatures,\n transformCoordinate: TransformCoordinate\n): BinaryFeatures {\n if (binaryFeatures.points) {\n transformBinaryGeometryPositions(binaryFeatures.points, transformCoordinate);\n }\n if (binaryFeatures.lines) {\n transformBinaryGeometryPositions(binaryFeatures.lines, transformCoordinate);\n }\n if (binaryFeatures.polygons) {\n transformBinaryGeometryPositions(binaryFeatures.polygons, transformCoordinate);\n }\n return binaryFeatures;\n}\n\n/** Transform one binary geometry */\nfunction transformBinaryGeometryPositions(binaryGeometry: BinaryGeometry, fn: TransformCoordinate) {\n const {positions} = binaryGeometry;\n for (let i = 0; i < positions.value.length; i += positions.size) {\n // @ts-ignore inclusion of bigint causes problems\n const coord: Array<number> = Array.from(positions.value.subarray(i, i + positions.size));\n const transformedCoord = fn(coord);\n // @ts-ignore typescript typing for .set seems to require bigint?\n positions.value.set(transformedCoord, i);\n }\n}\n\n/**\n * Apply transformation to every coordinate of GeoJSON features\n *\n * @param features Array of GeoJSON features\n * @param fn Function to call on each coordinate\n * @return Transformed GeoJSON features\n */\nexport function transformGeoJsonCoords(\n features: object[],\n fn: (coord: number[]) => number[]\n): object[] {\n for (const feature of features) {\n // @ts-ignore\n feature.geometry.coordinates = coordMap(feature.geometry.coordinates, fn);\n }\n return features;\n}\n\nfunction coordMap(array, fn) {\n if (isCoord(array)) {\n return fn(array);\n }\n\n return array.map((item) => {\n return coordMap(item, fn);\n });\n}\n\nfunction isCoord(array) {\n return Number.isFinite(array[0]) && Number.isFinite(array[1]);\n}\n"],"mappings":";;;;;;;;;;AAUO,SAASA,qBAAqBA,CACnCC,cAA8B,EAC9BC,mBAAwC,EACxB;EAChB,IAAID,cAAc,CAACE,MAAM,EAAE;IACzBC,gCAAgC,CAACH,cAAc,CAACE,MAAM,EAAED,mBAAmB,CAAC;EAC9E;EACA,IAAID,cAAc,CAACI,KAAK,EAAE;IACxBD,gCAAgC,CAACH,cAAc,CAACI,KAAK,EAAEH,mBAAmB,CAAC;EAC7E;EACA,IAAID,cAAc,CAACK,QAAQ,EAAE;IAC3BF,gCAAgC,CAACH,cAAc,CAACK,QAAQ,EAAEJ,mBAAmB,CAAC;EAChF;EACA,OAAOD,cAAc;AACvB;AAGA,SAASG,gCAAgCA,CAACG,cAA8B,EAAEC,EAAuB,EAAE;EACjG,IAAOC,SAAS,GAAIF,cAAc,CAA3BE,SAAS;EAChB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,SAAS,CAACE,KAAK,CAACC,MAAM,EAAEF,CAAC,IAAID,SAAS,CAACI,IAAI,EAAE;IAE/D,IAAMC,MAAoB,GAAGC,KAAK,CAACC,IAAI,CAACP,SAAS,CAACE,KAAK,CAACM,QAAQ,CAACP,CAAC,EAAEA,CAAC,GAAGD,SAAS,CAACI,IAAI,CAAC,CAAC;IACxF,IAAMK,gBAAgB,GAAGV,EAAE,CAACM,MAAK,CAAC;IAElCL,SAAS,CAACE,KAAK,CAACQ,GAAG,CAACD,gBAAgB,EAAER,CAAC,CAAC;EAC1C;AACF;AASO,SAASU,sBAAsBA,CACpCC,QAAkB,EAClBb,EAAiC,EACvB;EAAA,IAAAc,SAAA,GAAAC,0BAAA,CACYF,QAAQ;IAAAG,KAAA;EAAA;IAA9B,KAAAF,SAAA,CAAAG,CAAA,MAAAD,KAAA,GAAAF,SAAA,CAAAI,CAAA,IAAAC,IAAA,GAAgC;MAAA,IAArBC,OAAO,GAAAJ,KAAA,CAAAb,KAAA;MAEhBiB,OAAO,CAACC,QAAQ,CAACC,WAAW,GAAGC,QAAQ,CAACH,OAAO,CAACC,QAAQ,CAACC,WAAW,EAAEtB,EAAE,CAAC;IAC3E;EAAC,SAAAwB,GAAA;IAAAV,SAAA,CAAAW,CAAA,CAAAD,GAAA;EAAA;IAAAV,SAAA,CAAAY,CAAA;EAAA;EACD,OAAOb,QAAQ;AACjB;AAEA,SAASU,QAAQA,CAACI,KAAK,EAAE3B,EAAE,EAAE;EAC3B,IAAI4B,OAAO,CAACD,KAAK,CAAC,EAAE;IAClB,OAAO3B,EAAE,CAAC2B,KAAK,CAAC;EAClB;EAEA,OAAOA,KAAK,CAACE,GAAG,CAAC,UAACC,IAAI,EAAK;IACzB,OAAOP,QAAQ,CAACO,IAAI,EAAE9B,EAAE,CAAC;EAC3B,CAAC,CAAC;AACJ;AAEA,SAAS4B,OAAOA,CAACD,KAAK,EAAE;EACtB,OAAOI,MAAM,CAACC,QAAQ,CAACL,KAAK,CAAC,CAAC,CAAC,CAAC,IAAII,MAAM,CAACC,QAAQ,CAACL,KAAK,CAAC,CAAC,CAAC,CAAC;AAC/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.js","names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"sources":["../../src/bundle.ts"],"sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"mappings":"AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAS,CAAC;AACxCC,UAAU,CAACC,OAAO,GAAGD,UAAU,CAACC,OAAO,IAAI,CAAC,CAAC;AAC7CC,MAAM,CAACC,OAAO,GAAGC,MAAM,CAACC,MAAM,CAACL,UAAU,CAACC,OAAO,EAAEH,aAAa,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { flatGeojsonToBinary } from './lib/flat-geojson-to-binary';
|
|
2
|
+
export { geojsonToBinary } from './lib/geojson-to-binary';
|
|
3
|
+
export { geojsonToFlatGeojson } from './lib/geojson-to-flat-geojson';
|
|
4
|
+
export { binaryToGeojson, binaryToGeoJson, binaryToGeometry } from './lib/binary-to-geojson';
|
|
5
|
+
export { transformBinaryCoords, transformGeoJsonCoords } from './lib/transform';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["flatGeojsonToBinary","geojsonToBinary","geojsonToFlatGeojson","binaryToGeojson","binaryToGeoJson","binaryToGeometry","transformBinaryCoords","transformGeoJsonCoords"],"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,SAAQA,mBAAmB,QAAO,8BAA8B;AAChE,SAAQC,eAAe,QAAO,yBAAyB;AACvD,SAAQC,oBAAoB,QAAO,+BAA+B;AAClE,SAAQC,eAAe,EAAEC,eAAe,EAAEC,gBAAgB,QAAO,yBAAyB;AAC1F,SAAQC,qBAAqB,EAAEC,sBAAsB,QAAO,iBAAiB"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
export function binaryToGeojson(data, options) {
|
|
2
|
+
const globalFeatureId = options === null || options === void 0 ? void 0 : options.globalFeatureId;
|
|
3
|
+
if (globalFeatureId !== undefined) {
|
|
4
|
+
return getSingleFeature(data, globalFeatureId);
|
|
5
|
+
}
|
|
6
|
+
return parseFeatures(data, options === null || options === void 0 ? void 0 : options.type);
|
|
7
|
+
}
|
|
8
|
+
export function binaryToGeoJson(data, type) {
|
|
9
|
+
let format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'feature';
|
|
10
|
+
switch (format) {
|
|
11
|
+
case 'feature':
|
|
12
|
+
return parseFeatures(data, type);
|
|
13
|
+
case 'geometry':
|
|
14
|
+
return binaryToGeometry(data);
|
|
15
|
+
default:
|
|
16
|
+
throw new Error(format);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function getSingleFeature(data, globalFeatureId) {
|
|
20
|
+
const dataArray = normalizeInput(data);
|
|
21
|
+
for (const data of dataArray) {
|
|
22
|
+
let lastIndex = 0;
|
|
23
|
+
let lastValue = data.featureIds.value[0];
|
|
24
|
+
for (let i = 0; i < data.featureIds.value.length; i++) {
|
|
25
|
+
const currValue = data.featureIds.value[i];
|
|
26
|
+
if (currValue === lastValue) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (globalFeatureId === data.globalFeatureIds.value[lastIndex]) {
|
|
30
|
+
return parseFeature(data, lastIndex, i);
|
|
31
|
+
}
|
|
32
|
+
lastIndex = i;
|
|
33
|
+
lastValue = currValue;
|
|
34
|
+
}
|
|
35
|
+
if (globalFeatureId === data.globalFeatureIds.value[lastIndex]) {
|
|
36
|
+
return parseFeature(data, lastIndex, data.featureIds.value.length);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
throw new Error("featureId:".concat(globalFeatureId, " not found"));
|
|
40
|
+
}
|
|
41
|
+
function parseFeatures(data, type) {
|
|
42
|
+
const dataArray = normalizeInput(data, type);
|
|
43
|
+
return parseFeatureCollection(dataArray);
|
|
44
|
+
}
|
|
45
|
+
export function binaryToGeometry(data, startIndex, endIndex) {
|
|
46
|
+
switch (data.type) {
|
|
47
|
+
case 'Point':
|
|
48
|
+
return pointToGeoJson(data, startIndex, endIndex);
|
|
49
|
+
case 'LineString':
|
|
50
|
+
return lineStringToGeoJson(data, startIndex, endIndex);
|
|
51
|
+
case 'Polygon':
|
|
52
|
+
return polygonToGeoJson(data, startIndex, endIndex);
|
|
53
|
+
default:
|
|
54
|
+
const unexpectedInput = data;
|
|
55
|
+
throw new Error("Unsupported geometry type: ".concat(unexpectedInput === null || unexpectedInput === void 0 ? void 0 : unexpectedInput.type));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function normalizeInput(data, type) {
|
|
59
|
+
const isHeterogeneousType = Boolean(data.points || data.lines || data.polygons);
|
|
60
|
+
if (!isHeterogeneousType) {
|
|
61
|
+
data.type = type || parseType(data);
|
|
62
|
+
return [data];
|
|
63
|
+
}
|
|
64
|
+
const features = [];
|
|
65
|
+
if (data.points) {
|
|
66
|
+
data.points.type = 'Point';
|
|
67
|
+
features.push(data.points);
|
|
68
|
+
}
|
|
69
|
+
if (data.lines) {
|
|
70
|
+
data.lines.type = 'LineString';
|
|
71
|
+
features.push(data.lines);
|
|
72
|
+
}
|
|
73
|
+
if (data.polygons) {
|
|
74
|
+
data.polygons.type = 'Polygon';
|
|
75
|
+
features.push(data.polygons);
|
|
76
|
+
}
|
|
77
|
+
return features;
|
|
78
|
+
}
|
|
79
|
+
function parseFeatureCollection(dataArray) {
|
|
80
|
+
const features = [];
|
|
81
|
+
for (const data of dataArray) {
|
|
82
|
+
if (data.featureIds.value.length === 0) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
let lastIndex = 0;
|
|
86
|
+
let lastValue = data.featureIds.value[0];
|
|
87
|
+
for (let i = 0; i < data.featureIds.value.length; i++) {
|
|
88
|
+
const currValue = data.featureIds.value[i];
|
|
89
|
+
if (currValue === lastValue) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
features.push(parseFeature(data, lastIndex, i));
|
|
93
|
+
lastIndex = i;
|
|
94
|
+
lastValue = currValue;
|
|
95
|
+
}
|
|
96
|
+
features.push(parseFeature(data, lastIndex, data.featureIds.value.length));
|
|
97
|
+
}
|
|
98
|
+
return features;
|
|
99
|
+
}
|
|
100
|
+
function parseFeature(data, startIndex, endIndex) {
|
|
101
|
+
const geometry = binaryToGeometry(data, startIndex, endIndex);
|
|
102
|
+
const properties = parseProperties(data, startIndex, endIndex);
|
|
103
|
+
const fields = parseFields(data, startIndex, endIndex);
|
|
104
|
+
return {
|
|
105
|
+
type: 'Feature',
|
|
106
|
+
geometry,
|
|
107
|
+
properties,
|
|
108
|
+
...fields
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function parseFields(data) {
|
|
112
|
+
let startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
113
|
+
let endIndex = arguments.length > 2 ? arguments[2] : undefined;
|
|
114
|
+
return data.fields && data.fields[data.featureIds.value[startIndex]];
|
|
115
|
+
}
|
|
116
|
+
function parseProperties(data) {
|
|
117
|
+
let startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
118
|
+
let endIndex = arguments.length > 2 ? arguments[2] : undefined;
|
|
119
|
+
const properties = Object.assign({}, data.properties[data.featureIds.value[startIndex]]);
|
|
120
|
+
for (const key in data.numericProps) {
|
|
121
|
+
properties[key] = data.numericProps[key].value[startIndex];
|
|
122
|
+
}
|
|
123
|
+
return properties;
|
|
124
|
+
}
|
|
125
|
+
function polygonToGeoJson(data) {
|
|
126
|
+
let startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -Infinity;
|
|
127
|
+
let endIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity;
|
|
128
|
+
const {
|
|
129
|
+
positions
|
|
130
|
+
} = data;
|
|
131
|
+
const polygonIndices = data.polygonIndices.value.filter(x => x >= startIndex && x <= endIndex);
|
|
132
|
+
const primitivePolygonIndices = data.primitivePolygonIndices.value.filter(x => x >= startIndex && x <= endIndex);
|
|
133
|
+
const multi = polygonIndices.length > 2;
|
|
134
|
+
if (!multi) {
|
|
135
|
+
const coordinates = [];
|
|
136
|
+
for (let i = 0; i < primitivePolygonIndices.length - 1; i++) {
|
|
137
|
+
const startRingIndex = primitivePolygonIndices[i];
|
|
138
|
+
const endRingIndex = primitivePolygonIndices[i + 1];
|
|
139
|
+
const ringCoordinates = ringToGeoJson(positions, startRingIndex, endRingIndex);
|
|
140
|
+
coordinates.push(ringCoordinates);
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
type: 'Polygon',
|
|
144
|
+
coordinates
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
const coordinates = [];
|
|
148
|
+
for (let i = 0; i < polygonIndices.length - 1; i++) {
|
|
149
|
+
const startPolygonIndex = polygonIndices[i];
|
|
150
|
+
const endPolygonIndex = polygonIndices[i + 1];
|
|
151
|
+
const polygonCoordinates = polygonToGeoJson(data, startPolygonIndex, endPolygonIndex).coordinates;
|
|
152
|
+
coordinates.push(polygonCoordinates);
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
type: 'MultiPolygon',
|
|
156
|
+
coordinates
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function lineStringToGeoJson(data) {
|
|
160
|
+
let startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -Infinity;
|
|
161
|
+
let endIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity;
|
|
162
|
+
const {
|
|
163
|
+
positions
|
|
164
|
+
} = data;
|
|
165
|
+
const pathIndices = data.pathIndices.value.filter(x => x >= startIndex && x <= endIndex);
|
|
166
|
+
const multi = pathIndices.length > 2;
|
|
167
|
+
if (!multi) {
|
|
168
|
+
const coordinates = ringToGeoJson(positions, pathIndices[0], pathIndices[1]);
|
|
169
|
+
return {
|
|
170
|
+
type: 'LineString',
|
|
171
|
+
coordinates
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
const coordinates = [];
|
|
175
|
+
for (let i = 0; i < pathIndices.length - 1; i++) {
|
|
176
|
+
const ringCoordinates = ringToGeoJson(positions, pathIndices[i], pathIndices[i + 1]);
|
|
177
|
+
coordinates.push(ringCoordinates);
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
type: 'MultiLineString',
|
|
181
|
+
coordinates
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function pointToGeoJson(data, startIndex, endIndex) {
|
|
185
|
+
const {
|
|
186
|
+
positions
|
|
187
|
+
} = data;
|
|
188
|
+
const coordinates = ringToGeoJson(positions, startIndex, endIndex);
|
|
189
|
+
const multi = coordinates.length > 1;
|
|
190
|
+
if (multi) {
|
|
191
|
+
return {
|
|
192
|
+
type: 'MultiPoint',
|
|
193
|
+
coordinates
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
type: 'Point',
|
|
198
|
+
coordinates: coordinates[0]
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
function ringToGeoJson(positions, startIndex, endIndex) {
|
|
202
|
+
startIndex = startIndex || 0;
|
|
203
|
+
endIndex = endIndex || positions.value.length / positions.size;
|
|
204
|
+
const ringCoordinates = [];
|
|
205
|
+
for (let j = startIndex; j < endIndex; j++) {
|
|
206
|
+
const coord = Array();
|
|
207
|
+
for (let k = j * positions.size; k < (j + 1) * positions.size; k++) {
|
|
208
|
+
coord.push(Number(positions.value[k]));
|
|
209
|
+
}
|
|
210
|
+
ringCoordinates.push(coord);
|
|
211
|
+
}
|
|
212
|
+
return ringCoordinates;
|
|
213
|
+
}
|
|
214
|
+
function parseType(data) {
|
|
215
|
+
if (data.pathIndices) {
|
|
216
|
+
return 'LineString';
|
|
217
|
+
}
|
|
218
|
+
if (data.polygonIndices) {
|
|
219
|
+
return 'Polygon';
|
|
220
|
+
}
|
|
221
|
+
return 'Point';
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=binary-to-geojson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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","lastIndex","lastValue","featureIds","value","i","currValue","globalFeatureIds","parseFeature","concat","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":"AAmCA,OAAO,SAASA,eAAeA,CAC7BC,IAAoB,EACpBC,OAAgC,EACX;EACrB,MAAMC,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;AAGA,OAAO,SAASC,eAAeA,CAC7BP,IAAqC,EACrCM,IAAyB,EAEH;EAAA,IADtBE,MAA8B,GAAAC,SAAA,CA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,GAAGvC,QAAQ,EAAEuC,CAAC,EAAE,EAAE;IAC1C,MAAMC,KAAK,GAAGC,KAAK,CAAS,CAAC;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,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,SAASA,CAACpC,IAAI,EAAE;EACvB,IAAIA,IAAI,CAAC+D,WAAW,EAAE;IACpB,OAAO,YAAY;EACrB;EAEA,IAAI/D,IAAI,CAACkD,cAAc,EAAE;IACvB,OAAO,SAAS;EAClB;EAEA,OAAO,OAAO;AAChB"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export function extractGeometryInfo(features) {
|
|
2
|
+
let pointPositionsCount = 0;
|
|
3
|
+
let pointFeaturesCount = 0;
|
|
4
|
+
let linePositionsCount = 0;
|
|
5
|
+
let linePathsCount = 0;
|
|
6
|
+
let lineFeaturesCount = 0;
|
|
7
|
+
let polygonPositionsCount = 0;
|
|
8
|
+
let polygonObjectsCount = 0;
|
|
9
|
+
let polygonRingsCount = 0;
|
|
10
|
+
let polygonFeaturesCount = 0;
|
|
11
|
+
const coordLengths = new Set();
|
|
12
|
+
for (const feature of features) {
|
|
13
|
+
const geometry = feature.geometry;
|
|
14
|
+
switch (geometry.type) {
|
|
15
|
+
case 'Point':
|
|
16
|
+
pointFeaturesCount++;
|
|
17
|
+
pointPositionsCount++;
|
|
18
|
+
coordLengths.add(geometry.coordinates.length);
|
|
19
|
+
break;
|
|
20
|
+
case 'MultiPoint':
|
|
21
|
+
pointFeaturesCount++;
|
|
22
|
+
pointPositionsCount += geometry.coordinates.length;
|
|
23
|
+
for (const point of geometry.coordinates) {
|
|
24
|
+
coordLengths.add(point.length);
|
|
25
|
+
}
|
|
26
|
+
break;
|
|
27
|
+
case 'LineString':
|
|
28
|
+
lineFeaturesCount++;
|
|
29
|
+
linePositionsCount += geometry.coordinates.length;
|
|
30
|
+
linePathsCount++;
|
|
31
|
+
for (const coord of geometry.coordinates) {
|
|
32
|
+
coordLengths.add(coord.length);
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
case 'MultiLineString':
|
|
36
|
+
lineFeaturesCount++;
|
|
37
|
+
for (const line of geometry.coordinates) {
|
|
38
|
+
linePositionsCount += line.length;
|
|
39
|
+
linePathsCount++;
|
|
40
|
+
for (const coord of line) {
|
|
41
|
+
coordLengths.add(coord.length);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
case 'Polygon':
|
|
46
|
+
polygonFeaturesCount++;
|
|
47
|
+
polygonObjectsCount++;
|
|
48
|
+
polygonRingsCount += geometry.coordinates.length;
|
|
49
|
+
const flattened = geometry.coordinates.flat();
|
|
50
|
+
polygonPositionsCount += flattened.length;
|
|
51
|
+
for (const coord of flattened) {
|
|
52
|
+
coordLengths.add(coord.length);
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
55
|
+
case 'MultiPolygon':
|
|
56
|
+
polygonFeaturesCount++;
|
|
57
|
+
for (const polygon of geometry.coordinates) {
|
|
58
|
+
polygonObjectsCount++;
|
|
59
|
+
polygonRingsCount += polygon.length;
|
|
60
|
+
const flattened = polygon.flat();
|
|
61
|
+
polygonPositionsCount += flattened.length;
|
|
62
|
+
for (const coord of flattened) {
|
|
63
|
+
coordLengths.add(coord.length);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
throw new Error("Unsupported geometry type: ".concat(geometry.type));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
coordLength: coordLengths.size > 0 ? Math.max(...coordLengths) : 2,
|
|
73
|
+
pointPositionsCount,
|
|
74
|
+
pointFeaturesCount,
|
|
75
|
+
linePositionsCount,
|
|
76
|
+
linePathsCount,
|
|
77
|
+
lineFeaturesCount,
|
|
78
|
+
polygonPositionsCount,
|
|
79
|
+
polygonObjectsCount,
|
|
80
|
+
polygonRingsCount,
|
|
81
|
+
polygonFeaturesCount
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=extract-geometry-info.js.map
|
|
@@ -0,0 +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","concat","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":"AAQA,OAAO,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,GAAG,CAAC;EACzB,IAAIC,qBAAqB,GAAG,CAAC;EAC7B,IAAIC,mBAAmB,GAAG,CAAC;EAC3B,IAAIC,iBAAiB,GAAG,CAAC;EACzB,IAAIC,oBAAoB,GAAG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AAC;QAC7ChB,qBAAqB,IAAIe,SAAS,CAACJ,MAAM;QAEzC,KAAK,MAAME,KAAK,IAAIE,SAAS,EAAE;UAC7BX,YAAY,CAACK,GAAG,CAACI,KAAK,CAACF,MAAM,CAAC;QAChC;QACA;MACF,KAAK,cAAc;QACjBR,oBAAoB,EAAE;QACtB,KAAK,MAAMc,OAAO,IAAIV,QAAQ,CAACG,WAAW,EAAE;UAC1CT,mBAAmB,EAAE;UACrBC,iBAAiB,IAAIe,OAAO,CAACN,MAAM;UACnC,MAAMI,SAAS,GAAGE,OAAO,CAACD,IAAI,CAAC,CAAC;UAChChB,qBAAqB,IAAIe,SAAS,CAACJ,MAAM;UAGzC,KAAK,MAAME,KAAK,IAAIE,SAAS,EAAE;YAC7BX,YAAY,CAACK,GAAG,CAACI,KAAK,CAACF,MAAM,CAAC;UAChC;QACF;QACA;MACF;QACE,MAAM,IAAIO,KAAK,+BAAAC,MAAA,CAA+BZ,QAAQ,CAACC,IAAI,CAAE,CAAC;IAClE;EACF;EAEA,OAAO;IACLY,WAAW,EAAEhB,YAAY,CAACiB,IAAI,GAAG,CAAC,GAAGC,IAAI,CAACC,GAAG,CAAC,GAAGnB,YAAY,CAAC,GAAG,CAAC;IAElET,mBAAmB;IACnBC,kBAAkB;IAClBC,kBAAkB;IAClBC,cAAc;IACdC,iBAAiB;IACjBC,qBAAqB;IACrBC,mBAAmB;IACnBC,iBAAiB;IACjBC;EACF,CAAC;AACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flat-geojson-to-binary-types.js","names":[],"sources":["../../../src/lib/flat-geojson-to-binary-types.ts"],"sourcesContent":["import type {TypedArray} from '@loaders.gl/schema';\n\n/**\n * Permissable constructor for numeric props\n */\nexport type PropArrayConstructor =\n | Float32ArrayConstructor\n | Float64ArrayConstructor\n | ArrayConstructor;\n\n/**\n * Collection type for holding intermediate binary data before conversion to `BinaryPointGeometry`\n */\nexport type Points = {\n type: 'Point';\n positions: Float32Array | Float64Array;\n globalFeatureIds: Uint16Array | Uint32Array;\n featureIds: Uint16Array | Uint32Array;\n numericProps: {[key: string]: TypedArray};\n properties: {}[];\n fields: {\n id?: string | number;\n }[];\n};\n\n/**\n * Collection type for holding intermediate binary data before conversion to `BinaryLineStringGeometry`\n */\nexport type Lines = {\n type: 'LineString';\n positions: Float32Array | Float64Array;\n pathIndices: Uint16Array | Uint32Array;\n globalFeatureIds: Uint16Array | Uint32Array;\n featureIds: Uint16Array | Uint32Array;\n numericProps: {[key: string]: TypedArray};\n properties: {}[];\n fields: {\n id?: string | number;\n }[];\n};\n\n/**\n * Collection type for holding intermediate binary data before conversion to `BinaryPolygonGeometry`\n */\nexport type Polygons = {\n type: 'Polygon';\n positions: Float32Array | Float64Array;\n polygonIndices: Uint16Array | Uint32Array;\n primitivePolygonIndices: Uint16Array | Uint32Array;\n triangles: number[];\n globalFeatureIds: Uint16Array | Uint32Array;\n featureIds: Uint16Array | Uint32Array;\n numericProps: {[key: string]: TypedArray};\n properties: {}[];\n fields: {\n id?: string | number;\n }[];\n};\n"],"mappings":""}
|