@loaders.gl/mvt 4.0.0-alpha.4 → 4.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/dist.min.js +2289 -0
- package/dist/helpers/binary-util-functions.d.ts +35 -0
- package/dist/helpers/binary-util-functions.d.ts.map +1 -0
- package/dist/helpers/binary-util-functions.js +8 -5
- package/dist/helpers/binary-util-functions.js.map +1 -1
- package/dist/helpers/mapbox-util-functions.d.ts +29 -0
- package/dist/helpers/mapbox-util-functions.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts +41 -0
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +1 -0
- package/dist/lib/binary-vector-tile/vector-tile-feature.js +31 -30
- package/dist/lib/binary-vector-tile/vector-tile-feature.js.map +1 -1
- package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +23 -0
- package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts.map +1 -0
- package/dist/lib/binary-vector-tile/vector-tile-layer.js +2 -2
- package/dist/lib/binary-vector-tile/vector-tile-layer.js.map +1 -1
- package/dist/lib/binary-vector-tile/vector-tile.d.ts +9 -0
- package/dist/lib/binary-vector-tile/vector-tile.d.ts.map +1 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +27 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts.map +1 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts +20 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts.map +1 -0
- package/dist/lib/mapbox-vector-tile/vector-tile.d.ts +9 -0
- package/dist/lib/mapbox-vector-tile/vector-tile.d.ts.map +1 -0
- package/dist/lib/parse-mvt.d.ts +17 -0
- package/dist/lib/parse-mvt.d.ts.map +1 -0
- package/dist/lib/parse-mvt.js +6 -5
- package/dist/lib/parse-mvt.js.map +1 -1
- package/dist/lib/types.d.ts +28 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/mvt-loader.d.ts +10 -0
- package/dist/mvt-loader.d.ts.map +1 -0
- package/dist/mvt-loader.js +1 -1
- package/dist/mvt-worker.js +103 -98
- package/dist/workers/mvt-worker.d.ts +2 -0
- package/dist/workers/mvt-worker.d.ts.map +1 -0
- package/package.json +8 -7
- package/src/helpers/binary-util-functions.ts +9 -7
- package/src/lib/binary-vector-tile/vector-tile-feature.ts +36 -44
- package/src/lib/binary-vector-tile/vector-tile-layer.ts +4 -4
- package/src/lib/parse-mvt.ts +11 -9
- package/src/lib/types.ts +0 -69
- package/dist/lib/binary-vector-tile/features-to-binary.js +0 -327
- package/dist/lib/binary-vector-tile/features-to-binary.js.map +0 -1
- package/src/lib/binary-vector-tile/features-to-binary.ts +0 -518
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/binary-vector-tile/features-to-binary.ts"],"names":["earcut","featuresToBinary","features","firstPassData","options","fillArrays","numericPropKeys","extractNumericPropKeys","PositionDataType","Float32Array","TEST_EXPORTS","feature","properties","key","numericSoFar","undefined","val","isNumeric","Object","keys","filter","k","pointPositionsCount","pointFeaturesCount","linePositionsCount","linePathsCount","lineFeaturesCount","polygonPositionsCount","polygonObjectsCount","polygonRingsCount","polygonFeaturesCount","hasGlobalId","coordLength","GlobalFeatureIdsDataType","length","Uint32Array","Uint16Array","points","positions","globalFeatureIds","featureIds","numericProps","fields","lines","pathIndices","polygons","polygonIndices","primitivePolygonIndices","triangles","object","propName","indexMap","pointPosition","pointFeature","linePosition","linePath","lineFeature","polygonPosition","polygonObject","polygonRing","polygonFeature","geometry","type","handlePoint","push","keepStringProperties","id","handleLineString","handlePolygon","Error","makeAccessorObjects","set","data","nPositions","fillNumericProperties","fill","i","il","start","end","l","ll","startPosition","areas","nextLines","endPosition","triangulatePolygon","polygonPositions","subarray","offset","holes","slice","map","n","indices","t","tl","returnObj","value","size","geomType","numericProp","index","numericPropName","numericKeys","props","includes","x","Number","isFinite"],"mappings":"AACA,SAAQA,MAAR,QAAqB,kBAArB;AAwBA,OAAO,SAASC,gBAAT,CACLC,QADK,EAELC,aAFK,EAGLC,OAHK,EAIL;AACA,SAAOC,UAAU,CAACH,QAAD,EAAWC,aAAX,EAA0B;AACzCG,IAAAA,eAAe,EAAEF,OAAO,GAAGA,OAAO,CAACE,eAAX,GAA6BC,sBAAsB,CAACL,QAAD,CADlC;AAEzCM,IAAAA,gBAAgB,EAAEJ,OAAO,GAAGA,OAAO,CAACI,gBAAX,GAA8BC;AAFd,GAA1B,CAAjB;AAID;AAED,OAAO,MAAMC,YAAY,GAAG;AAC1BH,EAAAA,sBAD0B;AAE1BF,EAAAA;AAF0B,CAArB;;AAWP,SAASE,sBAAT,CAAgCL,QAAhC,EAA4E;AAC1E,QAAMI,eAAe,GAAG,EAAxB;;AACA,OAAK,MAAMK,OAAX,IAAsBT,QAAtB,EAAgC;AAC9B,QAAIS,OAAO,CAACC,UAAZ,EAAwB;AACtB,WAAK,MAAMC,GAAX,IAAkBF,OAAO,CAACC,UAA1B,EAAsC;AAIpC,cAAME,YAAY,GAAGR,eAAe,CAACO,GAAD,CAApC;;AACA,YAAIC,YAAY,IAAIA,YAAY,KAAKC,SAArC,EAAgD;AAC9C,gBAAMC,GAAG,GAAGL,OAAO,CAACC,UAAR,CAAmBC,GAAnB,CAAZ;AACAP,UAAAA,eAAe,CAACO,GAAD,CAAf,GAAuBI,SAAS,CAACD,GAAD,CAAhC;AACD;AACF;AACF;AACF;;AAED,SAAOE,MAAM,CAACC,IAAP,CAAYb,eAAZ,EAA6Bc,MAA7B,CAAqCC,CAAD,IAAOf,eAAe,CAACe,CAAD,CAA1D,CAAP;AACD;;AAWD,SAAShB,UAAT,CACEH,QADF,EAEEC,aAFF,EAGEC,OAHF,EAIE;AACA,QAAM;AACJkB,IAAAA,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EAAd;;AACA,OAAK,MAAM5F,GAAX,IAAkBD,UAAlB,EAA8B;AAC5B,QAAI,CAAC4F,WAAW,CAACE,QAAZ,CAAqB7F,GAArB,CAAL,EAAgC;AAC9B4F,MAAAA,KAAK,CAAC5F,GAAD,CAAL,GAAaD,UAAU,CAACC,GAAD,CAAvB;AACD;AACF;;AACD,SAAO4F,KAAP;AACD;;AAED,SAASxF,SAAT,CAAmB0F,CAAnB,EAA+B;AAC7B,SAAOC,MAAM,CAACC,QAAP,CAAgBF,CAAhB,CAAP;AACD","sourcesContent":["/* eslint-disable indent */\nimport {earcut} from '@math.gl/polygon';\nimport {\n MvtBinaryCoordinates,\n MvtBinaryGeometry,\n MvtBinaryOptions,\n MvtFirstPassedData,\n MvtLines,\n MvtPoints,\n MvtPolygons\n} from '../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 firstPassData\n * @param options\n * @returns filled arrays\n */\nexport function featuresToBinary(\n features: MvtBinaryCoordinates[],\n firstPassData: MvtFirstPassedData,\n options?: MvtBinaryOptions\n) {\n return fillArrays(features, firstPassData, {\n numericPropKeys: options ? options.numericPropKeys : extractNumericPropKeys(features),\n PositionDataType: options ? options.PositionDataType : Float32Array\n });\n}\n\nexport const TEST_EXPORTS = {\n extractNumericPropKeys,\n fillArrays\n};\n\n/**\n * Extracts properties that are always numeric\n *\n * @param features\n * @returns object with numeric keys\n */\nfunction extractNumericPropKeys(features: MvtBinaryCoordinates[]): string[] {\n const numericPropKeys = {};\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, false is stored to prevent rechecking in the future\n const numericSoFar = numericPropKeys[key];\n if (numericSoFar || numericSoFar === undefined) {\n const val = feature.properties[key];\n numericPropKeys[key] = isNumeric(val);\n }\n }\n }\n }\n\n return Object.keys(numericPropKeys).filter((k) => numericPropKeys[k]);\n}\n\n/**\n * Fills coordinates into pre-allocated typed arrays\n *\n * @param features\n * @param firstPassData\n * @param options\n * @returns an accessor object with value and size keys\n */\n// eslint-disable-next-line complexity\nfunction fillArrays(\n features: MvtBinaryCoordinates[],\n firstPassData: MvtFirstPassedData,\n options: MvtBinaryOptions\n) {\n const {\n pointPositionsCount,\n pointFeaturesCount,\n linePositionsCount,\n linePathsCount,\n lineFeaturesCount,\n polygonPositionsCount,\n polygonObjectsCount,\n polygonRingsCount,\n polygonFeaturesCount\n } = firstPassData;\n const {numericPropKeys, PositionDataType = Float32Array} = options;\n const hasGlobalId = features[0] && 'id' in features[0];\n const coordLength = 2;\n const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;\n const points: MvtPoints = {\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: MvtLines = {\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: MvtPolygons = {\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 triangles: [],\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 // 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 object.numericProps[propName] = new Float32Array(object.positions.length / coordLength);\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 case 'MultiPoint':\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 case 'MultiLineString':\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 case 'MultiPolygon':\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: MvtBinaryGeometry,\n points: MvtPoints,\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: MvtBinaryGeometry,\n lines: MvtLines,\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.lines.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.lines[i];\n const end =\n i === il - 1\n ? geometry.data.length // last line, so read to end of data\n : geometry.lines[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: MvtBinaryGeometry,\n polygons: MvtPolygons,\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.lines is a 2D array\n for (let l = 0, ll = geometry.lines.length; l < ll; ++l) {\n const startPosition = indexMap.polygonPosition;\n polygons.polygonIndices[indexMap.polygonObject++] = startPosition;\n\n const areas = geometry.areas![l];\n const lines = geometry.lines[l];\n const nextLines = geometry.lines[l + 1];\n\n for (let i = 0, il = lines.length; i < il; ++i) {\n const start = lines[i];\n const end =\n i === il - 1\n ? // last line, so either read to:\n nextLines === undefined\n ? geometry.data.length // end of data (no next lines)\n : nextLines[0] // start of first line in nextLines\n : lines[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, lines, {startPosition, endPosition, coordLength});\n }\n}\n\n/**\n * Triangulate polygon using earcut\n *\n * @param polygons\n * @param areas\n * @param lines\n * @param param3\n */\nfunction triangulatePolygon(\n polygons: MvtPolygons,\n areas: number,\n lines: number[],\n {\n startPosition,\n endPosition,\n coordLength\n }: {startPosition: number; endPosition: number; coordLength: number}\n): void {\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 = lines[0];\n const holes = lines.slice(1).map((n: number) => (n - offset) / coordLength);\n\n // Compute triangulation\n const indices = 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 = indices.length; t < tl; ++t) {\n polygons.triangles.push(startPosition + indices[t]);\n }\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: MvtPoints,\n lines: MvtLines,\n polygons: MvtPolygons,\n coordLength: number\n) {\n const returnObj = {\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 },\n lines: {\n ...lines,\n pathIndices: {value: lines.pathIndices, size: 1},\n positions: {value: lines.positions, size: coordLength},\n globalFeatureIds: {value: lines.globalFeatureIds, size: 1},\n featureIds: {value: lines.featureIds, size: 1}\n },\n polygons: {\n ...polygons,\n polygonIndices: {value: polygons.polygonIndices, size: 1},\n primitivePolygonIndices: {value: polygons.primitivePolygonIndices, size: 1},\n positions: {value: polygons.positions, size: coordLength},\n triangles: {value: new Uint32Array(polygons.triangles), size: 1},\n globalFeatureIds: {value: polygons.globalFeatureIds, size: 1},\n featureIds: {value: polygons.featureIds, size: 1}\n }\n };\n\n for (const geomType in returnObj) {\n for (const numericProp in returnObj[geomType].numericProps) {\n returnObj[geomType].numericProps[numericProp] = {\n value: returnObj[geomType].numericProps[numericProp],\n size: 1\n };\n }\n }\n return returnObj;\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: MvtPoints,\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 object.numericProps[numericPropName].fill(properties[numericPropName], 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\nfunction isNumeric(x: unknown) {\n return Number.isFinite(x);\n}\n"],"file":"features-to-binary.js"}
|
|
@@ -1,518 +0,0 @@
|
|
|
1
|
-
/* eslint-disable indent */
|
|
2
|
-
import {earcut} from '@math.gl/polygon';
|
|
3
|
-
import {
|
|
4
|
-
MvtBinaryCoordinates,
|
|
5
|
-
MvtBinaryGeometry,
|
|
6
|
-
MvtBinaryOptions,
|
|
7
|
-
MvtFirstPassedData,
|
|
8
|
-
MvtLines,
|
|
9
|
-
MvtPoints,
|
|
10
|
-
MvtPolygons
|
|
11
|
-
} from '../types';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Convert binary features to flat binary arrays. Similar to
|
|
15
|
-
* `geojsonToBinary` helper function, except that it expects
|
|
16
|
-
* a binary representation of the feature data, which enables
|
|
17
|
-
* 2X-3X speed increase in parse speed, compared to using
|
|
18
|
-
* geoJSON. See `binary-vector-tile/VectorTileFeature` for
|
|
19
|
-
* data format detais
|
|
20
|
-
*
|
|
21
|
-
* @param features
|
|
22
|
-
* @param firstPassData
|
|
23
|
-
* @param options
|
|
24
|
-
* @returns filled arrays
|
|
25
|
-
*/
|
|
26
|
-
export function featuresToBinary(
|
|
27
|
-
features: MvtBinaryCoordinates[],
|
|
28
|
-
firstPassData: MvtFirstPassedData,
|
|
29
|
-
options?: MvtBinaryOptions
|
|
30
|
-
) {
|
|
31
|
-
return fillArrays(features, firstPassData, {
|
|
32
|
-
numericPropKeys: options ? options.numericPropKeys : extractNumericPropKeys(features),
|
|
33
|
-
PositionDataType: options ? options.PositionDataType : Float32Array
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const TEST_EXPORTS = {
|
|
38
|
-
extractNumericPropKeys,
|
|
39
|
-
fillArrays
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Extracts properties that are always numeric
|
|
44
|
-
*
|
|
45
|
-
* @param features
|
|
46
|
-
* @returns object with numeric keys
|
|
47
|
-
*/
|
|
48
|
-
function extractNumericPropKeys(features: MvtBinaryCoordinates[]): string[] {
|
|
49
|
-
const numericPropKeys = {};
|
|
50
|
-
for (const feature of features) {
|
|
51
|
-
if (feature.properties) {
|
|
52
|
-
for (const key in feature.properties) {
|
|
53
|
-
// If property has not been seen before, or if property has been numeric
|
|
54
|
-
// in all previous features, check if numeric in this feature
|
|
55
|
-
// If not numeric, false is stored to prevent rechecking in the future
|
|
56
|
-
const numericSoFar = numericPropKeys[key];
|
|
57
|
-
if (numericSoFar || numericSoFar === undefined) {
|
|
58
|
-
const val = feature.properties[key];
|
|
59
|
-
numericPropKeys[key] = isNumeric(val);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return Object.keys(numericPropKeys).filter((k) => numericPropKeys[k]);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Fills coordinates into pre-allocated typed arrays
|
|
70
|
-
*
|
|
71
|
-
* @param features
|
|
72
|
-
* @param firstPassData
|
|
73
|
-
* @param options
|
|
74
|
-
* @returns an accessor object with value and size keys
|
|
75
|
-
*/
|
|
76
|
-
// eslint-disable-next-line complexity
|
|
77
|
-
function fillArrays(
|
|
78
|
-
features: MvtBinaryCoordinates[],
|
|
79
|
-
firstPassData: MvtFirstPassedData,
|
|
80
|
-
options: MvtBinaryOptions
|
|
81
|
-
) {
|
|
82
|
-
const {
|
|
83
|
-
pointPositionsCount,
|
|
84
|
-
pointFeaturesCount,
|
|
85
|
-
linePositionsCount,
|
|
86
|
-
linePathsCount,
|
|
87
|
-
lineFeaturesCount,
|
|
88
|
-
polygonPositionsCount,
|
|
89
|
-
polygonObjectsCount,
|
|
90
|
-
polygonRingsCount,
|
|
91
|
-
polygonFeaturesCount
|
|
92
|
-
} = firstPassData;
|
|
93
|
-
const {numericPropKeys, PositionDataType = Float32Array} = options;
|
|
94
|
-
const hasGlobalId = features[0] && 'id' in features[0];
|
|
95
|
-
const coordLength = 2;
|
|
96
|
-
const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
|
|
97
|
-
const points: MvtPoints = {
|
|
98
|
-
positions: new PositionDataType(pointPositionsCount * coordLength),
|
|
99
|
-
globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),
|
|
100
|
-
featureIds:
|
|
101
|
-
pointFeaturesCount > 65535
|
|
102
|
-
? new Uint32Array(pointPositionsCount)
|
|
103
|
-
: new Uint16Array(pointPositionsCount),
|
|
104
|
-
numericProps: {},
|
|
105
|
-
properties: [],
|
|
106
|
-
fields: []
|
|
107
|
-
};
|
|
108
|
-
const lines: MvtLines = {
|
|
109
|
-
pathIndices:
|
|
110
|
-
linePositionsCount > 65535
|
|
111
|
-
? new Uint32Array(linePathsCount + 1)
|
|
112
|
-
: new Uint16Array(linePathsCount + 1),
|
|
113
|
-
positions: new PositionDataType(linePositionsCount * coordLength),
|
|
114
|
-
globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),
|
|
115
|
-
featureIds:
|
|
116
|
-
lineFeaturesCount > 65535
|
|
117
|
-
? new Uint32Array(linePositionsCount)
|
|
118
|
-
: new Uint16Array(linePositionsCount),
|
|
119
|
-
numericProps: {},
|
|
120
|
-
properties: [],
|
|
121
|
-
fields: []
|
|
122
|
-
};
|
|
123
|
-
const polygons: MvtPolygons = {
|
|
124
|
-
polygonIndices:
|
|
125
|
-
polygonPositionsCount > 65535
|
|
126
|
-
? new Uint32Array(polygonObjectsCount + 1)
|
|
127
|
-
: new Uint16Array(polygonObjectsCount + 1),
|
|
128
|
-
primitivePolygonIndices:
|
|
129
|
-
polygonPositionsCount > 65535
|
|
130
|
-
? new Uint32Array(polygonRingsCount + 1)
|
|
131
|
-
: new Uint16Array(polygonRingsCount + 1),
|
|
132
|
-
positions: new PositionDataType(polygonPositionsCount * coordLength),
|
|
133
|
-
triangles: [],
|
|
134
|
-
globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),
|
|
135
|
-
featureIds:
|
|
136
|
-
polygonFeaturesCount > 65535
|
|
137
|
-
? new Uint32Array(polygonPositionsCount)
|
|
138
|
-
: new Uint16Array(polygonPositionsCount),
|
|
139
|
-
numericProps: {},
|
|
140
|
-
properties: [],
|
|
141
|
-
fields: []
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
// Instantiate numeric properties arrays; one value per vertex
|
|
145
|
-
for (const object of [points, lines, polygons]) {
|
|
146
|
-
for (const propName of numericPropKeys) {
|
|
147
|
-
// If property has been numeric in all previous features in which the property existed, check
|
|
148
|
-
// if numeric in this feature
|
|
149
|
-
object.numericProps[propName] = new Float32Array(object.positions.length / coordLength);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Set last element of path/polygon indices as positions length
|
|
154
|
-
lines.pathIndices[linePathsCount] = linePositionsCount;
|
|
155
|
-
polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;
|
|
156
|
-
polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;
|
|
157
|
-
|
|
158
|
-
const indexMap = {
|
|
159
|
-
pointPosition: 0,
|
|
160
|
-
pointFeature: 0,
|
|
161
|
-
linePosition: 0,
|
|
162
|
-
linePath: 0,
|
|
163
|
-
lineFeature: 0,
|
|
164
|
-
polygonPosition: 0,
|
|
165
|
-
polygonObject: 0,
|
|
166
|
-
polygonRing: 0,
|
|
167
|
-
polygonFeature: 0,
|
|
168
|
-
feature: 0
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
for (const feature of features) {
|
|
172
|
-
const geometry = feature.geometry;
|
|
173
|
-
const properties = feature.properties || {};
|
|
174
|
-
|
|
175
|
-
switch (geometry.type) {
|
|
176
|
-
case 'Point':
|
|
177
|
-
case 'MultiPoint':
|
|
178
|
-
handlePoint(geometry, points, indexMap, coordLength, properties);
|
|
179
|
-
points.properties.push(keepStringProperties(properties, numericPropKeys));
|
|
180
|
-
if (hasGlobalId) {
|
|
181
|
-
points.fields.push({id: feature.id});
|
|
182
|
-
}
|
|
183
|
-
indexMap.pointFeature++;
|
|
184
|
-
break;
|
|
185
|
-
case 'LineString':
|
|
186
|
-
case 'MultiLineString':
|
|
187
|
-
handleLineString(geometry, lines, indexMap, coordLength, properties);
|
|
188
|
-
lines.properties.push(keepStringProperties(properties, numericPropKeys));
|
|
189
|
-
if (hasGlobalId) {
|
|
190
|
-
lines.fields.push({id: feature.id});
|
|
191
|
-
}
|
|
192
|
-
indexMap.lineFeature++;
|
|
193
|
-
break;
|
|
194
|
-
case 'Polygon':
|
|
195
|
-
case 'MultiPolygon':
|
|
196
|
-
handlePolygon(geometry, polygons, indexMap, coordLength, properties);
|
|
197
|
-
polygons.properties.push(keepStringProperties(properties, numericPropKeys));
|
|
198
|
-
if (hasGlobalId) {
|
|
199
|
-
polygons.fields.push({id: feature.id});
|
|
200
|
-
}
|
|
201
|
-
indexMap.polygonFeature++;
|
|
202
|
-
break;
|
|
203
|
-
default:
|
|
204
|
-
throw new Error('Invalid geometry type');
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
indexMap.feature++;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Wrap each array in an accessor object with value and size keys
|
|
211
|
-
return makeAccessorObjects(points, lines, polygons, coordLength);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Fills (Multi)Point coordinates into points object of arrays
|
|
216
|
-
*
|
|
217
|
-
* @param geometry
|
|
218
|
-
* @param points
|
|
219
|
-
* @param indexMap
|
|
220
|
-
* @param coordLength
|
|
221
|
-
* @param properties
|
|
222
|
-
*/
|
|
223
|
-
function handlePoint(
|
|
224
|
-
geometry: MvtBinaryGeometry,
|
|
225
|
-
points: MvtPoints,
|
|
226
|
-
indexMap: {
|
|
227
|
-
pointPosition: number;
|
|
228
|
-
pointFeature: number;
|
|
229
|
-
linePosition?: number;
|
|
230
|
-
linePath?: number;
|
|
231
|
-
lineFeature?: number;
|
|
232
|
-
polygonPosition?: number;
|
|
233
|
-
polygonObject?: number;
|
|
234
|
-
polygonRing?: number;
|
|
235
|
-
polygonFeature?: number;
|
|
236
|
-
feature: number;
|
|
237
|
-
},
|
|
238
|
-
coordLength: number,
|
|
239
|
-
properties: {[x: string]: string | number | boolean | null}
|
|
240
|
-
): void {
|
|
241
|
-
points.positions.set(geometry.data, indexMap.pointPosition * coordLength);
|
|
242
|
-
|
|
243
|
-
const nPositions = geometry.data.length / coordLength;
|
|
244
|
-
fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);
|
|
245
|
-
points.globalFeatureIds.fill(
|
|
246
|
-
indexMap.feature,
|
|
247
|
-
indexMap.pointPosition,
|
|
248
|
-
indexMap.pointPosition + nPositions
|
|
249
|
-
);
|
|
250
|
-
points.featureIds.fill(
|
|
251
|
-
indexMap.pointFeature,
|
|
252
|
-
indexMap.pointPosition,
|
|
253
|
-
indexMap.pointPosition + nPositions
|
|
254
|
-
);
|
|
255
|
-
|
|
256
|
-
indexMap.pointPosition += nPositions;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Fills (Multi)LineString coordinates into lines object of arrays
|
|
261
|
-
*
|
|
262
|
-
* @param geometry
|
|
263
|
-
* @param lines
|
|
264
|
-
* @param indexMap
|
|
265
|
-
* @param coordLength
|
|
266
|
-
* @param properties
|
|
267
|
-
*/
|
|
268
|
-
function handleLineString(
|
|
269
|
-
geometry: MvtBinaryGeometry,
|
|
270
|
-
lines: MvtLines,
|
|
271
|
-
indexMap: {
|
|
272
|
-
pointPosition?: number;
|
|
273
|
-
pointFeature?: number;
|
|
274
|
-
linePosition: number;
|
|
275
|
-
linePath: number;
|
|
276
|
-
lineFeature: number;
|
|
277
|
-
polygonPosition?: number;
|
|
278
|
-
polygonObject?: number;
|
|
279
|
-
polygonRing?: number;
|
|
280
|
-
polygonFeature?: number;
|
|
281
|
-
feature: number;
|
|
282
|
-
},
|
|
283
|
-
coordLength: number,
|
|
284
|
-
properties: {[x: string]: string | number | boolean | null}
|
|
285
|
-
): void {
|
|
286
|
-
lines.positions.set(geometry.data, indexMap.linePosition * coordLength);
|
|
287
|
-
|
|
288
|
-
const nPositions = geometry.data.length / coordLength;
|
|
289
|
-
fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);
|
|
290
|
-
|
|
291
|
-
lines.globalFeatureIds.fill(
|
|
292
|
-
indexMap.feature,
|
|
293
|
-
indexMap.linePosition,
|
|
294
|
-
indexMap.linePosition + nPositions
|
|
295
|
-
);
|
|
296
|
-
lines.featureIds.fill(
|
|
297
|
-
indexMap.lineFeature,
|
|
298
|
-
indexMap.linePosition,
|
|
299
|
-
indexMap.linePosition + nPositions
|
|
300
|
-
);
|
|
301
|
-
|
|
302
|
-
for (let i = 0, il = geometry.lines.length; i < il; ++i) {
|
|
303
|
-
// Extract range of data we are working with, defined by start
|
|
304
|
-
// and end indices (these index into the geometry.data array)
|
|
305
|
-
const start = geometry.lines[i];
|
|
306
|
-
const end =
|
|
307
|
-
i === il - 1
|
|
308
|
-
? geometry.data.length // last line, so read to end of data
|
|
309
|
-
: geometry.lines[i + 1]; // start index for next line
|
|
310
|
-
|
|
311
|
-
lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;
|
|
312
|
-
indexMap.linePosition += (end - start) / coordLength;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Fills (Multi)Polygon coordinates into polygons object of arrays
|
|
318
|
-
*
|
|
319
|
-
* @param geometry
|
|
320
|
-
* @param polygons
|
|
321
|
-
* @param indexMap
|
|
322
|
-
* @param coordLength
|
|
323
|
-
* @param properties
|
|
324
|
-
*/
|
|
325
|
-
function handlePolygon(
|
|
326
|
-
geometry: MvtBinaryGeometry,
|
|
327
|
-
polygons: MvtPolygons,
|
|
328
|
-
indexMap: {
|
|
329
|
-
pointPosition?: number;
|
|
330
|
-
pointFeature?: number;
|
|
331
|
-
linePosition?: number;
|
|
332
|
-
linePath?: number;
|
|
333
|
-
lineFeature?: number;
|
|
334
|
-
polygonPosition: number;
|
|
335
|
-
polygonObject: number;
|
|
336
|
-
polygonRing: number;
|
|
337
|
-
polygonFeature: number;
|
|
338
|
-
feature: number;
|
|
339
|
-
},
|
|
340
|
-
coordLength: number,
|
|
341
|
-
properties: {[x: string]: string | number | boolean | null}
|
|
342
|
-
): void {
|
|
343
|
-
polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);
|
|
344
|
-
|
|
345
|
-
const nPositions = geometry.data.length / coordLength;
|
|
346
|
-
fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);
|
|
347
|
-
polygons.globalFeatureIds.fill(
|
|
348
|
-
indexMap.feature,
|
|
349
|
-
indexMap.polygonPosition,
|
|
350
|
-
indexMap.polygonPosition + nPositions
|
|
351
|
-
);
|
|
352
|
-
polygons.featureIds.fill(
|
|
353
|
-
indexMap.polygonFeature,
|
|
354
|
-
indexMap.polygonPosition,
|
|
355
|
-
indexMap.polygonPosition + nPositions
|
|
356
|
-
);
|
|
357
|
-
|
|
358
|
-
// Unlike Point & LineString geometry.lines is a 2D array
|
|
359
|
-
for (let l = 0, ll = geometry.lines.length; l < ll; ++l) {
|
|
360
|
-
const startPosition = indexMap.polygonPosition;
|
|
361
|
-
polygons.polygonIndices[indexMap.polygonObject++] = startPosition;
|
|
362
|
-
|
|
363
|
-
const areas = geometry.areas![l];
|
|
364
|
-
const lines = geometry.lines[l];
|
|
365
|
-
const nextLines = geometry.lines[l + 1];
|
|
366
|
-
|
|
367
|
-
for (let i = 0, il = lines.length; i < il; ++i) {
|
|
368
|
-
const start = lines[i];
|
|
369
|
-
const end =
|
|
370
|
-
i === il - 1
|
|
371
|
-
? // last line, so either read to:
|
|
372
|
-
nextLines === undefined
|
|
373
|
-
? geometry.data.length // end of data (no next lines)
|
|
374
|
-
: nextLines[0] // start of first line in nextLines
|
|
375
|
-
: lines[i + 1]; // start index for next line
|
|
376
|
-
|
|
377
|
-
polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
|
|
378
|
-
indexMap.polygonPosition += (end - start) / coordLength;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
const endPosition = indexMap.polygonPosition;
|
|
382
|
-
triangulatePolygon(polygons, areas, lines, {startPosition, endPosition, coordLength});
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Triangulate polygon using earcut
|
|
388
|
-
*
|
|
389
|
-
* @param polygons
|
|
390
|
-
* @param areas
|
|
391
|
-
* @param lines
|
|
392
|
-
* @param param3
|
|
393
|
-
*/
|
|
394
|
-
function triangulatePolygon(
|
|
395
|
-
polygons: MvtPolygons,
|
|
396
|
-
areas: number,
|
|
397
|
-
lines: number[],
|
|
398
|
-
{
|
|
399
|
-
startPosition,
|
|
400
|
-
endPosition,
|
|
401
|
-
coordLength
|
|
402
|
-
}: {startPosition: number; endPosition: number; coordLength: number}
|
|
403
|
-
): void {
|
|
404
|
-
const start = startPosition * coordLength;
|
|
405
|
-
const end = endPosition * coordLength;
|
|
406
|
-
|
|
407
|
-
// Extract positions and holes for just this polygon
|
|
408
|
-
const polygonPositions = polygons.positions.subarray(start, end);
|
|
409
|
-
|
|
410
|
-
// Holes are referenced relative to outer polygon
|
|
411
|
-
const offset = lines[0];
|
|
412
|
-
const holes = lines.slice(1).map((n: number) => (n - offset) / coordLength);
|
|
413
|
-
|
|
414
|
-
// Compute triangulation
|
|
415
|
-
const indices = earcut(polygonPositions, holes, coordLength, areas);
|
|
416
|
-
|
|
417
|
-
// Indices returned by triangulation are relative to start
|
|
418
|
-
// of polygon, so we need to offset
|
|
419
|
-
for (let t = 0, tl = indices.length; t < tl; ++t) {
|
|
420
|
-
polygons.triangles.push(startPosition + indices[t]);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
/**
|
|
425
|
-
* Wrap each array in an accessor object with value and size keys
|
|
426
|
-
*
|
|
427
|
-
* @param points
|
|
428
|
-
* @param lines
|
|
429
|
-
* @param polygons
|
|
430
|
-
* @param coordLength
|
|
431
|
-
* @returns object
|
|
432
|
-
*/
|
|
433
|
-
function makeAccessorObjects(
|
|
434
|
-
points: MvtPoints,
|
|
435
|
-
lines: MvtLines,
|
|
436
|
-
polygons: MvtPolygons,
|
|
437
|
-
coordLength: number
|
|
438
|
-
) {
|
|
439
|
-
const returnObj = {
|
|
440
|
-
points: {
|
|
441
|
-
...points,
|
|
442
|
-
positions: {value: points.positions, size: coordLength},
|
|
443
|
-
globalFeatureIds: {value: points.globalFeatureIds, size: 1},
|
|
444
|
-
featureIds: {value: points.featureIds, size: 1}
|
|
445
|
-
},
|
|
446
|
-
lines: {
|
|
447
|
-
...lines,
|
|
448
|
-
pathIndices: {value: lines.pathIndices, size: 1},
|
|
449
|
-
positions: {value: lines.positions, size: coordLength},
|
|
450
|
-
globalFeatureIds: {value: lines.globalFeatureIds, size: 1},
|
|
451
|
-
featureIds: {value: lines.featureIds, size: 1}
|
|
452
|
-
},
|
|
453
|
-
polygons: {
|
|
454
|
-
...polygons,
|
|
455
|
-
polygonIndices: {value: polygons.polygonIndices, size: 1},
|
|
456
|
-
primitivePolygonIndices: {value: polygons.primitivePolygonIndices, size: 1},
|
|
457
|
-
positions: {value: polygons.positions, size: coordLength},
|
|
458
|
-
triangles: {value: new Uint32Array(polygons.triangles), size: 1},
|
|
459
|
-
globalFeatureIds: {value: polygons.globalFeatureIds, size: 1},
|
|
460
|
-
featureIds: {value: polygons.featureIds, size: 1}
|
|
461
|
-
}
|
|
462
|
-
};
|
|
463
|
-
|
|
464
|
-
for (const geomType in returnObj) {
|
|
465
|
-
for (const numericProp in returnObj[geomType].numericProps) {
|
|
466
|
-
returnObj[geomType].numericProps[numericProp] = {
|
|
467
|
-
value: returnObj[geomType].numericProps[numericProp],
|
|
468
|
-
size: 1
|
|
469
|
-
};
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
return returnObj;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* Add numeric properties to object
|
|
477
|
-
*
|
|
478
|
-
* @param object
|
|
479
|
-
* @param properties
|
|
480
|
-
* @param index
|
|
481
|
-
* @param length
|
|
482
|
-
*/
|
|
483
|
-
function fillNumericProperties(
|
|
484
|
-
object: MvtPoints,
|
|
485
|
-
properties: {[x: string]: string | number | boolean | null},
|
|
486
|
-
index: number,
|
|
487
|
-
length: number
|
|
488
|
-
): void {
|
|
489
|
-
for (const numericPropName in object.numericProps) {
|
|
490
|
-
if (numericPropName in properties) {
|
|
491
|
-
object.numericProps[numericPropName].fill(properties[numericPropName], index, index + length);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* Keep string properties in object
|
|
498
|
-
*
|
|
499
|
-
* @param properties
|
|
500
|
-
* @param numericKeys
|
|
501
|
-
* @returns object
|
|
502
|
-
*/
|
|
503
|
-
function keepStringProperties(
|
|
504
|
-
properties: {[x: string]: string | number | boolean | null},
|
|
505
|
-
numericKeys: string[]
|
|
506
|
-
) {
|
|
507
|
-
const props = {};
|
|
508
|
-
for (const key in properties) {
|
|
509
|
-
if (!numericKeys.includes(key)) {
|
|
510
|
-
props[key] = properties[key];
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
return props;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
function isNumeric(x: unknown) {
|
|
517
|
-
return Number.isFinite(x);
|
|
518
|
-
}
|