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

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 (50) hide show
  1. package/dist/dist.dev.js +27 -12
  2. package/dist/es5/great-circle-layer/great-circle-layer.js +1 -26
  3. package/dist/es5/great-circle-layer/great-circle-layer.js.map +1 -1
  4. package/dist/es5/h3-layers/h3-cluster-layer.js +87 -149
  5. package/dist/es5/h3-layers/h3-cluster-layer.js.map +1 -1
  6. package/dist/es5/h3-layers/h3-hexagon-layer.js +226 -321
  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 +125 -151
  10. package/dist/es5/mesh-layer/mesh-layer.js.map +1 -1
  11. package/dist/es5/mvt-layer/coordinate-transform.js +19 -45
  12. package/dist/es5/mvt-layer/coordinate-transform.js.map +1 -1
  13. package/dist/es5/mvt-layer/find-index-binary.js +26 -45
  14. package/dist/es5/mvt-layer/find-index-binary.js.map +1 -1
  15. package/dist/es5/mvt-layer/mvt-layer.js +282 -374
  16. package/dist/es5/mvt-layer/mvt-layer.js.map +1 -1
  17. package/dist/es5/s2-layer/s2-geometry.js +32 -43
  18. package/dist/es5/s2-layer/s2-geometry.js.map +1 -1
  19. package/dist/es5/s2-layer/s2-layer.js +69 -104
  20. package/dist/es5/s2-layer/s2-layer.js.map +1 -1
  21. package/dist/es5/s2-layer/s2-utils.js +28 -27
  22. package/dist/es5/s2-layer/s2-utils.js.map +1 -1
  23. package/dist/es5/terrain-layer/terrain-layer.js +208 -254
  24. package/dist/es5/terrain-layer/terrain-layer.js.map +1 -1
  25. package/dist/es5/tile-3d-layer/tile-3d-layer.js +329 -382
  26. package/dist/es5/tile-3d-layer/tile-3d-layer.js.map +1 -1
  27. package/dist/es5/tile-layer/tile-2d-header.js +119 -183
  28. package/dist/es5/tile-layer/tile-2d-header.js.map +1 -1
  29. package/dist/es5/tile-layer/tile-2d-traversal.js +115 -178
  30. package/dist/es5/tile-layer/tile-2d-traversal.js.map +1 -1
  31. package/dist/es5/tile-layer/tile-layer.js +216 -258
  32. package/dist/es5/tile-layer/tile-layer.js.map +1 -1
  33. package/dist/es5/tile-layer/tileset-2d.js +290 -435
  34. package/dist/es5/tile-layer/tileset-2d.js.map +1 -1
  35. package/dist/es5/tile-layer/utils.js +61 -110
  36. package/dist/es5/tile-layer/utils.js.map +1 -1
  37. package/dist/es5/trips-layer/trips-layer.js +44 -81
  38. package/dist/es5/trips-layer/trips-layer.js.map +1 -1
  39. package/dist/esm/mvt-layer/mvt-layer.js.map +1 -1
  40. package/dist/esm/s2-layer/s2-utils.js.map +1 -1
  41. package/dist/esm/tile-3d-layer/tile-3d-layer.js.map +1 -1
  42. package/dist/esm/tile-layer/tile-2d-header.js.map +1 -1
  43. package/dist/esm/tile-layer/tile-2d-traversal.js.map +1 -1
  44. package/dist/esm/tile-layer/tile-layer.js.map +1 -1
  45. package/dist/esm/tile-layer/tileset-2d.js.map +1 -1
  46. package/dist.min.js +2 -2
  47. package/package.json +2 -2
  48. package/src/s2-layer/s2-utils.js +7 -1
  49. package/src/tile-3d-layer/tile-3d-layer.js +2 -7
  50. package/src/tile-layer/tile-2d-traversal.js +17 -3
@@ -7,26 +7,6 @@ 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
-
30
10
  var _core = require("@deck.gl/core");
31
11
 
32
12
  var _math = require("math.gl");
@@ -47,22 +27,8 @@ var _findIndexBinary = _interopRequireDefault(require("./find-index-binary"));
47
27
 
48
28
  var _layers = require("@deck.gl/layers");
