@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":"flat-geojson-to-binary.js","names":["_polygon","require","_createForOfIteratorHelper","o","allowArrayLike","it","Symbol","iterator","Array","isArray","_unsupportedIterableToArray","length","i","F","s","n","done","value","e","_e","f","TypeError","normalCompletion","didErr","err","call","step","next","_e2","return","minLen","_arrayLikeToArray","Object","prototype","toString","slice","constructor","name","from","test","arr","len","arr2","ownKeys","object","enumerableOnly","keys","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","arguments","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","flatGeojsonToBinary","features","geometryInfo","options","propArrayTypes","extractNumericPropTypes","numericPropKeys","k","fillArrays","PositionDataType","Float32Array","triangulate","TEST_EXPORTS","exports","_iterator","_step","feature","properties","val","deduceArrayType","pointPositionsCount","pointFeaturesCount","linePositionsCount","linePathsCount","lineFeaturesCount","polygonPositionsCount","polygonObjectsCount","polygonRingsCount","polygonFeaturesCount","coordLength","_options$numericPropK","_options$PositionData","_options$triangulate","hasGlobalId","GlobalFeatureIdsDataType","Uint32Array","Uint16Array","points","type","positions","globalFeatureIds","featureIds","numericProps","fields","lines","pathIndices","polygons","polygonIndices","primitivePolygonIndices","triangles","_i","_arr","_iterator2","_step2","propName","T","indexMap","pointPosition","pointFeature","linePosition","linePath","lineFeature","polygonPosition","polygonObject","polygonRing","polygonFeature","_iterator3","_step3","geometry","handlePoint","keepStringProperties","id","handleLineString","handlePolygon","Error","makeAccessorObjects","set","data","nPositions","fillNumericProperties","fill","il","indices","start","end","l","ll","startPosition","areas","nextIndices","undefined","endPosition","triangulatePolygon","_ref","polygonPositions","subarray","offset","holes","map","earcut","t","tl","wrapProps","obj","size","returnObj","binaryFeatures","index","numericPropName","numericKeys","props","includes","x","Number","isFinite","Float64Array","Math","fround"],"sources":["../../../src/lib/flat-geojson-to-binary.ts"],"sourcesContent":["/* eslint-disable indent */\nimport {earcut} from '@math.gl/polygon';\nimport type {\n BinaryAttribute,\n BinaryFeatureCollection,\n BinaryPolygonFeature,\n FlatFeature,\n FlatPoint,\n FlatLineString,\n FlatPolygon,\n GeojsonGeometryInfo,\n TypedArray\n} from '@loaders.gl/schema';\nimport {PropArrayConstructor, Lines, Points, Polygons} from './flat-geojson-to-binary-types';\n\n/**\n * Convert binary features to flat binary arrays. Similar to\n * `geojsonToBinary` helper function, except that it expects\n * a binary representation of the feature data, which enables\n * 2X-3X speed increase in parse speed, compared to using\n * geoJSON. See `binary-vector-tile/VectorTileFeature` for\n * data format detais\n *\n * @param features\n * @param geometryInfo\n * @param options\n * @returns filled arrays\n */\nexport function flatGeojsonToBinary(\n features: FlatFeature[],\n geometryInfo: GeojsonGeometryInfo,\n options?: FlatGeojsonToBinaryOptions\n) {\n const propArrayTypes = extractNumericPropTypes(features);\n const numericPropKeys = Object.keys(propArrayTypes).filter((k) => propArrayTypes[k] !== Array);\n return fillArrays(\n features,\n {\n propArrayTypes,\n ...geometryInfo\n },\n {\n numericPropKeys: (options && options.numericPropKeys) || numericPropKeys,\n PositionDataType: options ? options.PositionDataType : Float32Array,\n triangulate: options ? options.triangulate : true\n }\n );\n}\n\n/**\n * Options for `flatGeojsonToBinary`\n */\nexport type FlatGeojsonToBinaryOptions = {\n numericPropKeys?: string[];\n PositionDataType?: Float32ArrayConstructor | Float64ArrayConstructor;\n triangulate?: boolean;\n};\n\nexport const TEST_EXPORTS = {\n extractNumericPropTypes\n};\n\n/**\n * Extracts properties that are always numeric\n *\n * @param features\n * @returns object with numeric types\n */\nfunction extractNumericPropTypes(features: FlatFeature[]): {\n [key: string]: PropArrayConstructor;\n} {\n const propArrayTypes = {};\n for (const feature of features) {\n if (feature.properties) {\n for (const key in feature.properties) {\n // If property has not been seen before, or if property has been numeric\n // in all previous features, check if numeric in this feature\n // If not numeric, Array is stored to prevent rechecking in the future\n // Additionally, detects if 64 bit precision is required\n const val = feature.properties[key];\n propArrayTypes[key] = deduceArrayType(val, propArrayTypes[key]);\n }\n }\n }\n\n return propArrayTypes;\n}\n\n/**\n * Fills coordinates into pre-allocated typed arrays\n *\n * @param features\n * @param geometryInfo\n * @param options\n * @returns an accessor object with value and size keys\n */\n// eslint-disable-next-line complexity, max-statements\nfunction fillArrays(\n features: FlatFeature[],\n geometryInfo: GeojsonGeometryInfo & {\n propArrayTypes: {[key: string]: PropArrayConstructor};\n },\n options: FlatGeojsonToBinaryOptions\n) {\n const {\n pointPositionsCount,\n pointFeaturesCount,\n linePositionsCount,\n linePathsCount,\n lineFeaturesCount,\n polygonPositionsCount,\n polygonObjectsCount,\n polygonRingsCount,\n polygonFeaturesCount,\n propArrayTypes,\n coordLength\n } = geometryInfo;\n const {numericPropKeys = [], PositionDataType = Float32Array, triangulate = true} = options;\n const hasGlobalId = features[0] && 'id' in features[0];\n const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;\n const points: Points = {\n type: 'Point',\n positions: new PositionDataType(pointPositionsCount * coordLength),\n globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),\n featureIds:\n pointFeaturesCount > 65535\n ? new Uint32Array(pointPositionsCount)\n : new Uint16Array(pointPositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n const lines: Lines = {\n type: 'LineString',\n pathIndices:\n linePositionsCount > 65535\n ? new Uint32Array(linePathsCount + 1)\n : new Uint16Array(linePathsCount + 1),\n positions: new PositionDataType(linePositionsCount * coordLength),\n globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),\n featureIds:\n lineFeaturesCount > 65535\n ? new Uint32Array(linePositionsCount)\n : new Uint16Array(linePositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n const polygons: Polygons = {\n type: 'Polygon',\n polygonIndices:\n polygonPositionsCount > 65535\n ? new Uint32Array(polygonObjectsCount + 1)\n : new Uint16Array(polygonObjectsCount + 1),\n primitivePolygonIndices:\n polygonPositionsCount > 65535\n ? new Uint32Array(polygonRingsCount + 1)\n : new Uint16Array(polygonRingsCount + 1),\n positions: new PositionDataType(polygonPositionsCount * coordLength),\n globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),\n featureIds:\n polygonFeaturesCount > 65535\n ? new Uint32Array(polygonPositionsCount)\n : new Uint16Array(polygonPositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n\n if (triangulate) {\n polygons.triangles = [];\n }\n\n // Instantiate numeric properties arrays; one value per vertex\n for (const object of [points, lines, polygons]) {\n for (const propName of numericPropKeys) {\n // If property has been numeric in all previous features in which the property existed, check\n // if numeric in this feature\n const T = propArrayTypes[propName];\n object.numericProps[propName] = new T(object.positions.length / coordLength) as TypedArray;\n }\n }\n\n // Set last element of path/polygon indices as positions length\n lines.pathIndices[linePathsCount] = linePositionsCount;\n polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;\n polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;\n\n const indexMap = {\n pointPosition: 0,\n pointFeature: 0,\n linePosition: 0,\n linePath: 0,\n lineFeature: 0,\n polygonPosition: 0,\n polygonObject: 0,\n polygonRing: 0,\n polygonFeature: 0,\n feature: 0\n };\n\n for (const feature of features) {\n const geometry = feature.geometry;\n const properties = feature.properties || {};\n\n switch (geometry.type) {\n case 'Point':\n handlePoint(geometry, points, indexMap, coordLength, properties);\n points.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n points.fields.push({id: feature.id});\n }\n indexMap.pointFeature++;\n break;\n case 'LineString':\n handleLineString(geometry, lines, indexMap, coordLength, properties);\n lines.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n lines.fields.push({id: feature.id});\n }\n indexMap.lineFeature++;\n break;\n case 'Polygon':\n handlePolygon(geometry, polygons, indexMap, coordLength, properties);\n polygons.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n polygons.fields.push({id: feature.id});\n }\n indexMap.polygonFeature++;\n break;\n default:\n throw new Error('Invalid geometry type');\n }\n\n indexMap.feature++;\n }\n\n // Wrap each array in an accessor object with value and size keys\n return makeAccessorObjects(points, lines, polygons, coordLength);\n}\n\n/**\n * Fills (Multi)Point coordinates into points object of arrays\n *\n * @param geometry\n * @param points\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handlePoint(\n geometry: FlatPoint,\n points: Points,\n indexMap: {\n pointPosition: number;\n pointFeature: number;\n linePosition?: number;\n linePath?: number;\n lineFeature?: number;\n polygonPosition?: number;\n polygonObject?: number;\n polygonRing?: number;\n polygonFeature?: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\n points.positions.set(geometry.data, indexMap.pointPosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);\n points.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.pointPosition,\n indexMap.pointPosition + nPositions\n );\n points.featureIds.fill(\n indexMap.pointFeature,\n indexMap.pointPosition,\n indexMap.pointPosition + nPositions\n );\n\n indexMap.pointPosition += nPositions;\n}\n\n/**\n * Fills (Multi)LineString coordinates into lines object of arrays\n *\n * @param geometry\n * @param lines\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handleLineString(\n geometry: FlatLineString,\n lines: Lines,\n indexMap: {\n pointPosition?: number;\n pointFeature?: number;\n linePosition: number;\n linePath: number;\n lineFeature: number;\n polygonPosition?: number;\n polygonObject?: number;\n polygonRing?: number;\n polygonFeature?: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\n lines.positions.set(geometry.data, indexMap.linePosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);\n\n lines.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.linePosition,\n indexMap.linePosition + nPositions\n );\n lines.featureIds.fill(\n indexMap.lineFeature,\n indexMap.linePosition,\n indexMap.linePosition + nPositions\n );\n\n for (let i = 0, il = geometry.indices.length; i < il; ++i) {\n // Extract range of data we are working with, defined by start\n // and end indices (these index into the geometry.data array)\n const start = geometry.indices[i];\n const end =\n i === il - 1\n ? geometry.data.length // last line, so read to end of data\n : geometry.indices[i + 1]; // start index for next line\n\n lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;\n indexMap.linePosition += (end - start) / coordLength;\n }\n}\n\n/**\n * Fills (Multi)Polygon coordinates into polygons object of arrays\n *\n * @param geometry\n * @param polygons\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handlePolygon(\n geometry: FlatPolygon,\n polygons: Polygons,\n indexMap: {\n pointPosition?: number;\n pointFeature?: number;\n linePosition?: number;\n linePath?: number;\n lineFeature?: number;\n polygonPosition: number;\n polygonObject: number;\n polygonRing: number;\n polygonFeature: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\n polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);\n polygons.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.polygonPosition,\n indexMap.polygonPosition + nPositions\n );\n polygons.featureIds.fill(\n indexMap.polygonFeature,\n indexMap.polygonPosition,\n indexMap.polygonPosition + nPositions\n );\n\n // Unlike Point & LineString geometry.indices is a 2D array\n for (let l = 0, ll = geometry.indices.length; l < ll; ++l) {\n const startPosition = indexMap.polygonPosition;\n polygons.polygonIndices[indexMap.polygonObject++] = startPosition;\n\n const areas = geometry.areas[l];\n const indices = geometry.indices[l];\n const nextIndices = geometry.indices[l + 1];\n\n for (let i = 0, il = indices.length; i < il; ++i) {\n const start = indices[i];\n const end =\n i === il - 1\n ? // last line, so either read to:\n nextIndices === undefined\n ? geometry.data.length // end of data (no next indices)\n : nextIndices[0] // start of first line in nextIndices\n : indices[i + 1]; // start index for next line\n\n polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;\n indexMap.polygonPosition += (end - start) / coordLength;\n }\n\n const endPosition = indexMap.polygonPosition;\n triangulatePolygon(polygons, areas, indices, {startPosition, endPosition, coordLength});\n }\n}\n\n/**\n * Triangulate polygon using earcut\n *\n * @param polygons\n * @param areas\n * @param indices\n * @param param3\n */\nfunction triangulatePolygon(\n polygons: Polygons,\n areas: number[],\n indices: number[],\n {\n startPosition,\n endPosition,\n coordLength\n }: {startPosition: number; endPosition: number; coordLength: number}\n): void {\n if (!polygons.triangles) {\n return;\n }\n\n const start = startPosition * coordLength;\n const end = endPosition * coordLength;\n\n // Extract positions and holes for just this polygon\n const polygonPositions = polygons.positions.subarray(start, end);\n\n // Holes are referenced relative to outer polygon\n const offset = indices[0];\n const holes = indices.slice(1).map((n: number) => (n - offset) / coordLength);\n\n // Compute triangulation\n // @ts-expect-error TODO can earcut handle binary arrays? Add tests?\n const triangles = earcut(polygonPositions, holes, coordLength, areas);\n\n // Indices returned by triangulation are relative to start\n // of polygon, so we need to offset\n for (let t = 0, tl = triangles.length; t < tl; ++t) {\n polygons.triangles.push(startPosition + triangles[t]);\n }\n}\n\n/**\n * Wraps an object containing array into accessors\n *\n * @param obj\n * @param size\n */\nfunction wrapProps(\n obj: {[key: string]: TypedArray},\n size: number\n): {[key: string]: BinaryAttribute} {\n const returnObj = {};\n for (const key in obj) {\n returnObj[key] = {value: obj[key], size};\n }\n return returnObj;\n}\n\n/**\n * Wrap each array in an accessor object with value and size keys\n *\n * @param points\n * @param lines\n * @param polygons\n * @param coordLength\n * @returns object\n */\nfunction makeAccessorObjects(\n points: Points,\n lines: Lines,\n polygons: Polygons,\n coordLength: number\n): BinaryFeatureCollection {\n const binaryFeatures: BinaryFeatureCollection = {\n points: {\n ...points,\n positions: {value: points.positions, size: coordLength},\n globalFeatureIds: {value: points.globalFeatureIds, size: 1},\n featureIds: {value: points.featureIds, size: 1},\n numericProps: wrapProps(points.numericProps, 1)\n },\n lines: {\n ...lines,\n positions: {value: lines.positions, size: coordLength},\n pathIndices: {value: lines.pathIndices, size: 1},\n globalFeatureIds: {value: lines.globalFeatureIds, size: 1},\n featureIds: {value: lines.featureIds, size: 1},\n numericProps: wrapProps(lines.numericProps, 1)\n },\n polygons: {\n ...polygons,\n positions: {value: polygons.positions, size: coordLength},\n polygonIndices: {value: polygons.polygonIndices, size: 1},\n primitivePolygonIndices: {value: polygons.primitivePolygonIndices, size: 1},\n globalFeatureIds: {value: polygons.globalFeatureIds, size: 1},\n featureIds: {value: polygons.featureIds, size: 1},\n numericProps: wrapProps(polygons.numericProps, 1)\n } as BinaryPolygonFeature // triangles not expected\n };\n\n if (binaryFeatures.polygons && polygons.triangles) {\n binaryFeatures.polygons.triangles = {value: new Uint32Array(polygons.triangles), size: 1};\n }\n\n return binaryFeatures;\n}\n\n/**\n * Add numeric properties to object\n *\n * @param object\n * @param properties\n * @param index\n * @param length\n */\nfunction fillNumericProperties(\n object: Points | Lines | Polygons,\n properties: {[x: string]: string | number | boolean | null},\n index: number,\n length: number\n): void {\n for (const numericPropName in object.numericProps) {\n if (numericPropName in properties) {\n const value = properties[numericPropName] as number;\n object.numericProps[numericPropName].fill(value, index, index + length);\n }\n }\n}\n\n/**\n * Keep string properties in object\n *\n * @param properties\n * @param numericKeys\n * @returns object\n */\nfunction keepStringProperties(\n properties: {[x: string]: string | number | boolean | null},\n numericKeys: string[]\n) {\n const props = {};\n for (const key in properties) {\n if (!numericKeys.includes(key)) {\n props[key] = properties[key];\n }\n }\n return props;\n}\n\n/**\n *\n * Deduce correct array constructor to use for a given value\n *\n * @param x value to test\n * @param constructor previous constructor deduced\n * @returns PropArrayConstructor\n */\nfunction deduceArrayType(x: any, constructor: PropArrayConstructor): PropArrayConstructor {\n if (constructor === Array || !Number.isFinite(x)) {\n return Array;\n }\n\n // If this or previous value required 64bits use Float64Array\n return constructor === Float64Array || Math.fround(x) !== x ? Float64Array : Float32Array;\n}\n"],"mappings":";;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAAwC,SAAAC,2BAAAC,CAAA,EAAAC,cAAA,QAAAC,EAAA,UAAAC,MAAA,oBAAAH,CAAA,CAAAG,MAAA,CAAAC,QAAA,KAAAJ,CAAA,qBAAAE,EAAA,QAAAG,KAAA,CAAAC,OAAA,CAAAN,CAAA,MAAAE,EAAA,GAAAK,2BAAA,CAAAP,CAAA,MAAAC,cAAA,IAAAD,CAAA,WAAAA,CAAA,CAAAQ,MAAA,qBAAAN,EAAA,EAAAF,CAAA,GAAAE,EAAA,MAAAO,CAAA,UAAAC,CAAA,YAAAA,EAAA,eAAAC,CAAA,EAAAD,CAAA,EAAAE,CAAA,WAAAA,EAAA,QAAAH,CAAA,IAAAT,CAAA,CAAAQ,MAAA,WAAAK,IAAA,mBAAAA,IAAA,SAAAC,KAAA,EAAAd,CAAA,CAAAS,CAAA,UAAAM,CAAA,WAAAA,EAAAC,EAAA,UAAAA,EAAA,KAAAC,CAAA,EAAAP,CAAA,gBAAAQ,SAAA,iJAAAC,gBAAA,SAAAC,MAAA,UAAAC,GAAA,WAAAV,CAAA,WAAAA,EAAA,IAAAT,EAAA,GAAAA,EAAA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GA,OAAO4B,WAAW,KAAKiJ,YAAY,IAAIC,IAAI,CAACC,MAAM,CAACL,CAAC,CAAC,KAAKA,CAAC,GAAGG,YAAY,GAAGzG,YAAY;AAC3F"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.geojsonToBinary = geojsonToBinary;
|
|
7
|
-
var _extractGeometryInfo = require("./extract-geometry-info");
|
|
8
|
-
var _geojsonToFlatGeojson = require("./geojson-to-flat-geojson");
|
|
9
|
-
var _flatGeojsonToBinary = require("./flat-geojson-to-binary");
|
|
10
|
-
function geojsonToBinary(features) {
|
|
11
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
12
|
-
fixRingWinding: true,
|
|
13
|
-
triangulate: true
|
|
14
|
-
};
|
|
15
|
-
var geometryInfo = (0, _extractGeometryInfo.extractGeometryInfo)(features);
|
|
16
|
-
var coordLength = geometryInfo.coordLength;
|
|
17
|
-
var fixRingWinding = options.fixRingWinding;
|
|
18
|
-
var flatFeatures = (0, _geojsonToFlatGeojson.geojsonToFlatGeojson)(features, {
|
|
19
|
-
coordLength: coordLength,
|
|
20
|
-
fixRingWinding: fixRingWinding
|
|
21
|
-
});
|
|
22
|
-
return (0, _flatGeojsonToBinary.flatGeojsonToBinary)(flatFeatures, geometryInfo, {
|
|
23
|
-
numericPropKeys: options.numericPropKeys,
|
|
24
|
-
PositionDataType: options.PositionDataType || Float32Array,
|
|
25
|
-
triangulate: options.triangulate
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=geojson-to-binary.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"geojson-to-binary.js","names":["_extractGeometryInfo","require","_geojsonToFlatGeojson","_flatGeojsonToBinary","geojsonToBinary","features","options","arguments","length","undefined","fixRingWinding","triangulate","geometryInfo","extractGeometryInfo","coordLength","flatFeatures","geojsonToFlatGeojson","flatGeojsonToBinary","numericPropKeys","PositionDataType","Float32Array"],"sources":["../../../src/lib/geojson-to-binary.ts"],"sourcesContent":["import type {Feature} from '@loaders.gl/schema';\nimport type {BinaryFeatureCollection} from '@loaders.gl/schema';\n\nimport {extractGeometryInfo} from './extract-geometry-info';\nimport {geojsonToFlatGeojson} from './geojson-to-flat-geojson';\nimport {flatGeojsonToBinary} from './flat-geojson-to-binary';\n\n/**\n * Options for `geojsonToBinary`\n */\nexport type GeojsonToBinaryOptions = {\n fixRingWinding: boolean;\n numericPropKeys?: string[];\n PositionDataType?: Float32ArrayConstructor | Float64ArrayConstructor;\n triangulate?: boolean;\n};\n\n/**\n * Convert GeoJSON features to flat binary arrays\n *\n * @param features\n * @param options\n * @returns features in binary format, grouped by geometry type\n */\nexport function geojsonToBinary(\n features: Feature[],\n options: GeojsonToBinaryOptions = {fixRingWinding: true, triangulate: true}\n): BinaryFeatureCollection {\n const geometryInfo = extractGeometryInfo(features);\n const coordLength = geometryInfo.coordLength;\n const {fixRingWinding} = options;\n const flatFeatures = geojsonToFlatGeojson(features, {coordLength, fixRingWinding});\n return flatGeojsonToBinary(flatFeatures, geometryInfo, {\n numericPropKeys: options.numericPropKeys,\n PositionDataType: options.PositionDataType || Float32Array,\n triangulate: options.triangulate\n });\n}\n"],"mappings":";;;;;;AAGA,IAAAA,oBAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AAmBO,SAASG,eAAeA,CAC7BC,QAAmB,EAEM;EAAA,IADzBC,OAA+B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG;IAACG,cAAc,EAAE,IAAI;IAAEC,WAAW,EAAE;EAAI,CAAC;EAE3E,IAAMC,YAAY,GAAG,IAAAC,wCAAmB,EAACR,QAAQ,CAAC;EAClD,IAAMS,WAAW,GAAGF,YAAY,CAACE,WAAW;EAC5C,IAAOJ,cAAc,GAAIJ,OAAO,CAAzBI,cAAc;EACrB,IAAMK,YAAY,GAAG,IAAAC,0CAAoB,EAACX,QAAQ,EAAE;IAACS,WAAW,EAAXA,WAAW;IAAEJ,cAAc,EAAdA;EAAc,CAAC,CAAC;EAClF,OAAO,IAAAO,wCAAmB,EAACF,YAAY,EAAEH,YAAY,EAAE;IACrDM,eAAe,EAAEZ,OAAO,CAACY,eAAe;IACxCC,gBAAgB,EAAEb,OAAO,CAACa,gBAAgB,IAAIC,YAAY;IAC1DT,WAAW,EAAEL,OAAO,CAACK;EACvB,CAAC,CAAC;AACJ"}
|
|
@@ -1,136 +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.geojsonToFlatGeojson = geojsonToFlatGeojson;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
-
var _polygon = require("@math.gl/polygon");
|
|
11
|
-
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; }
|
|
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
|
-
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
|
-
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++) arr2[i] = arr[i]; return arr2; }
|
|
16
|
-
function geojsonToFlatGeojson(features) {
|
|
17
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
18
|
-
coordLength: 2,
|
|
19
|
-
fixRingWinding: true
|
|
20
|
-
};
|
|
21
|
-
return features.map(function (feature) {
|
|
22
|
-
return flattenFeature(feature, options);
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
function flattenPoint(coordinates, data, indices, options) {
|
|
26
|
-
indices.push(data.length);
|
|
27
|
-
data.push.apply(data, (0, _toConsumableArray2.default)(coordinates));
|
|
28
|
-
for (var i = coordinates.length; i < options.coordLength; i++) {
|
|
29
|
-
data.push(0);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function flattenLineString(coordinates, data, indices, options) {
|
|
33
|
-
indices.push(data.length);
|
|
34
|
-
var _iterator = _createForOfIteratorHelper(coordinates),
|
|
35
|
-
_step;
|
|
36
|
-
try {
|
|
37
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
38
|
-
var c = _step.value;
|
|
39
|
-
data.push.apply(data, (0, _toConsumableArray2.default)(c));
|
|
40
|
-
for (var i = c.length; i < options.coordLength; i++) {
|
|
41
|
-
data.push(0);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
} catch (err) {
|
|
45
|
-
_iterator.e(err);
|
|
46
|
-
} finally {
|
|
47
|
-
_iterator.f();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function flattenPolygon(coordinates, data, indices, areas, options) {
|
|
51
|
-
var count = 0;
|
|
52
|
-
var ringAreas = [];
|
|
53
|
-
var polygons = [];
|
|
54
|
-
var _iterator2 = _createForOfIteratorHelper(coordinates),
|
|
55
|
-
_step2;
|
|
56
|
-
try {
|
|
57
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
58
|
-
var lineString = _step2.value;
|
|
59
|
-
var lineString2d = lineString.map(function (p) {
|
|
60
|
-
return p.slice(0, 2);
|
|
61
|
-
});
|
|
62
|
-
var area = (0, _polygon.getPolygonSignedArea)(lineString2d.flat());
|
|
63
|
-
var ccw = area < 0;
|
|
64
|
-
if (options.fixRingWinding && (count === 0 && !ccw || count > 0 && ccw)) {
|
|
65
|
-
lineString.reverse();
|
|
66
|
-
area = -area;
|
|
67
|
-
}
|
|
68
|
-
ringAreas.push(area);
|
|
69
|
-
flattenLineString(lineString, data, polygons, options);
|
|
70
|
-
count++;
|
|
71
|
-
}
|
|
72
|
-
} catch (err) {
|
|
73
|
-
_iterator2.e(err);
|
|
74
|
-
} finally {
|
|
75
|
-
_iterator2.f();
|
|
76
|
-
}
|
|
77
|
-
if (count > 0) {
|
|
78
|
-
areas.push(ringAreas);
|
|
79
|
-
indices.push(polygons);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function flattenFeature(feature, options) {
|
|
83
|
-
var geometry = feature.geometry;
|
|
84
|
-
if (geometry.type === 'GeometryCollection') {
|
|
85
|
-
throw new Error('GeometryCollection type not supported');
|
|
86
|
-
}
|
|
87
|
-
var data = [];
|
|
88
|
-
var indices = [];
|
|
89
|
-
var areas;
|
|
90
|
-
var type;
|
|
91
|
-
switch (geometry.type) {
|
|
92
|
-
case 'Point':
|
|
93
|
-
type = 'Point';
|
|
94
|
-
flattenPoint(geometry.coordinates, data, indices, options);
|
|
95
|
-
break;
|
|
96
|
-
case 'MultiPoint':
|
|
97
|
-
type = 'Point';
|
|
98
|
-
geometry.coordinates.map(function (c) {
|
|
99
|
-
return flattenPoint(c, data, indices, options);
|
|
100
|
-
});
|
|
101
|
-
break;
|
|
102
|
-
case 'LineString':
|
|
103
|
-
type = 'LineString';
|
|
104
|
-
flattenLineString(geometry.coordinates, data, indices, options);
|
|
105
|
-
break;
|
|
106
|
-
case 'MultiLineString':
|
|
107
|
-
type = 'LineString';
|
|
108
|
-
geometry.coordinates.map(function (c) {
|
|
109
|
-
return flattenLineString(c, data, indices, options);
|
|
110
|
-
});
|
|
111
|
-
break;
|
|
112
|
-
case 'Polygon':
|
|
113
|
-
type = 'Polygon';
|
|
114
|
-
areas = [];
|
|
115
|
-
flattenPolygon(geometry.coordinates, data, indices, areas, options);
|
|
116
|
-
break;
|
|
117
|
-
case 'MultiPolygon':
|
|
118
|
-
type = 'Polygon';
|
|
119
|
-
areas = [];
|
|
120
|
-
geometry.coordinates.map(function (c) {
|
|
121
|
-
return flattenPolygon(c, data, indices, areas, options);
|
|
122
|
-
});
|
|
123
|
-
break;
|
|
124
|
-
default:
|
|
125
|
-
throw new Error("Unknown type: ".concat(type));
|
|
126
|
-
}
|
|
127
|
-
return _objectSpread(_objectSpread({}, feature), {}, {
|
|
128
|
-
geometry: {
|
|
129
|
-
type: type,
|
|
130
|
-
indices: indices,
|
|
131
|
-
data: data,
|
|
132
|
-
areas: areas
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
//# sourceMappingURL=geojson-to-flat-geojson.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"geojson-to-flat-geojson.js","names":["_polygon","require","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","_createForOfIteratorHelper","o","allowArrayLike","it","Symbol","iterator","Array","isArray","_unsupportedIterableToArray","F","s","n","done","value","e","_e","f","TypeError","normalCompletion","didErr","err","call","step","next","_e2","return","minLen","_arrayLikeToArray","prototype","toString","slice","constructor","name","from","test","arr","len","arr2","geojsonToFlatGeojson","features","options","undefined","coordLength","fixRingWinding","map","feature","flattenFeature","flattenPoint","coordinates","data","indices","_toConsumableArray2","flattenLineString","_iterator","_step","c","flattenPolygon","areas","count","ringAreas","polygons","_iterator2","_step2","lineString","lineString2d","p","area","getPolygonSignedArea","flat","ccw","reverse","geometry","type","Error","concat"],"sources":["../../../src/lib/geojson-to-flat-geojson.ts"],"sourcesContent":["import {getPolygonSignedArea} from '@math.gl/polygon';\n\nimport {Feature, Position, FlatFeature} from '@loaders.gl/schema';\n\n/**\n * Options for `geojsonToFlatGeojson`\n */\nexport type GeojsonToFlatGeojsonOptions = {\n coordLength: number;\n fixRingWinding: boolean;\n};\n\n// Coordinates defining a Point\ntype PointCoordinates = Position;\n// Coordinates defining a LineString\ntype LineStringCoordinates = Position[];\n// Coordinates defining a Polygon\ntype PolygonCoordinates = Position[][];\n\n/**\n * Convert GeoJSON features to Flat GeoJSON features\n *\n * @param features\n * @param options\n * @returns an Array of Flat GeoJSON features\n */\nexport function geojsonToFlatGeojson(\n features: Feature[],\n options: GeojsonToFlatGeojsonOptions = {coordLength: 2, fixRingWinding: true}\n): FlatFeature[] {\n return features.map((feature) => flattenFeature(feature, options));\n}\n\n/**\n * Helper function to copy Point values from `coordinates` into `data` & `indices`\n *\n * @param coordinates\n * @param data\n * @param indices\n * @param options\n */\nfunction flattenPoint(\n coordinates: PointCoordinates,\n data: number[],\n indices: number[],\n options: GeojsonToFlatGeojsonOptions\n) {\n indices.push(data.length);\n data.push(...coordinates);\n\n // Pad up to coordLength\n for (let i = coordinates.length; i < options.coordLength; i++) {\n data.push(0);\n }\n}\n\n/**\n * Helper function to copy LineString values from `coordinates` into `data` & `indices`\n *\n * @param coordinates\n * @param data\n * @param indices\n * @param options\n */\nfunction flattenLineString(\n coordinates: LineStringCoordinates,\n data: number[],\n indices: number[],\n options: GeojsonToFlatGeojsonOptions\n) {\n indices.push(data.length);\n for (const c of coordinates) {\n data.push(...c);\n\n // Pad up to coordLength\n for (let i = c.length; i < options.coordLength; i++) {\n data.push(0);\n }\n }\n}\n\n/**\n * Helper function to copy Polygon values from `coordinates` into `data` & `indices` & `areas`\n *\n * @param coordinates\n * @param data\n * @param indices\n * @param areas\n * @param options\n */\nfunction flattenPolygon(\n coordinates: PolygonCoordinates,\n data: number[],\n indices: number[][],\n areas: number[][],\n options: GeojsonToFlatGeojsonOptions\n) {\n let count = 0;\n const ringAreas: number[] = [];\n const polygons: number[] = [];\n for (const lineString of coordinates) {\n const lineString2d = lineString.map((p) => p.slice(0, 2));\n let area = getPolygonSignedArea(lineString2d.flat());\n const ccw = area < 0;\n\n // Exterior ring must be CCW and interior rings CW\n if (options.fixRingWinding && ((count === 0 && !ccw) || (count > 0 && ccw))) {\n lineString.reverse();\n area = -area;\n }\n ringAreas.push(area);\n flattenLineString(lineString, data, polygons, options);\n count++;\n }\n\n if (count > 0) {\n areas.push(ringAreas);\n indices.push(polygons);\n }\n}\n\n/**\n * Flatten single GeoJSON feature into Flat GeoJSON\n *\n * @param feature\n * @param options\n * @returns A Flat GeoJSON feature\n */\nfunction flattenFeature(feature: Feature, options: GeojsonToFlatGeojsonOptions): FlatFeature {\n const {geometry} = feature;\n if (geometry.type === 'GeometryCollection') {\n throw new Error('GeometryCollection type not supported');\n }\n const data = [];\n const indices = [];\n let areas;\n let type;\n\n switch (geometry.type) {\n case 'Point':\n type = 'Point';\n flattenPoint(geometry.coordinates, data, indices, options);\n break;\n case 'MultiPoint':\n type = 'Point';\n geometry.coordinates.map((c) => flattenPoint(c, data, indices, options));\n break;\n case 'LineString':\n type = 'LineString';\n flattenLineString(geometry.coordinates, data, indices, options);\n break;\n case 'MultiLineString':\n type = 'LineString';\n geometry.coordinates.map((c) => flattenLineString(c, data, indices, options));\n break;\n case 'Polygon':\n type = 'Polygon';\n areas = [];\n flattenPolygon(geometry.coordinates, data, indices, areas, options);\n break;\n case 'MultiPolygon':\n type = 'Polygon';\n areas = [];\n geometry.coordinates.map((c) => flattenPolygon(c, data, indices, areas, options));\n break;\n default:\n throw new Error(`Unknown type: ${type}`);\n }\n\n return {...feature, geometry: {type, indices, data, areas}};\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAAsD,SAAAC,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA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,OAAO,EAAEV,OAAO,CAAC;MAAA,EAAC;MAC7E;IACF,KAAK,SAAS;MACZgC,IAAI,GAAG,SAAS;MAChBf,KAAK,GAAG,EAAE;MACVD,cAAc,CAACe,QAAQ,CAACvB,WAAW,EAAEC,IAAI,EAAEC,OAAO,EAAEO,KAAK,EAAEjB,OAAO,CAAC;MACnE;IACF,KAAK,cAAc;MACjBgC,IAAI,GAAG,SAAS;MAChBf,KAAK,GAAG,EAAE;MACVc,QAAQ,CAACvB,WAAW,CAACJ,GAAG,CAAC,UAACW,CAAC;QAAA,OAAKC,cAAc,CAACD,CAAC,EAAEN,IAAI,EAAEC,OAAO,EAAEO,KAAK,EAAEjB,OAAO,CAAC;MAAA,EAAC;MACjF;IACF;MACE,MAAM,IAAIiC,KAAK,kBAAAC,MAAA,CAAkBF,IAAI,CAAE,CAAC;EAC5C;EAEA,OAAArF,aAAA,CAAAA,aAAA,KAAW0D,OAAO;IAAE0B,QAAQ,EAAE;MAACC,IAAI,EAAJA,IAAI;MAAEtB,OAAO,EAAPA,OAAO;MAAED,IAAI,EAAJA,IAAI;MAAEQ,KAAK,EAALA;IAAK;EAAC;AAC5D"}
|
|
@@ -1,57 +0,0 @@
|
|
|
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 Array.isArray(array) && Number.isFinite(array[0]) && Number.isFinite(array[1]);
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=transform.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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","isArray","Number","isFinite"],"sources":["../../../src/lib/transform.ts"],"sourcesContent":["import type {BinaryFeatureCollection, BinaryGeometry, Feature} 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: BinaryFeatureCollection,\n transformCoordinate: TransformCoordinate\n): BinaryFeatureCollection {\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: Feature[],\n fn: (coord: number[]) => number[]\n): Feature[] {\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: unknown, fn: (coord: number[]) => number[]): unknown[] {\n if (isCoord(array)) {\n return fn(array as number[]);\n }\n\n return (array as unknown[]).map((item) => {\n return coordMap(item, fn);\n });\n}\n\nfunction isCoord(array: unknown) {\n return Array.isArray(array) && Number.isFinite(array[0]) && Number.isFinite(array[1]);\n}\n"],"mappings":";;;;;;;;;;AAUO,SAASA,qBAAqBA,CACnCC,cAAuC,EACvCC,mBAAwC,EACf;EACzB,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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AAE;IAClB,OAAO3B,EAAE,CAAC2B,KAAiB,CAAC;EAC9B;EAEA,OAAQA,KAAK,CAAeE,GAAG,CAAC,UAACC,IAAI,EAAK;IACxC,OAAOP,QAAQ,CAACO,IAAI,EAAE9B,EAAE,CAAC;EAC3B,CAAC,CAAC;AACJ;AAEA,SAAS4B,OAAOA,CAACD,KAAc,EAAE;EAC/B,OAAOpB,KAAK,CAACwB,OAAO,CAACJ,KAAK,CAAC,IAAIK,MAAM,CAACC,QAAQ,CAACN,KAAK,CAAC,CAAC,CAAC,CAAC,IAAIK,MAAM,CAACC,QAAQ,CAACN,KAAK,CAAC,CAAC,CAAC,CAAC;AACvF"}
|
package/dist/esm/bundle.js
DELETED
package/dist/esm/bundle.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/esm/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
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, binaryToGeometry } from './lib/binary-to-geojson';
|
|
5
|
-
export { transformBinaryCoords, transformGeoJsonCoords } from './lib/transform';
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["flatGeojsonToBinary","geojsonToBinary","geojsonToFlatGeojson","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, 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,gBAAgB,QAAO,yBAAyB;AACzE,SAAQC,qBAAqB,EAAEC,sBAAsB,QAAO,iBAAiB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"binary-to-geojson.js","names":["binaryToGeojson","data","options","globalFeatureId","undefined","getSingleFeature","parseFeatures","type","dataArray","normalizeInput","lastIndex","lastValue","featureIds","value","i","length","currValue","globalFeatureIds","parseFeature","Error","concat","parseFeatureCollection","binaryToGeometry","startIndex","endIndex","pointToGeoJson","lineStringToGeoJson","polygonToGeoJson","unexpectedInput","features","points","push","lines","polygons","geometry","properties","parseProperties","fields","parseFields","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++) {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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,CAAChC,KAAK,CAACmD,CAAC,CAAC,CAAC,CAAC;IACxC;IACAV,eAAe,CAACvB,IAAI,CAAC+B,KAAK,CAAC;EAC7B;EACA,OAAOR,eAAe;AACxB"}
|
|
@@ -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","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,CAAC;EAC5B,MAAMC,YAAY,GAAG,IAAIC,G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,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"}
|
|
@@ -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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flat-geojson-to-binary.js","names":["earcut","flatGeojsonToBinary","features","geometryInfo","options","propArrayTypes","extractNumericPropTypes","numericPropKeys","Object","keys","filter","k","Array","fillArrays","PositionDataType","Float32Array","triangulate","TEST_EXPORTS","feature","properties","key","val","deduceArrayType","pointPositionsCount","pointFeaturesCount","linePositionsCount","linePathsCount","lineFeaturesCount","polygonPositionsCount","polygonObjectsCount","polygonRingsCount","polygonFeaturesCount","coordLength","hasGlobalId","GlobalFeatureIdsDataType","length","Uint32Array","Uint16Array","points","type","positions","globalFeatureIds","featureIds","numericProps","fields","lines","pathIndices","polygons","polygonIndices","primitivePolygonIndices","triangles","object","propName","T","indexMap","pointPosition","pointFeature","linePosition","linePath","lineFeature","polygonPosition","polygonObject","polygonRing","polygonFeature","geometry","handlePoint","push","keepStringProperties","id","handleLineString","handlePolygon","Error","makeAccessorObjects","set","data","nPositions","fillNumericProperties","fill","i","il","indices","start","end","l","ll","startPosition","areas","nextIndices","undefined","endPosition","triangulatePolygon","_ref","polygonPositions","subarray","offset","holes","slice","map","n","t","tl","wrapProps","obj","size","returnObj","value","binaryFeatures","index","numericPropName","numericKeys","props","includes","x","constructor","Number","isFinite","Float64Array","Math","fround"],"sources":["../../../src/lib/flat-geojson-to-binary.ts"],"sourcesContent":["/* eslint-disable indent */\nimport {earcut} from '@math.gl/polygon';\nimport type {\n BinaryAttribute,\n BinaryFeatureCollection,\n BinaryPolygonFeature,\n FlatFeature,\n FlatPoint,\n FlatLineString,\n FlatPolygon,\n GeojsonGeometryInfo,\n TypedArray\n} from '@loaders.gl/schema';\nimport {PropArrayConstructor, Lines, Points, Polygons} from './flat-geojson-to-binary-types';\n\n/**\n * Convert binary features to flat binary arrays. Similar to\n * `geojsonToBinary` helper function, except that it expects\n * a binary representation of the feature data, which enables\n * 2X-3X speed increase in parse speed, compared to using\n * geoJSON. See `binary-vector-tile/VectorTileFeature` for\n * data format detais\n *\n * @param features\n * @param geometryInfo\n * @param options\n * @returns filled arrays\n */\nexport function flatGeojsonToBinary(\n features: FlatFeature[],\n geometryInfo: GeojsonGeometryInfo,\n options?: FlatGeojsonToBinaryOptions\n) {\n const propArrayTypes = extractNumericPropTypes(features);\n const numericPropKeys = Object.keys(propArrayTypes).filter((k) => propArrayTypes[k] !== Array);\n return fillArrays(\n features,\n {\n propArrayTypes,\n ...geometryInfo\n },\n {\n numericPropKeys: (options && options.numericPropKeys) || numericPropKeys,\n PositionDataType: options ? options.PositionDataType : Float32Array,\n triangulate: options ? options.triangulate : true\n }\n );\n}\n\n/**\n * Options for `flatGeojsonToBinary`\n */\nexport type FlatGeojsonToBinaryOptions = {\n numericPropKeys?: string[];\n PositionDataType?: Float32ArrayConstructor | Float64ArrayConstructor;\n triangulate?: boolean;\n};\n\nexport const TEST_EXPORTS = {\n extractNumericPropTypes\n};\n\n/**\n * Extracts properties that are always numeric\n *\n * @param features\n * @returns object with numeric types\n */\nfunction extractNumericPropTypes(features: FlatFeature[]): {\n [key: string]: PropArrayConstructor;\n} {\n const propArrayTypes = {};\n for (const feature of features) {\n if (feature.properties) {\n for (const key in feature.properties) {\n // If property has not been seen before, or if property has been numeric\n // in all previous features, check if numeric in this feature\n // If not numeric, Array is stored to prevent rechecking in the future\n // Additionally, detects if 64 bit precision is required\n const val = feature.properties[key];\n propArrayTypes[key] = deduceArrayType(val, propArrayTypes[key]);\n }\n }\n }\n\n return propArrayTypes;\n}\n\n/**\n * Fills coordinates into pre-allocated typed arrays\n *\n * @param features\n * @param geometryInfo\n * @param options\n * @returns an accessor object with value and size keys\n */\n// eslint-disable-next-line complexity, max-statements\nfunction fillArrays(\n features: FlatFeature[],\n geometryInfo: GeojsonGeometryInfo & {\n propArrayTypes: {[key: string]: PropArrayConstructor};\n },\n options: FlatGeojsonToBinaryOptions\n) {\n const {\n pointPositionsCount,\n pointFeaturesCount,\n linePositionsCount,\n linePathsCount,\n lineFeaturesCount,\n polygonPositionsCount,\n polygonObjectsCount,\n polygonRingsCount,\n polygonFeaturesCount,\n propArrayTypes,\n coordLength\n } = geometryInfo;\n const {numericPropKeys = [], PositionDataType = Float32Array, triangulate = true} = options;\n const hasGlobalId = features[0] && 'id' in features[0];\n const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;\n const points: Points = {\n type: 'Point',\n positions: new PositionDataType(pointPositionsCount * coordLength),\n globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),\n featureIds:\n pointFeaturesCount > 65535\n ? new Uint32Array(pointPositionsCount)\n : new Uint16Array(pointPositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n const lines: Lines = {\n type: 'LineString',\n pathIndices:\n linePositionsCount > 65535\n ? new Uint32Array(linePathsCount + 1)\n : new Uint16Array(linePathsCount + 1),\n positions: new PositionDataType(linePositionsCount * coordLength),\n globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),\n featureIds:\n lineFeaturesCount > 65535\n ? new Uint32Array(linePositionsCount)\n : new Uint16Array(linePositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n const polygons: Polygons = {\n type: 'Polygon',\n polygonIndices:\n polygonPositionsCount > 65535\n ? new Uint32Array(polygonObjectsCount + 1)\n : new Uint16Array(polygonObjectsCount + 1),\n primitivePolygonIndices:\n polygonPositionsCount > 65535\n ? new Uint32Array(polygonRingsCount + 1)\n : new Uint16Array(polygonRingsCount + 1),\n positions: new PositionDataType(polygonPositionsCount * coordLength),\n globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),\n featureIds:\n polygonFeaturesCount > 65535\n ? new Uint32Array(polygonPositionsCount)\n : new Uint16Array(polygonPositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n\n if (triangulate) {\n polygons.triangles = [];\n }\n\n // Instantiate numeric properties arrays; one value per vertex\n for (const object of [points, lines, polygons]) {\n for (const propName of numericPropKeys) {\n // If property has been numeric in all previous features in which the property existed, check\n // if numeric in this feature\n const T = propArrayTypes[propName];\n object.numericProps[propName] = new T(object.positions.length / coordLength) as TypedArray;\n }\n }\n\n // Set last element of path/polygon indices as positions length\n lines.pathIndices[linePathsCount] = linePositionsCount;\n polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;\n polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;\n\n const indexMap = {\n pointPosition: 0,\n pointFeature: 0,\n linePosition: 0,\n linePath: 0,\n lineFeature: 0,\n polygonPosition: 0,\n polygonObject: 0,\n polygonRing: 0,\n polygonFeature: 0,\n feature: 0\n };\n\n for (const feature of features) {\n const geometry = feature.geometry;\n const properties = feature.properties || {};\n\n switch (geometry.type) {\n case 'Point':\n handlePoint(geometry, points, indexMap, coordLength, properties);\n points.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n points.fields.push({id: feature.id});\n }\n indexMap.pointFeature++;\n break;\n case 'LineString':\n handleLineString(geometry, lines, indexMap, coordLength, properties);\n lines.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n lines.fields.push({id: feature.id});\n }\n indexMap.lineFeature++;\n break;\n case 'Polygon':\n handlePolygon(geometry, polygons, indexMap, coordLength, properties);\n polygons.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n polygons.fields.push({id: feature.id});\n }\n indexMap.polygonFeature++;\n break;\n default:\n throw new Error('Invalid geometry type');\n }\n\n indexMap.feature++;\n }\n\n // Wrap each array in an accessor object with value and size keys\n return makeAccessorObjects(points, lines, polygons, coordLength);\n}\n\n/**\n * Fills (Multi)Point coordinates into points object of arrays\n *\n * @param geometry\n * @param points\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handlePoint(\n geometry: FlatPoint,\n points: Points,\n indexMap: {\n pointPosition: number;\n pointFeature: number;\n linePosition?: number;\n linePath?: number;\n lineFeature?: number;\n polygonPosition?: number;\n polygonObject?: number;\n polygonRing?: number;\n polygonFeature?: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\n points.positions.set(geometry.data, indexMap.pointPosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);\n points.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.pointPosition,\n indexMap.pointPosition + nPositions\n );\n points.featureIds.fill(\n indexMap.pointFeature,\n indexMap.pointPosition,\n indexMap.pointPosition + nPositions\n );\n\n indexMap.pointPosition += nPositions;\n}\n\n/**\n * Fills (Multi)LineString coordinates into lines object of arrays\n *\n * @param geometry\n * @param lines\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handleLineString(\n geometry: FlatLineString,\n lines: Lines,\n indexMap: {\n pointPosition?: number;\n pointFeature?: number;\n linePosition: number;\n linePath: number;\n lineFeature: number;\n polygonPosition?: number;\n polygonObject?: number;\n polygonRing?: number;\n polygonFeature?: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\n lines.positions.set(geometry.data, indexMap.linePosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);\n\n lines.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.linePosition,\n indexMap.linePosition + nPositions\n );\n lines.featureIds.fill(\n indexMap.lineFeature,\n indexMap.linePosition,\n indexMap.linePosition + nPositions\n );\n\n for (let i = 0, il = geometry.indices.length; i < il; ++i) {\n // Extract range of data we are working with, defined by start\n // and end indices (these index into the geometry.data array)\n const start = geometry.indices[i];\n const end =\n i === il - 1\n ? geometry.data.length // last line, so read to end of data\n : geometry.indices[i + 1]; // start index for next line\n\n lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;\n indexMap.linePosition += (end - start) / coordLength;\n }\n}\n\n/**\n * Fills (Multi)Polygon coordinates into polygons object of arrays\n *\n * @param geometry\n * @param polygons\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handlePolygon(\n geometry: FlatPolygon,\n polygons: Polygons,\n indexMap: {\n pointPosition?: number;\n pointFeature?: number;\n linePosition?: number;\n linePath?: number;\n lineFeature?: number;\n polygonPosition: number;\n polygonObject: number;\n polygonRing: number;\n polygonFeature: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\n polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);\n polygons.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.polygonPosition,\n indexMap.polygonPosition + nPositions\n );\n polygons.featureIds.fill(\n indexMap.polygonFeature,\n indexMap.polygonPosition,\n indexMap.polygonPosition + nPositions\n );\n\n // Unlike Point & LineString geometry.indices is a 2D array\n for (let l = 0, ll = geometry.indices.length; l < ll; ++l) {\n const startPosition = indexMap.polygonPosition;\n polygons.polygonIndices[indexMap.polygonObject++] = startPosition;\n\n const areas = geometry.areas[l];\n const indices = geometry.indices[l];\n const nextIndices = geometry.indices[l + 1];\n\n for (let i = 0, il = indices.length; i < il; ++i) {\n const start = indices[i];\n const end =\n i === il - 1\n ? // last line, so either read to:\n nextIndices === undefined\n ? geometry.data.length // end of data (no next indices)\n : nextIndices[0] // start of first line in nextIndices\n : indices[i + 1]; // start index for next line\n\n polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;\n indexMap.polygonPosition += (end - start) / coordLength;\n }\n\n const endPosition = indexMap.polygonPosition;\n triangulatePolygon(polygons, areas, indices, {startPosition, endPosition, coordLength});\n }\n}\n\n/**\n * Triangulate polygon using earcut\n *\n * @param polygons\n * @param areas\n * @param indices\n * @param param3\n */\nfunction triangulatePolygon(\n polygons: Polygons,\n areas: number[],\n indices: number[],\n {\n startPosition,\n endPosition,\n coordLength\n }: {startPosition: number; endPosition: number; coordLength: number}\n): void {\n if (!polygons.triangles) {\n return;\n }\n\n const start = startPosition * coordLength;\n const end = endPosition * coordLength;\n\n // Extract positions and holes for just this polygon\n const polygonPositions = polygons.positions.subarray(start, end);\n\n // Holes are referenced relative to outer polygon\n const offset = indices[0];\n const holes = indices.slice(1).map((n: number) => (n - offset) / coordLength);\n\n // Compute triangulation\n // @ts-expect-error TODO can earcut handle binary arrays? Add tests?\n const triangles = earcut(polygonPositions, holes, coordLength, areas);\n\n // Indices returned by triangulation are relative to start\n // of polygon, so we need to offset\n for (let t = 0, tl = triangles.length; t < tl; ++t) {\n polygons.triangles.push(startPosition + triangles[t]);\n }\n}\n\n/**\n * Wraps an object containing array into accessors\n *\n * @param obj\n * @param size\n */\nfunction wrapProps(\n obj: {[key: string]: TypedArray},\n size: number\n): {[key: string]: BinaryAttribute} {\n const returnObj = {};\n for (const key in obj) {\n returnObj[key] = {value: obj[key], size};\n }\n return returnObj;\n}\n\n/**\n * Wrap each array in an accessor object with value and size keys\n *\n * @param points\n * @param lines\n * @param polygons\n * @param coordLength\n * @returns object\n */\nfunction makeAccessorObjects(\n points: Points,\n lines: Lines,\n polygons: Polygons,\n coordLength: number\n): BinaryFeatureCollection {\n const binaryFeatures: BinaryFeatureCollection = {\n points: {\n ...points,\n positions: {value: points.positions, size: coordLength},\n globalFeatureIds: {value: points.globalFeatureIds, size: 1},\n featureIds: {value: points.featureIds, size: 1},\n numericProps: wrapProps(points.numericProps, 1)\n },\n lines: {\n ...lines,\n positions: {value: lines.positions, size: coordLength},\n pathIndices: {value: lines.pathIndices, size: 1},\n globalFeatureIds: {value: lines.globalFeatureIds, size: 1},\n featureIds: {value: lines.featureIds, size: 1},\n numericProps: wrapProps(lines.numericProps, 1)\n },\n polygons: {\n ...polygons,\n positions: {value: polygons.positions, size: coordLength},\n polygonIndices: {value: polygons.polygonIndices, size: 1},\n primitivePolygonIndices: {value: polygons.primitivePolygonIndices, size: 1},\n globalFeatureIds: {value: polygons.globalFeatureIds, size: 1},\n featureIds: {value: polygons.featureIds, size: 1},\n numericProps: wrapProps(polygons.numericProps, 1)\n } as BinaryPolygonFeature // triangles not expected\n };\n\n if (binaryFeatures.polygons && polygons.triangles) {\n binaryFeatures.polygons.triangles = {value: new Uint32Array(polygons.triangles), size: 1};\n }\n\n return binaryFeatures;\n}\n\n/**\n * Add numeric properties to object\n *\n * @param object\n * @param properties\n * @param index\n * @param length\n */\nfunction fillNumericProperties(\n object: Points | Lines | Polygons,\n properties: {[x: string]: string | number | boolean | null},\n index: number,\n length: number\n): void {\n for (const numericPropName in object.numericProps) {\n if (numericPropName in properties) {\n const value = properties[numericPropName] as number;\n object.numericProps[numericPropName].fill(value, index, index + length);\n }\n }\n}\n\n/**\n * Keep string properties in object\n *\n * @param properties\n * @param numericKeys\n * @returns object\n */\nfunction keepStringProperties(\n properties: {[x: string]: string | number | boolean | null},\n numericKeys: string[]\n) {\n const props = {};\n for (const key in properties) {\n if (!numericKeys.includes(key)) {\n props[key] = properties[key];\n }\n }\n return props;\n}\n\n/**\n *\n * Deduce correct array constructor to use for a given value\n *\n * @param x value to test\n * @param constructor previous constructor deduced\n * @returns PropArrayConstructor\n */\nfunction deduceArrayType(x: any, constructor: PropArrayConstructor): PropArrayConstructor {\n if (constructor === Array || !Number.isFinite(x)) {\n return Array;\n }\n\n // If this or previous value required 64bits use Float64Array\n return constructor === Float64Array || Math.fround(x) !== x ? Float64Array : Float32Array;\n}\n"],"mappings":"AACA,SAAQA,MAAM,QAAO,kBAAkB;AA2BvC,OAAO,SAASC,mBAAmBA,CACjCC,QAAuB,EACvBC,YAAiC,EACjCC,OAAoC,EACpC;EACA,MAAMC,cAAc,GAAGC,uBAAuB,CAACJ,QAAQ,CAAC;EACxD,MAAMK,eAAe,GAAGC,MAAM,CAACC,IAAI,CAACJ,cAAc,CAAC,CAACK,MAAM,CAAEC,CAAC,IAAKN,cAAc,CAACM,CAAC,CAAC,KAAKC,KAAK,CAAC;EAC9F,OAAOC,UAAU,CACfX,QAAQ,EACR;IACEG,cAAc;IACd,GAAGF;EACL,CAAC,EACD;IACEI,eAAe,EAAGH,OAAO,IAAIA,OAAO,CAACG,eAAe,IAAKA,eAAe;IACxEO,gBAAgB,EAAEV,OAAO,GAAGA,OAAO,CAACU,gBAAgB,GAAGC,YAAY;IACnEC,WAAW,EAAEZ,OAAO,GAAGA,OAAO,CAACY,WAAW,GAAG;EAC/C,CACF,CAAC;AACH;AAWA,OAAO,MAAMC,YAAY,GAAG;EAC1BX;AACF,CAAC;AAQD,SAASA,uBAAuBA,CAACJ,QAAuB,EAEtD;EACA,MAAMG,cAAc,GAAG,CAAC,CAAC;EACzB,KAAK,MAAMa,OAAO,IAAIhB,QAAQ,EAAE;IAC9B,IAAIgB,OAAO,CAACC,UAAU,EAAE;MACtB,KAAK,MAAMC,GAAG,IAAIF,OAAO,CAACC,UAAU,EAAE;QAKpC,MAAME,GAAG,GAAGH,OAAO,CAACC,UAAU,CAACC,GAAG,CAAC;QACnCf,cAAc,CAACe,GAAG,CAAC,GAAGE,eAAe,CAACD,GAAG,EAAEhB,cAAc,CAACe,GAAG,CAAC,CAA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A,OAAOqG,WAAW,KAAKG,YAAY,IAAIC,IAAI,CAACC,MAAM,CAACN,CAAC,CAAC,KAAKA,CAAC,GAAGI,YAAY,GAAGrG,YAAY;AAC3F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"geojson-to-binary.js","names":["extractGeometryInfo","geojsonToFlatGeojson","flatGeojsonToBinary","geojsonToBinary","features","options","arguments","length","undefined","fixRingWinding","triangulate","geometryInfo","coordLength","flatFeatures","numericPropKeys","PositionDataType","Float32Array"],"sources":["../../../src/lib/geojson-to-binary.ts"],"sourcesContent":["import type {Feature} from '@loaders.gl/schema';\nimport type {BinaryFeatureCollection} from '@loaders.gl/schema';\n\nimport {extractGeometryInfo} from './extract-geometry-info';\nimport {geojsonToFlatGeojson} from './geojson-to-flat-geojson';\nimport {flatGeojsonToBinary} from './flat-geojson-to-binary';\n\n/**\n * Options for `geojsonToBinary`\n */\nexport type GeojsonToBinaryOptions = {\n fixRingWinding: boolean;\n numericPropKeys?: string[];\n PositionDataType?: Float32ArrayConstructor | Float64ArrayConstructor;\n triangulate?: boolean;\n};\n\n/**\n * Convert GeoJSON features to flat binary arrays\n *\n * @param features\n * @param options\n * @returns features in binary format, grouped by geometry type\n */\nexport function geojsonToBinary(\n features: Feature[],\n options: GeojsonToBinaryOptions = {fixRingWinding: true, triangulate: true}\n): BinaryFeatureCollection {\n const geometryInfo = extractGeometryInfo(features);\n const coordLength = geometryInfo.coordLength;\n const {fixRingWinding} = options;\n const flatFeatures = geojsonToFlatGeojson(features, {coordLength, fixRingWinding});\n return flatGeojsonToBinary(flatFeatures, geometryInfo, {\n numericPropKeys: options.numericPropKeys,\n PositionDataType: options.PositionDataType || Float32Array,\n triangulate: options.triangulate\n });\n}\n"],"mappings":"AAGA,SAAQA,mBAAmB,QAAO,yBAAyB;AAC3D,SAAQC,oBAAoB,QAAO,2BAA2B;AAC9D,SAAQC,mBAAmB,QAAO,0BAA0B;AAmB5D,OAAO,SAASC,eAAeA,CAC7BC,QAAmB,EAEM;EAAA,IADzBC,OAA+B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG;IAACG,cAAc,EAAE,IAAI;IAAEC,WAAW,EAAE;EAAI,CAAC;EAE3E,MAAMC,YAAY,GAAGX,mBAAmB,CAACI,QAAQ,CAAC;EAClD,MAAMQ,WAAW,GAAGD,YAAY,CAACC,WAAW;EAC5C,MAAM;IAACH;EAAc,CAAC,GAAGJ,OAAO;EAChC,MAAMQ,YAAY,GAAGZ,oBAAoB,CAACG,QAAQ,EAAE;IAACQ,WAAW;IAAEH;EAAc,CAAC,CAAC;EAClF,OAAOP,mBAAmB,CAACW,YAAY,EAAEF,YAAY,EAAE;IACrDG,eAAe,EAAET,OAAO,CAACS,eAAe;IACxCC,gBAAgB,EAAEV,OAAO,CAACU,gBAAgB,IAAIC,YAAY;IAC1DN,WAAW,EAAEL,OAAO,CAACK;EACvB,CAAC,CAAC;AACJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"geojson-to-flat-geojson.js","names":["getPolygonSignedArea","geojsonToFlatGeojson","features","options","arguments","length","undefined","coordLength","fixRingWinding","map","feature","flattenFeature","flattenPoint","coordinates","data","indices","push","i","flattenLineString","c","flattenPolygon","areas","count","ringAreas","polygons","lineString","lineString2d","p","slice","area","flat","ccw","reverse","geometry","type","Error","concat"],"sources":["../../../src/lib/geojson-to-flat-geojson.ts"],"sourcesContent":["import {getPolygonSignedArea} from '@math.gl/polygon';\n\nimport {Feature, Position, FlatFeature} from '@loaders.gl/schema';\n\n/**\n * Options for `geojsonToFlatGeojson`\n */\nexport type GeojsonToFlatGeojsonOptions = {\n coordLength: number;\n fixRingWinding: boolean;\n};\n\n// Coordinates defining a Point\ntype PointCoordinates = Position;\n// Coordinates defining a LineString\ntype LineStringCoordinates = Position[];\n// Coordinates defining a Polygon\ntype PolygonCoordinates = Position[][];\n\n/**\n * Convert GeoJSON features to Flat GeoJSON features\n *\n * @param features\n * @param options\n * @returns an Array of Flat GeoJSON features\n */\nexport function geojsonToFlatGeojson(\n features: Feature[],\n options: GeojsonToFlatGeojsonOptions = {coordLength: 2, fixRingWinding: true}\n): FlatFeature[] {\n return features.map((feature) => flattenFeature(feature, options));\n}\n\n/**\n * Helper function to copy Point values from `coordinates` into `data` & `indices`\n *\n * @param coordinates\n * @param data\n * @param indices\n * @param options\n */\nfunction flattenPoint(\n coordinates: PointCoordinates,\n data: number[],\n indices: number[],\n options: GeojsonToFlatGeojsonOptions\n) {\n indices.push(data.length);\n data.push(...coordinates);\n\n // Pad up to coordLength\n for (let i = coordinates.length; i < options.coordLength; i++) {\n data.push(0);\n }\n}\n\n/**\n * Helper function to copy LineString values from `coordinates` into `data` & `indices`\n *\n * @param coordinates\n * @param data\n * @param indices\n * @param options\n */\nfunction flattenLineString(\n coordinates: LineStringCoordinates,\n data: number[],\n indices: number[],\n options: GeojsonToFlatGeojsonOptions\n) {\n indices.push(data.length);\n for (const c of coordinates) {\n data.push(...c);\n\n // Pad up to coordLength\n for (let i = c.length; i < options.coordLength; i++) {\n data.push(0);\n }\n }\n}\n\n/**\n * Helper function to copy Polygon values from `coordinates` into `data` & `indices` & `areas`\n *\n * @param coordinates\n * @param data\n * @param indices\n * @param areas\n * @param options\n */\nfunction flattenPolygon(\n coordinates: PolygonCoordinates,\n data: number[],\n indices: number[][],\n areas: number[][],\n options: GeojsonToFlatGeojsonOptions\n) {\n let count = 0;\n const ringAreas: number[] = [];\n const polygons: number[] = [];\n for (const lineString of coordinates) {\n const lineString2d = lineString.map((p) => p.slice(0, 2));\n let area = getPolygonSignedArea(lineString2d.flat());\n const ccw = area < 0;\n\n // Exterior ring must be CCW and interior rings CW\n if (options.fixRingWinding && ((count === 0 && !ccw) || (count > 0 && ccw))) {\n lineString.reverse();\n area = -area;\n }\n ringAreas.push(area);\n flattenLineString(lineString, data, polygons, options);\n count++;\n }\n\n if (count > 0) {\n areas.push(ringAreas);\n indices.push(polygons);\n }\n}\n\n/**\n * Flatten single GeoJSON feature into Flat GeoJSON\n *\n * @param feature\n * @param options\n * @returns A Flat GeoJSON feature\n */\nfunction flattenFeature(feature: Feature, options: GeojsonToFlatGeojsonOptions): FlatFeature {\n const {geometry} = feature;\n if (geometry.type === 'GeometryCollection') {\n throw new Error('GeometryCollection type not supported');\n }\n const data = [];\n const indices = [];\n let areas;\n let type;\n\n switch (geometry.type) {\n case 'Point':\n type = 'Point';\n flattenPoint(geometry.coordinates, data, indices, options);\n break;\n case 'MultiPoint':\n type = 'Point';\n geometry.coordinates.map((c) => flattenPoint(c, data, indices, options));\n break;\n case 'LineString':\n type = 'LineString';\n flattenLineString(geometry.coordinates, data, indices, options);\n break;\n case 'MultiLineString':\n type = 'LineString';\n geometry.coordinates.map((c) => flattenLineString(c, data, indices, options));\n break;\n case 'Polygon':\n type = 'Polygon';\n areas = [];\n flattenPolygon(geometry.coordinates, data, indices, areas, options);\n break;\n case 'MultiPolygon':\n type = 'Polygon';\n areas = [];\n geometry.coordinates.map((c) => flattenPolygon(c, data, indices, areas, options));\n break;\n default:\n throw new Error(`Unknown type: ${type}`);\n }\n\n return {...feature, geometry: {type, indices, data, areas}};\n}\n"],"mappings":"AAAA,SAAQA,oBAAoB,QAAO,kBAAkB;AA0BrD,OAAO,SAASC,oBAAoBA,CAClCC,QAAmB,EAEJ;EAAA,IADfC,OAAoC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG;IAACG,WAAW,EAAE,CAAC;IAAEC,cAAc,EAAE;EAAI,CAAC;EAE7E,OAAON,QAAQ,CAACO,GAAG,CAAEC,OAAO,IAAKC,cAAc,CAACD,OAAO,EAAEP,OAAO,CAAC,CAAC;AACpE;AAUA,SAASS,YAAYA,CACnBC,WAA6B,EAC7BC,IAAc,EACdC,OAAiB,EACjBZ,OAAoC,EACpC;EACAY,OAAO,CAACC,IAAI,CAACF,IAAI,CAACT,MAAM,CAA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,CAACJ,GAAG,CAAEU,CAAC,IAAKD,iBAAiB,CAACC,CAAC,EAAEL,IAAI,EAAEC,OAAO,EAAEZ,OAAO,CAAC,CAAC;MAC7E;IACF,KAAK,SAAS;MACZ+B,IAAI,GAAG,SAAS;MAChBb,KAAK,GAAG,EAAE;MACVD,cAAc,CAACa,QAAQ,CAACpB,WAAW,EAAEC,IAAI,EAAEC,OAAO,EAAEM,KAAK,EAAElB,OAAO,CAAC;MACnE;IACF,KAAK,cAAc;MACjB+B,IAAI,GAAG,SAAS;MAChBb,KAAK,GAAG,EAAE;MACVY,QAAQ,CAACpB,WAAW,CAACJ,GAAG,CAAEU,CAAC,IAAKC,cAAc,CAACD,CAAC,EAAEL,IAAI,EAAEC,OAAO,EAAEM,KAAK,EAAElB,OAAO,CAAC,CAAC;MACjF;IACF;MACE,MAAM,IAAIgC,KAAK,kBAAAC,MAAA,CAAkBF,IAAI,CAAE,CAAC;EAC5C;EAEA,OAAO;IAAC,GAAGxB,OAAO;IAAEuB,QAAQ,EAAE;MAACC,IAAI;MAAEnB,OAAO;MAAED,IAAI;MAAEO;IAAK;EAAC,CAAC;AAC7D"}
|
|
@@ -1 +0,0 @@
|
|
|
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","feature","geometry","coordinates","coordMap","array","isCoord","map","item","isArray","Number","isFinite"],"sources":["../../../src/lib/transform.ts"],"sourcesContent":["import type {BinaryFeatureCollection, BinaryGeometry, Feature} 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: BinaryFeatureCollection,\n transformCoordinate: TransformCoordinate\n): BinaryFeatureCollection {\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: Feature[],\n fn: (coord: number[]) => number[]\n): Feature[] {\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: unknown, fn: (coord: number[]) => number[]): unknown[] {\n if (isCoord(array)) {\n return fn(array as number[]);\n }\n\n return (array as unknown[]).map((item) => {\n return coordMap(item, fn);\n });\n}\n\nfunction isCoord(array: unknown) {\n return Array.isArray(array) && Number.isFinite(array[0]) && Number.isFinite(array[1]);\n}\n"],"mappings":"AAUA,OAAO,SAASA,qBAAqBA,CACnCC,cAAuC,EACvCC,mBAAwC,EACf;EACzB,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,IA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