geojs 1.8.7 → 1.8.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geojs",
3
- "version": "1.8.7",
3
+ "version": "1.8.8",
4
4
  "description": "JavaScript Geo Visualization and Analysis Library",
5
5
  "homepage": "https://github.com/OpenGeoscience/geojs",
6
6
  "license": "Apache-2.0",
@@ -80,7 +80,7 @@ var graphFeature = function (arg) {
80
80
  arg.style === undefined ? {} : arg.style);
81
81
 
82
82
  m_this.style(defaultStyle);
83
- m_this.nodes(function (d) { return d; });
83
+ m_this.nodes(util.identityFunction);
84
84
  return m_this;
85
85
  };
86
86
 
@@ -2,6 +2,7 @@ var $ = require('jquery');
2
2
  var inherit = require('./inherit');
3
3
  var feature = require('./feature');
4
4
  var transform = require('./transform');
5
+ var util = require('./util');
5
6
 
6
7
  /**
7
8
  * Heatmap feature specification.
@@ -79,7 +80,7 @@ var heatmapFeature = function (arg) {
79
80
 
80
81
  this.featureType = 'heatmap';
81
82
 
82
- m_position = arg.position || function (d) { return d; };
83
+ m_position = arg.position || util.identityFunction;
83
84
  m_intensity = arg.intensity || function (d) { return 1; };
84
85
  m_maxIntensity = arg.maxIntensity !== undefined ? arg.maxIntensity : null;
85
86
  m_minIntensity = arg.minIntensity !== undefined ? arg.minIntensity : null;
@@ -438,8 +438,8 @@ var lineFeature = function (arg) {
438
438
  });
439
439
 
440
440
  /* Set the reduced lines as the data and use simple accessors. */
441
- m_this.style('position', function (d) { return d; });
442
- m_this.style('line', function (d) { return d; });
441
+ m_this.style('position', util.identityFunction);
442
+ m_this.style('line', util.identityFunction);
443
443
  m_this.data(data);
444
444
  return m_this;
445
445
  };
@@ -465,7 +465,7 @@ var lineFeature = function (arg) {
465
465
  // Values of 2 and above appear smoothest.
466
466
  antialiasing: 2.0,
467
467
  closed: false,
468
- line: function (d) { return d; },
468
+ line: util.identityFunction,
469
469
  position: (d) => Array.isArray(d) ? {x: d[0], y: d[1], z: d[2] || 0} : d,
470
470
  origin: (p) => (p.length >= 3 ? p.slice(0, 3) : [0, 0, 0])
471
471
  },
@@ -285,7 +285,7 @@ var pixelmapFeature = function (arg) {
285
285
  a: 1
286
286
  };
287
287
  },
288
- position: function (d) { return d; }
288
+ position: util.identityFunction
289
289
  },
290
290
  arg.style === undefined ? {} : arg.style
291
291
  );
@@ -634,8 +634,8 @@ var polygonFeature = function (arg) {
634
634
  });
635
635
 
636
636
  /* Set the reduced polgons as the data and use simple accessors. */
637
- m_this.style('position', function (d) { return d; });
638
- m_this.style('polygon', function (d) { return d; });
637
+ m_this.style('position', util.identityFunction);
638
+ m_this.style('polygon', util.identityFunction);
639
639
  m_this.data(data);
640
640
  return m_this;
641
641
  };
