geojs 1.4.3 → 1.6.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 (49) hide show
  1. package/.github/workflows/main.yml +3 -3
  2. package/CHANGELOG.md +273 -247
  3. package/geo.js +82534 -86247
  4. package/geo.lean.js +69723 -64014
  5. package/geo.lean.min.js +28 -41
  6. package/geo.min.js +30 -47
  7. package/package.json +64 -84
  8. package/src/annotationLayer.js +13 -13
  9. package/src/canvas/heatmapFeature.js +39 -16
  10. package/src/choroplethFeature.js +3 -3
  11. package/src/feature.js +4 -4
  12. package/src/geojsonReader.js +5 -4
  13. package/src/heatmapFeature.js +16 -5
  14. package/src/index.js +1 -1
  15. package/src/isolineFeature.js +4 -4
  16. package/src/lineFeature.js +4 -4
  17. package/src/map.js +2 -2
  18. package/src/mapInteractor.js +3 -0
  19. package/src/markerFeature.js +8 -8
  20. package/src/object.js +1 -3
  21. package/src/osmLayer.js +5 -3
  22. package/src/pixelmapFeature.js +1 -1
  23. package/src/pointFeature.js +1 -1
  24. package/src/polygonFeature.js +4 -4
  25. package/src/registry.js +1 -1
  26. package/src/svg/svgRenderer.js +3 -0
  27. package/src/svg/vectorFeature.js +1 -1
  28. package/src/tile.js +1 -1
  29. package/src/tileLayer.js +4 -4
  30. package/src/trackFeature.js +12 -12
  31. package/src/transform.js +11 -10
  32. package/src/ui/colorLegendWidget.js +6 -6
  33. package/src/ui/colorLegendWidget.styl +1 -1
  34. package/src/ui/legendWidget.js +3 -3
  35. package/src/ui/sliderWidget.js +4 -4
  36. package/src/util/common.js +9 -8
  37. package/src/util/mockVGL.js +3 -2
  38. package/src/util/throttle.js +3 -3
  39. package/src/vendor.js +0 -2
  40. package/src/vtkjs/vtkjsRenderer.js +3 -0
  41. package/src/webgl/layer.js +1 -1
  42. package/src/webgl/markerFeature.js +4 -4
  43. package/src/webgl/meshColored.js +3 -3
  44. package/src/webgl/pointFeature.js +11 -11
  45. package/src/webgl/polygonFeature.js +3 -3
  46. package/src/webgl/quadFeature.js +3 -1
  47. package/src/webgl/quadFeatureColor.vert +0 -1
  48. package/src/webgl/webglRenderer.js +1 -2
  49. package/src/polyfills.js +0 -4
