@deck.gl/geo-layers 8.6.3 → 8.7.0-alpha.1

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.
Files changed (40) hide show
  1. package/dist/dist.dev.js +1449 -1449
  2. package/dist/es5/great-circle-layer/great-circle-layer.js +26 -1
  3. package/dist/es5/great-circle-layer/great-circle-layer.js.map +1 -1
  4. package/dist/es5/h3-layers/h3-cluster-layer.js +149 -87
  5. package/dist/es5/h3-layers/h3-cluster-layer.js.map +1 -1
  6. package/dist/es5/h3-layers/h3-hexagon-layer.js +321 -226
  7. package/dist/es5/h3-layers/h3-hexagon-layer.js.map +1 -1
  8. package/dist/es5/index.js +9 -9
  9. package/dist/es5/mesh-layer/mesh-layer.js +151 -125
  10. package/dist/es5/mesh-layer/mesh-layer.js.map +1 -1
  11. package/dist/es5/mvt-layer/coordinate-transform.js +45 -19
  12. package/dist/es5/mvt-layer/coordinate-transform.js.map +1 -1
  13. package/dist/es5/mvt-layer/find-index-binary.js +45 -26
  14. package/dist/es5/mvt-layer/find-index-binary.js.map +1 -1
  15. package/dist/es5/mvt-layer/mvt-layer.js +374 -282
  16. package/dist/es5/mvt-layer/mvt-layer.js.map +1 -1
  17. package/dist/es5/s2-layer/s2-geometry.js +43 -32
  18. package/dist/es5/s2-layer/s2-geometry.js.map +1 -1
  19. package/dist/es5/s2-layer/s2-layer.js +104 -69
  20. package/dist/es5/s2-layer/s2-layer.js.map +1 -1
  21. package/dist/es5/s2-layer/s2-utils.js +27 -28
  22. package/dist/es5/s2-layer/s2-utils.js.map +1 -1
  23. package/dist/es5/terrain-layer/terrain-layer.js +254 -208
  24. package/dist/es5/terrain-layer/terrain-layer.js.map +1 -1
  25. package/dist/es5/tile-3d-layer/tile-3d-layer.js +382 -329
  26. package/dist/es5/tile-3d-layer/tile-3d-layer.js.map +1 -1
  27. package/dist/es5/tile-layer/tile-2d-header.js +183 -119
  28. package/dist/es5/tile-layer/tile-2d-header.js.map +1 -1
  29. package/dist/es5/tile-layer/tile-2d-traversal.js +178 -115
  30. package/dist/es5/tile-layer/tile-2d-traversal.js.map +1 -1
  31. package/dist/es5/tile-layer/tile-layer.js +258 -214
  32. package/dist/es5/tile-layer/tile-layer.js.map +1 -1
  33. package/dist/es5/tile-layer/tileset-2d.js +435 -290
  34. package/dist/es5/tile-layer/tileset-2d.js.map +1 -1
  35. package/dist/es5/tile-layer/utils.js +110 -61
  36. package/dist/es5/tile-layer/utils.js.map +1 -1
  37. package/dist/es5/trips-layer/trips-layer.js +81 -44
  38. package/dist/es5/trips-layer/trips-layer.js.map +1 -1
  39. package/dist.min.js +1 -1
  40. package/package.json +2 -2
@@ -7,6 +7,26 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
15
+
16
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
17
+
18
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
19
+
20
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
21
+
22
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
23
+
24
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
25
+
26
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
27
+
28
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
29
+
10
30
  var _core = require("@deck.gl/core");
11
31
 
12
32
  var _math = require("math.gl");
@@ -27,8 +47,22 @@ var _findIndexBinary = _interopRequireDefault(require("./find-index-binary"));
27
47
 
28
48
  var _layers = require("@deck.gl/layers");
29
49
 
