UNPKG

@deck.gl/layers

Version:

deck.gl core layers

48 lines 1.7 kB
// deck.gl // SPDX-License-Identifier: MIT // Copyright (c) vis.gl contributors /** * Return the feature for an accesor */ export function binaryToFeatureForAccesor(data, index) { if (!data) { return null; } const featureIndex = 'startIndices' in data ? data.startIndices[index] : index; const geometryIndex = data.featureIds.value[featureIndex]; if (featureIndex !== -1) { return getPropertiesForIndex(data, geometryIndex, featureIndex); } return null; } function getPropertiesForIndex(data, propertiesIndex, numericPropsIndex) { const feature = { properties: { ...data.properties[propertiesIndex] } }; for (const prop in data.numericProps) { feature.properties[prop] = data.numericProps[prop].value[numericPropsIndex]; } return feature; } // Custom picking color to keep binary indexes export function calculatePickingColors(geojsonBinary, encodePickingColor) { const pickingColors = { points: null, lines: null, polygons: null }; for (const key in pickingColors) { const featureIds = geojsonBinary[key].globalFeatureIds.value; pickingColors[key] = new Uint8ClampedArray(featureIds.length * 4); const pickingColor = []; for (let i = 0; i < featureIds.length; i++) { encodePickingColor(featureIds[i], pickingColor); pickingColors[key][i * 4 + 0] = pickingColor[0]; pickingColors[key][i * 4 + 1] = pickingColor[1]; pickingColors[key][i * 4 + 2] = pickingColor[2]; pickingColors[key][i * 4 + 3] = 255; } } return pickingColors; } //# sourceMappingURL=geojson-binary.js.map