UNPKG

kepler.gl

Version:

kepler.gl is a webgl based application to visualize large scale location data in the browser

63 lines (60 loc) 5.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCentroid = getCentroid; exports.getHexFields = void 0; exports.getVertices = getVertices; Object.defineProperty(exports, "h3GetResolution", { enumerable: true, get: function get() { return _h3Js.h3GetResolution; } }); Object.defineProperty(exports, "h3IsValid", { enumerable: true, get: function get() { return _h3Js.h3IsValid; } }); exports.idToPolygonGeo = idToPolygonGeo; exports.isHexField = void 0; var _h3Js = require("h3-js"); var _constants = require("@kepler.gl/constants"); // SPDX-License-Identifier: MIT // Copyright contributors to the kepler.gl project // get vertices should return [lon, lat] function getVertices(_ref) { var id = _ref.id; // always reverse it return (0, _h3Js.h3ToGeoBoundary)(id, true); } // get centroid should return [lon, lat] function getCentroid(_ref2) { var id = _ref2.id; // always reverse it to [lng, lat] return (0, _h3Js.h3ToGeo)(id).reverse(); } function idToPolygonGeo(object, properties) { if (!(object !== null && object !== void 0 && object.id)) { return null; } var vertices = getVertices(object); return { type: 'Feature', geometry: { coordinates: properties !== null && properties !== void 0 && properties.isClosed ? [vertices] : vertices, type: properties !== null && properties !== void 0 && properties.isClosed ? 'Polygon' : 'LineString' }, properties: properties }; } var isHexField = exports.isHexField = function isHexField(field, _fieldIdx, _dataContainer) { return field.type === _constants.ALL_FIELD_TYPES.h3; }; var getHexFields = exports.getHexFields = function getHexFields(fields, dataContainer) { return fields.filter(function (f, i) { return isHexField(f, i, dataContainer); }); }; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfaDNKcyIsInJlcXVpcmUiLCJfY29uc3RhbnRzIiwiZ2V0VmVydGljZXMiLCJfcmVmIiwiaWQiLCJoM1RvR2VvQm91bmRhcnkiLCJnZXRDZW50cm9pZCIsIl9yZWYyIiwiaDNUb0dlbyIsInJldmVyc2UiLCJpZFRvUG9seWdvbkdlbyIsIm9iamVjdCIsInByb3Bl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