Skip to content

Commit

Permalink
Merge pull request #1040 from OpenGeoscience/track-feature
Browse files Browse the repository at this point in the history
Add a track feature.
  • Loading branch information
manthey authored May 29, 2020
2 parents 6d4b3a5 + 7720d9e commit 2136d8d
Show file tree
Hide file tree
Showing 16 changed files with 1,590 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Added a marker feature (#1035)
- The mapInteractor cancelOnMove option can now take a movement threshold (#1058)
- GCS can now be specified in pointSearch, boxSearch, and polygonSearch (#1051)
- Added a track feature (#1040)

## Version 0.19.8

Expand Down
7 changes: 3 additions & 4 deletions examples/flights/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ function draw(drawData) {
}
feature.data(data);
}
// feature.draw();
map.scheduleAnimationFrame(feature.draw);
}

Expand Down Expand Up @@ -115,12 +114,12 @@ feature = layer.createFeature('line', {selectionAPI: canSelect})
.style({
strokeColor: function (d, i, l) {
if (!hasScale) {
// d3 scales are slow
// d3 scales are slow; don't do:
// return d3Scale(0);
return scale[0];
}
var val = (l.v[i] - ranges.v.min) / ranges.v.range;
// d3 scales are slow
// d3 scales are slow, don't do:
// return d3Scale(val);
return val < 0 ? scale[0] : val > 1 ? scale[d3ScaleParts] : scale[Math.round(d3ScaleParts * val)];
},
Expand Down Expand Up @@ -151,7 +150,7 @@ feature = layer.createFeature('line', {selectionAPI: canSelect})
d.hover = false;
});
evt.data.hover = true;
console.log(evt.data.id);
console.log(evt.data.id, evt.data.callsign);
this.modified();
feature.draw();
});
Expand Down
6 changes: 4 additions & 2 deletions examples/flights/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ onmessage = function (evt) {
});
}
// Process each aircraft state.
var id, state = {}, last;
var id, callsign, state = {}, last;
data.states.forEach(function (record, idx) {
// Only process the data if passes some basic checks.
if (!record.length) {
Expand All @@ -122,6 +122,7 @@ onmessage = function (evt) {
return;
}
id = record[rr.icao24];
callsign = record[rr.callsign].trim();
state.time = data.time;
state.lon = record[rr.longitude];
state.lat = record[rr.latitude];
Expand Down Expand Up @@ -149,7 +150,7 @@ onmessage = function (evt) {
}
// Store data in arrays to reduce memory use.
if (!flights[id]) {
flights[id] = {time: [], lon: [], lat: [], z: [], v: [], dir: [], id: id};
flights[id] = {time: [], lon: [], lat: [], z: [], v: [], dir: [], id: id, callsign: callsign};
}
['time', 'lon', 'lat', 'z', 'v', 'dir'].forEach(function (key) {
flights[id][key].push(state[key]);
Expand All @@ -169,6 +170,7 @@ onmessage = function (evt) {
z: [flights[id].z[0] - 1e-6, flights[id].z[0]],
v: [flights[id].v[0] - 1e-6, flights[id].v[0]],
dir: [flights[id].dir[0], flights[id].dir[0]],
callsign: flights[id].callsign,
id: flights[id].id
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/canvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ module.exports = {
pixelmapFeature: require('./pixelmapFeature'),
quadFeature: require('./quadFeature'),
textFeature: require('./textFeature'),
tileLayer: require('./tileLayer')
tileLayer: require('./tileLayer'),
trackFeature: require('./trackFeature')
};
34 changes: 34 additions & 0 deletions src/canvas/trackFeature.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var inherit = require('../inherit');
var registerFeature = require('../registry').registerFeature;
var trackFeature = require('../trackFeature');

/**
* Create a new instance of class trackFeature.
*
* @class
* @alias geo.canvas.trackFeature
* @extends geo.trackFeature
* @param {geo.trackFeature.spec} arg
* @returns {geo.canvas.trackFeature}
*/
var canvas_trackFeature = function (arg) {
'use strict';
if (!(this instanceof canvas_trackFeature)) {
return new canvas_trackFeature(arg);
}

arg = arg || {};
trackFeature.call(this, arg);

var object = require('./object');
object.call(this);

this._init(arg);
return this;
};

inherit(canvas_trackFeature, trackFeature);

// Now register it
registerFeature('canvas', 'track', canvas_trackFeature);
module.exports = canvas_trackFeature;
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ module.exports = $.extend({
tileCache: require('./tileCache'),
tileLayer: require('./tileLayer'),
timestamp: require('./timestamp'),
trackFeature: require('./trackFeature'),
transform: require('./transform'),
typedef: require('./typedef'),
vectorFeature: require('./vectorFeature'),
Expand Down
3 changes: 2 additions & 1 deletion src/lineFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ var lineFeature = function (arg) {
i, j, record, u, v, r;
for (i = 0; i < m_pointSearchInfo.length; i += 1) {
record = m_pointSearchInfo[i];
if (record.max.x < min.x - record.max.r * scale ||
if (!record.max ||
record.max.x < min.x - record.max.r * scale ||
record.min.x > max.x + record.max.r * scale ||
record.max.y < min.y - record.max.r * scale ||
record.min.y > max.y + record.max.r * scale) {
Expand Down
1 change: 1 addition & 0 deletions src/svg/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
quadFeature: require('./quadFeature'),
renderer: require('./svgRenderer'),
tileLayer: require('./tileLayer'),
trackFeature: require('./trackFeature'),
uniqueID: require('./uniqueID'),
vectorFeature: require('./vectorFeature')
};
34 changes: 34 additions & 0 deletions src/svg/trackFeature.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var inherit = require('../inherit');
var registerFeature = require('../registry').registerFeature;
var trackFeature = require('../trackFeature');

/**
* Create a new instance of class trackFeature.
*
* @class
* @alias geo.svg.trackFeature
* @extends geo.trackFeature
* @param {geo.trackFeature.spec} arg
* @returns {geo.svg.trackFeature}
*/
var svg_trackFeature = function (arg) {
'use strict';
if (!(this instanceof svg_trackFeature)) {
return new svg_trackFeature(arg);
}

arg = arg || {};
trackFeature.call(this, arg);

var object = require('./object');
object.call(this);

this._init(arg);
return this;
};

inherit(svg_trackFeature, trackFeature);

// Now register it
registerFeature('svg', 'track', svg_trackFeature);
module.exports = svg_trackFeature;
Loading

0 comments on commit 2136d8d

Please sign in to comment.