Move parser and vector layer into related functions
This commit is contained in:
parent
1aa1852b2d
commit
90d8bf05cc
31
src/map.js
31
src/map.js
@ -15,18 +15,12 @@ import {APRSParser} from 'aprs-parser';
|
|||||||
|
|
||||||
import icon from "./arrow.png";
|
import icon from "./arrow.png";
|
||||||
|
|
||||||
let parser = new APRSParser();
|
|
||||||
|
|
||||||
let tile_layer = new TileLayer({source: new OSM()});
|
let tile_layer = new TileLayer({source: new OSM()});
|
||||||
let vector_layer = new VectorLayer({
|
|
||||||
source: new VectorSource()
|
|
||||||
});
|
|
||||||
|
|
||||||
let map = new olMap({
|
let map = new olMap({
|
||||||
target: 'map',
|
target: 'map',
|
||||||
layers: [
|
layers: [
|
||||||
tile_layer,
|
tile_layer
|
||||||
vector_layer
|
|
||||||
],
|
],
|
||||||
view: new View({
|
view: new View({
|
||||||
center: fromLonLat([-72.15, 43.90]),
|
center: fromLonLat([-72.15, 43.90]),
|
||||||
@ -79,7 +73,11 @@ function pathStyle(feature) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function plotPaths(packets) {
|
function plotPaths(packets) {
|
||||||
|
let vector_layer = new VectorLayer({source: new VectorSource()});
|
||||||
|
map.addLayer(vector_layer);
|
||||||
|
|
||||||
packets
|
packets
|
||||||
|
.filter(packet => packet.date > new Date("2018-07-14") && packet.date < new Date("2018-07-15"))
|
||||||
// filter by callsign
|
// filter by callsign
|
||||||
.filter(packet => (packet.from !== undefined) &&
|
.filter(packet => (packet.from !== undefined) &&
|
||||||
(packet.from.toString() === "W1HS-9"))
|
(packet.from.toString() === "W1HS-9"))
|
||||||
@ -107,13 +105,16 @@ function plotPaths(packets) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let packets = packetLog.split("\n")
|
function parsePackets(packetLog) {
|
||||||
// restrict to just prouty times
|
let parser = new APRSParser();
|
||||||
.filter(line => {
|
return packetLog.trim().split("\n")
|
||||||
let date = new Date(line.slice(0,18));
|
// parse to Date and APRS packet
|
||||||
return date > new Date("2018-07-14") && date < new Date("2018-07-15");
|
.map(line => {
|
||||||
})
|
let packet = parser.parse(line.slice(29));
|
||||||
// parse to APRS packet
|
packet.date = new Date(line.slice(0,18));
|
||||||
.map(line => parser.parse(line.slice(29)));
|
return packet;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let packets = parsePackets(packetLog);
|
||||||
plotPaths(packets);
|
plotPaths(packets);
|
||||||
|
Loading…
Reference in New Issue
Block a user