@loaders.gl/gis 4.0.0-beta.2 → 4.0.0-beta.4
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/index.cjs +708 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/{esm/lib → lib}/binary-to-geojson.js +2 -2
- package/dist/lib/binary-to-geojson.js.map +1 -0
- package/dist/{esm/lib → lib}/extract-geometry-info.js +1 -1
- package/dist/lib/extract-geometry-info.js.map +1 -0
- package/dist/lib/flat-geojson-to-binary-types.js.map +1 -0
- package/dist/lib/flat-geojson-to-binary.js.map +1 -0
- package/dist/{esm/lib → lib}/geojson-to-binary.js +3 -3
- package/dist/lib/geojson-to-binary.js.map +1 -0
- package/dist/{esm/lib → lib}/geojson-to-flat-geojson.js +1 -1
- package/dist/lib/geojson-to-flat-geojson.js.map +1 -0
- package/dist/lib/transform.js.map +1 -0
- package/package.json +16 -8
- package/src/lib/flat-geojson-to-binary.ts +0 -1
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/es5/bundle.js +0 -6
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/index.js +0 -53
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/lib/binary-to-geojson.js +0 -221
- package/dist/es5/lib/binary-to-geojson.js.map +0 -1
- package/dist/es5/lib/extract-geometry-info.js +0 -167
- package/dist/es5/lib/extract-geometry-info.js.map +0 -1
- package/dist/es5/lib/flat-geojson-to-binary-types.js +0 -2
- package/dist/es5/lib/flat-geojson-to-binary-types.js.map +0 -1
- package/dist/es5/lib/flat-geojson-to-binary.js +0 -355
- package/dist/es5/lib/flat-geojson-to-binary.js.map +0 -1
- package/dist/es5/lib/geojson-to-binary.js +0 -28
- package/dist/es5/lib/geojson-to-binary.js.map +0 -1
- package/dist/es5/lib/geojson-to-flat-geojson.js +0 -136
- package/dist/es5/lib/geojson-to-flat-geojson.js.map +0 -1
- package/dist/es5/lib/transform.js +0 -57
- package/dist/es5/lib/transform.js.map +0 -1
- package/dist/esm/bundle.js +0 -4
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/index.js +0 -6
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/binary-to-geojson.js.map +0 -1
- package/dist/esm/lib/extract-geometry-info.js.map +0 -1
- package/dist/esm/lib/flat-geojson-to-binary-types.js.map +0 -1
- package/dist/esm/lib/flat-geojson-to-binary.js.map +0 -1
- package/dist/esm/lib/geojson-to-binary.js.map +0 -1
- package/dist/esm/lib/geojson-to-flat-geojson.js.map +0 -1
- package/dist/esm/lib/transform.js.map +0 -1
- package/src/bundle.ts +0 -4
- /package/dist/{esm/lib → lib}/flat-geojson-to-binary-types.js +0 -0
- /package/dist/{esm/lib → lib}/flat-geojson-to-binary.js +0 -0
- /package/dist/{esm/lib → lib}/transform.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"binary-to-geojson.js","names":["binaryToGeojson","data","options","globalFeatureId","undefined","getSingleFeature","parseFeatures","type","dataArray","normalizeInput","_i","_dataArray","length","lastIndex","lastValue","featureIds","value","i","currValue","globalFeatureIds","parseFeature","Error","concat","parseFeatureCollection","binaryToGeometry","startIndex","endIndex","pointToGeoJson","lineStringToGeoJson","polygonToGeoJson","unexpectedInput","features","points","push","lines","polygons","_iterator","_createForOfIteratorHelper","_step","s","n","done","err","e","f","geometry","properties","parseProperties","fields","parseFields","_objectSpread","arguments","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":["// loaders.gl, MIT license\n\nimport type {\n BinaryGeometry,\n BinaryGeometryType,\n BinaryPointGeometry,\n BinaryLineGeometry,\n BinaryPolygonGeometry,\n BinaryFeatureCollection,\n BinaryFeature,\n // BinaryPointFeature,\n // BinaryLineFeature,\n // BinaryPolygonFeature,\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: BinaryFeatureCollection,\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 | BinaryFeatureCollection,\n type?: BinaryGeometryType,\n format: 'feature' | 'geometry' = 'feature'\n): Geometry | Feature[] {\n switch (format) {\n case 'feature':\n return parseFeatures(data as BinaryFeatureCollection, type);\n case 'geometry':\n return binaryToGeometry(data as any);\n default:\n throw new Error(format);\n }\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: BinaryFeatureCollection, 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: BinaryFeatureCollection, 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\n// Normalize features\n// Return an array of data objects, each of which have a type key\nfunction normalizeInput(data: BinaryFeatureCollection, type?: BinaryGeometryType): BinaryFeature[] {\n const features: BinaryFeature[] = [];\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: BinaryFeature[]): 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: BinaryFeature, 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: BinaryPolygonGeometry,\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: BinaryLineGeometry,\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: BinaryPointGeometry, 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 ringCoord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;EAEA,OAAO;IAACxD,IAAI,EAAE,OAAO;IAAEwD,WAAW,EAAEA,WAAW,CAAC,CAAC;EAAC,CAAC;AACrD;AAUA,SAASI,aAAaA,CACpBV,SAA0B,EAC1BhC,UAAmB,EACnBC,QAAiB,EACL;EACZD,UAAU,GAAGA,UAAU,IAAI,CAAC;EAC5BC,QAAQ,GAAGA,QAAQ,IAAI+B,SAAS,CAACzC,KAAK,CAACJ,MAAM,GAAG6C,SAAS,CAACe,IAAI;EAE9D,IAAMN,eAA2B,GAAG,EAAE;EACtC,KAAK,IAAIO,CAAC,GAAGhD,UAAU,EAAEgD,CAAC,GAAG/C,QAAQ,EAAE+C,CAAC,EAAE,EAAE;IAC1C,IAAMC,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,CAACzC,IAAI,CAAC4C,MAAM,CAACpB,SAAS,CAACzC,KAAK,CAAC4D,CAAC,CAAC,CAAC,CAAC;IACxC;IACAV,eAAe,CAACjC,IAAI,CAACyC,KAAK,CAAC;EAC7B;EACA,OAAOR,eAAe;AACxB"}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.extractGeometryInfo = extractGeometryInfo;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
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
|
-
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++) arr2[i] = arr[i]; return arr2; }
|
|
12
|
-
function extractGeometryInfo(features) {
|
|
13
|
-
var pointPositionsCount = 0;
|
|
14
|
-
var pointFeaturesCount = 0;
|
|
15
|
-
var linePositionsCount = 0;
|
|
16
|
-
var linePathsCount = 0;
|
|
17
|
-
var lineFeaturesCount = 0;
|
|
18
|
-
var polygonPositionsCount = 0;
|
|
19
|
-
var polygonObjectsCount = 0;
|
|
20
|
-
var polygonRingsCount = 0;
|
|
21
|
-
var polygonFeaturesCount = 0;
|
|
22
|
-
var coordLengths = new Set();
|
|
23
|
-
var _iterator = _createForOfIteratorHelper(features),
|
|
24
|
-
_step;
|
|
25
|
-
try {
|
|
26
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
27
|
-
var feature = _step.value;
|
|
28
|
-
var geometry = feature.geometry;
|
|
29
|
-
switch (geometry.type) {
|
|
30
|
-
case 'Point':
|
|
31
|
-
pointFeaturesCount++;
|
|
32
|
-
pointPositionsCount++;
|
|
33
|
-
coordLengths.add(geometry.coordinates.length);
|
|
34
|
-
break;
|
|
35
|
-
case 'MultiPoint':
|
|
36
|
-
pointFeaturesCount++;
|
|
37
|
-
pointPositionsCount += geometry.coordinates.length;
|
|
38
|
-
var _iterator2 = _createForOfIteratorHelper(geometry.coordinates),
|
|
39
|
-
_step2;
|
|
40
|
-
try {
|
|
41
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
42
|
-
var point = _step2.value;
|
|
43
|
-
coordLengths.add(point.length);
|
|
44
|
-
}
|
|
45
|
-
} catch (err) {
|
|
46
|
-
_iterator2.e(err);
|
|
47
|
-
} finally {
|
|
48
|
-
_iterator2.f();
|
|
49
|
-
}
|
|
50
|
-
break;
|
|
51
|
-
case 'LineString':
|
|
52
|
-
lineFeaturesCount++;
|
|
53
|
-
linePositionsCount += geometry.coordinates.length;
|
|
54
|
-
linePathsCount++;
|
|
55
|
-
var _iterator3 = _createForOfIteratorHelper(geometry.coordinates),
|
|
56
|
-
_step3;
|
|
57
|
-
try {
|
|
58
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
59
|
-
var coord = _step3.value;
|
|
60
|
-
coordLengths.add(coord.length);
|
|
61
|
-
}
|
|
62
|
-
} catch (err) {
|
|
63
|
-
_iterator3.e(err);
|
|
64
|
-
} finally {
|
|
65
|
-
_iterator3.f();
|
|
66
|
-
}
|
|
67
|
-
break;
|
|
68
|
-
case 'MultiLineString':
|
|
69
|
-
lineFeaturesCount++;
|
|
70
|
-
var _iterator4 = _createForOfIteratorHelper(geometry.coordinates),
|
|
71
|
-
_step4;
|
|
72
|
-
try {
|
|
73
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
74
|
-
var line = _step4.value;
|
|
75
|
-
linePositionsCount += line.length;
|
|
76
|
-
linePathsCount++;
|
|
77
|
-
var _iterator5 = _createForOfIteratorHelper(line),
|
|
78
|
-
_step5;
|
|
79
|
-
try {
|
|
80
|
-
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
81
|
-
var _coord = _step5.value;
|
|
82
|
-
coordLengths.add(_coord.length);
|
|
83
|
-
}
|
|
84
|
-
} catch (err) {
|
|
85
|
-
_iterator5.e(err);
|
|
86
|
-
} finally {
|
|
87
|
-
_iterator5.f();
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
} catch (err) {
|
|
91
|
-
_iterator4.e(err);
|
|
92
|
-
} finally {
|
|
93
|
-
_iterator4.f();
|
|
94
|
-
}
|
|
95
|
-
break;
|
|
96
|
-
case 'Polygon':
|
|
97
|
-
polygonFeaturesCount++;
|
|
98
|
-
polygonObjectsCount++;
|
|
99
|
-
polygonRingsCount += geometry.coordinates.length;
|
|
100
|
-
var flattened = geometry.coordinates.flat();
|
|
101
|
-
polygonPositionsCount += flattened.length;
|
|
102
|
-
var _iterator6 = _createForOfIteratorHelper(flattened),
|
|
103
|
-
_step6;
|
|
104
|
-
try {
|
|
105
|
-
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
106
|
-
var _coord2 = _step6.value;
|
|
107
|
-
coordLengths.add(_coord2.length);
|
|
108
|
-
}
|
|
109
|
-
} catch (err) {
|
|
110
|
-
_iterator6.e(err);
|
|
111
|
-
} finally {
|
|
112
|
-
_iterator6.f();
|
|
113
|
-
}
|
|
114
|
-
break;
|
|
115
|
-
case 'MultiPolygon':
|
|
116
|
-
polygonFeaturesCount++;
|
|
117
|
-
var _iterator7 = _createForOfIteratorHelper(geometry.coordinates),
|
|
118
|
-
_step7;
|
|
119
|
-
try {
|
|
120
|
-
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
121
|
-
var polygon = _step7.value;
|
|
122
|
-
polygonObjectsCount++;
|
|
123
|
-
polygonRingsCount += polygon.length;
|
|
124
|
-
var _flattened = polygon.flat();
|
|
125
|
-
polygonPositionsCount += _flattened.length;
|
|
126
|
-
var _iterator8 = _createForOfIteratorHelper(_flattened),
|
|
127
|
-
_step8;
|
|
128
|
-
try {
|
|
129
|
-
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
130
|
-
var _coord3 = _step8.value;
|
|
131
|
-
coordLengths.add(_coord3.length);
|
|
132
|
-
}
|
|
133
|
-
} catch (err) {
|
|
134
|
-
_iterator8.e(err);
|
|
135
|
-
} finally {
|
|
136
|
-
_iterator8.f();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
} catch (err) {
|
|
140
|
-
_iterator7.e(err);
|
|
141
|
-
} finally {
|
|
142
|
-
_iterator7.f();
|
|
143
|
-
}
|
|
144
|
-
break;
|
|
145
|
-
default:
|
|
146
|
-
throw new Error("Unsupported geometry type: ".concat(geometry.type));
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
} catch (err) {
|
|
150
|
-
_iterator.e(err);
|
|
151
|
-
} finally {
|
|
152
|
-
_iterator.f();
|
|
153
|
-
}
|
|
154
|
-
return {
|
|
155
|
-
coordLength: coordLengths.size > 0 ? Math.max.apply(Math, (0, _toConsumableArray2.default)(coordLengths)) : 2,
|
|
156
|
-
pointPositionsCount: pointPositionsCount,
|
|
157
|
-
pointFeaturesCount: pointFeaturesCount,
|
|
158
|
-
linePositionsCount: linePositionsCount,
|
|
159
|
-
linePathsCount: linePathsCount,
|
|
160
|
-
lineFeaturesCount: lineFeaturesCount,
|
|
161
|
-
polygonPositionsCount: polygonPositionsCount,
|
|
162
|
-
polygonObjectsCount: polygonObjectsCount,
|
|
163
|
-
polygonRingsCount: polygonRingsCount,
|
|
164
|
-
polygonFeaturesCount: polygonFeaturesCount
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
//# sourceMappingURL=extract-geometry-info.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,GAAG,CAAC;EACzB,IAAIC,qBAAqB,GAAG,CAAC;EAC7B,IAAIC,mBAAmB,GAAG,CAAC;EAC3B,IAAIC,iBAAiB,GAAG,CAAC;EACzB,IAAIC,oBAAoB,GAAG,CAAC;EAC5B,IAAMC,YAAY,GAAG,IAAIC,GAAG,CAAS,CAAC;EAAC,IAAAC,SAAA,GAAAC,0BAAA,CAEjBb,QAAQ;IAAAc,KAAA;EAAA;IAA9B,KAAAF,SAAA,CAAAG,CAAA,MAAAD,KAAA,GAAAF,SAAA,CAAAI,CAAA,IAAAC,IAAA,GAAgC;MAAA,IAArBC,OAAO,GAAAJ,KA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,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"}
|
|
@@ -1 +0,0 @@
|
|
|
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":""}
|
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.TEST_EXPORTS = void 0;
|
|
8
|
-
exports.flatGeojsonToBinary = flatGeojsonToBinary;
|
|
9
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
-
var _polygon = require("@math.gl/polygon");
|
|
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
|
-
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++) arr2[i] = arr[i]; return arr2; }
|
|
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
|
-
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
|
-
function flatGeojsonToBinary(features, geometryInfo, options) {
|
|
17
|
-
var propArrayTypes = extractNumericPropTypes(features);
|
|
18
|
-
var numericPropKeys = Object.keys(propArrayTypes).filter(function (k) {
|
|
19
|
-
return propArrayTypes[k] !== Array;
|
|
20
|
-
});
|
|
21
|
-
return fillArrays(features, _objectSpread({
|
|
22
|
-
propArrayTypes: propArrayTypes
|
|
23
|
-
}, geometryInfo), {
|
|
24
|
-
numericPropKeys: options && options.numericPropKeys || numericPropKeys,
|
|
25
|
-
PositionDataType: options ? options.PositionDataType : Float32Array,
|
|
26
|
-
triangulate: options ? options.triangulate : true
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
var TEST_EXPORTS = {
|
|
30
|
-
extractNumericPropTypes: extractNumericPropTypes
|
|
31
|
-
};
|
|
32
|
-
exports.TEST_EXPORTS = TEST_EXPORTS;
|
|
33
|
-
function extractNumericPropTypes(features) {
|
|
34
|
-
var propArrayTypes = {};
|
|
35
|
-
var _iterator = _createForOfIteratorHelper(features),
|
|
36
|
-
_step;
|
|
37
|
-
try {
|
|
38
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
39
|
-
var feature = _step.value;
|
|
40
|
-
if (feature.properties) {
|
|
41
|
-
for (var _key in feature.properties) {
|
|
42
|
-
var val = feature.properties[_key];
|
|
43
|
-
propArrayTypes[_key] = deduceArrayType(val, propArrayTypes[_key]);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
} catch (err) {
|
|
48
|
-
_iterator.e(err);
|
|
49
|
-
} finally {
|
|
50
|
-
_iterator.f();
|
|
51
|
-
}
|
|
52
|
-
return propArrayTypes;
|
|
53
|
-
}
|
|
54
|
-
function fillArrays(features, geometryInfo, options) {
|
|
55
|
-
var pointPositionsCount = geometryInfo.pointPositionsCount,
|
|
56
|
-
pointFeaturesCount = geometryInfo.pointFeaturesCount,
|
|
57
|
-
linePositionsCount = geometryInfo.linePositionsCount,
|
|
58
|
-
linePathsCount = geometryInfo.linePathsCount,
|
|
59
|
-
lineFeaturesCount = geometryInfo.lineFeaturesCount,
|
|
60
|
-
polygonPositionsCount = geometryInfo.polygonPositionsCount,
|
|
61
|
-
polygonObjectsCount = geometryInfo.polygonObjectsCount,
|
|
62
|
-
polygonRingsCount = geometryInfo.polygonRingsCount,
|
|
63
|
-
polygonFeaturesCount = geometryInfo.polygonFeaturesCount,
|
|
64
|
-
propArrayTypes = geometryInfo.propArrayTypes,
|
|
65
|
-
coordLength = geometryInfo.coordLength;
|
|
66
|
-
var _options$numericPropK = options.numericPropKeys,
|
|
67
|
-
numericPropKeys = _options$numericPropK === void 0 ? [] : _options$numericPropK,
|
|
68
|
-
_options$PositionData = options.PositionDataType,
|
|
69
|
-
PositionDataType = _options$PositionData === void 0 ? Float32Array : _options$PositionData,
|
|
70
|
-
_options$triangulate = options.triangulate,
|
|
71
|
-
triangulate = _options$triangulate === void 0 ? true : _options$triangulate;
|
|
72
|
-
var hasGlobalId = features[0] && 'id' in features[0];
|
|
73
|
-
var GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
|
|
74
|
-
var points = {
|
|
75
|
-
type: 'Point',
|
|
76
|
-
positions: new PositionDataType(pointPositionsCount * coordLength),
|
|
77
|
-
globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),
|
|
78
|
-
featureIds: pointFeaturesCount > 65535 ? new Uint32Array(pointPositionsCount) : new Uint16Array(pointPositionsCount),
|
|
79
|
-
numericProps: {},
|
|
80
|
-
properties: [],
|
|
81
|
-
fields: []
|
|
82
|
-
};
|
|
83
|
-
var lines = {
|
|
84
|
-
type: 'LineString',
|
|
85
|
-
pathIndices: linePositionsCount > 65535 ? new Uint32Array(linePathsCount + 1) : new Uint16Array(linePathsCount + 1),
|
|
86
|
-
positions: new PositionDataType(linePositionsCount * coordLength),
|
|
87
|
-
globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),
|
|
88
|
-
featureIds: lineFeaturesCount > 65535 ? new Uint32Array(linePositionsCount) : new Uint16Array(linePositionsCount),
|
|
89
|
-
numericProps: {},
|
|
90
|
-
properties: [],
|
|
91
|
-
fields: []
|
|
92
|
-
};
|
|
93
|
-
var polygons = {
|
|
94
|
-
type: 'Polygon',
|
|
95
|
-
polygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonObjectsCount + 1) : new Uint16Array(polygonObjectsCount + 1),
|
|
96
|
-
primitivePolygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonRingsCount + 1) : new Uint16Array(polygonRingsCount + 1),
|
|
97
|
-
positions: new PositionDataType(polygonPositionsCount * coordLength),
|
|
98
|
-
globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),
|
|
99
|
-
featureIds: polygonFeaturesCount > 65535 ? new Uint32Array(polygonPositionsCount) : new Uint16Array(polygonPositionsCount),
|
|
100
|
-
numericProps: {},
|
|
101
|
-
properties: [],
|
|
102
|
-
fields: []
|
|
103
|
-
};
|
|
104
|
-
if (triangulate) {
|
|
105
|
-
polygons.triangles = [];
|
|
106
|
-
}
|
|
107
|
-
for (var _i = 0, _arr = [points, lines, polygons]; _i < _arr.length; _i++) {
|
|
108
|
-
var object = _arr[_i];
|
|
109
|
-
var _iterator2 = _createForOfIteratorHelper(numericPropKeys),
|
|
110
|
-
_step2;
|
|
111
|
-
try {
|
|
112
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
113
|
-
var propName = _step2.value;
|
|
114
|
-
var T = propArrayTypes[propName];
|
|
115
|
-
object.numericProps[propName] = new T(object.positions.length / coordLength);
|
|
116
|
-
}
|
|
117
|
-
} catch (err) {
|
|
118
|
-
_iterator2.e(err);
|
|
119
|
-
} finally {
|
|
120
|
-
_iterator2.f();
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
lines.pathIndices[linePathsCount] = linePositionsCount;
|
|
124
|
-
polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;
|
|
125
|
-
polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;
|
|
126
|
-
var indexMap = {
|
|
127
|
-
pointPosition: 0,
|
|
128
|
-
pointFeature: 0,
|
|
129
|
-
linePosition: 0,
|
|
130
|
-
linePath: 0,
|
|
131
|
-
lineFeature: 0,
|
|
132
|
-
polygonPosition: 0,
|
|
133
|
-
polygonObject: 0,
|
|
134
|
-
polygonRing: 0,
|
|
135
|
-
polygonFeature: 0,
|
|
136
|
-
feature: 0
|
|
137
|
-
};
|
|
138
|
-
var _iterator3 = _createForOfIteratorHelper(features),
|
|
139
|
-
_step3;
|
|
140
|
-
try {
|
|
141
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
142
|
-
var feature = _step3.value;
|
|
143
|
-
var geometry = feature.geometry;
|
|
144
|
-
var properties = feature.properties || {};
|
|
145
|
-
switch (geometry.type) {
|
|
146
|
-
case 'Point':
|
|
147
|
-
handlePoint(geometry, points, indexMap, coordLength, properties);
|
|
148
|
-
points.properties.push(keepStringProperties(properties, numericPropKeys));
|
|
149
|
-
if (hasGlobalId) {
|
|
150
|
-
points.fields.push({
|
|
151
|
-
id: feature.id
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
indexMap.pointFeature++;
|
|
155
|
-
break;
|
|
156
|
-
case 'LineString':
|
|
157
|
-
handleLineString(geometry, lines, indexMap, coordLength, properties);
|
|
158
|
-
lines.properties.push(keepStringProperties(properties, numericPropKeys));
|
|
159
|
-
if (hasGlobalId) {
|
|
160
|
-
lines.fields.push({
|
|
161
|
-
id: feature.id
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
indexMap.lineFeature++;
|
|
165
|
-
break;
|
|
166
|
-
case 'Polygon':
|
|
167
|
-
handlePolygon(geometry, polygons, indexMap, coordLength, properties);
|
|
168
|
-
polygons.properties.push(keepStringProperties(properties, numericPropKeys));
|
|
169
|
-
if (hasGlobalId) {
|
|
170
|
-
polygons.fields.push({
|
|
171
|
-
id: feature.id
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
indexMap.polygonFeature++;
|
|
175
|
-
break;
|
|
176
|
-
default:
|
|
177
|
-
throw new Error('Invalid geometry type');
|
|
178
|
-
}
|
|
179
|
-
indexMap.feature++;
|
|
180
|
-
}
|
|
181
|
-
} catch (err) {
|
|
182
|
-
_iterator3.e(err);
|
|
183
|
-
} finally {
|
|
184
|
-
_iterator3.f();
|
|
185
|
-
}
|
|
186
|
-
return makeAccessorObjects(points, lines, polygons, coordLength);
|
|
187
|
-
}
|
|
188
|
-
function handlePoint(geometry, points, indexMap, coordLength, properties) {
|
|
189
|
-
points.positions.set(geometry.data, indexMap.pointPosition * coordLength);
|
|
190
|
-
var nPositions = geometry.data.length / coordLength;
|
|
191
|
-
fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);
|
|
192
|
-
points.globalFeatureIds.fill(indexMap.feature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
|
|
193
|
-
points.featureIds.fill(indexMap.pointFeature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
|
|
194
|
-
indexMap.pointPosition += nPositions;
|
|
195
|
-
}
|
|
196
|
-
function handleLineString(geometry, lines, indexMap, coordLength, properties) {
|
|
197
|
-
lines.positions.set(geometry.data, indexMap.linePosition * coordLength);
|
|
198
|
-
var nPositions = geometry.data.length / coordLength;
|
|
199
|
-
fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);
|
|
200
|
-
lines.globalFeatureIds.fill(indexMap.feature, indexMap.linePosition, indexMap.linePosition + nPositions);
|
|
201
|
-
lines.featureIds.fill(indexMap.lineFeature, indexMap.linePosition, indexMap.linePosition + nPositions);
|
|
202
|
-
for (var i = 0, il = geometry.indices.length; i < il; ++i) {
|
|
203
|
-
var start = geometry.indices[i];
|
|
204
|
-
var end = i === il - 1 ? geometry.data.length : geometry.indices[i + 1];
|
|
205
|
-
lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;
|
|
206
|
-
indexMap.linePosition += (end - start) / coordLength;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
function handlePolygon(geometry, polygons, indexMap, coordLength, properties) {
|
|
210
|
-
polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);
|
|
211
|
-
var nPositions = geometry.data.length / coordLength;
|
|
212
|
-
fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);
|
|
213
|
-
polygons.globalFeatureIds.fill(indexMap.feature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
|
|
214
|
-
polygons.featureIds.fill(indexMap.polygonFeature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
|
|
215
|
-
for (var l = 0, ll = geometry.indices.length; l < ll; ++l) {
|
|
216
|
-
var startPosition = indexMap.polygonPosition;
|
|
217
|
-
polygons.polygonIndices[indexMap.polygonObject++] = startPosition;
|
|
218
|
-
var areas = geometry.areas[l];
|
|
219
|
-
var indices = geometry.indices[l];
|
|
220
|
-
var nextIndices = geometry.indices[l + 1];
|
|
221
|
-
for (var i = 0, il = indices.length; i < il; ++i) {
|
|
222
|
-
var start = indices[i];
|
|
223
|
-
var end = i === il - 1 ? nextIndices === undefined ? geometry.data.length : nextIndices[0] : indices[i + 1];
|
|
224
|
-
polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
|
|
225
|
-
indexMap.polygonPosition += (end - start) / coordLength;
|
|
226
|
-
}
|
|
227
|
-
var endPosition = indexMap.polygonPosition;
|
|
228
|
-
triangulatePolygon(polygons, areas, indices, {
|
|
229
|
-
startPosition: startPosition,
|
|
230
|
-
endPosition: endPosition,
|
|
231
|
-
coordLength: coordLength
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
function triangulatePolygon(polygons, areas, indices, _ref) {
|
|
236
|
-
var startPosition = _ref.startPosition,
|
|
237
|
-
endPosition = _ref.endPosition,
|
|
238
|
-
coordLength = _ref.coordLength;
|
|
239
|
-
if (!polygons.triangles) {
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
var start = startPosition * coordLength;
|
|
243
|
-
var end = endPosition * coordLength;
|
|
244
|
-
var polygonPositions = polygons.positions.subarray(start, end);
|
|
245
|
-
var offset = indices[0];
|
|
246
|
-
var holes = indices.slice(1).map(function (n) {
|
|
247
|
-
return (n - offset) / coordLength;
|
|
248
|
-
});
|
|
249
|
-
var triangles = (0, _polygon.earcut)(polygonPositions, holes, coordLength, areas);
|
|
250
|
-
for (var t = 0, tl = triangles.length; t < tl; ++t) {
|
|
251
|
-
polygons.triangles.push(startPosition + triangles[t]);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
function wrapProps(obj, size) {
|
|
255
|
-
var returnObj = {};
|
|
256
|
-
for (var _key2 in obj) {
|
|
257
|
-
returnObj[_key2] = {
|
|
258
|
-
value: obj[_key2],
|
|
259
|
-
size: size
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
return returnObj;
|
|
263
|
-
}
|
|
264
|
-
function makeAccessorObjects(points, lines, polygons, coordLength) {
|
|
265
|
-
var binaryFeatures = {
|
|
266
|
-
points: _objectSpread(_objectSpread({}, points), {}, {
|
|
267
|
-
positions: {
|
|
268
|
-
value: points.positions,
|
|
269
|
-
size: coordLength
|
|
270
|
-
},
|
|
271
|
-
globalFeatureIds: {
|
|
272
|
-
value: points.globalFeatureIds,
|
|
273
|
-
size: 1
|
|
274
|
-
},
|
|
275
|
-
featureIds: {
|
|
276
|
-
value: points.featureIds,
|
|
277
|
-
size: 1
|
|
278
|
-
},
|
|
279
|
-
numericProps: wrapProps(points.numericProps, 1)
|
|
280
|
-
}),
|
|
281
|
-
lines: _objectSpread(_objectSpread({}, lines), {}, {
|
|
282
|
-
positions: {
|
|
283
|
-
value: lines.positions,
|
|
284
|
-
size: coordLength
|
|
285
|
-
},
|
|
286
|
-
pathIndices: {
|
|
287
|
-
value: lines.pathIndices,
|
|
288
|
-
size: 1
|
|
289
|
-
},
|
|
290
|
-
globalFeatureIds: {
|
|
291
|
-
value: lines.globalFeatureIds,
|
|
292
|
-
size: 1
|
|
293
|
-
},
|
|
294
|
-
featureIds: {
|
|
295
|
-
value: lines.featureIds,
|
|
296
|
-
size: 1
|
|
297
|
-
},
|
|
298
|
-
numericProps: wrapProps(lines.numericProps, 1)
|
|
299
|
-
}),
|
|
300
|
-
polygons: _objectSpread(_objectSpread({}, polygons), {}, {
|
|
301
|
-
positions: {
|
|
302
|
-
value: polygons.positions,
|
|
303
|
-
size: coordLength
|
|
304
|
-
},
|
|
305
|
-
polygonIndices: {
|
|
306
|
-
value: polygons.polygonIndices,
|
|
307
|
-
size: 1
|
|
308
|
-
},
|
|
309
|
-
primitivePolygonIndices: {
|
|
310
|
-
value: polygons.primitivePolygonIndices,
|
|
311
|
-
size: 1
|
|
312
|
-
},
|
|
313
|
-
globalFeatureIds: {
|
|
314
|
-
value: polygons.globalFeatureIds,
|
|
315
|
-
size: 1
|
|
316
|
-
},
|
|
317
|
-
featureIds: {
|
|
318
|
-
value: polygons.featureIds,
|
|
319
|
-
size: 1
|
|
320
|
-
},
|
|
321
|
-
numericProps: wrapProps(polygons.numericProps, 1)
|
|
322
|
-
})
|
|
323
|
-
};
|
|
324
|
-
if (binaryFeatures.polygons && polygons.triangles) {
|
|
325
|
-
binaryFeatures.polygons.triangles = {
|
|
326
|
-
value: new Uint32Array(polygons.triangles),
|
|
327
|
-
size: 1
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
return binaryFeatures;
|
|
331
|
-
}
|
|
332
|
-
function fillNumericProperties(object, properties, index, length) {
|
|
333
|
-
for (var numericPropName in object.numericProps) {
|
|
334
|
-
if (numericPropName in properties) {
|
|
335
|
-
var value = properties[numericPropName];
|
|
336
|
-
object.numericProps[numericPropName].fill(value, index, index + length);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
function keepStringProperties(properties, numericKeys) {
|
|
341
|
-
var props = {};
|
|
342
|
-
for (var _key3 in properties) {
|
|
343
|
-
if (!numericKeys.includes(_key3)) {
|
|
344
|
-
props[_key3] = properties[_key3];
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
return props;
|
|
348
|
-
}
|
|
349
|
-
function deduceArrayType(x, constructor) {
|
|
350
|
-
if (constructor === Array || !Number.isFinite(x)) {
|
|
351
|
-
return Array;
|
|
352
|
-
}
|
|
353
|
-
return constructor === Float64Array || Math.fround(x) !== x ? Float64Array : Float32Array;
|
|
354
|
-
}
|
|
355
|
-
//# sourceMappingURL=flat-geojson-to-binary.js.map
|