@carto/kepler.gl 0.0.34-alpha.0 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,11 +23,10 @@ import {findDefaultColorField} from 'utils/dataset-utils';
23
23
  import {GeoJsonLayer} from '@deck.gl/layers';
24
24
  import {H3HexagonLayer} from '@deck.gl/geo-layers';
25
25
  import EnhancedColumnLayer from 'deckgl-layers/column-layer/enhanced-column-layer';
26
- import {getCentroid, idToPolygonGeo, h3IsValid, getHexFields} from './h3-utils';
26
+ import {getCentroid, idToPolygonGeo, h3IsValid, getHexFields, getVertices} from './h3-utils';
27
27
  import H3HexagonLayerIcon from './h3-hexagon-layer-icon';
28
28
  import {CHANNEL_SCALES, HIGHLIGH_COLOR_3D} from 'constants/default-settings';
29
-
30
- import {createDataContainer} from 'utils/table-utils';
29
+ import {getLatLngBounds} from 'utils/data-utils';
31
30
 
32
31
  const DEFAULT_LINE_SCALE_VALUE = 8;
33
32
 
@@ -183,22 +182,20 @@ export default class HexagonIdLayer extends Layer {
183
182
  /* eslint-enable complexity */
184
183
 
185
184
  updateLayerMeta(dataContainer, getHexId) {
186
- const centroids = dataContainer.map((d, index) => {
187
- const id = getHexId({index});
188
- if (!h3IsValid(id)) {
189
- return null;
190
- }
191
- // save a reference of centroids to dataToFeature
192
- // so we don't have to re calculate it again
193
- return getCentroid({id});
194
- }, true);
185
+ const validHexagonIds = dataContainer.map((d, index) => getHexId({index})).filter(h3IsValid);
195
186
 
196
- const centroidsDataContainer = createDataContainer(centroids);
197
-
198
- const bounds = this.getPointsBounds(centroidsDataContainer, (d, dc) => {
199
- return [dc.valueAt(d.index, 0), dc.valueAt(d.index, 1)];
200
- });
187
+ // save a reference of centroids to dataToFeature
188
+ // so we don't have to re calculate it again
189
+ const centroids = validHexagonIds.map(id => getCentroid({id}));
201
190
  this.dataToFeature = {centroids};
191
+
192
+ const vertices = validHexagonIds.map(id => getVertices({id})).flat();
193
+ // using the same way to compute bounds as in base-layer.js, even if it's complicated and not very efficient
194
+ const latBounds = getLatLngBounds(vertices, 1, [-90, 90]);
195
+ const lngBounds = getLatLngBounds(vertices, 0, [-180, 180]);
196
+
197
+ const bounds =
198
+ !latBounds || !lngBounds ? null : [lngBounds[0], latBounds[0], lngBounds[1], latBounds[1]];
202
199
  this.updateMeta({bounds});
203
200
  }
204
201