geojs 1.4.0 → 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.lean.js CHANGED
@@ -29638,8 +29638,10 @@ function continuousVerticesProcessAction(m_this, evt, name) {
29638
29638
  }
29639
29639
  var cpp = layer.options('continuousPointProximity');
29640
29640
  var cpc = layer.options('continuousPointColinearity');
29641
+ var ccp = layer.options('continuousCloseProximity');
29641
29642
  if (cpp || cpp === 0) {
29642
29643
  var vertices = m_this.options('vertices');
29644
+ var update = false;
29643
29645
  if (!vertices.length) {
29644
29646
  vertices.push(evt.mouse.mapgcs);
29645
29647
  vertices.push(evt.mouse.mapgcs);
@@ -29661,8 +29663,17 @@ function continuousVerticesProcessAction(m_this, evt, name) {
29661
29663
  }
29662
29664
  vertices[vertices.length - 1] = evt.mouse.mapgcs;
29663
29665
  vertices.push(evt.mouse.mapgcs);
29664
- return true;
29666
+ update = true;
29667
+ }
29668
+ if ((ccp || ccp === 0) && evt.event === geo_event.actionup && (ccp === true || layer.displayDistance(vertices[0], null, evt.mouse.map, 'display') <= cpp)) {
29669
+ if (vertices.length < 3 + (name === 'polygon' ? 1 : 0)) {
29670
+ return 'remove';
29671
+ }
29672
+ vertices.pop();
29673
+ m_this.state(annotationState.done);
29674
+ return 'done';
29665
29675
  }
29676
+ return update;
29666
29677
  }
29667
29678
  }
29668
29679
 
@@ -42246,8 +42257,11 @@ var transform = __webpack_require__(7);
42246
42257
  * @property {number} [minIntensity=null] Minimum intensity of the data.
42247
42258
  * Minimum intensity must be a positive real number and is used to normalize
42248
42259
  * all intensities within a dataset. If `null`, it is computed.
42249
- * @property {number} [updateDelay=1000] Delay in milliseconds after a zoom,
42250
- * 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.
42251
42265
  * @property {boolean|number|'auto'} [binned='auto'] If `true` or a number,
42252
42266
  * spatially bin data as part of producing the heatmap. If falsy, each
42253
42267
  * datapoint stands on its own. If `'auto'`, bin data if there are more data
@@ -42264,6 +42278,11 @@ var transform = __webpack_require__(7);
42264
42278
  * approximation. The total weight of the gaussian area is approximately the
42265
42279
  * `9/16 r^2`. The sum of `radius + blurRadius` is used as the radius for
42266
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.
42267
42286
  */
42268
42287
 
42269
42288
  /**
@@ -42308,7 +42327,7 @@ var heatmapFeature = function heatmapFeature(arg) {
42308
42327
  m_maxIntensity = arg.maxIntensity !== undefined ? arg.maxIntensity : null;
42309
42328
  m_minIntensity = arg.minIntensity !== undefined ? arg.minIntensity : null;
42310
42329
  m_binned = arg.binned !== undefined ? arg.binned : 'auto';
42311
- m_updateDelay = arg.updateDelay ? parseInt(arg.updateDelay, 10) : 1000;
42330
+ m_updateDelay = arg.updateDelay || arg.updateDelay === 0 ? parseInt(arg.updateDelay, 10) : -1;
42312
42331
 
42313
42332
  /**
42314
42333
  * Get/Set maxIntensity.
@@ -42353,7 +42372,9 @@ var heatmapFeature = function heatmapFeature(arg) {
42353
42372
  *
42354
42373
  * @param {number} [val] If not specified, return the current update delay.
42355
42374
  * If specified, this is the delay in milliseconds after a zoom, rotate,
42356
- * 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.
42357
42378
  * @returns {number|this}
42358
42379
  */
42359
42380
  this.updateDelay = function (val) {
@@ -42463,7 +42484,8 @@ var heatmapFeature = function heatmapFeature(arg) {
42463
42484
  0.25: { r: 0, g: 0, b: 1, a: 0.5 },
42464
42485
  0.5: { r: 0, g: 1, b: 1, a: 0.6 },
42465
42486
  0.75: { r: 1, g: 1, b: 0, a: 0.7 },
42466
- 1: { r: 1, g: 0, b: 0, a: 0.8 } }
42487
+ 1: { r: 1, g: 0, b: 0, a: 0.8 } },
42488
+ scaleWithZoom: false
42467
42489
  }, arg.style === undefined ? {} : arg.style);
