geojs 1.4.3 → 1.5.0

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.
package/geo.js CHANGED
@@ -46119,8 +46119,11 @@ var transform = __webpack_require__(17);
46119
46119
  * @property {number} [minIntensity=null] Minimum intensity of the data.
46120
46120
  * Minimum intensity must be a positive real number and is used to normalize
46121
46121
  * all intensities within a dataset. If `null`, it is computed.
46122
- * @property {number} [updateDelay=1000] Delay in milliseconds after a zoom,
46123
- * rotate, or pan event before recomputing the heatmap.
46122
+ * @property {number} [updateDelay=-1] Delay in milliseconds after a zoom,
46123
+ * rotate, or pan event before recomputing the heatmap. If 0, this is double
46124
+ * the last render time. If negative, it is roughly the last render time
46125
+ * plus the absolute value of the specified number of refresh intervals.
46126
+ * compute a delay based on the last heatmap render time.
46124
46127
  * @property {boolean|number|'auto'} [binned='auto'] If `true` or a number,
46125
46128
  * spatially bin data as part of producing the heatmap. If falsy, each
46126
46129
  * datapoint stands on its own. If `'auto'`, bin data if there are more data
@@ -46137,6 +46140,11 @@ var transform = __webpack_require__(17);
46137
46140
  * approximation. The total weight of the gaussian area is approximately the
46138
46141
  * `9/16 r^2`. The sum of `radius + blurRadius` is used as the radius for
46139
46142
  * the gaussian distribution.
46143
+ * @property {boolean} [scaleWithZoom=false] If truthy, the value for radius
46144
+ * and blurRadius scale with zoom. In this case, the values for radius and
46145
+ * blurRadius are the values at zoom-level zero. If the scaled radius is
46146
+ * less than 0.5 or more than 8192 screen pixels, the heatmap will not
46147
+ * render.
46140
46148
  */
46141
46149
 
46142
46150
  /**
@@ -46181,7 +46189,7 @@ var heatmapFeature = function heatmapFeature(arg) {
46181
46189
  m_maxIntensity = arg.maxIntensity !== undefined ? arg.maxIntensity : null;
46182
46190
  m_minIntensity = arg.minIntensity !== undefined ? arg.minIntensity : null;
46183
46191
  m_binned = arg.binned !== undefined ? arg.binned : 'auto';
46184
- m_updateDelay = arg.updateDelay ? parseInt(arg.updateDelay, 10) : 1000;
46192
+ m_updateDelay = arg.updateDelay || arg.updateDelay === 0 ? parseInt(arg.updateDelay, 10) : -1;
46185
46193
 
46186
46194
  /**
46187
46195
  * Get/Set maxIntensity.
@@ -46226,7 +46234,9 @@ var heatmapFeature = function heatmapFeature(arg) {
46226
46234
  *
46227
46235
  * @param {number} [val] If not specified, return the current update delay.
46228
46236
  * If specified, this is the delay in milliseconds after a zoom, rotate,
46229
- * or pan event before recomputing the heatmap.
46237
+ * or pan event before recomputing the heatmap. If 0, this is double the
46238
+ * last render time. If negative, it is roughly the last render time plus
46239
+ * the absolute value of the specified number of refresh intervals.
46230
46240
  * @returns {number|this}
46231
46241
  */
46232
46242
  this.updateDelay = function (val) {
@@ -46336,7 +46346,8 @@ var heatmapFeature = function heatmapFeature(arg) {
46336
46346
  0.25: { r: 0, g: 0, b: 1, a: 0.5 },
46337
46347
  0.5: { r: 0, g: 1, b: 1, a: 0.6 },
46338
46348
  0.75: { r: 1, g: 1, b: 0, a: 0.7 },
46339
- 1: { r: 1, g: 0, b: 0, a: 0.8 } }
46349
+ 1: { r: 1, g: 0, b: 0, a: 0.8 } },
46350
+ scaleWithZoom: false
46340
46351
  }, arg.style === undefined ? {} : arg.style);
46341
46352
 
