kepler.gl
Version:
kepler.gl is a webgl based application to visualize large scale location data in the browser
42 lines (39 loc) • 5.83 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.pointToPolygonGeo = pointToPolygonGeo;
var _core = require("@deck.gl/core");
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
/**
* top left of the grid to a square polygon for the hover layer
* and current latitude
* @param object
* @param cellSize
* @param coverage
* @param properties
* @param mapState
* @returns - geojson feature
*/
// TODO: TEST
function pointToPolygonGeo(_ref) {
var object = _ref.object,
cellSize = _ref.cellSize,
coverage = _ref.coverage,
properties = _ref.properties,
mapState = _ref.mapState;
var position = object.position;
var viewport = new _core.WebMercatorViewport(mapState);
if (!position) {
return null;
}
return {
geometry: {
coordinates: [viewport.addMetersToLngLat(position, [cellSize * (0.5 - coverage / 2), cellSize * (0.5 - coverage / 2)]), viewport.addMetersToLngLat(position, [cellSize * (0.5 + coverage / 2), cellSize * (0.5 - coverage / 2)]), viewport.addMetersToLngLat(position, [cellSize * (0.5 + coverage / 2), cellSize * (0.5 + coverage / 2)]), viewport.addMetersToLngLat(position, [cellSize * (0.5 - coverage / 2), cellSize * (0.5 + coverage / 2)]), viewport.addMetersToLngLat(position, [cellSize * (0.5 - coverage / 2), cellSize * (0.5 - coverage / 2)])],
type: 'LineString'
},
properties: properties
};
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfY29yZSIsInJlcXVpcmUiLCJwb2ludFRvUG9seWdvbkdlbyIsIl9yZWYiLCJvYmplY3QiLCJjZWxsU2l6ZSIsImNvdmVyYWdlIiwicHJvcGVydGllcyIsIm1hcFN0YXRlIiwicG9zaXRpb24iLCJ2aWV3cG9ydCIsIldlYk1lcmNhdG9yVmlld3BvcnQiLCJnZW9tZXRyeSIsImNvb3JkaW5hdGVzIiwiYWRkTWV0ZXJzVG9MbmdMYXQiLCJ0eXBlIl0sInNvdXJjZXMiOlsiLi4vLi4vc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