map: Add points for each packet

This commit is contained in:
Adam Goldsmith 2018-08-10 17:25:55 -04:00
parent cdad5f7da8
commit 2452eef3a6

View File

@ -80,7 +80,7 @@ function plotPaths(packets) {
.reduce((acc, packet) => { .reduce((acc, packet) => {
let callsign = packet.from.toString().trim(); let callsign = packet.from.toString().trim();
if (!acc.has(callsign)) acc.set(callsign, []); if (!acc.has(callsign)) acc.set(callsign, []);
acc.get(callsign).push([packet.data.longitude, packet.data.latitude]); acc.get(callsign).push([packet.data.longitude, packet.data.latitude, packet]);
return acc; return acc;
}, new Map()); }, new Map());
@ -88,19 +88,36 @@ function plotPaths(packets) {
// plot on map // plot on map
paths.forEach((points, callsign) => { paths.forEach((points, callsign) => {
let color = 'hsl(' + colorGen.get() + ', 75%, 50%)';
let path_layer = new VectorLayer({ let path_layer = new VectorLayer({
title: callsign, title: "Path",
source: new VectorSource({features: [ source: new VectorSource({features: [
new Feature({ new Feature({geometry: transformGeometry(new LineString(points))})
geometry: transformGeometry(new LineString(points))
})
]}), ]}),
style: new Style({ style: new Style({stroke: new Stroke({color: color, width: 2})})
stroke: new Stroke(
{color: 'hsl(' + colorGen.get() + ', 75%, 50%)', width: 2}
)})
}); });
path_layers.getLayers().push(path_layer);
let points_layer = new VectorLayer({
title: "Points",
source: new VectorSource({
features: points.map(point => new Feature({
geometry: transformGeometry(new Point(point)),
packet: point[3] // TODO: this seems a bit bad
}))
}),
style: new Style({
image: new CircleStyle({
radius: 4,
fill: new Fill({color: color})
})
})
});
let callsign_layer = new LayerGroup({
title: callsign,
layers: [path_layer, points_layer]
});
path_layers.getLayers().push(callsign_layer);
}); });
} }