42468
42490
 
42469
42491
  m_this.style(defaultStyle);
@@ -49310,6 +49332,7 @@ module.exports.mockWebglRenderer = function mockWebglRenderer(supported) {
49310
49332
  enable: noop('enable'),
49311
49333
  enableVertexAttribArray: noop('enableVertexAttribArray'),
49312
49334
  finish: noop('finish'),
49335
+ getError: noop('getError'),
49313
49336
  getExtension: incID('getExtension'),
49314
49337
  getParameter: function getParameter(key) {
49315
49338
  count('getParameter');
@@ -62667,6 +62690,10 @@ var textFeature = __webpack_require__(28);
62667
62690
  * @property {number} [continuousPointColinearity=1.0deg] The minimum angle
62668
62691
  * between a series of three points when dragging to not interpret them as
62669
62692
  * colinear. Only applies if `continuousPointProximity` is not `false`.
62693
+ * @property {number} [continuousCloseProximity=10] The minimum distance in
62694
+ * display coordinates (pixels) to close a polygon or end drawing a line when
62695
+ * dragging to create an annotation. `false` never closes at the end of a
62696
+ * drag. `true` is effectively infinite.
62670
62697
  * @property {number} [finalPointProximity=10] The maximum distance in display
62671
62698
  * coordinates (pixels) between the starting point and the mouse coordinates
62672
62699
  * to signal closing a polygon. A value of 0 requires an exact match. A
@@ -62773,6 +62800,7 @@ var annotationLayer = function annotationLayer(arg) {
62773
62800
  // in radians, minimum angle between continuous points to interpret them as
62774
62801
  // being coliner
62775
62802
  continuousPointColinearity: 1.0 * Math.PI / 180,
62803
+ continuousCloseProximity: 10, // in pixels, 0 is exact
62776
62804
  finalPointProximity: 10, // in pixels, 0 is exact
62777
62805
  showLabels: true,
62778
62806
  clickToEdit: false
@@ -67500,6 +67528,9 @@ osmLayer.defaults = $.extend({}, tileLayer.defaults, {
67500
67528
  * http://{s}.tile.stamen.com/toner-lite/{z}/{x}/{y}.png */
67501
67529
  var StamenAttribution = 'Map tiles by <a href="http://stamen.com">Stamen ' + 'Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">' + 'CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap' + '</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.';
67502
67530
 
67531
+ /* Per Carto's website regarding basemap attribution: https://carto.com/help/working-with-data/attribution/#basemaps */
67532
+ var CartoAttribution = '<a href="https://carto.com"> Carto</a> ' + 'Contributors <a href="https://www.openstreetmap.org/"> OpenStreetMap</a>';
67533
+
67503
67534
  /**
67504
67535
  * This is a list of known tile sources. It can be added to via
67505
67536
  * `geo.osmLayer.tilesource[<key>] = <object>`, where the object has `url`,
@@ -67508,22 +67539,53 @@ var StamenAttribution = 'Map tiles by <a href="http://stamen.com">Stamen ' + 'De
67508
67539
  * @type {object}
67509
67540
  */
67510
67541
  osmLayer.tileSources = {
67542
+ 'dark-matter-with-labels': {
67543
+ url: ' https://{s}.basemaps.cartocdn.com/rastertiles/dark_all/{z}/{x}/{y}.png',
67544
+ attribution: CartoAttribution,
67545
+ name: 'Carto Dark Matter With Labels',
67546
+ minLevel: 0,
67547
+ maxLevel: 18
67548
+ },
67549
+ 'dark-matter-without-labels': {
67550
+ url: 'https://{s}.basemaps.cartocdn.com/rastertiles/dark_nolabels/{z}/{x}/{y}.png',
67551
+ attribution: CartoAttribution,
67552
+ name: 'Carto Dark Matter Without Labels',
67553
+ minLevel: 0,
67554
+ maxLevel: 18
67555
+ },
67511
67556
  'nationalmap-satellite': {
67512
67557
  url: 'https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}',
67513
67558
  attribution: 'Tile data from <a href="https://basemap.nationalmap.gov/">USGS</a>',
67559
+ name: 'National Map Satellite',
67514
67560
  minLevel: 0,
67515
67561
  maxLevel: 16
67516
67562
  },
67517
67563
  osm: {
67518
67564
  url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
67519
67565
  attribution: 'Tile data &copy; <a href="https://osm.org/copyright">' + 'OpenStreetMap</a> contributors',
67566
+ name: 'OpenStreetMap',
67520
67567
  subdomains: 'abc',
67521
67568
  minLevel: 0,
67522
67569
  maxLevel: 19
67523
67570
  },
67571
+ 'positron-with-labels': {
67572
+ url: 'https://{s}.basemaps.cartocdn.com/rastertiles/light_all/{z}/{x}/{y}.png',
67573
+ attribution: CartoAttribution,
67574
+ name: 'Carto Positron With Labels',
67575
+ minLevel: 0,
67576
+ maxLevel: 18
67577
+ },
67578
+ 'positron-without-labels': {
67579
+ url: 'https://{s}.basemaps.cartocdn.com/rastertiles/light_nolabels/{z}/{x}/{y}.png',
67580
+ attribution: CartoAttribution,
67581
+ name: 'Carto Positron Without Labels',
67582
+ minLevel: 0,
67583
+ maxLevel: 18
67584
+ },
67524
67585
  'stamen-terrain': {
67525
67586
  url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png',
67526
67587
  attribution: StamenAttribution,
67588
+ name: 'Stamen Terrain',
67527
67589
  subdomains: 'abcd',
67528
67590
  minLevel: 0,
67529
67591
  maxLevel: 14
@@ -67531,6 +67593,7 @@ osmLayer.tileSources = {
67531
67593
  'stamen-terrain-background': {
67532
67594
  url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/terrain-background/{z}/{x}/{y}.png',
67533
67595
  attribution: StamenAttribution,
67596
+ name: 'Stamen Terrain Background',
67534
67597
  subdomains: 'abcd',
67535
67598
  minLevel: 0,
67536
67599
  maxLevel: 14
@@ -67538,6 +67601,7 @@ osmLayer.tileSources = {
67538
67601
  'stamen-toner': {
67539
67602
  url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/toner/{z}/{x}/{y}.png',
67540
67603
  attribution: StamenAttribution,
67604
+ name: 'Stamen Toner',
67541
67605
  subdomains: 'abcd',
67542
67606
  minLevel: 0,
67543
67607
  maxLevel: 20
@@ -67545,15 +67609,24 @@ osmLayer.tileSources = {
67545
67609
  'stamen-toner-lite': {
67546
67610
  url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}.png',
67547
67611
  attribution: StamenAttribution,
67612
+ name: 'Stamen Toner Lite',
67548
67613
  subdomains: 'abcd',
67549
67614
  minLevel: 0,
67550
67615
  maxLevel: 20
67551
67616
  },
67552
- 'wikimedia': {
67553
- url: 'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png',
67554
- attribution: '<a href="https://wikimediafoundation.org/wiki/Maps_Terms_of_Use">Wikimedia maps</a> | Map data &copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap contributors</a>',
67617
+ 'voyager-with-labels': {
67618
+ url: 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}.png',
67619
+ attribution: CartoAttribution,
67620
+ name: 'Carto Voyager With Labels',
67555
67621
  minLevel: 0,
67556
- maxLevel: 19
67622
+ maxLevel: 18
67623
+ },
67624
+ 'voyager-without-layers': {
67625
+ url: 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager_nolabels/{z}/{x}/{y}.png',
67626
+ attribution: CartoAttribution,
67627
+ name: 'Carto Voyager Without Layers',
67628
+ minLevel: 0,
67629
+ maxLevel: 18
67557
67630
  }
67558
67631
  };
67559
67632
 
@@ -67824,7 +67897,7 @@ module.exports = osmLayer;
67824
67897
  * @constant
67825
67898
  * @type {string}
67826
67899
  */
67827
- module.exports = "1.4.0";
67900
+ module.exports = "1.5.0";
67828
67901
 
67829
67902
  /***/ }),
67830
67903
  /* 297 */
@@ -67842,7 +67915,7 @@ module.exports = "1.4.0";
67842
67915
  * @constant
67843
67916
  * @type {string}
67844
67917
  */
67845
- module.exports = "b5a6d9aaf6dab70f9a45588dcc5e8a8828023042";
67918
+ module.exports = "29ceeda3ffe254a1300d6237e88b3f5bc480c4fa";
67846
67919
 
67847
67920
  /***/ }),
67848
67921
  /* 298 */
@@ -68113,6 +68186,7 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
68113
68186
  m_heatMapTransform,
68114
68187
  s_init = this._init,
68115
68188
  s_update = this._update,
68189
+ m_lastRenderDuration,
68116
68190
  m_renderTime = timestamp();
68117
68191
 
68118
68192
  /**
@@ -68146,15 +68220,22 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
68146
68220
  };
68147
68221
 
68148
68222
  /**
68149
- * Create circle for each data point.
68223
+ * Create a circle to render at each data point.
68150
68224
  *
68151
68225
  * @returns {this}
68152
68226
  */
68153
68227
  this._createCircle = function () {
68154
- var circle, ctx, r, r2, blur, gaussian;
68228
+ var circle, ctx, r, r2, blur, gaussian, scale;
68155
68229
  r = m_this.style('radius');
68156
68230
  blur = m_this.style('blurRadius');
68157
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
+ }
68158
68239
  if (!m_this._circle || m_this._circle.gaussian !== gaussian || m_this._circle.radius !== r || m_this._circle.blurRadius !== blur) {
68159
68240
  circle = m_this._circle = document.createElement('canvas');
68160
68241
  ctx = circle.getContext('2d');
@@ -68379,6 +68460,7 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
68379
68460
  this._renderOnCanvas = function (context2d, map) {
68380
68461
 
68381
68462
  if (m_renderTime.timestamp() < m_this.buildTime().timestamp()) {
68463
+ var starttime = Date.now();
68382
68464
  var data = m_this.data() || [],
68383
68465
  radius = m_this.style('radius') + m_this.style('blurRadius'),
68384
68466
  binned = m_this.binned(),
@@ -68387,9 +68469,12 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
68387
68469
  layer = m_this.layer(),
68388
68470
  mapSize = map.size();
68389
68471
 
68472
+ if (m_this.style('scaleWithZoom')) {
68473
+ radius *= Math.pow(2, map.zoom());
68474
+ }
68390
68475
  /* Determine if we should bin the data */
68391
68476
  if (binned === true || binned === 'auto') {
68392
- 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)));
68393
68478
  if (m_this.binned() === 'auto') {
68394
68479
  var numbins = Math.ceil((mapSize.width + radius * 2) / binned) * Math.ceil((mapSize.height + radius * 2) / binned);
68395
68480
  if (numbins >= data.length) {
@@ -68406,20 +68491,22 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
68406
68491
  context2d.setTransform(1, 0, 0, 1, 0, 0);
68407
68492
  context2d.clearRect(0, 0, mapSize.width, mapSize.height);
68408
68493
  m_heatMapTransform = '';
68409
- map.scheduleAnimationFrame(m_this._setTransform, false);
68410
- layer.canvas().css({ transform: '' });
68411
-
68412
- m_this._createCircle();
68413
- m_this._computeGradient();
68414
- if (!binned) {
68415
- m_this._renderPoints(context2d, map, data, radius);
68416
- } else {
68417
- 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);
68418
68509
  }
68419
- canvas = layer.canvas()[0];
68420
- pixelArray = context2d.getImageData(0, 0, canvas.width, canvas.height);
68421
- m_this._colorize(pixelArray.data, m_this._grad);
68422
- context2d.putImageData(pixelArray, 0, 0);
68423
68510
 
68424
68511
  m_heatMapPosition = {
68425
68512
  zoom: map.zoom(),
@@ -68431,6 +68518,7 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
68431
68518
  };
68432
68519
  m_renderTime.modified();
68433
68520
  layer.renderer().clearCanvas(false);
68521
+ m_lastRenderDuration = Date.now() - starttime;
68434
68522
  }
68435
68523
 
68436
68524
  return m_this;
@@ -68511,6 +68599,14 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
68511
68599
  * close to where the heatmap was originally computed, don't bother
68512
68600
  * updating it. */
68513
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
+ }
68514
68610
  m_heatMapPosition.timeout = window.setTimeout(function () {
68515
68611
  m_heatMapPosition.timeout = undefined;
68516
68612
  m_this.buildTime().modified();
@@ -74567,7 +74663,9 @@ var webgl_quadFeature = function webgl_quadFeature(arg) {
74567
74663
  return;
74568
74664
  }
74569
74665
  quad.texture.bind(renderState);
74570
-
74666
+ if (context.getError() === context.OUT_OF_MEMORY) {
74667
+ console.log('Insufficient GPU memory for texture');
74668
+ }
74571
74669
  if (quad.opacity !== opacity) {
74572
74670
  opacity = quad.opacity;
74573
74671
  context.uniform1fv(renderState.m_material.shaderProgram().uniformLocation('opacity'), new Float32Array([opacity]));