@@ -719,7 +719,7 @@ var polygonFeature = function (arg) {
719
719
  strokeStyle: 'solid',
720
720
  strokeColor: {r: 0.0, g: 1.0, b: 1.0},
721
721
  strokeOpacity: 1.0,
722
- polygon: function (d) { return d; },
722
+ polygon: util.identityFunction,
723
723
  position: (d) => Array.isArray(d) ? {x: d[0], y: d[1], z: d[2] || 0} : d,
724
724
  origin: (items) => {
725
725
  for (let i = 0; i < items.length; i += 1) {
@@ -699,7 +699,7 @@ var quadFeature = function (arg) {
699
699
  previewImage: null,
700
700
  image: function (d) { return d.image; },
701
701
  video: function (d) { return d.video; },
702
- position: function (d) { return d; }
702
+ position: util.identityFunction
703
703
  },
704
704
  arg.style === undefined ? {} : arg.style
705
705
  );
@@ -814,8 +814,8 @@ var trackFeature = function (arg) {
814
814
  true,
815
815
  {},
816
816
  {
817
- track: (d) => d,
818
- position: (d) => d,
817
+ track: util.identityFunction,
818
+ position: util.identityFunction,
819
819
  time: (d, i) => (d.t !== undefined ? d.t : i)
820
820
  },
821
821
  arg.style === undefined ? {} : arg.style
package/src/transform.js CHANGED
@@ -19,7 +19,7 @@ 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 = /^(.* |)\\+axis=e(n|s)u(| .*)$/;
22
+ var axisPattern = /^(.* |)\+axis=e(n|s)u(| .*)$/;
23
23
  var affinePattern = /(^|\s)\+(s[1-3][1-3]|[xyz]off)=\S/;
24
24
 
25
25
  /**
@@ -1443,6 +1443,17 @@ var util = {
1443
1443
  return value !== null && value !== undefined && (type === 'object' || type === 'function');
1444
1444
  },
1445
1445
 
1446
+ /**
1447
+ * Return the first value passed to the function. Using this function for
1448
+ * identity calls can allow some code to bypass making such a call entirely.
1449
+ *
1450
+ * @param {*} d Any value.
1451
+ * @returns {*} The passed value.
1452
+ */
1453
+ identityFunction: function (d) {
1454
+ return d;
1455
+ },
1456
+
1446
1457
  ///////////////////////////////////////////////////////////////////////////
1447
1458
  /*
1448
1459
  * Utility member properties.
@@ -1,5 +1,6 @@
1
1
  var inherit = require('./inherit');
2
2
  var feature = require('./feature');
3
+ var util = require('./util');
3
4
 
4
5
  /**
5
6
  * Object specification for a graph feature.
@@ -120,7 +121,7 @@ var vectorFeature = function (arg) {
120
121
  originStyle: 'none',
121
122
  endStyle: 'arrow',
122
123
  origin: {x: 0, y: 0, z: 0},
123
- delta: function (d) { return d; },
124
+ delta: util.identityFunction,
124
125
  scale: null // size scaling factor (null -> renderer decides)
125
126
  },
126
127
  arg.style === undefined ? {} : arg.style
@@ -178,6 +178,7 @@ var webgl_lineFeature = function (arg) {
178
178
  if (!onlyStyle) {
179
179
  var position = [],
180
180
  posFunc = m_this.position();
181
+ posFunc = posFunc === util.identityFunction ? null : posFunc;
181
182
  lineItemList = new Array(data.length);
182
183
  closed = new Array(data.length);
183
184
  for (i = 0; i < data.length; i += 1) {
@@ -189,7 +190,7 @@ var webgl_lineFeature = function (arg) {
189
190
  }
190
191
  numSegments += lineItem.length - 1;
191
192
  for (j = 0; j < lineItem.length; j += 1) {
192
- pos = posFunc(lineItem[j], j, d, i);
193
+ pos = posFunc ? posFunc(lineItem[j], j, d, i) : lineItem[j];
193
194
  position.push(pos.x);
194
195
  position.push(simpleInverse ? -pos.y : pos.y);
195
196
  position.push(pos.z || 0.0);
@@ -98,11 +98,13 @@ var webgl_polygonFeature = function (arg) {
98
98
 
99
99
  if (!onlyStyle) {
100
100
  posFunc = m_this.style.get('position');
101
+ posFunc = posFunc === util.identityFunction ? null : posFunc;
101
102
  polyFunc = m_this.style.get('polygon');
103
+ polyFunc = polyFunc === util.identityFunction ? null : polyFunc;
102
104
  m_this.data().forEach(function (item, itemIndex) {
103
105
  var polygon, outer, geometry, c;
104
106
 
105
- polygon = polyFunc(item, itemIndex);
107
+ polygon = polyFunc ? polyFunc(item, itemIndex) : item;
106
108
  if (!polygon) {
107
109
  return;
108
110
  }
@@ -116,7 +118,7 @@ var webgl_polygonFeature = function (arg) {
116
118
  * test). */
117
119
  geometry = new Array(outer.length * 3);
118
120
  for (i = d3 = 0; i < outer.length; i += 1, d3 += 3) {
119
- c = posFunc(outer[i], i, item, itemIndex);
121
+ c = posFunc ? posFunc(outer[i], i, item, itemIndex) : outer[i];
120
122
  geometry[d3] = c.x;
121
123
  geometry[d3 + 1] = simpleInverse ? -c.y : c.y;
122
124
  // ignore the z values until we support them
@@ -133,7 +135,7 @@ var webgl_polygonFeature = function (arg) {
133
135
  original = original.concat(hole);
134
136
  geometry.holes.push(d3 / 3);
135
137
  for (i = 0; i < hole.length; i += 1, d3 += 3) {
136
- c = posFunc(hole[i], i, item, itemIndex);
138
+ c = posFunc ? posFunc(hole[i], i, item, itemIndex) : hole[i];
137
139
  geometry.vertices[d3] = c.x;
138
140
  geometry.vertices[d3 + 1] = simpleInverse ? -c.y : c.y;
139
141
  // ignore the z values until we support them