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.js CHANGED
@@ -33500,8 +33500,10 @@ function continuousVerticesProcessAction(m_this, evt, name) {
33500
33500
  }
33501
33501
  var cpp = layer.options('continuousPointProximity');
33502
33502
  var cpc = layer.options('continuousPointColinearity');
33503
+ var ccp = layer.options('continuousCloseProximity');
33503
33504
  if (cpp || cpp === 0) {
33504
33505
  var vertices = m_this.options('vertices');
33506
+ var update = false;
33505
33507
  if (!vertices.length) {
33506
33508
  vertices.push(evt.mouse.mapgcs);
33507
33509
  vertices.push(evt.mouse.mapgcs);
@@ -33523,8 +33525,17 @@ function continuousVerticesProcessAction(m_this, evt, name) {
33523
33525
  }
33524
33526
  vertices[vertices.length - 1] = evt.mouse.mapgcs;
33525
33527
  vertices.push(evt.mouse.mapgcs);
33526
- return true;
33528
+ update = true;
33529
+ }
33530
+ if ((ccp || ccp === 0) && evt.event === geo_event.actionup && (ccp === true || layer.displayDistance(vertices[0], null, evt.mouse.map, 'display') <= cpp)) {
33531
+ if (vertices.length < 3 + (name === 'polygon' ? 1 : 0)) {
33532
+ return 'remove';
33533
+ }
33534
+ vertices.pop();
33535
+ m_this.state(annotationState.done);
33536
+ return 'done';
33527
33537
  }
33538
+ return update;
33528
33539
  }
33529
33540
  }
33530
33541
 
@@ -46108,8 +46119,11 @@ var transform = __webpack_require__(17);
46108
46119
  * @property {number} [minIntensity=null] Minimum intensity of the data.
46109
46120
  * Minimum intensity must be a positive real number and is used to normalize
46110
46121
  * all intensities within a dataset. If `null`, it is computed.
46111
- * @property {number} [updateDelay=1000] Delay in milliseconds after a zoom,
46112
- * 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.
46113
46127
  * @property {boolean|number|'auto'} [binned='auto'] If `true` or a number,
46114
46128
  * spatially bin data as part of producing the heatmap. If falsy, each
46115
46129
  * datapoint stands on its own. If `'auto'`, bin data if there are more data
@@ -46126,6 +46140,11 @@ var transform = __webpack_require__(17);
46126
46140
  * approximation. The total weight of the gaussian area is approximately the
46127
46141
  * `9/16 r^2`. The sum of `radius + blurRadius` is used as the radius for
46128
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.
46129
46148
  */
46130
46149
 
46131
46150
  /**
@@ -46170,7 +46189,7 @@ var heatmapFeature = function heatmapFeature(arg) {
46170
46189
  m_maxIntensity = arg.maxIntensity !== undefined ? arg.maxIntensity : null;
46171
46190
  m_minIntensity = arg.minIntensity !== undefined ? arg.minIntensity : null;
46172
46191
  m_binned = arg.binned !== undefined ? arg.binned : 'auto';
46173
- m_updateDelay = arg.updateDelay ? parseInt(arg.updateDelay, 10) : 1000;
46192
+ m_updateDelay = arg.updateDelay || arg.updateDelay === 0 ? parseInt(arg.updateDelay, 10) : -1;
46174
46193
 
46175
46194
  /**
46176
46195
  * Get/Set maxIntensity.
@@ -46215,7 +46234,9 @@ var heatmapFeature = function heatmapFeature(arg) {
46215
46234
  *
46216
46235
  * @param {number} [val] If not specified, return the current update delay.
46217
46236
  * If specified, this is the delay in milliseconds after a zoom, rotate,
46218
- * 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.
46219
46240
  * @returns {number|this}
46220
46241
  */
46221
46242
  this.updateDelay = function (val) {
@@ -46325,7 +46346,8 @@ var heatmapFeature = function heatmapFeature(arg) {
46325
46346
  0.25: { r: 0, g: 0, b: 1, a: 0.5 },
46326
46347
  0.5: { r: 0, g: 1, b: 1, a: 0.6 },
46327
46348
  0.75: { r: 1, g: 1, b: 0, a: 0.7 },
46328
- 1: { r: 1, g: 0, b: 0, a: 0.8 } }
46349
+ 1: { r: 1, g: 0, b: 0, a: 0.8 } },
46350
+ scaleWithZoom: false
46329
46351
  }, arg.style === undefined ? {} : arg.style);