46342
46353
  m_this.style(defaultStyle);
@@ -58760,6 +58771,7 @@ module.exports.mockWebglRenderer = function mockWebglRenderer(supported) {
58760
58771
  enable: noop('enable'),
58761
58772
  enableVertexAttribArray: noop('enableVertexAttribArray'),
58762
58773
  finish: noop('finish'),
58774
+ getError: noop('getError'),
58763
58775
  getExtension: incID('getExtension'),
58764
58776
  getParameter: function getParameter(key) {
58765
58777
  count('getParameter');
@@ -89496,7 +89508,7 @@ module.exports = osmLayer;
89496
89508
  * @constant
89497
89509
  * @type {string}
89498
89510
  */
89499
- module.exports = "1.4.3";
89511
+ module.exports = "1.5.0";
89500
89512
 
89501
89513
  /***/ }),
89502
89514
  /* 630 */
@@ -89514,7 +89526,7 @@ module.exports = "1.4.3";
89514
89526
  * @constant
89515
89527
  * @type {string}
89516
89528
  */
89517
- module.exports = "0773dbf20ff4ff7497cc776659981763cf95eaa9";
89529
+ module.exports = "29ceeda3ffe254a1300d6237e88b3f5bc480c4fa";
89518
89530
 
89519
89531
  /***/ }),
89520
89532
  /* 631 */
@@ -89785,6 +89797,7 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
89785
89797
  m_heatMapTransform,
89786
89798
  s_init = this._init,
89787
89799
  s_update = this._update,
89800
+ m_lastRenderDuration,
89788
89801
  m_renderTime = timestamp();
89789
89802
 
89790
89803
  /**
@@ -89818,15 +89831,22 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
89818
89831
  };
89819
89832
 
89820
89833
  /**
89821
- * Create circle for each data point.
89834
+ * Create a circle to render at each data point.
89822
89835
  *
89823
89836
  * @returns {this}
89824
89837
  */