49
29
 
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 = {
30
+ const WORLD_SIZE = 512;
31
+ const defaultProps = {
66
32
  uniqueIdProperty: {
67
33
  type: 'string',
68
34
  value: ''
@@ -72,385 +38,328 @@ var defaultProps = {
72
38
  binary: true
73
39
  };
74
40
 
75
- var MVTLayer = function (_TileLayer) {
76
- (0, _inherits2.default)(MVTLayer, _TileLayer);
41
+ class MVTLayer extends _tileLayer.default {
42
+ initializeState() {
43
+ super.initializeState();
44
+ this.setState({
45
+ data: null,
46
+ tileJSON: null
47
+ });
48
+ }
77
49
 
78
- var _super = _createSuper(MVTLayer);
50
+ get isLoaded() {
51
+ return this.state.data && this.state.tileset && super.isLoaded;
52
+ }
79
53
 
80
- function MVTLayer() {
81
- (0, _classCallCheck2.default)(this, MVTLayer);
82
- return _super.apply(this, arguments);
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
+ }
83
74
  }
84
75
 
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);
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;
89
87
  this.setState({
90
88
  data: null,
91
89
  tileJSON: null
92
90
  });
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
- }
105
91
 
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
92
+ try {
93
+ tileJSON = await fetch(data, {
94
+ propName: 'data',
95
+ layer: this,
96
+ loaders: []
112
97
  });
98
+ } catch (error) {
99
+ this.raiseError(error, 'loading TileJSON');
100
+ data = null;
101
+ }
113
102
 
114
- this._setWGS84PropertyForTiles();
103
+ if (onDataLoad) {
104
+ onDataLoad(tileJSON);
115
105
  }
106
+ } else if (data.tilejson) {
107
+ tileJSON = data;
116
108
  }
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
- }));
189
109
 
190
- function _updateTileData() {
191
- return _updateTileData2.apply(this, arguments);
192
- }
110
+ if (tileJSON) {
111
+ data = tileJSON.tiles;
112
+ }
193
113
 
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
- }
114
+ this.setState({
115
+ data,
116
+ tileJSON
117
+ });
118
+ }
206
119
 
207
- if (Number.isFinite(tileJSON.maxzoom) && (!Number.isFinite(props.maxZoom) || tileJSON.maxzoom < props.maxZoom)) {
208
- opts.maxZoom = tileJSON.maxzoom;
209
- }
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;
210
130
  }
211
131
 
212
- return opts;
213
- }
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);
132
+ if (Number.isFinite(tileJSON.maxzoom) && (!Number.isFinite(props.maxZoom) || tileJSON.maxzoom < props.maxZoom)) {
133
+ opts.maxZoom = tileJSON.maxzoom;
134
+ }
219
135
  }
220
- }, {
221
- key: "getTileData",
222
- value: function getTileData(tile) {
223
- var _loadOptions;
224
136
 
225
- var url = (0, _utils.getURLFromTemplate)(this.state.data, tile);
137
+ return opts;
138
+ }
226
139
 
227
- if (!url) {
228
- return Promise.reject('Invalid URL');
229
- }
140
+ renderLayers() {
141
+ if (!this.state.data) return null;
142
+ return super.renderLayers();
143
+ }
230
144
 
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
- } : {}
252
- });
253
- return fetch(url, {
254
- propName: 'data',
255
- layer: this,
256
- loadOptions: loadOptions,
257
- signal: signal
258
- });
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');
259
152
  }
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
- }
278
153
 
279
- var subLayers = (0, _get2.default)((0, _getPrototypeOf2.default)(MVTLayer.prototype), "renderSubLayers", this).call(this, props);
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
173
+ }
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
+ }
280
186
 
281
- if (this.props.binary && !(subLayers instanceof _layers.GeoJsonLayer)) {
282
- _core.log.warn('renderSubLayers() must return GeoJsonLayer when using binary:true')();
283
- }
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()];
204
+ }
205
+
206
+ const subLayers = super.renderSubLayers(props);
284
207
 
285
- return subLayers;
208
+ if (this.props.binary && !(subLayers instanceof _layers.GeoJsonLayer)) {
209
+ _core.log.warn('renderSubLayers() must return GeoJsonLayer when using binary:true')();
286
210
  }
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
- }
302
211
 
