map: clean up, use transformGeometry function where appropriate

This commit is contained in:
Adam Goldsmith 2018-08-05 00:11:03 +01:00
parent bd14d1fa56
commit 3b1ba37435

View File

@ -112,8 +112,6 @@ function plotPacketPaths(packets) {
(acc, callsign, index) => (acc, callsign, index) =>
acc.set(callsign, colorGen.hues[index]), new Map()); acc.set(callsign, colorGen.hues[index]), new Map());
console.log(colorMap);
// plot digis // plot digis
// TODO: icons // TODO: icons
let digi_style = new Style({ let digi_style = new Style({
@ -143,13 +141,11 @@ function plotPacketPaths(packets) {
digiPos.forEach((position, callsign) => { digiPos.forEach((position, callsign) => {
let feature = new Feature({ let feature = new Feature({
geometry: new Point(position), geometry: transformGeometry(new Point(position)),
callsign: callsign callsign: callsign
}); });
digi_layer.getSource().addFeature(feature); digi_layer.getSource().addFeature(feature);
feature.getGeometry().transform(new Projection({code: "EPSG:4326"}),
tile_layer.getSource().getProjection());
}); });
let packet_path_layers = new LayerGroup({title: "Packet Paths"}); let packet_path_layers = new LayerGroup({title: "Packet Paths"});
@ -173,14 +169,14 @@ function plotPacketPaths(packets) {
[packet.data.longitude, packet.data.latitude] : [packet.data.longitude, packet.data.latitude] :
digiPos.get(stations[index - 1]) || [0, 0]; digiPos.get(stations[index - 1]) || [0, 0];
let pathFeature = new Feature( let pathFeature = new Feature(transformGeometry(
new LineString([previous, digiPos.get(station) || [0, 0]])); new LineString([previous, digiPos.get(station) || [0, 0]])));
// TODO: want to color per station that hears it, probably means // TODO: want to color per station that hears it, probably means
// making a lot more features // making a lot more features
let color = colorMap.get(station); let color = colorMap.get(station);
pathFeature.setStyle(new Style( pathFeature.setStyle(new Style({
{stroke: new Stroke( stroke: new Stroke(
{color: 'hsl(' + color + ', 60%, 60%)', width: 2} {color: 'hsl(' + color + ', 60%, 60%)', width: 2}
)})); )}));
@ -188,15 +184,11 @@ function plotPacketPaths(packets) {
layers_map.set(station, new VectorLayer({ layers_map.set(station, new VectorLayer({
title: station, title: station,
source: new VectorSource(), source: new VectorSource(),
renderMode: 'image', renderMode: 'image'
features: [pathFeature]
})); }));
packet_path_layers.getLayers().push(layers_map.get(station)); packet_path_layers.getLayers().push(layers_map.get(station));
} }
layers_map.get(station).getSource().addFeature(pathFeature); layers_map.get(station).getSource().addFeature(pathFeature);
pathFeature.getGeometry().transform(new Projection({code: "EPSG:4326"}),
tile_layer.getSource().getProjection());
}); });
}); });
} }
@ -227,7 +219,6 @@ function render_layer_toggles(event) {
event.map.getLayers().getArray() event.map.getLayers().getArray()
.filter(layer => layer.get('title') !== undefined) .filter(layer => layer.get('title') !== undefined)
.forEach(layer => { .forEach(layer => {
console.log(layer.get('title'));
if (layer instanceof LayerGroup) { if (layer instanceof LayerGroup) {
if (layer.group_toggle === undefined) { if (layer.group_toggle === undefined) {
let label = layer.group_toggle = inner.appendChild( let label = layer.group_toggle = inner.appendChild(