89825
89838
  this._createCircle = function () {
89826
- var circle, ctx, r, r2, blur, gaussian;
89839
+ var circle, ctx, r, r2, blur, gaussian, scale;
89827
89840
  r = m_this.style('radius');
89828
89841
  blur = m_this.style('blurRadius');
89829
89842
  gaussian = m_this.style('gaussian');
89843
+ scale = m_this.style('scaleWithZoom');
89844
+ if (scale) {
89845
+ var zoom = this.layer().map().zoom();
89846
+ scale = Math.pow(2, zoom);
89847
+ r *= scale;
89848
+ blur *= scale;
89849
+ }
89830
89850
  if (!m_this._circle || m_this._circle.gaussian !== gaussian || m_this._circle.radius !== r || m_this._circle.blurRadius !== blur) {
89831
89851
  circle = m_this._circle = document.createElement('canvas');
89832
89852
  ctx = circle.getContext('2d');
@@ -90051,6 +90071,7 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
90051
90071
  this._renderOnCanvas = function (context2d, map) {
90052
90072
 
90053
90073
  if (m_renderTime.timestamp() < m_this.buildTime().timestamp()) {
90074
+ var starttime = Date.now();
90054
90075
  var data = m_this.data() || [],
90055
90076
  radius = m_this.style('radius') + m_this.style('blurRadius'),
90056
90077
  binned = m_this.binned(),
@@ -90059,9 +90080,12 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
90059
90080
  layer = m_this.layer(),
90060
90081
  mapSize = map.size();
90061
90082
 
90083
+ if (m_this.style('scaleWithZoom')) {
90084
+ radius *= Math.pow(2, map.zoom());
90085
+ }
90062
90086
  /* Determine if we should bin the data */
90063
90087
  if (binned === true || binned === 'auto') {
90064
- binned = Math.max(Math.floor(radius / 8), 3);
90088
+ binned = Math.max(Math.floor(radius / 8), Math.max(1.5, Math.min(3, radius / 2.5)));
90065
90089
  if (m_this.binned() === 'auto') {
90066
90090
  var numbins = Math.ceil((mapSize.width + radius * 2) / binned) * Math.ceil((mapSize.height + radius * 2) / binned);
90067
90091
  if (numbins >= data.length) {
@@ -90078,20 +90102,22 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
90078
90102
  context2d.setTransform(1, 0, 0, 1, 0, 0);
90079
90103
  context2d.clearRect(0, 0, mapSize.width, mapSize.height);
90080
90104
  m_heatMapTransform = '';
90081
- map.scheduleAnimationFrame(m_this._setTransform, false);
90082
- layer.canvas().css({ transform: '' });
90083
-
90084
- m_this._createCircle();
90085
- m_this._computeGradient();
90086
- if (!binned) {
90087
- m_this._renderPoints(context2d, map, data, radius);
90088
- } else {
90089
- m_this._renderBinnedData(context2d, map, data, radius, binned);
90105
+ if (radius > 0.5 && radius < 8192) {
90106
+ map.scheduleAnimationFrame(m_this._setTransform, false);
90107
+ layer.canvas().css({ transform: '' });
90108
+
90109
+ m_this._createCircle();
90110
+ m_this._computeGradient();
90111
+ if (!binned) {
90112
+ m_this._renderPoints(context2d, map, data, radius);
90113
+ } else {
90114
+ m_this._renderBinnedData(context2d, map, data, radius, binned);
90115
+ }
90116
+ canvas = layer.canvas()[0];
90117
+ pixelArray = context2d.getImageData(0, 0, canvas.width, canvas.height);
90118
+ m_this._colorize(pixelArray.data, m_this._grad);
90119
+ context2d.putImageData(pixelArray, 0, 0);
90090
90120
  }
90091
- canvas = layer.canvas()[0];
90092
- pixelArray = context2d.getImageData(0, 0, canvas.width, canvas.height);
90093
- m_this._colorize(pixelArray.data, m_this._grad);
90094
- context2d.putImageData(pixelArray, 0, 0);
90095
90121
 
90096
90122
  m_heatMapPosition = {
90097
90123
  zoom: map.zoom(),
@@ -90103,6 +90129,7 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
90103
90129
  };
90104
90130
  m_renderTime.modified();
90105
90131
  layer.renderer().clearCanvas(false);
90132
+ m_lastRenderDuration = Date.now() - starttime;
90106
90133
  }
90107
90134
 
90108
90135
  return m_this;
@@ -90183,6 +90210,14 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
90183
90210
  * close to where the heatmap was originally computed, don't bother
90184
90211
  * updating it. */
90185
90212
  if (parseFloat(scale.toFixed(4)) !== 1 || parseFloat((rotation - m_heatMapPosition.rotation).toFixed(4)) !== 0 || parseFloat(origin.x.toFixed(1)) !== 0 || parseFloat(origin.y.toFixed(1)) !== 0) {
90213
+ var delay = m_this.updateDelay();
90214
+ if (delay < 0 && m_lastRenderDuration) {
90215
+ delay = m_lastRenderDuration - Math.floor(1000 / 60 * delay);
90216
+ } else if (m_lastRenderDuration) {
90217
+ delay = m_lastRenderDuration * 2;
90218
+ } else {
90219
+ delay = 100;
90220
+ }
90186
90221
  m_heatMapPosition.timeout = window.setTimeout(function () {
90187
90222
  m_heatMapPosition.timeout = undefined;
90188
90223
  m_this.buildTime().modified();
@@ -96240,7 +96275,9 @@ var webgl_quadFeature = function webgl_quadFeature(arg) {
96240
96275
  return;
96241
96276
  }
96242
96277
  quad.texture.bind(renderState);
96243
-
96278
+ if (context.getError() === context.OUT_OF_MEMORY) {
96279
+ console.log('Insufficient GPU memory for texture');
96280
+ }
96244
96281
  if (quad.opacity !== opacity) {
96245
96282
  opacity = quad.opacity;
96246
96283
  context.uniform1fv(renderState.m_material.shaderProgram().uniformLocation('opacity'), new Float32Array([opacity]));
package/geo.lean.js CHANGED
@@ -42257,8 +42257,11 @@ var transform = __webpack_require__(7);
42257
42257
  * @property {number} [minIntensity=null] Minimum intensity of the data.
42258
42258
  * Minimum intensity must be a positive real number and is used to normalize
42259
42259
  * all intensities within a dataset. If `null`, it is computed.
42260
- * @property {number} [updateDelay=1000] Delay in milliseconds after a zoom,
42261
- * rotate, or pan event before recomputing the heatmap.
42260
+ * @property {number} [updateDelay=-1] Delay in milliseconds after a zoom,
42261
+ * rotate, or pan event before recomputing the heatmap. If 0, this is double
42262
+ * the last render time. If negative, it is roughly the last render time
42263
+ * plus the absolute value of the specified number of refresh intervals.
42264
+ * compute a delay based on the last heatmap render time.
42262
42265
  * @property {boolean|number|'auto'} [binned='auto'] If `true` or a number,
42263
42266
  * spatially bin data as part of producing the heatmap. If falsy, each
42264
42267
  * datapoint stands on its own. If `'auto'`, bin data if there are more data
@@ -42275,6 +42278,11 @@ var transform = __webpack_require__(7);
42275
42278
  * approximation. The total weight of the gaussian area is approximately the
42276
42279
  * `9/16 r^2`. The sum of `radius + blurRadius` is used as the radius for
42277
42280
  * the gaussian distribution.
42281
+ * @property {boolean} [scaleWithZoom=false] If truthy, the value for radius
42282
+ * and blurRadius scale with zoom. In this case, the values for radius and
42283
+ * blurRadius are the values at zoom-level zero. If the scaled radius is
42284
+ * less than 0.5 or more than 8192 screen pixels, the heatmap will not
42285
+ * render.
42278
42286
  */
42279
42287
 
42280
42288
  /**
@@ -42319,7 +42327,7 @@ var heatmapFeature = function heatmapFeature(arg) {
42319
42327
  m_maxIntensity = arg.maxIntensity !== undefined ? arg.maxIntensity : null;
42320
42328
  m_minIntensity = arg.minIntensity !== undefined ? arg.minIntensity : null;
42321
42329
  m_binned = arg.binned !== undefined ? arg.binned : 'auto';
42322
- m_updateDelay = arg.updateDelay ? parseInt(arg.updateDelay, 10) : 1000;
42330
+ m_updateDelay = arg.updateDelay || arg.updateDelay === 0 ? parseInt(arg.updateDelay, 10) : -1;
42323
42331
 
42324
42332
  /**
42325
42333
  * Get/Set maxIntensity.
@@ -42364,7 +42372,9 @@ var heatmapFeature = function heatmapFeature(arg) {
42364
42372
  *
42365
42373
  * @param {number} [val] If not specified, return the current update delay.
42366
42374
  * If specified, this is the delay in milliseconds after a zoom, rotate,
42367
- * or pan event before recomputing the heatmap.
42375
+ * or pan event before recomputing the heatmap. If 0, this is double the
42376
+ * last render time. If negative, it is roughly the last render time plus
42377
+ * the absolute value of the specified number of refresh intervals.
42368
42378
  * @returns {number|this}
42369
42379
  */
42370
42380
  this.updateDelay = function (val) {
@@ -42474,7 +42484,8 @@ var heatmapFeature = function heatmapFeature(arg) {
42474
42484
  0.25: { r: 0, g: 0, b: 1, a: 0.5 },
42475
42485
  0.5: { r: 0, g: 1, b: 1, a: 0.6 },
42476
42486
  0.75: { r: 1, g: 1, b: 0, a: 0.7 },
42477
- 1: { r: 1, g: 0, b: 0, a: 0.8 } }
42487
+ 1: { r: 1, g: 0, b: 0, a: 0.8 } },
42488
+ scaleWithZoom: false
42478
42489
  }, arg.style === undefined ? {} : arg.style);
42479
42490
 
42480
42491
  m_this.style(defaultStyle);
@@ -49321,6 +49332,7 @@ module.exports.mockWebglRenderer = function mockWebglRenderer(supported) {
49321
49332
  enable: noop('enable'),
49322
49333
  enableVertexAttribArray: noop('enableVertexAttribArray'),
49323
49334
  finish: noop('finish'),
49335
+ getError: noop('getError'),
49324
49336
  getExtension: incID('getExtension'),
49325
49337
  getParameter: function getParameter(key) {
49326
49338
  count('getParameter');
@@ -67885,7 +67897,7 @@ module.exports = osmLayer;
67885
67897
  * @constant
67886
67898
  * @type {string}
67887
67899
  */
67888
- module.exports = "1.4.3";
67900
+ module.exports = "1.5.0";
67889
67901
 
67890
67902
  /***/ }),
67891
67903
  /* 297 */
@@ -67903,7 +67915,7 @@ module.exports = "1.4.3";
67903
67915
  * @constant
67904
67916
  * @type {string}
67905
67917
  */
67906
- module.exports = "0773dbf20ff4ff7497cc776659981763cf95eaa9";
67918
+ module.exports = "29ceeda3ffe254a1300d6237e88b3f5bc480c4fa";
67907
67919
 
67908
67920
  /***/ }),
67909
67921
  /* 298 */
@@ -68174,6 +68186,7 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
68174
68186
  m_heatMapTransform,
68175
68187
  s_init = this._init,
68176
68188
  s_update = this._update,
68189
+ m_lastRenderDuration,
68177
68190
  m_renderTime = timestamp();
68178
68191
 
68179
68192
  /**
@@ -68207,15 +68220,22 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
68207
68220
  };
68208
68221
 
68209
68222
  /**
68210
- * Create circle for each data point.
68223
+ * Create a circle to render at each data point.
68211
68224
  *
68212
68225
  * @returns {this}
68213
68226
  */
68214
68227
  this._createCircle = function () {
68215
- var circle, ctx, r, r2, blur, gaussian;
68228
+ var circle, ctx, r, r2, blur, gaussian, scale;
68216
68229
  r = m_this.style('radius');
68217
68230
  blur = m_this.style('blurRadius');
68218
68231
  gaussian = m_this.style('gaussian');
68232
+ scale = m_this.style('scaleWithZoom');
68233
+ if (scale) {
68234
+ var zoom = this.layer().map().zoom();
68235
+ scale = Math.pow(2, zoom);
68236
+ r *= scale;
68237
+ blur *= scale;
68238
+ }
68219
68239
  if (!m_this._circle || m_this._circle.gaussian !== gaussian || m_this._circle.radius !== r || m_this._circle.blurRadius !== blur) {
68220
68240
  circle = m_this._circle = document.createElement('canvas');
68221
68241
  ctx = circle.getContext('2d');
@@ -68440,6 +68460,7 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
68440
68460
  this._renderOnCanvas = function (context2d, map) {
68441
68461
 
68442
68462
  if (m_renderTime.timestamp() < m_this.buildTime().timestamp()) {
68463
+ var starttime = Date.now();
68443
68464
  var data = m_this.data() || [],
68444
68465
  radius = m_this.style('radius') + m_this.style('blurRadius'),
68445
68466
  binned = m_this.binned(),
@@ -68448,9 +68469,12 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
68448
68469
  layer = m_this.layer(),
68449
68470
  mapSize = map.size();
68450
68471
 
68472
+ if (m_this.style('scaleWithZoom')) {
68473
+ radius *= Math.pow(2, map.zoom());
68474
+ }
68451
68475
  /* Determine if we should bin the data */
68452
68476
  if (binned === true || binned === 'auto') {
68453
- binned = Math.max(Math.floor(radius / 8), 3);
68477
+ binned = Math.max(Math.floor(radius / 8), Math.max(1.5, Math.min(3, radius / 2.5)));
68454
68478
  if (m_this.binned() === 'auto') {
68455
68479
  var numbins = Math.ceil((mapSize.width + radius * 2) / binned) * Math.ceil((mapSize.height + radius * 2) / binned);
68456
68480
  if (numbins >= data.length) {
@@ -68467,20 +68491,22 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
68467
68491
  context2d.setTransform(1, 0, 0, 1, 0, 0);
68468
68492
  context2d.clearRect(0, 0, mapSize.width, mapSize.height);
68469
68493
  m_heatMapTransform = '';
68470
- map.scheduleAnimationFrame(m_this._setTransform, false);
68471
- layer.canvas().css({ transform: '' });
68472
-
68473
- m_this._createCircle();
68474
- m_this._computeGradient();
68475
- if (!binned) {
68476
- m_this._renderPoints(context2d, map, data, radius);
68477
- } else {
68478
- m_this._renderBinnedData(context2d, map, data, radius, binned);
68494
+ if (radius > 0.5 && radius < 8192) {
68495
+ map.scheduleAnimationFrame(m_this._setTransform, false);
68496
+ layer.canvas().css({ transform: '' });
68497
+
68498
+ m_this._createCircle();
68499
+ m_this._computeGradient();
68500
+ if (!binned) {
68501
+ m_this._renderPoints(context2d, map, data, radius);
68502
+ } else {
68503
+ m_this._renderBinnedData(context2d, map, data, radius, binned);
68504
+ }
68505
+ canvas = layer.canvas()[0];
68506
+ pixelArray = context2d.getImageData(0, 0, canvas.width, canvas.height);
68507
+ m_this._colorize(pixelArray.data, m_this._grad);
68508
+ context2d.putImageData(pixelArray, 0, 0);
68479
68509
  }
68480
- canvas = layer.canvas()[0];
68481
- pixelArray = context2d.getImageData(0, 0, canvas.width, canvas.height);
68482
- m_this._colorize(pixelArray.data, m_this._grad);
68483
- context2d.putImageData(pixelArray, 0, 0);
68484
68510
 
68485
68511
  m_heatMapPosition = {
68486
68512
  zoom: map.zoom(),
@@ -68492,6 +68518,7 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
68492
68518
  };
68493
68519
  m_renderTime.modified();
68494
68520
  layer.renderer().clearCanvas(false);
68521
+ m_lastRenderDuration = Date.now() - starttime;
68495
68522
  }
68496
68523
 
68497
68524
  return m_this;
@@ -68572,6 +68599,14 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
68572
68599
  * close to where the heatmap was originally computed, don't bother
68573
68600
  * updating it. */
68574
68601
  if (parseFloat(scale.toFixed(4)) !== 1 || parseFloat((rotation - m_heatMapPosition.rotation).toFixed(4)) !== 0 || parseFloat(origin.x.toFixed(1)) !== 0 || parseFloat(origin.y.toFixed(1)) !== 0) {
68602
+ var delay = m_this.updateDelay();
68603
+ if (delay < 0 && m_lastRenderDuration) {
68604
+ delay = m_lastRenderDuration - Math.floor(1000 / 60 * delay);
68605
+ } else if (m_lastRenderDuration) {
68606
+ delay = m_lastRenderDuration * 2;
68607
+ } else {
68608
+ delay = 100;
68609
+ }
68575
68610
  m_heatMapPosition.timeout = window.setTimeout(function () {
68576
68611
  m_heatMapPosition.timeout = undefined;
68577
68612
  m_this.buildTime().modified();
@@ -74628,7 +74663,9 @@ var webgl_quadFeature = function webgl_quadFeature(arg) {
74628
74663
  return;
74629
74664
  }
74630
74665
  quad.texture.bind(renderState);
74631
-
74666
+ if (context.getError() === context.OUT_OF_MEMORY) {
74667
+ console.log('Insufficient GPU memory for texture');
74668
+ }
74632
74669
  if (quad.opacity !== opacity) {
74633
74670
  opacity = quad.opacity;
74634
74671
  context.uniform1fv(renderState.m_material.shaderProgram().uniformLocation('opacity'), new Float32Array([opacity]));