30
- const WORLD_SIZE = 512;
31
- const defaultProps = {
50
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
51
+
52
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
53
+
54
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
55
+
56
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
57
+
58
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
59
+
60
+ 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); }; }
61
+
62
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
63
+
64
+ var WORLD_SIZE = 512;
65
+ var defaultProps = {
32
66
  uniqueIdProperty: {
33
67
  type: 'string',
34
68
  value: ''
@@ -38,328 +72,385 @@ const defaultProps = {
38
72
  binary: true
39
73
  };
40
74
 
41
- class MVTLayer extends _tileLayer.default {
42
- initializeState() {
43
- super.initializeState();
44
- this.setState({
45
- data: null,
46
- tileJSON: null
47
- });
48
- }
75
+ var MVTLayer = function (_TileLayer) {
76
+ (0, _inherits2.default)(MVTLayer, _TileLayer);
49
77
 
50
- get isLoaded() {
51
- return this.state.data && this.state.tileset && super.isLoaded;
52
- }
78
+ var _super = _createSuper(MVTLayer);
53
79
 
54
- updateState({
55
- props,
56
- oldProps,
57
- context,
58
- changeFlags
59
- }) {
60
- if (changeFlags.dataChanged) {
61
- this._updateTileData();
62
- }
63
-
64
- if (this.state.data) {
65
- super.updateState({
66
- props,
67
- oldProps,
68
- context,
69
- changeFlags
70
- });
71
-
72
- this._setWGS84PropertyForTiles();
73
- }
80
+ function MVTLayer() {
81
+ (0, _classCallCheck2.default)(this, MVTLayer);
82
+ return _super.apply(this, arguments);
74
83
  }
75
84
 
76
- async _updateTileData() {
77
- let {
78
- data
79
- } = this.props;
80
- let tileJSON = null;
81
-
82
- if (typeof data === 'string' && !(0, _utils.isURLTemplate)(data)) {
83
- const {
84
- onDataLoad,
85
- fetch
86
- } = this.props;
85
+ (0, _createClass2.default)(MVTLayer, [{
86
+ key: "initializeState",
87
+ value: function initializeState() {
88
+ (0, _get2.default)((0, _getPrototypeOf2.default)(MVTLayer.prototype), "initializeState", this).call(this);
87
89
  this.setState({
88
90
  data: null,
89
91
  tileJSON: null
90
92
  });
93
+ }
94
+ }, {
95
+ key: "updateState",
96
+ value: function updateState(_ref) {
97
+ var props = _ref.props,
98
+ oldProps = _ref.oldProps,
99
+ context = _ref.context,
100
+ changeFlags = _ref.changeFlags;
101
+
102
+ if (changeFlags.dataChanged) {
103
+ this._updateTileData();
104
+ }
91
105
 
92
- try {
93
- tileJSON = await fetch(data, {
94
- propName: 'data',
95
- layer: this,
96
- loaders: []
106
+ if (this.state.data) {
107
+ (0, _get2.default)((0, _getPrototypeOf2.default)(MVTLayer.prototype), "updateState", this).call(this, {
108
+ props: props,
109
+ oldProps: oldProps,
110
+ context: context,
111
+ changeFlags: changeFlags
97
112
  });
98
- } catch (error) {
99
- this.raiseError(error, 'loading TileJSON');
100
- data = null;
101
- }
102
113
 
103
- if (onDataLoad) {
104
- onDataLoad(tileJSON);
114
+ this._setWGS84PropertyForTiles();
105
115
  }
106
- } else if (data.tilejson) {
107
- tileJSON = data;
108
- }
109
-
110
- if (tileJSON) {
111
- data = tileJSON.tiles;
112
116
  }
117
+ }, {
118
+ key: "_updateTileData",
119
+ value: function () {
120
+ var _updateTileData2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
121
+ var data, tileJSON, _this$props, onDataLoad, fetch;
122
+
123
+ return _regenerator.default.wrap(function _callee$(_context) {
124
+ while (1) {
125
+ switch (_context.prev = _context.next) {
126
+ case 0:
127
+ data = this.props.data;
128
+ tileJSON = null;
129
+
130
+ if (!(typeof data === 'string' && !(0, _utils.isURLTemplate)(data))) {
131
+ _context.next = 18;
132
+ break;
133
+ }
134
+
135
+ _this$props = this.props, onDataLoad = _this$props.onDataLoad, fetch = _this$props.fetch;
136
+ this.setState({
137
+ data: null,
138
+ tileJSON: null
139
+ });
140
+ _context.prev = 5;
141
+ _context.next = 8;
142
+ return fetch(data, {
143
+ propName: 'data',
144
+ layer: this,
145
+ loaders: []
146
+ });
147
+
148
+ case 8:
149
+ tileJSON = _context.sent;
150
+ _context.next = 15;
151
+ break;
152
+
153
+ case 11:
154
+ _context.prev = 11;
155
+ _context.t0 = _context["catch"](5);
156
+ this.raiseError(_context.t0, 'loading TileJSON');
157
+ data = null;
158
+
159
+ case 15:
160
+ if (onDataLoad) {
161
+ onDataLoad(tileJSON);
162
+ }
163
+
164
+ _context.next = 19;
165
+ break;
166
+
167
+ case 18:
168
+ if (data.tilejson) {
169
+ tileJSON = data;
170
+ }
171
+
172
+ case 19:
173
+ if (tileJSON) {
174
+ data = tileJSON.tiles;
175
+ }
176
+
177
+ this.setState({
178
+ data: data,
179
+ tileJSON: tileJSON
180
+ });
181
+
182
+ case 21:
183
+ case "end":
184
+ return _context.stop();
185
+ }
186
+ }
187
+ }, _callee, this, [[5, 11]]);
188
+ }));
113
189
 
114
- this.setState({
115
- data,
116
- tileJSON
117
- });
118
- }
119
-
120
- _getTilesetOptions(props) {
121
- const opts = super._getTilesetOptions(props);
122
-
123
- const {
124
- tileJSON
125
- } = this.state;
126
-
127
- if (tileJSON) {
128
- if (Number.isFinite(tileJSON.minzoom) && tileJSON.minzoom > props.minZoom) {
129
- opts.minZoom = tileJSON.minzoom;
130
- }
131
-
132
- if (Number.isFinite(tileJSON.maxzoom) && (!Number.isFinite(props.maxZoom) || tileJSON.maxzoom < props.maxZoom)) {
133
- opts.maxZoom = tileJSON.maxzoom;
190
+ function _updateTileData() {
191
+ return _updateTileData2.apply(this, arguments);
134
192
  }
135
- }
136
193
 
137
- return opts;
138
- }
139
-
140
- renderLayers() {
141
- if (!this.state.data) return null;
142
- return super.renderLayers();
143
- }
144
-
145
- getTileData(tile) {
146
- var _loadOptions;
147
-
148
- const url = (0, _utils.getURLFromTemplate)(this.state.data, tile);
149
-
150
- if (!url) {
151
- return Promise.reject('Invalid URL');
152
- }
194
+ return _updateTileData;
195
+ }()
196
+ }, {
197
+ key: "_getTilesetOptions",
198
+ value: function _getTilesetOptions(props) {
199
+ var opts = (0, _get2.default)((0, _getPrototypeOf2.default)(MVTLayer.prototype), "_getTilesetOptions", this).call(this, props);
200
+ var tileJSON = this.state.tileJSON;
201
+
202
+ if (tileJSON) {
203
+ if (Number.isFinite(tileJSON.minzoom) && tileJSON.minzoom > props.minZoom) {
204
+ opts.minZoom = tileJSON.minzoom;
205
+ }
153
206
 
154
- let loadOptions = this.getLoadOptions();
155
- const {
156
- binary,
157
- fetch
158
- } = this.props;
159
- const {
160
- signal,
161
- x,
162
- y,
163
- z
164
- } = tile;
165
- loadOptions = { ...loadOptions,
166
- mimeType: 'application/x-protobuf',
167
- mvt: { ...((_loadOptions = loadOptions) === null || _loadOptions === void 0 ? void 0 : _loadOptions.mvt),
168
- coordinates: this.context.viewport.resolution ? 'wgs84' : 'local',
169
- tileIndex: {
170
- x,
171
- y,
172
- z
207
+ if (Number.isFinite(tileJSON.maxzoom) && (!Number.isFinite(props.maxZoom) || tileJSON.maxzoom < props.maxZoom)) {
208
+ opts.maxZoom = tileJSON.maxzoom;
173
209
  }
174
- },
175
- gis: binary ? {
176
- format: 'binary'
177
- } : {}
178
- };
179
- return fetch(url, {
180
- propName: 'data',
181
- layer: this,
182
- loadOptions,
183
- signal
184
- });
185
- }
210
+ }
186
211
 
187
- renderSubLayers(props) {
188
- const {
189
- tile
190
- } = props;
191
- const worldScale = Math.pow(2, tile.z);
192
- const xScale = WORLD_SIZE / worldScale;
193
- const yScale = -xScale;
194
- const xOffset = WORLD_SIZE * tile.x / worldScale;
195
- const yOffset = WORLD_SIZE * (1 - tile.y / worldScale);
196
- const modelMatrix = new _math.Matrix4().scale([xScale, yScale, 1]);
197
- props.autoHighlight = false;
198
-
199
- if (!this.context.viewport.resolution) {
200
- props.modelMatrix = modelMatrix;
201
- props.coordinateOrigin = [xOffset, yOffset, 0];
202
- props.coordinateSystem = _core.COORDINATE_SYSTEM.CARTESIAN;
203
- props.extensions = [...(props.extensions || []), new _extensions.ClipExtension()];
212
+ return opts;
204
213
  }
205
-
206
- const subLayers = super.renderSubLayers(props);
207
-
208
- if (this.props.binary && !(subLayers instanceof _layers.GeoJsonLayer)) {
209
- _core.log.warn('renderSubLayers() must return GeoJsonLayer when using binary:true')();
214
+ }, {
215
+ key: "renderLayers",
216
+ value: function renderLayers() {
217
+ if (!this.state.data) return null;
218
+ return (0, _get2.default)((0, _getPrototypeOf2.default)(MVTLayer.prototype), "renderLayers", this).call(this);
210
219
  }
220
+ }, {
221
+ key: "getTileData",
222
+ value: function getTileData(tile) {
223
+ var _loadOptions;
211
224
 
212
- return subLayers;
213
- }
225
+ var url = (0, _utils.getURLFromTemplate)(this.state.data, tile);
214
226
 
215
- _updateAutoHighlight(info) {
216
- const {
217
- uniqueIdProperty
218
- } = this.props;
219
- const {
220
- hoveredFeatureId,
221
- hoveredFeatureLayerName
222
- } = this.state;
223
- const hoveredFeature = info.object;
224
- let newHoveredFeatureId;
225
- let newHoveredFeatureLayerName;
226
-
227
- if (hoveredFeature) {
228
- newHoveredFeatureId = getFeatureUniqueId(hoveredFeature, uniqueIdProperty);
229
- newHoveredFeatureLayerName = getFeatureLayerName(hoveredFeature);
230
- }
227
+ if (!url) {
228
+ return Promise.reject('Invalid URL');
229
+ }
231
230
 
232
- if (hoveredFeatureId !== newHoveredFeatureId || hoveredFeatureLayerName !== newHoveredFeatureLayerName) {
233
- this.setState({
234
- hoveredFeatureId: newHoveredFeatureId,
235
- hoveredFeatureLayerName: newHoveredFeatureLayerName
231
+ var loadOptions = this.getLoadOptions();
232
+ var _this$props2 = this.props,
233
+ binary = _this$props2.binary,
234
+ fetch = _this$props2.fetch;
235
+ var signal = tile.signal,
236
+ x = tile.x,
237
+ y = tile.y,
238
+ z = tile.z;
239
+ loadOptions = _objectSpread(_objectSpread({}, loadOptions), {}, {
240
+ mimeType: 'application/x-protobuf',
241
+ mvt: _objectSpread(_objectSpread({}, (_loadOptions = loadOptions) === null || _loadOptions === void 0 ? void 0 : _loadOptions.mvt), {}, {
242
+ coordinates: this.context.viewport.resolution ? 'wgs84' : 'local',
243
+ tileIndex: {
244
+ x: x,
245
+ y: y,
246
+ z: z
247
+ }
248
+ }),
249
+ gis: binary ? {
250
+ format: 'binary'
251
+ } : {}
236
252
  });
237
- }
238
- }
239
-
240
- getPickingInfo(params) {
241
- const info = super.getPickingInfo(params);
242
- const isWGS84 = this.context.viewport.resolution;
243
-
244
- if (this.props.binary && info.index !== -1) {
245
- const {
246
- data
247
- } = params.sourceLayer.props;
248
- info.object = (0, _gis.binaryToGeojson)(data, {
249
- globalFeatureId: info.index
253
+ return fetch(url, {
254
+ propName: 'data',
255
+ layer: this,
256
+ loadOptions: loadOptions,
257
+ signal: signal
250
258
  });
251
259
  }
260
+ }, {
261
+ key: "renderSubLayers",
262
+ value: function renderSubLayers(props) {
263
+ var tile = props.tile;
264
+ var worldScale = Math.pow(2, tile.z);
265
+ var xScale = WORLD_SIZE / worldScale;
266
+ var yScale = -xScale;
267
+ var xOffset = WORLD_SIZE * tile.x / worldScale;
268
+ var yOffset = WORLD_SIZE * (1 - tile.y / worldScale);
269
+ var modelMatrix = new _math.Matrix4().scale([xScale, yScale, 1]);
270
+ props.autoHighlight = false;
271
+
272
+ if (!this.context.viewport.resolution) {
273
+ props.modelMatrix = modelMatrix;
274
+ props.coordinateOrigin = [xOffset, yOffset, 0];
275
+ props.coordinateSystem = _core.COORDINATE_SYSTEM.CARTESIAN;
276
+ props.extensions = [].concat((0, _toConsumableArray2.default)(props.extensions || []), [new _extensions.ClipExtension()]);
277
+ }
252
278
 
253
- if (info.object && !isWGS84) {
254
- info.object = transformTileCoordsToWGS84(info.object, info.tile.bbox, this.context.viewport);
255
- }
279
+ var subLayers = (0, _get2.default)((0, _getPrototypeOf2.default)(MVTLayer.prototype), "renderSubLayers", this).call(this, props);
256
280
 
257
- return info;
258
- }
281
+ if (this.props.binary && !(subLayers instanceof _layers.GeoJsonLayer)) {
282
+ _core.log.warn('renderSubLayers() must return GeoJsonLayer when using binary:true')();
283
+ }
259
284
 
260
- getHighlightedObjectIndex(tile) {
261
- const {
262
- hoveredFeatureId,
263
- hoveredFeatureLayerName
264
- } = this.state;
265
- const {
266
- uniqueIdProperty,
267
- highlightedFeatureId,
268
- binary
269
- } = this.props;
270
- const data = tile.content;
271
- const isHighlighted = isFeatureIdDefined(highlightedFeatureId);
272
- const isFeatureIdPresent = isFeatureIdDefined(hoveredFeatureId) || isHighlighted;
273
-
274
- if (!isFeatureIdPresent) {
275
- return -1;
285
+ return subLayers;
276
286
  }
287
+ }, {
288
+ key: "_updateAutoHighlight",
289
+ value: function _updateAutoHighlight(info) {
290
+ var uniqueIdProperty = this.props.uniqueIdProperty;
291
+ var _this$state = this.state,
292
+ hoveredFeatureId = _this$state.hoveredFeatureId,
293
+ hoveredFeatureLayerName = _this$state.hoveredFeatureLayerName;
294
+ var hoveredFeature = info.object;
295
+ var newHoveredFeatureId;
296
+ var newHoveredFeatureLayerName;
297
+
298
+ if (hoveredFeature) {
299
+ newHoveredFeatureId = getFeatureUniqueId(hoveredFeature, uniqueIdProperty);
300
+ newHoveredFeatureLayerName = getFeatureLayerName(hoveredFeature);
301
+ }
277
302
 
278
- const featureIdToHighlight = isHighlighted ? highlightedFeatureId : hoveredFeatureId;
279
-
280
- if (Array.isArray(data)) {
281
- return data.findIndex(feature => {
282
- const isMatchingId = getFeatureUniqueId(feature, uniqueIdProperty) === featureIdToHighlight;
283
- const isMatchingLayer = isHighlighted || getFeatureLayerName(feature) === hoveredFeatureLayerName;
284
- return isMatchingId && isMatchingLayer;
285
- });
286
- } else if (data && binary) {
287
- return (0, _findIndexBinary.default)(data, uniqueIdProperty, featureIdToHighlight, isHighlighted ? '' : hoveredFeatureLayerName);
303
+ if (hoveredFeatureId !== newHoveredFeatureId || hoveredFeatureLayerName !== newHoveredFeatureLayerName) {
304
+ this.setState({
305
+ hoveredFeatureId: newHoveredFeatureId,
306
+ hoveredFeatureLayerName: newHoveredFeatureLayerName
307
+ });
308
+ }
288
309
  }
310
+ }, {
311
+ key: "getPickingInfo",
312
+ value: function getPickingInfo(params) {
313
+ var info = (0, _get2.default)((0, _getPrototypeOf2.default)(MVTLayer.prototype), "getPickingInfo", this).call(this, params);
314
+ var isWGS84 = this.context.viewport.resolution;
315
+
316
+ if (this.props.binary && info.index !== -1) {
317
+ var data = params.sourceLayer.props.data;
318
+ info.object = (0, _gis.binaryToGeojson)(data, {
319
+ globalFeatureId: info.index
320
+ });
321
+ }
289
322
 
290
- return -1;
291
- }
292
-
293
- _pickObjects(maxObjects) {
294
- const {
295
- deck,
296
- viewport
297
- } = this.context;
298
- const width = viewport.width;
299
- const height = viewport.height;
300
- const x = viewport.x;
301
- const y = viewport.y;
302
- const layerIds = [this.id];
303
- return deck.pickObjects({
304
- x,
305
- y,
306
- width,
307
- height,
308
- layerIds,
309
- maxObjects
310
- });
311
- }
312
-
313
- getRenderedFeatures(maxFeatures = null) {
314
- const features = this._pickObjects(maxFeatures);
323
+ if (info.object && !isWGS84) {
324
+ info.object = transformTileCoordsToWGS84(info.object, info.tile.bbox, this.context.viewport);
325
+ }
315
326
 
316
- const featureCache = new Set();
317
- const renderedFeatures = [];
327
+ return info;
328
+ }
329
+ }, {
330
+ key: "getHighlightedObjectIndex",
331
+ value: function getHighlightedObjectIndex(tile) {
332
+ var _this$state2 = this.state,
333
+ hoveredFeatureId = _this$state2.hoveredFeatureId,
334
+ hoveredFeatureLayerName = _this$state2.hoveredFeatureLayerName;
335
+ var _this$props3 = this.props,
336
+ uniqueIdProperty = _this$props3.uniqueIdProperty,
337
+ highlightedFeatureId = _this$props3.highlightedFeatureId,
338
+ binary = _this$props3.binary;
339
+ var data = tile.content;
340
+ var isHighlighted = isFeatureIdDefined(highlightedFeatureId);
341
+ var isFeatureIdPresent = isFeatureIdDefined(hoveredFeatureId) || isHighlighted;
342
+
343
+ if (!isFeatureIdPresent) {
344
+ return -1;
345
+ }
318
346
 
319
- for (const f of features) {
320
- const featureId = getFeatureUniqueId(f.object, this.props.uniqueIdProperty);
347
+ var featureIdToHighlight = isHighlighted ? highlightedFeatureId : hoveredFeatureId;
321
348
 
322
- if (featureId === undefined) {
323
- renderedFeatures.push(f.object);
324
- } else if (!featureCache.has(featureId)) {
325
- featureCache.add(featureId);
326
- renderedFeatures.push(f.object);
349
+ if (Array.isArray(data)) {
350
+ return data.findIndex(function (feature) {
351
+ var isMatchingId = getFeatureUniqueId(feature, uniqueIdProperty) === featureIdToHighlight;
352
+ var isMatchingLayer = isHighlighted || getFeatureLayerName(feature) === hoveredFeatureLayerName;
353
+ return isMatchingId && isMatchingLayer;
354
+ });
355
+ } else if (data && binary) {
356
+ return (0, _findIndexBinary.default)(data, uniqueIdProperty, featureIdToHighlight, isHighlighted ? '' : hoveredFeatureLayerName);
327
357
  }
328
- }
329
358
 
330
- return renderedFeatures;
331
- }
359
+ return -1;
360
+ }
361
+ }, {
362
+ key: "_pickObjects",
363
+ value: function _pickObjects(maxObjects) {
364
+ var _this$context = this.context,
365
+ deck = _this$context.deck,
366
+ viewport = _this$context.viewport;
367
+ var width = viewport.width;
368
+ var height = viewport.height;
369
+ var x = viewport.x;
370
+ var y = viewport.y;
371
+ var layerIds = [this.id];
372
+ return deck.pickObjects({
373
+ x: x,
374
+ y: y,
375
+ width: width,
376
+ height: height,
377
+ layerIds: layerIds,
378
+ maxObjects: maxObjects
379
+ });
380
+ }
381
+ }, {
382
+ key: "getRenderedFeatures",
383
+ value: function getRenderedFeatures() {
384
+ var maxFeatures = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
332
385
 
333
- _setWGS84PropertyForTiles() {
334
- const propName = 'dataInWGS84';
335
- const {
336
- tileset
337
- } = this.state;
338
- tileset.selectedTiles.forEach(tile => {
339
- if (!tile.hasOwnProperty(propName)) {
340
- Object.defineProperty(tile, propName, {
341
- get: () => {
342
- if (!tile.content) {
343
- return null;
344
- }
386
+ var features = this._pickObjects(maxFeatures);
345
387
 
346
- if (this.props.binary && Array.isArray(tile.content) && !tile.content.length) {
347
- return [];
348
- }
388
+ var featureCache = new Set();
389
+ var renderedFeatures = [];
349
390
 
350
- if (tile._contentWGS84 === undefined) {
351
- const content = this.props.binary ? (0, _gis.binaryToGeojson)(tile.content) : tile.content;
352
- tile._contentWGS84 = content.map(feature => transformTileCoordsToWGS84(feature, tile.bbox, this.context.viewport));
353
- }
391
+ var _iterator = _createForOfIteratorHelper(features),
392
+ _step;
354
393
 
355
- return tile._contentWGS84;
394
+ try {
395
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
396
+ var f = _step.value;
397
+ var featureId = getFeatureUniqueId(f.object, this.props.uniqueIdProperty);
398
+
399
+ if (featureId === undefined) {
400
+ renderedFeatures.push(f.object);
401
+ } else if (!featureCache.has(featureId)) {
402
+ featureCache.add(featureId);
403
+ renderedFeatures.push(f.object);
356
404
  }
357
- });
405
+ }
406
+ } catch (err) {
407
+ _iterator.e(err);
408
+ } finally {
409
+ _iterator.f();
358
410
  }
359
- });
360
- }
361
411
 
362
- }
412
+ return renderedFeatures;
413
+ }
414
+ }, {
415
+ key: "_setWGS84PropertyForTiles",
416
+ value: function _setWGS84PropertyForTiles() {
417
+ var _this = this;
418
+
419
+ var propName = 'dataInWGS84';
420
+ var tileset = this.state.tileset;
421
+ tileset.selectedTiles.forEach(function (tile) {
422
+ if (!tile.hasOwnProperty(propName)) {
423
+ Object.defineProperty(tile, propName, {
424
+ get: function get() {
425
+ if (!tile.content) {
426
+ return null;
427
+ }
428
+
429
+ if (_this.props.binary && Array.isArray(tile.content) && !tile.content.length) {
430
+ return [];
431
+ }
432
+
433
+ if (tile._contentWGS84 === undefined) {
434
+ var content = _this.props.binary ? (0, _gis.binaryToGeojson)(tile.content) : tile.content;
435
+ tile._contentWGS84 = content.map(function (feature) {
436
+ return transformTileCoordsToWGS84(feature, tile.bbox, _this.context.viewport);
437
+ });
438
+ }
439
+
440
+ return tile._contentWGS84;
441
+ }
442
+ });
443
+ }
444
+ });
445
+ }
446
+ }, {
447
+ key: "isLoaded",
448
+ get: function get() {
449
+ return this.state.data && this.state.tileset && (0, _get2.default)((0, _getPrototypeOf2.default)(MVTLayer.prototype), "isLoaded", this);
450
+ }
451
+ }]);
452
+ return MVTLayer;
453
+ }(_tileLayer.default);
363
454
 
364
455
  exports.default = MVTLayer;
365
456
 
@@ -386,14 +477,15 @@ function isFeatureIdDefined(value) {
386
477
  }
387
478
 
388
479
  function transformTileCoordsToWGS84(object, bbox, viewport) {
389
- const feature = { ...object,
480
+ var feature = _objectSpread(_objectSpread({}, object), {}, {
390
481
  geometry: {
391
482
  type: object.geometry.type
392
483
  }
393
- };
484
+ });
485
+
394
486
  Object.defineProperty(feature.geometry, 'coordinates', {
395
- get: () => {
396
- const wgs84Geom = (0, _coordinateTransform.transform)(object.geometry, bbox, viewport);
487
+ get: function get() {
488
+ var wgs84Geom = (0, _coordinateTransform.transform)(object.geometry, bbox, viewport);
397
489
  return wgs84Geom.coordinates;
398
490
  }
399
491
  });