@@ -111,11 +111,11 @@ var markerFeature = function (arg) {
111
111
  pts = m_this.data().map(function (d, i) {
112
112
  var pt = position(d, i);
113
113
 
114
- let r = radius(d, i),
115
- swz = scaleWithZoom(d, i),
114
+ let swz = scaleWithZoom(d, i);
115
+ const r = radius(d, i),
116
116
  s = strokeWidth(d, i),
117
117
  so = Math.sign(strokeOffset(d, i));
118
- let rwiths = r + s * (so + 1) / 2, // radius with stroke
118
+ const rwiths = r + s * (so + 1) / 2, // radius with stroke
119
119
  rwos = r + s * (so - 1) / 2; // radius without stroke
120
120
  swz = markerFeature.scaleMode[swz] || (swz >= 1 && swz <= 3 ? swz : 0);
121
121
  switch (swz) {
@@ -155,7 +155,7 @@ var markerFeature = function (arg) {
155
155
  */
156
156
  this._approximateMaxRadius = function (zoom) {
157
157
  m_this._updateRangeTree();
158
- let zoomFactor = Math.pow(2, zoom);
158
+ const zoomFactor = Math.pow(2, zoom);
159
159
  return Math.max(m_maxFixedRadius + m_maxZoomStroke * zoomFactor, m_maxZoomRadius * zoomFactor);
160
160
  };
161
161
 
@@ -344,10 +344,10 @@ var markerFeature = function (arg) {
344
344
  var d = data[i];
345
345
  let p = m_this.position()(d, i);
346
346
  let rad = radius(data[i], i),
347
- swz = scaleWithZoom(data[i], i),
348
- so = strokeOffset(data[i], i),
347
+ swz = scaleWithZoom(data[i], i);
348
+ const so = strokeOffset(data[i], i),
349
349
  s = swz ? strokeWidth(data[i], i) : 0;
350
- let rwos = rad + s * (so - 1) / 2; // radius without stroke
350
+ const rwos = rad + s * (so - 1) / 2; // radius without stroke
351
351
  swz = markerFeature.scaleMode[swz] || (swz >= 1 && swz <= 3 ? swz : 0);
352
352
  rad = rwos + s;
353
353
  switch (swz) {
@@ -363,7 +363,7 @@ var markerFeature = function (arg) {
363
363
  }
364
364
  if (rad) {
365
365
  p = map.gcsToDisplay(p, fgcs);
366
- let dist = util.distanceToPolygon2d(p, poly);
366
+ const dist = util.distanceToPolygon2d(p, poly);
367
367
  if (dist >= rad || (dist >= 0 && opts.partial === 'center') || (dist >= -rad && opts.partial && opts.partial !== 'center')) {
368
368
  found.push(d);
369
369
  ifound.push(i);
package/src/object.js CHANGED
@@ -166,9 +166,7 @@ var object = function () {
166
166
  * the handler that was passed to the function.
167
167
  */
168
168
  this.geoOnce = function (event, handler) {
169
- let wrapper;
170
-
171
- wrapper = function (args) {
169
+ const wrapper = function (args) {
172
170
  m_this.geoOff(event, wrapper);
173
171
  handler.call(m_this, args);
174
172
  };
package/src/osmLayer.js CHANGED
@@ -44,6 +44,8 @@ var osmLayer = function (arg) {
44
44
  this.constructor.defaults,
45
45
  osmLayer.tileSources[this.constructor.defaults.source] || {},
46
46
  osmLayer.tileSources[arg.source] || {},
47
+ // don't name the layer based on the source
48
+ {name: ''},
47
49
  arg);
48
50
  tileLayer.call(this, arg);
49
51
 
@@ -93,7 +95,7 @@ var osmLayer = function (arg) {
93
95
  */
94
96
  this.source = function (source) {
95
97
  if (source === undefined) {
96
- for (let key in osmLayer.tileSources) {
98
+ for (const key in osmLayer.tileSources) {
97
99
  if (osmLayer.tileSources[key].url === m_this.url()) {
98
100
  return key;
99
101
  }
@@ -126,13 +128,13 @@ osmLayer.defaults = $.extend({}, tileLayer.defaults, {
126
128
  /* Stamen's website (http://maps.stamen.com) as of 2019-08-28 says that the
127
129
  * maps they host may be used free of charge. For http access, use a url like
128
130
  * http://{s}.tile.stamen.com/toner-lite/{z}/{x}/{y}.png */
129
- let StamenAttribution = 'Map tiles by <a href="http://stamen.com">Stamen ' +
131
+ const StamenAttribution = 'Map tiles by <a href="http://stamen.com">Stamen ' +
130
132
  'Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">' +
131
133
  'CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap' +
132
134
  '</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.';
133
135
 
134
136
  /* Per Carto's website regarding basemap attribution: https://carto.com/help/working-with-data/attribution/#basemaps */
135
- let CartoAttribution = '<a href="https://carto.com"> Carto</a> ' + 'Contributors <a href="https://www.openstreetmap.org/"> OpenStreetMap</a>';
137
+ const CartoAttribution = '<a href="https://carto.com"> Carto</a> ' + 'Contributors <a href="https://www.openstreetmap.org/"> OpenStreetMap</a>';
136
138
 
137
139
  /**
138
140
  * This is a list of known tile sources. It can be added to via
@@ -47,7 +47,7 @@ var util = require('./util');
47
47
  * @property {object[]} mappedColors This has one entry for each distinct index
48
48
  * value. Each entry has `first` and `last` with the first and last pixel
49
49
  * locations where that index occurs. Note that last is the inclusive value
50
- * of the location (so its maximum possible value is `size -1`).
50
+ * of the location (so its maximum possible value is `size - 1`).
51
51
  */
52
52
 
53
53
  /**
@@ -443,7 +443,7 @@ var pointFeature = function (arg) {
443
443
  rad += hasstroke ? strokeWidth(data[i], i) : 0;
444
444
  if (rad) {
445
445
  p = map.gcsToDisplay(p, fgcs);
446
- let dist = util.distanceToPolygon2d(p, poly);
446
+ const dist = util.distanceToPolygon2d(p, poly);
447
447
  if (dist >= rad || (dist >= 0 && opts.partial === 'center') || (dist >= -rad && opts.partial && opts.partial !== 'center')) {
448
448
  found.push(d);
449
449
  ifound.push(i);
@@ -113,7 +113,7 @@ var polygonFeature = function (arg) {
113
113
  * `outer` and `inner` if it has any coordinates, or is `undefined`.
114
114
  */
115
115
  function getCoordinates(data, posFunc, polyFunc) {
116
- let fcs = m_this.gcs(),
116
+ const fcs = m_this.gcs(),
117
117
  mapgcs = m_this.layer().map().gcs();
118
118
  data = data || m_this.data();
119
119
  posFunc = posFunc || m_this.style.get('position');
@@ -121,7 +121,7 @@ var polygonFeature = function (arg) {
121
121
  var coordinates = data.map(function (d, i) {
122
122
  var poly = polyFunc(d, i);
123
123
  if (!poly) {
124
- return;
124
+ return undefined;
125
125
  }
126
126
  var outer, inner, range, coord, j, x, y, mapouter, mapinner, maprange;
127
127
 
@@ -350,9 +350,9 @@ var polygonFeature = function (arg) {
350
350
  let inside, partial;
351
351
  // do something similar to the line's polygonSearch
352
352
  for (let r = -1; r < coord.mapinner.length && !partial; r += 1) {
353
- let record = r < 0 ? coord.mapouter : coord.mapinner[r];
353
+ const record = r < 0 ? coord.mapouter : coord.mapinner[r];
354
354
  for (let i = 0, len = record.length, j = len - 1; i < len; j = i, i += 1) {
355
- let dist0 = util.distanceToPolygon2d(record[i], poly),
355
+ const dist0 = util.distanceToPolygon2d(record[i], poly),
356
356
  dist1 = util.distanceToPolygon2d(record[j], poly);
357
357
  if (dist0 * dist1 < 0) {
358
358
  partial = true;
package/src/registry.js CHANGED
@@ -216,7 +216,7 @@ util.registerFeature = function (category, name, func, capabilities) {
216
216
  */
217
217
  util.createFeature = function (name, layer, renderer, arg) {
218
218
  var category = renderer.api(),
219
- options = {'layer': layer, 'renderer': renderer};
219
+ options = {layer: layer, renderer: renderer};
220
220
  if (category in features && name in features[category]) {
221
221
  if (arg !== undefined) {
222
222
  $.extend(true, options, arg);
@@ -681,6 +681,9 @@ svgRenderer.supported = function () {
681
681
  // webpack expects optional dependencies to be wrapped in a try-catch
682
682
  try {
683
683
  svgRenderer.d3 = require('d3');
684
+ if (!svgRenderer.d3 || !svgRenderer.d3.rgb) {
685
+ svgRenderer.d3 = undefined;
686
+ }
684
687
  } catch (_error) {}
685
688
  return svgRenderer.d3 !== undefined;
686
689
  };
@@ -157,7 +157,7 @@ var svg_vectorFeature = function (arg) {
157
157
  .each(function (d) {
158
158
  var marker = d3.select(this);
159
159
  var markerData = d.head ? markerConfigs[endStyle(d.data, d.dataIndex)] : markerConfigs[originStyle(d.data, d.dataIndex)];
160
- Object.keys(markerData.attrs).map(function (attrName) {
160
+ Object.keys(markerData.attrs).forEach(function (attrName) {
161
161
  marker.attr(attrName, markerData.attrs[attrName]);
162
162
  });
163
163
  })
package/src/tile.js CHANGED
@@ -144,7 +144,7 @@ var tile = function (spec) {
144
144
  };
145
145
 
146
146
  /**
147
- * Return a unique string representation of the given tile useble as a hash
147
+ * Return a unique string representation of the given tile usable as a hash
148
148
  * key. Possibly extend later to include url information to make caches
149
149
  * aware of the tile source.
150
150
  *
package/src/tileLayer.js CHANGED
@@ -121,10 +121,10 @@ function m_getTileSubdomain(x, y, z, subdomains) {
121
121
  * @private.
122
122
  */
123
123
  function m_tileUrlFromTemplate(base) {
124
- var xPattern = new RegExp(/\$?\{[xX]\}/g),
125
- yPattern = new RegExp(/\$?\{[yY]\}/g),
126
- zPattern = new RegExp(/\$?\{[zZ]\}/g),
127
- sPattern = new RegExp(/\$?\{(s|S|[sS]:[^{}]+|[^-{}]-[^-{}]|([^,{}]+,)+[^,{}]+)\}/);
124
+ var xPattern = /\$?\{[xX]\}/g,
125
+ yPattern = /\$?\{[yY]\}/g,
126
+ zPattern = /\$?\{[zZ]\}/g,
127
+ sPattern = /\$?\{(s|S|[sS]:[^{}]+|[^-{}]-[^-{}]|([^,{}]+,)+[^,{}]+)\}/;
128
128
  var url = base
129
129
  .replace(new RegExp(sPattern, 'g'), '{s}')
130
130
  .replace(xPattern, '{x}')
@@ -228,21 +228,21 @@ var trackFeature = function (arg) {
228
228
  if (d.posidx1 === undefined) {
229
229
  pos = m_tracks.positionFunc(tracks[i][d.posidx], d.posidx, tracks[i], i);
230
230
  } else {
231
- pos0 = trans.forward(m_tracks.positionFunc(tracks[i][d.posidx0], d.posidx0, tracks[i], i));
232
- pos1 = trans.forward(m_tracks.positionFunc(tracks[i][d.posidx1], d.posidx1, tracks[i], i));
231
+ pos0 = trans.forward(m_tracks.positionFunc(tracks[i][d.posidx0], d.posidx0, tracks[i], i), true);
232
+ pos1 = trans.forward(m_tracks.positionFunc(tracks[i][d.posidx1], d.posidx1, tracks[i], i), true);
233
233
  pos = trans.inverse({
234
234
  x: pos0.x * d.factor0 + pos1.x * d.factor1,
235
235
  y: pos0.y * d.factor0 + pos1.y * d.factor1,
236
236
  z: (pos0.z || 0) * d.factor0 + (pos1.z || 0) * d.factor1
237
- });
237
+ }, true);
238
238
  }
239
239
  d.x = pos.x;
240
240
  d.y = pos.y;
241
241
  d.z = pos.z || 0;
242
242
  if (calcAngle) {
243
243
  if (d.posidx1 === undefined) {
244
- pos0 = trans.forward(d.angidx0 === d.posidx ? pos : m_tracks.positionFunc(tracks[i][d.angidx0], d.angidx0, tracks[i], i));
245
- pos1 = trans.forward(d.angidx1 === d.posidx ? pos : m_tracks.positionFunc(tracks[i][d.angidx1], d.angidx1, tracks[i], i));
244
+ pos0 = trans.forward(d.angidx0 === d.posidx ? pos : m_tracks.positionFunc(tracks[i][d.angidx0], d.angidx0, tracks[i], i), true);
245
+ pos1 = trans.forward(d.angidx1 === d.posidx ? pos : m_tracks.positionFunc(tracks[i][d.angidx1], d.angidx1, tracks[i], i), true);
246
246
  }
247
247
  d.angle = Math.atan2(pos1.y - pos0.y, pos1.x - pos0.x);
248
248
  }
@@ -319,25 +319,25 @@ var trackFeature = function (arg) {
319
319
  });
320
320
  if (hasMarker && !m_markerFeature) {
321
321
  if (!(registry.registries.features[m_this.layer().rendererName()] || {}).marker) {
322
- let renderer = registry.rendererForFeatures(['marker']);
322
+ const renderer = registry.rendererForFeatures(['marker']);
323
323
  m_markerLayer = registry.createLayer('feature', m_this.layer().map(), {renderer: renderer});
324
324
  m_this.layer().addChild(m_markerLayer);
325
325
  m_this.layer().node().append(m_markerLayer.node());
326
326
  }
327
327
  m_markerFeature = (m_markerLayer || m_this.layer()).createFeature('marker');
328
- let df = m_this.dependentFeatures();
328
+ const df = m_this.dependentFeatures();
329
329
  df.push(m_markerFeature);
330
330
  m_this.dependentFeatures(df);
331
331
  }
332
332
  if (hasText && !m_textFeature) {
333
333
  if (!(registry.registries.features[m_this.layer().rendererName()] || {}).text) {
334
- let renderer = registry.rendererForFeatures(['text']);
334
+ const renderer = registry.rendererForFeatures(['text']);
335
335
  m_textLayer = registry.createLayer('feature', m_this.layer().map(), {renderer: renderer});
336
336
  m_this.layer().addChild(m_textLayer);
337
337
  m_this.layer().node().append(m_textLayer.node());
338
338
  }
339
339
  m_textFeature = (m_textLayer || m_this.layer()).createFeature('text');
340
- let df = m_this.dependentFeatures();
340
+ const df = m_this.dependentFeatures();
341
341
  df.push(m_textFeature);
342
342
  m_this.dependentFeatures(df);
343
343
  }
@@ -348,7 +348,7 @@ var trackFeature = function (arg) {
348
348
  .gcs(m_this.gcs())
349
349
  .data(data)
350
350
  .position(m_this._headPosition);
351
- let radiusFunc = m_markerFeature.style.get('radius');
351
+ const radiusFunc = m_markerFeature.style.get('radius');
352
352
  m_markerFeature.style('radius', (d, i) => {
353
353
  if (m_tracks.text[i] || m_tracks.startPosition[i].posidx < 0) {
354
354
  return 0;
@@ -728,7 +728,7 @@ var trackFeature = function (arg) {
728
728
  * if the point was found in the current part of the track.
729
729
  */
730
730
  this.pointSearch = function (p) {
731
- let result = m_lineFeatures.current.pointSearch(p),
731
+ const result = m_lineFeatures.current.pointSearch(p),
732
732
  past = m_lineFeatures.past.pointSearch(p),
733
733
  future = m_lineFeatures.future.pointSearch(p),
734
734
  marker = m_markerFeature ? m_markerFeature.pointSearch(p) : {index: []};
@@ -759,7 +759,7 @@ var trackFeature = function (arg) {
759
759
  * the current part of the track.
760
760
  */
761
761
  this.polygonSearch = function (poly, opts) {
762
- let result = m_lineFeatures.current.polygonSearch(poly, opts),
762
+ const result = m_lineFeatures.current.polygonSearch(poly, opts),
763
763
  past = m_lineFeatures.past.polygonSearch(poly, opts),
764
764
  future = m_lineFeatures.future.polygonSearch(poly, opts),
765
765
  marker = m_markerFeature ? m_markerFeature.polygonSearch(poly, opts) : {index: []};
package/src/transform.js CHANGED
@@ -19,8 +19,8 @@ var maxTransformCacheSize = 10;
19
19
 
20
20
  /* A RegExp to detect if two transforms only different by the middle axis's
21
21
  * direction. */
22
- var axisPattern = new RegExp('^(.* |)\\+axis=e(n|s)u(| .*)$');
23
- var affinePattern = new RegExp(/(^|\s)\+(s[1-3][1-3]|[xyz]off)=\S/);
22
+ var axisPattern = /^(.* |)\\+axis=e(n|s)u(| .*)$/;
23
+ var affinePattern = /(^|\s)\+(s[1-3][1-3]|[xyz]off)=\S/;
24
24
 
25
25
  /**
26
26
  * This purpose of this class is to provide a generic interface for computing
@@ -49,13 +49,13 @@ var transform = function (options) {
49
49
  if (!(this instanceof transform)) {
50
50
  options = options || {};
51
51
  if (!(options.source in transformCache)) {
52
- if (Object.size(transformCache) >= maxTransformCacheSize) {
52
+ if (Object.keys(transformCache).length >= maxTransformCacheSize) {
53
53
  transformCache = {};
54
54
  }
55
55
  transformCache[options.source] = {};
56
56
  }
57
57
  if (!(options.target in transformCache[options.source])) {
58
- if (Object.size(transformCache[options.source]) >= maxTransformCacheSize) {
58
+ if (Object.keys(transformCache[options.source]).length >= maxTransformCacheSize) {
59
59
  transformCache[options.source] = {};
60
60
  }
61
61
  transformCache[options.source][options.target] = new transform(options);
@@ -193,7 +193,7 @@ var transform = function (options) {
193
193
  var mp = vec3.transformMat4(util.vec3AsArray(), [point.x, point.y, point.z || 0], m_source_matrix_inv);
194
194
  point = {x: mp[0], y: mp[1], z: mp[2]};
195
195
  }
196
- var pt = m_proj.forward(point);
196
+ var pt = m_proj.forward(point, true);
197
197
  pt.z = point.z || 0;
198
198
  if (m_target_matrix) {
199
199
  var ip = vec3.transformMat4(util.vec3AsArray(), [pt.x, pt.y, pt.z], m_target_matrix);
@@ -214,7 +214,7 @@ var transform = function (options) {
214
214
  var mp = vec3.transformMat4(util.vec3AsArray(), [point.x, point.y, point.z || 0], m_target_matrix_inv);
215
215
  point = {x: mp[0], y: mp[1], z: mp[2]};
216
216
  }
217
- var pt = m_proj.inverse(point);
217
+ var pt = m_proj.inverse(point, true);
218
218
  pt.z = point.z || 0;
219
219
  if (m_source_matrix) {
220
220
  var ip = vec3.transformMat4(util.vec3AsArray(), [pt.x, pt.y, pt.z], m_source_matrix);
@@ -359,7 +359,7 @@ transform.transformCoordinates = function (srcPrj, tgtPrj, coordinates, numberOf
359
359
  }
360
360
  var trans = transform({source: srcPrj, target: tgtPrj}), output;
361
361
  if (util.isObject(coordinates) && 'x' in coordinates && 'y' in coordinates) {
362
- output = trans.forward({x: +coordinates.x, y: +coordinates.y, z: +coordinates.z || 0});
362
+ output = trans.forward({x: +coordinates.x, y: +coordinates.y, z: +coordinates.z || 0}, true);
363
363
  if ('z' in coordinates) {
364
364
  return output;
365
365
  }
@@ -368,7 +368,7 @@ transform.transformCoordinates = function (srcPrj, tgtPrj, coordinates, numberOf
368
368
  if (Array.isArray(coordinates) && coordinates.length === 1 &&
369
369
  util.isObject(coordinates[0]) && 'x' in coordinates[0] &&
370
370
  'y' in coordinates[0]) {
371
- output = trans.forward({x: +coordinates[0].x, y: +coordinates[0].y, z: +coordinates[0].z || 0});
371
+ output = trans.forward({x: +coordinates[0].x, y: +coordinates[0].y, z: +coordinates[0].z || 0}, true);
372
372
  if ('z' in coordinates[0]) {
373
373
  return [output];
374
374
  }
@@ -549,7 +549,7 @@ transform.transformCoordinatesArray = function (trans, coordinates, numberOfComp
549
549
  initPoint.x = xAcc(i);
550
550
  initPoint.y = yAcc(i);
551
551
  initPoint.z = zAcc(i);
552
- projPoint = trans.forward(initPoint);
552
+ projPoint = trans.forward(initPoint, true);
553
553
  writer(i, projPoint.x, projPoint.y, projPoint.z);
554
554
  }
555
555
  return output;
@@ -582,11 +582,12 @@ transform.transformCoordinatesFlatArray3 = function (srcPrj, tgtPrj, coordinates
582
582
  var src = proj4.Proj(srcPrj),
583
583
  tgt = proj4.Proj(tgtPrj),
584
584
  projPoint, initPoint = {};
585
+ const trans = new proj4(src, tgt);
585
586
  for (i = coordinates.length - 3; i >= 0; i -= 3) {
586
587
  initPoint.x = +coordinates[i];
587
588
  initPoint.y = +coordinates[i + 1];
588
589
  initPoint.z = +(coordinates[i + 2] || 0.0);
589
- projPoint = proj4.transform(src, tgt, initPoint);
590
+ projPoint = trans.forward(initPoint, true);
590
591
  coordinates[i] = projPoint.x;
591
592
  coordinates[i + 1] = projPoint.y;
592
593
  coordinates[i + 2] = projPoint.z === undefined ? initPoint.z : projPoint.z;
@@ -109,10 +109,10 @@ var colorLegendWidget = function (arg) {
109
109
  var legendSvg = legendContainer
110
110
  .append('svg')
111
111
  .attr({
112
- 'class': 'svg',
113
- 'width': width,
114
- 'height': '40px',
115
- 'viewBox': -margin + ' 0 ' + width + ' 40'
112
+ class: 'svg',
113
+ width: width,
114
+ height: '40px',
115
+ viewBox: -margin + ' 0 ' + width + ' 40'
116
116
  });
117
117
 
118
118
  if (category.type === 'discrete') {
@@ -402,9 +402,9 @@ var colorLegendWidget = function (arg) {
402
402
  m_this.popup
403
403
  .style({
404
404
  // If the popup will be longer or almost longer than the container
405
- 'left': offset[0] - (offset[0] +
405
+ left: offset[0] - (offset[0] +
406
406
  popupWidth - containerWidth > -10 ? popupWidth : 0) + 'px',
407
- 'top': (offset[1] - 22) + 'px'
407
+ top: (offset[1] - 22) + 'px'
408
408
  })
409
409
  .transition()
410
410
  .duration(200)
@@ -27,7 +27,7 @@
27
27
  stroke-width 0.7
28
28
  text
29
29
  font-size 12px
30
-
30
+
31
31
  .color-legend-popup
32
32
  position absolute
33
33
  background white
@@ -251,11 +251,11 @@ var legendWidget = function (arg) {
251
251
  .attr('rx', 3)
252
252
  .attr('ry', 3)
253
253
  .style({
254
- 'stroke': 'black',
254
+ stroke: 'black',
255
255
  'stroke-width': '1.5px',
256
- 'fill': 'white',
256
+ fill: 'white',
257
257
  'fill-opacity': 0.75,
258
- 'display': 'none'
258
+ display: 'none'
259
259
  });
260
260
  m_group.on('mousedown', function () {
261
261
  d3.event.stopPropagation();
@@ -131,7 +131,7 @@ var sliderWidget = function (arg) {
131
131
  .attr('cy', m_yscale(0.0) - m_width + 2)
132
132
  .attr('r', (m_width - 2) / 2)
133
133
  .style({
134
- 'cursor': 'pointer'
134
+ cursor: 'pointer'
135
135
  })
136
136
  .on('click', function () {
137
137
  var z = map.zoom();
@@ -171,7 +171,7 @@ var sliderWidget = function (arg) {
171
171
  .attr('cy', m_yscale(1.0) + m_width - 2)
172
172
  .attr('r', (m_width - 2) / 2)
173
173
  .style({
174
- 'cursor': 'pointer'
174
+ cursor: 'pointer'
175
175
  })
176
176
  .on('click', function () {
177
177
  var z = map.zoom();
@@ -237,7 +237,7 @@ var sliderWidget = function (arg) {
237
237
  .attr('width', m_width / 3)
238
238
  .attr('height', m_height - m_width * 3)
239
239
  .style({
240
- 'cursor': 'pointer'
240
+ cursor: 'pointer'
241
241
  })
242
242
  .on('click', function () {
243
243
  respond(d3.event, true);
@@ -257,7 +257,7 @@ var sliderWidget = function (arg) {
257
257
  .attr('width', m_width)
258
258
  .attr('height', m_nubSize)
259
259
  .style({
260
- 'cursor': 'pointer'
260
+ cursor: 'pointer'
261
261
  })
262
262
  .on('mousedown', function () {
263
263
  d3.select(document).on('mousemove.geo.slider', function () {
@@ -686,11 +686,11 @@ var util = {
686
686
  * @memberof geo.util
687
687
  */
688
688
  distanceToPolygon2d: function (pt, poly, onlySign) {
689
- let outer = poly.outer || poly;
689
+ const outer = poly.outer || poly;
690
690
  let inside = false,
691
- minDistSq, distSq, dist;
691
+ minDistSq, distSq;
692
692
  for (let i = 0, len = outer.length, j = len - 1; i < len; j = i, i += 1) {
693
- let p0 = outer[i],
693
+ const p0 = outer[i],
694
694
  p1 = outer[j];
695
695
  if (((p0.y > pt.y) !== (p1.y > pt.y)) && (pt.x < (p1.x - p0.x) * (pt.y - p0.y) / (p1.y - p0.y) + p0.x)) {
696
696
  inside = !inside;
@@ -702,7 +702,7 @@ var util = {
702
702
  }
703
703
  if (poly.inner) {
704
704
  poly.inner.forEach(inner => {
705
- let innerDist = util.distanceToPolygon2d(pt, inner, onlySign);
705
+ const innerDist = util.distanceToPolygon2d(pt, inner, onlySign);
706
706
  if (innerDist * innerDist < minDistSq) {
707
707
  minDistSq = innerDist * innerDist;
708
708
  }
@@ -711,7 +711,7 @@ var util = {
711
711
  }
712
712
  });
713
713
  }
714
- dist = (inside ? 1 : -1) * Math.sqrt(minDistSq);
714
+ const dist = (inside ? 1 : -1) * Math.sqrt(minDistSq);
715
715
  return dist;
716
716
  },
717
717
 
@@ -738,8 +738,8 @@ var util = {
738
738
  * @memberof geo.util
739
739
  */
740
740
  crossedLineSegmentPolygon2d: function (pt1, pt2, poly) {
741
- let outer = poly.outer || poly,
742
- len = outer.length, i, j;
741
+ const outer = poly.outer || poly, len = outer.length;
742
+ let i, j;
743
743
  for (i = 0, j = len - 1; i < len; j = i, i += 1) {
744
744
  if (util.crossedLineSegments2d(pt1, pt2, outer[i], outer[j])) {
745
745
  return true;
@@ -817,6 +817,7 @@ var util = {
817
817
  if (idx) {
818
818
  return util.crossedLineSegments2d(pt1, pt2, line[idx - 1], linePt);
819
819
  }
820
+ return false;
820
821
  });
821
822
  });
822
823
  return result;
@@ -1166,7 +1167,7 @@ var util = {
1166
1167
  /* Create a containing div with the parent's class and id (so css
1167
1168
  * will be used), but override size and background. */
1168
1169
  container = $('<div>').attr({
1169
- 'class': parent.attr('class'),
1170
+ class: parent.attr('class'),
1170
1171
  id: parent.attr('id')
1171
1172
  }).css({
1172
1173
  width: '100%',
@@ -1,8 +1,6 @@
1
1
  /* eslint-disable camelcase */
2
- /* eslint-disable underscore/prefer-constant */
3
2
 
4
3
  var $ = require('jquery');
5
- var vgl = require('vgl');
6
4
  var webglRenderer = require('../webgl/webglRenderer');
7
5
 
8
6
  var _renderWindow, _supported;
@@ -85,6 +83,7 @@ module.exports.mockWebglRenderer = function mockWebglRenderer(supported) {
85
83
  enable: noop('enable'),
86
84
  enableVertexAttribArray: noop('enableVertexAttribArray'),
87
85
  finish: noop('finish'),
86
+ getError: noop('getError'),
88
87
  getExtension: incID('getExtension'),
89
88
  getParameter: function (key) {
90
89
  count('getParameter');
@@ -190,6 +189,8 @@ module.exports.mockWebglRenderer = function mockWebglRenderer(supported) {
190
189
  * @alias geo.util.restoreWebglRenderer
191
190
  */
192
191
  module.exports.restoreWebglRenderer = function () {
192
+ var vgl = require('vgl');
193
+
193
194
  if (vgl._mocked) {
194
195
  vgl.renderWindow = _renderWindow;
195
196
  webglRenderer.supported = _supported;
@@ -112,9 +112,9 @@ var throttle = function (delay, no_trailing, callback, accumulator, debounce_mod
112
112
  }
113
113
 
114
114
  // Clear any existing timeout.
115
- void (
116
- timeout_id && clearTimeout(timeout_id)
117
- );
115
+ if (timeout_id) {
116
+ clearTimeout(timeout_id);
117
+ }
118
118
 
119
119
  if (debounce_mode === undefined && elapsed > delay) {
120
120
  // In throttle mode, if `delay` time has been exceeded, execute
package/src/vendor.js CHANGED
@@ -5,8 +5,6 @@
5
5
  * @license BSD-3-Clause
6
6
  */
7
7
 
8
- require('./polyfills');
9
-
10
8
  var globals = {
11
9
  d3: require('d3'),
12
10
  hammerjs: require('hammerjs')
@@ -184,6 +184,9 @@ vtkjsRenderer.supported = function () {
184
184
  if ((!vtkjsRenderer.vtkjs || !vtkjsRenderer.vtkjs.Rendering) && window.vtk && window.vtk.Rendering) {
185
185
  vtkjsRenderer.vtkjs = window.vtk;
186
186
  }
187
+ if (!vtkjsRenderer.vtkjs || !vtkjsRenderer.vtkjs.Rendering) {
188
+ vtkjsRenderer.vtkjs = undefined;
189
+ }
187
190
  return vtkjsRenderer.vtkjs !== undefined;
188
191
  };
189
192
 
@@ -141,7 +141,7 @@ var webgl_layer = function () {
141
141
  opacity,
142
142
  lowerTileLayers;
143
143
  layers.forEach(function (layer) {
144
- let autoshare = layer.autoshareRenderer(),
144
+ const autoshare = layer.autoshareRenderer(),
145
145
  isTileLayer = layer instanceof tileLayer;
146
146
  if (!autoshare || !layer.renderer() || layer.renderer().api() !== webglRenderer.apiname) {
147
147
  renderer = null;
@@ -129,7 +129,7 @@ var webgl_markerFeature = function (arg) {
129
129
 
130
130
  posFunc = m_this.position();
131
131
 
132
- for (let key in styleKeys) {
132
+ for (const key in styleKeys) {
133
133
  styleFunc[key] = m_this.style.get(key);
134
134
  if (!util.isFunction(m_this.style(key))) {
135
135
  styleUni[key] = styleFunc[key]();
@@ -183,7 +183,7 @@ var webgl_markerFeature = function (arg) {
183
183
  }
184
184
  }
185
185
  // unrolling this would speed it up
186
- for (let key in styleKeys) {
186
+ for (const key in styleKeys) {
187
187
  styleVal[key] = styleUni[key] === undefined ? styleFunc[key](item, i) : styleUni[key];
188
188
  }
189
189
  styleVal.scaleWithZoom = markerFeature.scaleMode[styleVal.scaleWithZoom] || (styleVal.scaleWithZoom >= 1 && styleVal.scaleWithZoom <= 3 ? styleVal.scaleWithZoom : 0);
@@ -219,7 +219,7 @@ var webgl_markerFeature = function (arg) {
219
219
  }
220
220
 
221
221
  if (m_this._primitiveShapeAuto) {
222
- let maxr = m_this._approximateMaxRadius(m_this.renderer().map().zoom());
222
+ const maxr = m_this._approximateMaxRadius(m_this.renderer().map().zoom());
223
223
  if ((m_this._primitiveShape === markerFeature.primitiveShapes.sprite && maxr > webglRenderer._maxPointSize) ||
224
224
  (m_this._primitiveShape !== markerFeature.primitiveShapes.sprite && maxr <= webglRenderer._maxPointSize)) {
225
225
  // Switch primitive
@@ -339,7 +339,7 @@ var webgl_markerFeature = function (arg) {
339
339
  needsRefresh = true;
340
340
  }
341
341
  if (key === sbkey) {
342
- let mod = m_this.modified;
342
+ const mod = m_this.modified;
343
343
  if (!needsRefresh) {
344
344
  // don't allow modified to be adjusted if we don't need to refresh
345
345
  m_this.modified = () => {};
@@ -140,11 +140,11 @@ var webgl_meshColored = function (arg) {
140
140
  posAttr = vgl.vertexAttribute('pos'),
141
141
  valueAttr = vgl.vertexAttribute('value'),
142
142
  opacityAttr = vgl.vertexAttribute('opacity'),
143
- sourcePositions = vgl.sourceDataP3fv({'name': 'pos'}),
143
+ sourcePositions = vgl.sourceDataP3fv({name: 'pos'}),
144
144
  sourceValues = vgl.sourceDataAnyfv(
145
- 1, vgl.vertexAttributeKeysIndexed.One, {'name': 'value'}),
145
+ 1, vgl.vertexAttributeKeysIndexed.One, {name: 'value'}),
146
146
  sourceOpacity = vgl.sourceDataAnyfv(
147
- 1, vgl.vertexAttributeKeysIndexed.Two, {'name': 'opacity'}),
147
+ 1, vgl.vertexAttributeKeysIndexed.Two, {name: 'opacity'}),
148
148
  primitive = new vgl.triangles();
149
149
  m_modelViewUniform = new vgl.modelViewOriginUniform('modelViewMatrix');
150
150