kepler.gl
Version:
kepler.gl is a webgl based application to visualize large scale location data in the browser
26 lines (24 loc) • 3.6 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getPositionFromHexValue = getPositionFromHexValue;
exports.maybeHexToGeo = maybeHexToGeo;
var _h3Js = require("h3-js");
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
function getPositionFromHexValue(token) {
var pos = (0, _h3Js.h3ToGeo)(token);
if (Array.isArray(pos) && pos.every(Number.isFinite)) {
return [pos[1], pos[0]];
}
return null;
}
function maybeHexToGeo(dc, d, lat, lng) {
// lat or lng column could be hex column
// we assume string value is hex and try to convert it to geo lat lng
var latVal = dc.valueAt(d.index, lat.fieldIdx);
var lngVal = dc.valueAt(d.index, lng.fieldIdx);
return typeof latVal === 'string' ? getPositionFromHexValue(latVal) : typeof lngVal === 'string' ? getPositionFromHexValue(lngVal) : null;
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfaDNKcyIsInJlcXVpcmUiLCJnZXRQb3NpdGlvbkZyb21IZXhWYWx1ZSIsInRva2VuIiwicG9zIiwiaDNUb0dlbyIsIkFycmF5IiwiaXNBcnJheSIsImV2ZXJ5IiwiTnVtYmVyIiwiaXNGaW5pdGUiLCJtYXliZUhleFRvR2VvIiwiZGMiLCJkIiwibGF0IiwibG5nIiwibGF0VmFsIiwidmFsdWVBdCIsImluZGV4IiwiZmllbGRJZHgiLCJsbmdWYWwiXSwic291cmNlcyI6WyIuLi9zcmMvcG9zaXRpb24tdXRpbHMudHMiXSwic291cmNlc0NvbnRlbnQiOlsiLy8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVFxuLy8gQ29weXJpZ2h0IGNvbnRyaWJ1dG9ycyB0byB0aGUga2VwbGVyLmdsIHByb2plY3RcblxuaW1wb3J0IHtoM1RvR2VvfSBmcm9tICdoMy1qcyc7XG5cbmltcG9ydCB7TGF5ZXJDb2x1bW59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