303
- if (hoveredFeatureId !== newHoveredFeatureId || hoveredFeatureLayerName !== newHoveredFeatureLayerName) {
304
- this.setState({
305
- hoveredFeatureId: newHoveredFeatureId,
306
- hoveredFeatureLayerName: newHoveredFeatureLayerName
307
- });
308
- }
212
+ return subLayers;
213
+ }
214
+
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);
309
230
  }
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
- }
322
231
 
323
- if (info.object && !isWGS84) {
324
- info.object = transformTileCoordsToWGS84(info.object, info.tile.bbox, this.context.viewport);
325
- }
232
+ if (hoveredFeatureId !== newHoveredFeatureId || hoveredFeatureLayerName !== newHoveredFeatureLayerName) {
233
+ this.setState({
234
+ hoveredFeatureId: newHoveredFeatureId,
235
+ hoveredFeatureLayerName: newHoveredFeatureLayerName
236
+ });
237
+ }
238
+ }
239
+
240
+ getPickingInfo(params) {
241
+ const info = super.getPickingInfo(params);
242
+ const isWGS84 = this.context.viewport.resolution;
326
243
 
327
- return info;
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
250
+ });
328
251
  }
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
- }
346
252
 
347
- var featureIdToHighlight = isHighlighted ? highlightedFeatureId : hoveredFeatureId;
253
+ if (info.object && !isWGS84) {
254
+ info.object = transformTileCoordsToWGS84(info.object, info.tile.bbox, this.context.viewport);
255
+ }
348
256
 
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);
357
- }
257
+ return info;
258
+ }
358
259
 
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) {
359
275
  return -1;
360
276
  }
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
277
+
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;
379
285
  });
286
+ } else if (data && binary) {
287
+ return (0, _findIndexBinary.default)(data, uniqueIdProperty, featureIdToHighlight, isHighlighted ? '' : hoveredFeatureLayerName);
380
288
  }
381
- }, {
382
- key: "getRenderedFeatures",
383
- value: function getRenderedFeatures() {
384
- var maxFeatures = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
385
289
 
386
- var features = this._pickObjects(maxFeatures);
290
+ return -1;
291
+ }
387
292
 
388
- var featureCache = new Set();
389
- var renderedFeatures = [];
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
+ }
390
312
 
391
- var _iterator = _createForOfIteratorHelper(features),
392
- _step;
313
+ getRenderedFeatures(maxFeatures = null) {
314
+ const features = this._pickObjects(maxFeatures);
393
315
 
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);
404
- }
405
- }
406
- } catch (err) {
407
- _iterator.e(err);
408
- } finally {
409
- _iterator.f();
410
- }
316
+ const featureCache = new Set();
317
+ const renderedFeatures = [];
318
+
319
+ for (const f of features) {
320
+ const featureId = getFeatureUniqueId(f.object, this.props.uniqueIdProperty);
411
321
 
412
- return renderedFeatures;
322
+ if (featureId === undefined) {
323
+ renderedFeatures.push(f.object);
324
+ } else if (!featureCache.has(featureId)) {
325
+ featureCache.add(featureId);
326
+ renderedFeatures.push(f.object);
327
+ }
413
328
  }
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;
329
+
330
+ return renderedFeatures;
331
+ }
332
+
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;
441
344
  }
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);
345
+
346
+ if (this.props.binary && Array.isArray(tile.content) && !tile.content.length) {
347
+ return [];
348
+ }
349
+
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
+ }
354
+
355
+ return tile._contentWGS84;
356
+ }
357
+ });
358
+ }
359
+ });
360
+ }
361
+
362
+ }
454
363
 
455
364
  exports.default = MVTLayer;
456
365
 
@@ -477,15 +386,14 @@ function isFeatureIdDefined(value) {
477
386
  }
478
387
 
479
388
  function transformTileCoordsToWGS84(object, bbox, viewport) {
480
- var feature = _objectSpread(_objectSpread({}, object), {}, {
389
+ const feature = { ...object,
481
390
  geometry: {
482
391
  type: object.geometry.type
483
392
  }
484
- });
485
-
393
+ };
486
394
  Object.defineProperty(feature.geometry, 'coordinates', {
487
- get: function get() {
488
- var wgs84Geom = (0, _coordinateTransform.transform)(object.geometry, bbox, viewport);
395
+ get: () => {
396
+ const wgs84Geom = (0, _coordinateTransform.transform)(object.geometry, bbox, viewport);
489
397
  return wgs84Geom.coordinates;
490
398
  }
491
399
  });