46330
46352
 
46331
46353
  m_this.style(defaultStyle);
@@ -58749,6 +58771,7 @@ module.exports.mockWebglRenderer = function mockWebglRenderer(supported) {
58749
58771
  enable: noop('enable'),
58750
58772
  enableVertexAttribArray: noop('enableVertexAttribArray'),
58751
58773
  finish: noop('finish'),
58774
+ getError: noop('getError'),
58752
58775
  getExtension: incID('getExtension'),
58753
58776
  getParameter: function getParameter(key) {
58754
58777
  count('getParameter');
@@ -72079,6 +72102,10 @@ var textFeature = __webpack_require__(80);
72079
72102
  * @property {number} [continuousPointColinearity=1.0deg] The minimum angle
72080
72103
  * between a series of three points when dragging to not interpret them as
72081
72104
  * colinear. Only applies if `continuousPointProximity` is not `false`.
72105
+ * @property {number} [continuousCloseProximity=10] The minimum distance in
72106
+ * display coordinates (pixels) to close a polygon or end drawing a line when
72107
+ * dragging to create an annotation. `false` never closes at the end of a
72108
+ * drag. `true` is effectively infinite.
72082
72109
  * @property {number} [finalPointProximity=10] The maximum distance in display
72083
72110
  * coordinates (pixels) between the starting point and the mouse coordinates
72084
72111
  * to signal closing a polygon. A value of 0 requires an exact match. A
@@ -72185,6 +72212,7 @@ var annotationLayer = function annotationLayer(arg) {
72185
72212
  // in radians, minimum angle between continuous points to interpret them as
72186
72213
  // being coliner
72187
72214
  continuousPointColinearity: 1.0 * Math.PI / 180,
72215
+ continuousCloseProximity: 10, // in pixels, 0 is exact
72188
72216
  finalPointProximity: 10, // in pixels, 0 is exact
72189
72217
  showLabels: true,
72190
72218
  clickToEdit: false
@@ -89111,6 +89139,9 @@ osmLayer.defaults = $.extend({}, tileLayer.defaults, {
89111
89139
  * http://{s}.tile.stamen.com/toner-lite/{z}/{x}/{y}.png */
89112
89140
  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>.';
89113
89141
 
89142
+ /* Per Carto's website regarding basemap attribution: https://carto.com/help/working-with-data/attribution/#basemaps */
89143
+ var CartoAttribution = '<a href="https://carto.com"> Carto</a> ' + 'Contributors <a href="https://www.openstreetmap.org/"> OpenStreetMap</a>';
89144
+
89114
89145
  /**
89115
89146
  * This is a list of known tile sources. It can be added to via
89116
89147
  * `geo.osmLayer.tilesource[<key>] = <object>`, where the object has `url`,
@@ -89119,22 +89150,53 @@ var StamenAttribution = 'Map tiles by <a href="http://stamen.com">Stamen ' + 'De
89119
89150
  * @type {object}
89120
89151
  */
89121
89152
  osmLayer.tileSources = {
89153
+ 'dark-matter-with-labels': {
89154
+ url: ' https://{s}.basemaps.cartocdn.com/rastertiles/dark_all/{z}/{x}/{y}.png',
89155
+ attribution: CartoAttribution,
89156
+ name: 'Carto Dark Matter With Labels',
89157
+ minLevel: 0,
89158
+ maxLevel: 18
89159
+ },
89160
+ 'dark-matter-without-labels': {
89161
+ url: 'https://{s}.basemaps.cartocdn.com/rastertiles/dark_nolabels/{z}/{x}/{y}.png',
89162
+ attribution: CartoAttribution,
89163
+ name: 'Carto Dark Matter Without Labels',
89164
+ minLevel: 0,
89165
+ maxLevel: 18
89166
+ },
89122
89167
  'nationalmap-satellite': {
89123
89168
  url: 'https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}',
89124
89169
  attribution: 'Tile data from <a href="https://basemap.nationalmap.gov/">USGS</a>',
89170
+ name: 'National Map Satellite',
89125
89171
  minLevel: 0,
89126
89172
  maxLevel: 16
89127
89173
  },
89128
89174
  osm: {
89129
89175
  url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
89130
89176
  attribution: 'Tile data &copy; <a href="https://osm.org/copyright">' + 'OpenStreetMap</a> contributors',
89177
+ name: 'OpenStreetMap',
89131
89178
  subdomains: 'abc',
89132
89179
  minLevel: 0,
89133
89180
  maxLevel: 19
89134
89181
  },
89182
+ 'positron-with-labels': {
89183
+ url: 'https://{s}.basemaps.cartocdn.com/rastertiles/light_all/{z}/{x}/{y}.png',
89184
+ attribution: CartoAttribution,
89185
+ name: 'Carto Positron With Labels',
89186
+ minLevel: 0,
89187
+ maxLevel: 18
89188
+ },
89189
+ 'positron-without-labels': {
89190
+ url: 'https://{s}.basemaps.cartocdn.com/rastertiles/light_nolabels/{z}/{x}/{y}.png',
89191
+ attribution: CartoAttribution,
89192
+ name: 'Carto Positron Without Labels',
89193
+ minLevel: 0,
89194
+ maxLevel: 18
89195
+ },
89135
89196
  'stamen-terrain': {
89136
89197
  url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png',
89137
89198
  attribution: StamenAttribution,
89199
+ name: 'Stamen Terrain',
89138
89200
  subdomains: 'abcd',
89139
89201
  minLevel: 0,
89140
89202
  maxLevel: 14
@@ -89142,6 +89204,7 @@ osmLayer.tileSources = {
89142
89204
  'stamen-terrain-background': {
89143
89205
  url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/terrain-background/{z}/{x}/{y}.png',
89144
89206
  attribution: StamenAttribution,
89207
+ name: 'Stamen Terrain Background',
89145
89208
  subdomains: 'abcd',
89146
89209
  minLevel: 0,
89147
89210
  maxLevel: 14
@@ -89149,6 +89212,7 @@ osmLayer.tileSources = {
89149
89212
  'stamen-toner': {
89150
89213
  url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/toner/{z}/{x}/{y}.png',
89151
89214
  attribution: StamenAttribution,
89215
+ name: 'Stamen Toner',
89152
89216
  subdomains: 'abcd',
89153
89217
  minLevel: 0,
89154
89218
  maxLevel: 20
@@ -89156,15 +89220,24 @@ osmLayer.tileSources = {
89156
89220
  'stamen-toner-lite': {
89157
89221
  url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}.png',
89158
89222
  attribution: StamenAttribution,
89223
+ name: 'Stamen Toner Lite',
89159
89224
  subdomains: 'abcd',
89160
89225
  minLevel: 0,
89161
89226
  maxLevel: 20
89162
89227
  },
89163
- 'wikimedia': {
89164
- url: 'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png',
89165
- 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>',
89228
+ 'voyager-with-labels': {
89229
+ url: 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}.png',
89230
+ attribution: CartoAttribution,
89231
+ name: 'Carto Voyager With Labels',
89166
89232
  minLevel: 0,
89167
- maxLevel: 19
89233
+ maxLevel: 18
89234
+ },
89235
+ 'voyager-without-layers': {
89236
+ url: 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager_nolabels/{z}/{x}/{y}.png',
89237
+ attribution: CartoAttribution,
89238
+ name: 'Carto Voyager Without Layers',
89239
+ minLevel: 0,
89240
+ maxLevel: 18
89168
89241
  }
89169
89242
  };
89170
89243
 
@@ -89435,7 +89508,7 @@ module.exports = osmLayer;
89435
89508
  * @constant
89436
89509
  * @type {string}
89437
89510
  */
89438
- module.exports = "1.4.0";
89511
+ module.exports = "1.5.0";
89439
89512
 
89440
89513
  /***/ }),
89441
89514
  /* 630 */
@@ -89453,7 +89526,7 @@ module.exports = "1.4.0";
89453
89526
  * @constant
89454
89527
  * @type {string}
89455
89528
  */
89456
- module.exports = "b5a6d9aaf6dab70f9a45588dcc5e8a8828023042";
89529
+ module.exports = "29ceeda3ffe254a1300d6237e88b3f5bc480c4fa";
89457
89530
 
89458
89531
  /***/ }),
89459
89532
  /* 631 */
@@ -89724,6 +89797,7 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
89724
89797
  m_heatMapTransform,
89725
89798
  s_init = this._init,
89726
89799
  s_update = this._update,
89800
+ m_lastRenderDuration,
89727
89801
  m_renderTime = timestamp();
89728
89802
 
89729
89803
  /**
@@ -89757,15 +89831,22 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
89757
89831
  };
89758
89832
 
89759
89833
  /**
89760
- * Create circle for each data point.
89834
+ * Create a circle to render at each data point.
89761
89835
  *
89762
89836
  * @returns {this}
89763
89837
  */
89764
89838
  this._createCircle = function () {
89765
- var circle, ctx, r, r2, blur, gaussian;
89839
+ var circle, ctx, r, r2, blur, gaussian, scale;
89766
89840
  r = m_this.style('radius');
89767
89841
  blur = m_this.style('blurRadius');
89768
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
+ }
89769
89850
  if (!m_this._circle || m_this._circle.gaussian !== gaussian || m_this._circle.radius !== r || m_this._circle.blurRadius !== blur) {
89770
89851
  circle = m_this._circle = document.createElement('canvas');
89771
89852
  ctx = circle.getContext('2d');
@@ -89990,6 +90071,7 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
89990
90071
  this._renderOnCanvas = function (context2d, map) {
89991
90072
 
89992
90073
  if (m_renderTime.timestamp() < m_this.buildTime().timestamp()) {
90074
+ var starttime = Date.now();
89993
90075
  var data = m_this.data() || [],
89994
90076
  radius = m_this.style('radius') + m_this.style('blurRadius'),
89995
90077
  binned = m_this.binned(),
@@ -89998,9 +90080,12 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
89998
90080
  layer = m_this.layer(),
89999
90081
  mapSize = map.size();
90000
90082
 
90083
+ if (m_this.style('scaleWithZoom')) {
90084
+ radius *= Math.pow(2, map.zoom());
90085
+ }
90001
90086
  /* Determine if we should bin the data */
90002
90087
  if (binned === true || binned === 'auto') {
90003
- 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)));
90004
90089
  if (m_this.binned() === 'auto') {
90005
90090
  var numbins = Math.ceil((mapSize.width + radius * 2) / binned) * Math.ceil((mapSize.height + radius * 2) / binned);
90006
90091
  if (numbins >= data.length) {
@@ -90017,20 +90102,22 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
90017
90102
  context2d.setTransform(1, 0, 0, 1, 0, 0);
90018
90103
  context2d.clearRect(0, 0, mapSize.width, mapSize.height);
90019
90104
  m_heatMapTransform = '';
90020
- map.scheduleAnimationFrame(m_this._setTransform, false);
90021
- layer.canvas().css({ transform: '' });
90022
-
90023
- m_this._createCircle();
90024
- m_this._computeGradient();
90025
- if (!binned) {
90026
- m_this._renderPoints(context2d, map, data, radius);
90027
- } else {
90028
- 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);
90029
90120
  }
90030
- canvas = layer.canvas()[0];
90031
- pixelArray = context2d.getImageData(0, 0, canvas.width, canvas.height);
90032
- m_this._colorize(pixelArray.data, m_this._grad);
90033
- context2d.putImageData(pixelArray, 0, 0);
90034
90121
 
90035
90122
  m_heatMapPosition = {
90036
90123
  zoom: map.zoom(),
@@ -90042,6 +90129,7 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
90042
90129
  };
90043
90130
  m_renderTime.modified();
90044
90131
  layer.renderer().clearCanvas(false);
90132
+ m_lastRenderDuration = Date.now() - starttime;
90045
90133
  }
90046
90134
 
90047
90135
  return m_this;
@@ -90122,6 +90210,14 @@ var canvas_heatmapFeature = function canvas_heatmapFeature(arg) {
90122
90210
  * close to where the heatmap was originally computed, don't bother
90123
90211
  * updating it. */
90124
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
+ }
90125
90221
  m_heatMapPosition.timeout = window.setTimeout(function () {
90126
90222
  m_heatMapPosition.timeout = undefined;
90127
90223
  m_this.buildTime().modified();
@@ -96179,7 +96275,9 @@ var webgl_quadFeature = function webgl_quadFeature(arg) {
96179
96275
  return;
96180
96276
  }
96181
96277
  quad.texture.bind(renderState);
96182
-
96278
+ if (context.getError() === context.OUT_OF_MEMORY) {
96279
+ console.log('Insufficient GPU memory for texture');
96280
+ }
96183
96281
  if (quad.opacity !== opacity) {
96184
96282
  opacity = quad.opacity;
96185
96283
  context.uniform1fv(renderState.m_material.shaderProgram().uniformLocation('opacity'), new Float32Array([opacity]));