New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@deck.gl/carto

Package Overview
Dependencies
Maintainers
6
Versions
269
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@deck.gl/carto - npm Package Compare versions

Comparing version 8.8.0-alpha.3 to 8.8.0-alpha.4

dist/es5/layers/spatial-index-tile-layer.js

4

dist/es5/layers/carto-layer.js

@@ -87,3 +87,5 @@ "use strict";

value: null
}
},
aggregationExp: null,
aggregationResLevel: null
};

@@ -90,0 +92,0 @@

@@ -26,2 +26,4 @@ "use strict";

var _spatialIndexTileLayer = _interopRequireDefault(require("./spatial-index-tile-layer"));
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }

@@ -41,2 +43,6 @@

var defaultProps = {
aggregationResLevel: 4
};
var H3TileLayer = function (_CompositeLayer) {

@@ -81,4 +87,7 @@ (0, _inherits2.default)(H3TileLayer, _CompositeLayer);

value: function renderLayers() {
var data = this.state.data;
return [new _geoLayers.TileLayer(this.props, {
var _this$state = this.state,
data = _this$state.data,
tileJSON = _this$state.tileJSON;
var maxZoom = parseInt(tileJSON.maxresolution);
return [new _spatialIndexTileLayer.default(this.props, {
id: 'h3-tile-layer',

@@ -90,3 +99,4 @@ data: data,

TilesetClass: _h3Tileset2d.default,
renderSubLayers: renderSubLayers
renderSubLayers: renderSubLayers,
maxZoom: maxZoom
})];

@@ -100,2 +110,3 @@ }

H3TileLayer.layerName = 'H3TileLayer';
H3TileLayer.defaultProps = defaultProps;
//# sourceMappingURL=h3-tile-layer.js.map

@@ -8,4 +8,2 @@ "use strict";

});
exports.getHexagonsInBoundingBox = getHexagonsInBoundingBox;
exports.tileToBoundingBox = tileToBoundingBox;
exports.default = void 0;

@@ -59,3 +57,3 @@

var oversample = 1;
var oversample = 2;
var h3Indices = (0, _h3Js.polyfill)([[[west, north], [west, south], [east, south], [east, north], [west, north]]], resolution + oversample, true);

@@ -87,2 +85,10 @@ return oversample ? (0, _toConsumableArray2.default)(new Set(h3Indices.map(function (i) {

var BIAS = 2;
function getHexagonResolution(viewport) {
var hexagonScaleFactor = 2 / 3 * viewport.zoom;
var latitudeScaleFactor = Math.log(1 / Math.cos(Math.PI * viewport.latitude / 180));
return Math.max(0, Math.floor(hexagonScaleFactor + latitudeScaleFactor - BIAS));
}
var H3Tileset2D = function (_Tileset2D) {

@@ -112,3 +118,4 @@ (0, _inherits2.default)(H3Tileset2D, _Tileset2D);

var z = viewport.zoom;
var z = getHexagonResolution(viewport);
var indices = [];

@@ -121,11 +128,14 @@ if (typeof minZoom === 'number' && Number.isFinite(minZoom) && z < minZoom) {

z = maxZoom;
var center = (0, _h3Js.geoToH3)(viewport.latitude, viewport.longitude, maxZoom);
indices = (0, _h3Js.kRing)(center, 1);
} else {
indices = getHexagonsInBoundingBox({
west: west,
north: north,
east: east,
south: south
}, z);
}
var resolution = Math.max(0, Math.floor(2 * z / 3) - 2);
return getHexagonsInBoundingBox({
west: west,
north: north,
east: east,
south: south
}, resolution).map(function (i) {
return indices.map(function (i) {
return {

@@ -132,0 +142,0 @@ i: i

@@ -26,2 +26,4 @@ "use strict";

var _spatialIndexTileLayer = _interopRequireDefault(require("./spatial-index-tile-layer"));
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }

@@ -37,2 +39,6 @@

var defaultProps = {
aggregationResLevel: 6
};
var QuadkeyTileLayer = function (_CompositeLayer) {

@@ -80,5 +86,4 @@ (0, _inherits2.default)(QuadkeyTileLayer, _CompositeLayer);

tileJSON = _this$state.tileJSON;
var maxresolution = tileJSON.maxresolution;
var maxZoom = maxresolution - this.props.aggregationResLevel;
return [new _geoLayers.TileLayer(this.props, {
var maxZoom = parseInt(tileJSON.maxresolution);
return [new _spatialIndexTileLayer.default(this.props, {
id: 'quadkey-tile-layer',

@@ -100,2 +105,3 @@ data: data,

QuadkeyTileLayer.layerName = 'QuadkeyTileLayer';
QuadkeyTileLayer.defaultProps = defaultProps;
//# sourceMappingURL=quadkey-tile-layer.js.map

@@ -36,3 +36,5 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

value: null
}
},
aggregationExp: null,
aggregationResLevel: null
};

@@ -39,0 +41,0 @@ export default class CartoLayer extends CompositeLayer {

import { CompositeLayer } from '@deck.gl/core';
import { H3HexagonLayer, TileLayer } from '@deck.gl/geo-layers';
import { H3HexagonLayer } from '@deck.gl/geo-layers';
import H3Tileset2D from './h3-tileset-2d';
import SpatialIndexTileLayer from './spatial-index-tile-layer';

@@ -19,2 +20,5 @@ const renderSubLayers = props => {

const defaultProps = {
aggregationResLevel: 4
};
export default class H3TileLayer extends CompositeLayer {

@@ -49,5 +53,7 @@ initializeState() {

const {
data
data,
tileJSON
} = this.state;
return [new TileLayer(this.props, {
const maxZoom = parseInt(tileJSON.maxresolution);
return [new SpatialIndexTileLayer(this.props, {
id: 'h3-tile-layer',

@@ -57,3 +63,4 @@ data,

TilesetClass: H3Tileset2D,
renderSubLayers
renderSubLayers,
maxZoom
})];

@@ -64,2 +71,3 @@ }

H3TileLayer.layerName = 'H3TileLayer';
H3TileLayer.defaultProps = defaultProps;
//# sourceMappingURL=h3-tile-layer.js.map
import { _Tileset2D as Tileset2D } from '@deck.gl/geo-layers';
import { polyfill, getRes0Indexes, h3GetResolution, h3ToGeoBoundary, h3ToParent } from 'h3-js';
export function getHexagonsInBoundingBox({
import { polyfill, getRes0Indexes, geoToH3, h3GetResolution, h3ToGeoBoundary, h3ToParent, kRing } from 'h3-js';
function getHexagonsInBoundingBox({
west,

@@ -27,7 +28,8 @@ north,

const oversample = 1;
const oversample = 2;
const h3Indices = polyfill([[[west, north], [west, south], [east, south], [east, north], [west, north]]], resolution + oversample, true);
return oversample ? [...new Set(h3Indices.map(i => h3ToParent(i, resolution)))] : h3Indices;
}
export function tileToBoundingBox(index) {
function tileToBoundingBox(index) {
const coordinates = h3ToGeoBoundary(index);

@@ -47,2 +49,11 @@ const latitudes = coordinates.map(c => c[0]);

}
const BIAS = 2;
function getHexagonResolution(viewport) {
const hexagonScaleFactor = 2 / 3 * viewport.zoom;
const latitudeScaleFactor = Math.log(1 / Math.cos(Math.PI * viewport.latitude / 180));
return Math.max(0, Math.floor(hexagonScaleFactor + latitudeScaleFactor - BIAS));
}
export default class H3Tileset2D extends Tileset2D {

@@ -55,3 +66,4 @@ getTileIndices({

const [east, south, west, north] = viewport.getBounds();
let z = viewport.zoom;
let z = getHexagonResolution(viewport);
let indices = [];

@@ -64,11 +76,14 @@ if (typeof minZoom === 'number' && Number.isFinite(minZoom) && z < minZoom) {

z = maxZoom;
const center = geoToH3(viewport.latitude, viewport.longitude, maxZoom);
indices = kRing(center, 1);
} else {
indices = getHexagonsInBoundingBox({
west,
north,
east,
south
}, z);
}
const resolution = Math.max(0, Math.floor(2 * z / 3) - 2);
return getHexagonsInBoundingBox({
west,
north,
east,
south
}, resolution).map(i => ({
return indices.map(i => ({
i

@@ -75,0 +90,0 @@ }));

import { CompositeLayer } from '@deck.gl/core';
import { QuadkeyLayer, TileLayer } from '@deck.gl/geo-layers';
import { QuadkeyLayer } from '@deck.gl/geo-layers';
import QuadkeyTileset2D from './quadkey-tileset-2d';
import SpatialIndexTileLayer from './spatial-index-tile-layer';

@@ -13,2 +14,5 @@ const renderSubLayers = props => {

const defaultProps = {
aggregationResLevel: 6
};
export default class QuadkeyTileLayer extends CompositeLayer {

@@ -46,7 +50,4 @@ initializeState() {

} = this.state;
const {
maxresolution
} = tileJSON;
const maxZoom = maxresolution - this.props.aggregationResLevel;
return [new TileLayer(this.props, {
const maxZoom = parseInt(tileJSON.maxresolution);
return [new SpatialIndexTileLayer(this.props, {
id: 'quadkey-tile-layer',

@@ -63,2 +64,3 @@ data,

QuadkeyTileLayer.layerName = 'QuadkeyTileLayer';
QuadkeyTileLayer.defaultProps = defaultProps;
//# sourceMappingURL=quadkey-tile-layer.js.map

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "8.8.0-alpha.3",
"version": "8.8.0-alpha.4",
"publishConfig": {

@@ -62,3 +62,3 @@ "access": "public"

},
"gitHead": "edad7cf75b75a137d63ec89d2d644727d3082e25"
"gitHead": "608c74fff3c955142c4e1f5e77b9e21ebbf690f7"
}

@@ -60,3 +60,9 @@ import {CompositeLayer, Layer, log} from '@deck.gl/core';

// (Array<String>, optional): names of columns to fetch. By default, all columns are fetched.
columns: {type: 'array', value: null}
columns: {type: 'array', value: null},
// (String, optional): aggregration SQL expression. Only used for spatial index datasets
aggregationExp: null,
// (Number, optional): aggregration resolution level. Only used for spatial index datasets, defaults to 6 for quadkeys, 4 for h3
aggregationResLevel: null
};

@@ -63,0 +69,0 @@

import {CompositeLayer} from '@deck.gl/core';
import {H3HexagonLayer, TileLayer} from '@deck.gl/geo-layers';
import {H3HexagonLayer} from '@deck.gl/geo-layers';
import H3Tileset2D from './h3-tileset-2d';
import SpatialIndexTileLayer from './spatial-index-tile-layer';

@@ -16,2 +17,6 @@ const renderSubLayers = props => {

const defaultProps = {
aggregationResLevel: 4
};
export default class H3TileLayer extends CompositeLayer {

@@ -32,5 +37,6 @@ initializeState() {

renderLayers() {
const {data} = this.state;
const {data, tileJSON} = this.state;
const maxZoom = parseInt(tileJSON.maxresolution);
return [
new TileLayer(this.props, {
new SpatialIndexTileLayer(this.props, {
id: 'h3-tile-layer',

@@ -40,3 +46,4 @@ data,

TilesetClass: H3Tileset2D,
renderSubLayers
renderSubLayers,
maxZoom
})

@@ -48,1 +55,2 @@ ];

H3TileLayer.layerName = 'H3TileLayer';
H3TileLayer.defaultProps = defaultProps;
import {_Tileset2D as Tileset2D} from '@deck.gl/geo-layers';
import {polyfill, getRes0Indexes, h3GetResolution, h3ToGeoBoundary, h3ToParent} from 'h3-js';
import {
polyfill,
getRes0Indexes,
geoToH3,
h3GetResolution,
h3ToGeoBoundary,
h3ToParent,
kRing
} from 'h3-js';
export function getHexagonsInBoundingBox({west, north, east, south}, resolution) {
function getHexagonsInBoundingBox({west, north, east, south}, resolution) {
if (resolution === 0) {

@@ -18,3 +26,3 @@ return getRes0Indexes();

// prematurely. Get more accurate coverage by oversampling
const oversample = 1;
const oversample = 2;
const h3Indices = polyfill(

@@ -37,3 +45,3 @@ [

export function tileToBoundingBox(index) {
function tileToBoundingBox(index) {
const coordinates = h3ToGeoBoundary(index);

@@ -49,2 +57,15 @@ const latitudes = coordinates.map(c => c[0]);

// Resolution conversion function. Takes a WebMercatorViewport and returns
// a H3 resolution such that the screen space size of the hexagons is
// similar
// Relative scale factor (0 = no biasing, 2 = a few hexagons cover view)
const BIAS = 2;
function getHexagonResolution(viewport) {
const hexagonScaleFactor = (2 / 3) * viewport.zoom;
const latitudeScaleFactor = Math.log(1 / Math.cos((Math.PI * viewport.latitude) / 180));
// Clip and bias
return Math.max(0, Math.floor(hexagonScaleFactor + latitudeScaleFactor - BIAS));
}
export default class H3Tileset2D extends Tileset2D {

@@ -54,4 +75,4 @@ getTileIndices({viewport, minZoom, maxZoom}) {

// TODO ignores extent
let z = viewport.zoom;
let z = getHexagonResolution(viewport);
let indices = [];
if (typeof minZoom === 'number' && Number.isFinite(minZoom) && z < minZoom) {

@@ -62,7 +83,12 @@ z = minZoom;

z = maxZoom;
// Once we are at max zoom, getHexagonsInBoundingBox doesn't work, simply
// get a ring centered on the hexagon in the viewport center
const center = geoToH3(viewport.latitude, viewport.longitude, maxZoom);
indices = kRing(center, 1);
} else {
indices = getHexagonsInBoundingBox({west, north, east, south}, z);
}
// Heuristic to get h3 resolution
const resolution = Math.max(0, Math.floor((2 * z) / 3) - 2);
return getHexagonsInBoundingBox({west, north, east, south}, resolution).map(i => ({i}));
return indices.map(i => ({i}));
}

@@ -69,0 +95,0 @@

import {CompositeLayer} from '@deck.gl/core';
import {QuadkeyLayer, TileLayer} from '@deck.gl/geo-layers';
import {QuadkeyLayer} from '@deck.gl/geo-layers';
import QuadkeyTileset2D from './quadkey-tileset-2d';
import SpatialIndexTileLayer from './spatial-index-tile-layer';

@@ -11,2 +12,6 @@ const renderSubLayers = props => {

const defaultProps = {
aggregationResLevel: 6
};
export default class QuadkeyTileLayer extends CompositeLayer {

@@ -28,6 +33,5 @@ initializeState() {

const {data, tileJSON} = this.state;
const {maxresolution} = tileJSON;
const maxZoom = maxresolution - this.props.aggregationResLevel;
const maxZoom = parseInt(tileJSON.maxresolution);
return [
new TileLayer(this.props, {
new SpatialIndexTileLayer(this.props, {
id: 'quadkey-tile-layer',

@@ -45,1 +49,2 @@ data,

QuadkeyTileLayer.layerName = 'QuadkeyTileLayer';
QuadkeyTileLayer.defaultProps = defaultProps;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc