2019-07-15 18:08:15 -04:00
|
|
|
<template>
|
|
|
|
<vl-map data-projection="EPSG:4326">
|
|
|
|
<vl-view :zoom="10" :center="[-72.15, 43.9]">
|
|
|
|
<vl-layer-tile>
|
|
|
|
<vl-source-osm> </vl-source-osm>
|
|
|
|
</vl-layer-tile>
|
|
|
|
<vl-layer-group>
|
|
|
|
<vl-layer-vector v-for="(gpxURL, name) in routes" :key="name">
|
|
|
|
<vl-source-vector :url="gpxURL" :format-factory="gpxFormatFactory">
|
|
|
|
</vl-source-vector>
|
2019-07-15 20:13:04 -04:00
|
|
|
<vl-style-box>
|
|
|
|
<vl-style-stroke color="hsl(200, 90%, 30%)" :width="5">
|
|
|
|
</vl-style-stroke>
|
|
|
|
</vl-style-box>
|
2019-07-15 18:08:15 -04:00
|
|
|
</vl-layer-vector>
|
|
|
|
</vl-layer-group>
|
|
|
|
|
2019-07-15 20:13:04 -04:00
|
|
|
<!-- Station Paths -->
|
2019-07-15 18:08:15 -04:00
|
|
|
<vl-layer-group>
|
|
|
|
<vl-layer-group
|
2019-07-15 20:13:04 -04:00
|
|
|
v-for="(packets, callsign, idx) in stationPaths"
|
2019-07-15 18:08:15 -04:00
|
|
|
:key="callsign"
|
|
|
|
>
|
|
|
|
<!--Paths -->
|
2019-07-16 11:15:37 -04:00
|
|
|
<vl-layer-vector render-mode="image">
|
2019-07-15 18:08:15 -04:00
|
|
|
<vl-source-vector>
|
|
|
|
<vl-feature>
|
2019-07-15 20:13:04 -04:00
|
|
|
<vl-geom-line-string
|
|
|
|
:coordinates="packetsToStationPathPoints(packets)"
|
|
|
|
>
|
2019-07-15 18:08:15 -04:00
|
|
|
</vl-geom-line-string>
|
|
|
|
</vl-feature>
|
|
|
|
</vl-source-vector>
|
|
|
|
<vl-style-box>
|
|
|
|
<vl-style-stroke :color="stationColors[idx].hex()" :width="2">
|
|
|
|
</vl-style-stroke>
|
|
|
|
</vl-style-box>
|
|
|
|
</vl-layer-vector>
|
|
|
|
|
|
|
|
<!-- Points -->
|
2019-07-16 11:15:37 -04:00
|
|
|
<vl-layer-vector render-mode="image">
|
2019-07-15 18:08:15 -04:00
|
|
|
<vl-source-vector>
|
|
|
|
<vl-feature>
|
2019-07-15 20:13:04 -04:00
|
|
|
<vl-geom-multi-point
|
|
|
|
:coordinates="packetsToStationPathPoints(packets)"
|
|
|
|
>
|
2019-07-15 18:08:15 -04:00
|
|
|
</vl-geom-multi-point>
|
|
|
|
</vl-feature>
|
|
|
|
</vl-source-vector>
|
|
|
|
<vl-style-box>
|
|
|
|
<vl-style-circle :radius="3">
|
|
|
|
<vl-style-fill :color="stationColors[idx].hex()">
|
|
|
|
</vl-style-fill>
|
|
|
|
</vl-style-circle>
|
|
|
|
</vl-style-box>
|
|
|
|
</vl-layer-vector>
|
|
|
|
</vl-layer-group>
|
|
|
|
</vl-layer-group>
|
2019-07-15 20:13:04 -04:00
|
|
|
|
|
|
|
<!-- Digipeater locations -->
|
|
|
|
<vl-layer-vector>
|
|
|
|
<vl-source-vector>
|
|
|
|
<vl-feature v-for="(position, callsign) in digiPos" :key="callsign">
|
|
|
|
<vl-geom-point :coordinates="position"> </vl-geom-point>
|
|
|
|
<vl-style-box>
|
|
|
|
<vl-style-circle>
|
|
|
|
<vl-style-fill :color="digiColors[callsign].hex()">
|
|
|
|
</vl-style-fill
|
|
|
|
></vl-style-circle>
|
|
|
|
<vl-style-text :text="callsign" :offsetY="12"> </vl-style-text>
|
|
|
|
</vl-style-box>
|
|
|
|
</vl-feature>
|
|
|
|
</vl-source-vector>
|
|
|
|
</vl-layer-vector>
|
|
|
|
|
|
|
|
<!-- Packet Paths -->
|
2019-07-16 11:15:37 -04:00
|
|
|
<vl-layer-vector render-mode="image">
|
|
|
|
<vl-source-vector :features="packetPathsGeoJSON"> </vl-source-vector>
|
|
|
|
<vl-style-func :factory="() => packetPathStyleFunc"> </vl-style-func>
|
|
|
|
</vl-layer-vector>
|
2019-07-15 18:08:15 -04:00
|
|
|
</vl-view>
|
|
|
|
</vl-map>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-05-04 02:04:44 -04:00
|
|
|
import Vue from 'vue';
|
2019-07-16 11:15:37 -04:00
|
|
|
|
2020-05-04 02:04:44 -04:00
|
|
|
import { APRSParser } from 'aprs-parser';
|
|
|
|
import distinctColors from 'distinct-colors';
|
2019-07-15 18:08:15 -04:00
|
|
|
|
2020-05-04 02:04:44 -04:00
|
|
|
import VueLayers from 'vuelayers';
|
|
|
|
import { createStyle, createLineGeom } from 'vuelayers/lib/ol-ext';
|
|
|
|
import { Control } from 'ol/control';
|
|
|
|
import { GPX } from 'ol/format';
|
2019-07-15 18:08:15 -04:00
|
|
|
|
2020-05-04 02:04:44 -04:00
|
|
|
import 'vuelayers/lib/style.css';
|
2019-07-15 18:08:15 -04:00
|
|
|
|
|
|
|
Vue.use(VueLayers);
|
|
|
|
|
2020-05-04 02:04:44 -04:00
|
|
|
import route_data from 'gpx/*.gpx';
|
|
|
|
import { readFileSync } from 'fs';
|
|
|
|
const packetLog = readFileSync(__dirname + '/../IS_packets.txt', 'utf-8');
|
2019-07-15 18:08:15 -04:00
|
|
|
|
|
|
|
function parsePackets(packetLog) {
|
|
|
|
let parser = new APRSParser();
|
|
|
|
return (
|
|
|
|
packetLog
|
|
|
|
.trim()
|
2020-05-04 02:04:44 -04:00
|
|
|
.split('\n')
|
2019-07-15 18:08:15 -04:00
|
|
|
// parse to Date and APRS packet
|
2020-05-04 02:04:44 -04:00
|
|
|
.map((line) => {
|
2019-07-15 18:08:15 -04:00
|
|
|
let packet = parser.parse(line.slice(29));
|
|
|
|
packet.date = new Date(line.slice(0, 18));
|
|
|
|
return packet;
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
packets: parsePackets(packetLog),
|
2020-05-04 02:04:44 -04:00
|
|
|
routes: route_data,
|
2019-07-15 18:08:15 -04:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
gpxFormatFactory(options) {
|
|
|
|
return new GPX(options);
|
|
|
|
},
|
|
|
|
|
2019-07-15 20:13:04 -04:00
|
|
|
packetsToStationPathPoints(packets) {
|
2020-05-04 02:04:44 -04:00
|
|
|
return packets.map((packet) => [
|
2019-07-15 18:08:15 -04:00
|
|
|
packet.data.longitude,
|
2020-05-04 02:04:44 -04:00
|
|
|
packet.data.latitude,
|
2019-07-15 18:08:15 -04:00
|
|
|
]);
|
2019-07-15 20:13:04 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
pathToString(path) {
|
|
|
|
return path
|
|
|
|
.filter(
|
2020-05-04 02:04:44 -04:00
|
|
|
(station) => !station.call.match(/WIDE[12]|qA?|UV[123]|.*\*$|UNCAN/)
|
2019-07-15 20:13:04 -04:00
|
|
|
)
|
2020-05-04 02:04:44 -04:00
|
|
|
.map((station) => station.toString().trim().replace(/\*$/, ''));
|
2019-07-15 20:13:04 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
groupByCall(acc, packet) {
|
|
|
|
let callsign = packet.from.toString().trim();
|
|
|
|
if (!(callsign in acc)) acc[callsign] = [];
|
|
|
|
acc[callsign].push(packet);
|
|
|
|
return acc;
|
|
|
|
},
|
|
|
|
|
|
|
|
colorForDigi(digi) {
|
|
|
|
if (digi in this.digiColors) {
|
|
|
|
return this.digiColors[digi].hex();
|
|
|
|
} else {
|
2020-05-04 02:04:44 -04:00
|
|
|
return '#000000';
|
2019-07-15 20:13:04 -04:00
|
|
|
}
|
2019-07-16 11:15:37 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
packetPathStyleFunc(feature, resolution) {
|
|
|
|
let paths = feature.getProperties().paths.slice(0);
|
|
|
|
let styles = [];
|
|
|
|
|
|
|
|
feature
|
|
|
|
.getGeometry()
|
|
|
|
.getLineStrings()
|
2020-05-04 02:04:44 -04:00
|
|
|
.forEach((ls) => {
|
2019-07-16 11:15:37 -04:00
|
|
|
let path = paths.shift().slice(0);
|
|
|
|
ls.forEachSegment((start, end) => {
|
|
|
|
let color = this.colorForDigi(path.shift());
|
|
|
|
|
|
|
|
styles.push(
|
|
|
|
createStyle({
|
|
|
|
geom: createLineGeom([start, end]),
|
|
|
|
strokeColor: color,
|
2020-05-04 02:04:44 -04:00
|
|
|
strokeWidth: 2,
|
2019-07-16 11:15:37 -04:00
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
return styles;
|
2020-05-04 02:04:44 -04:00
|
|
|
},
|
2019-07-15 18:08:15 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2019-07-16 11:15:37 -04:00
|
|
|
positionalPackets() {
|
2019-07-15 18:08:15 -04:00
|
|
|
return (
|
|
|
|
this.packets
|
|
|
|
.filter(
|
2020-05-04 02:04:44 -04:00
|
|
|
(packet) =>
|
|
|
|
packet.date > new Date('2018-07-13') &&
|
|
|
|
packet.date < new Date('2018-07-14')
|
2019-07-15 18:08:15 -04:00
|
|
|
)
|
|
|
|
// filter to just positional data
|
2020-05-04 02:04:44 -04:00
|
|
|
.filter((packet) => 'data' in packet && 'latitude' in packet.data)
|
2019-07-15 18:08:15 -04:00
|
|
|
);
|
|
|
|
},
|
|
|
|
|
2019-07-16 11:15:37 -04:00
|
|
|
stationPaths() {
|
|
|
|
// group by callsign
|
|
|
|
return this.positionalPackets.reduce(this.groupByCall, {});
|
|
|
|
},
|
|
|
|
|
2019-07-15 20:13:04 -04:00
|
|
|
digis() {
|
|
|
|
let digiCalls = new Set(
|
|
|
|
this.packets
|
2020-05-04 02:04:44 -04:00
|
|
|
.map((packet) => this.pathToString(packet.via))
|
2019-07-15 20:13:04 -04:00
|
|
|
.reduce((acc, stations) => acc.concat(stations))
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
this.packets
|
|
|
|
// filter to digis
|
2020-05-04 02:04:44 -04:00
|
|
|
.filter((packet) => digiCalls.has(packet.from.toString().trim()))
|
2019-07-15 20:13:04 -04:00
|
|
|
// filter to just positional data
|
2020-05-04 02:04:44 -04:00
|
|
|
.filter((packet) => 'data' in packet && 'latitude' in packet.data)
|
2019-07-15 20:13:04 -04:00
|
|
|
// group by call
|
|
|
|
.reduce(this.groupByCall, {})
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
digiPos() {
|
|
|
|
return Object.entries(this.digis).reduce((acc, [digi, packets]) => {
|
|
|
|
let lastPacket = packets[packets.length - 1];
|
|
|
|
acc[digi] = [lastPacket.data.longitude, lastPacket.data.latitude];
|
|
|
|
return acc;
|
|
|
|
}, {});
|
|
|
|
},
|
|
|
|
|
2019-07-16 11:15:37 -04:00
|
|
|
packetPathsGeoJSON() {
|
|
|
|
let digiPos = { ...this.digiPos }; // localize for performance
|
|
|
|
return Object.entries(this.stationPaths).map(([station, packets]) => {
|
2020-05-04 02:04:44 -04:00
|
|
|
let lines = packets.map((packet) => {
|
2019-07-16 11:15:37 -04:00
|
|
|
let path = this.pathToString(packet.via);
|
|
|
|
return {
|
|
|
|
// first point in path is originating station
|
|
|
|
coords: [
|
|
|
|
[packet.data.longitude, packet.data.latitude],
|
2020-05-04 02:04:44 -04:00
|
|
|
...path.map((hop) => digiPos[hop] || [0, 0]),
|
2019-07-16 11:15:37 -04:00
|
|
|
],
|
2020-05-04 02:04:44 -04:00
|
|
|
path: path,
|
2019-07-16 11:15:37 -04:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
2020-05-04 02:04:44 -04:00
|
|
|
type: 'Feature',
|
2019-07-16 11:15:37 -04:00
|
|
|
id: station,
|
|
|
|
geometry: {
|
2020-05-04 02:04:44 -04:00
|
|
|
type: 'MultiLineString',
|
|
|
|
coordinates: lines.map((p) => p.coords),
|
2019-07-16 11:15:37 -04:00
|
|
|
},
|
2020-05-04 02:04:44 -04:00
|
|
|
properties: { paths: lines.map((p) => p.path) },
|
2019-07-16 11:15:37 -04:00
|
|
|
};
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2019-07-15 18:08:15 -04:00
|
|
|
stationColors() {
|
|
|
|
return distinctColors({
|
2019-07-15 20:13:04 -04:00
|
|
|
count: Object.keys(this.stationPaths).length,
|
|
|
|
lightMin: 20,
|
2020-05-04 02:04:44 -04:00
|
|
|
lightMax: 80,
|
2019-07-15 20:13:04 -04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
digiColors() {
|
|
|
|
let colors = distinctColors({
|
|
|
|
count: Object.keys(this.digis).length,
|
2019-07-15 18:08:15 -04:00
|
|
|
lightMin: 20,
|
2020-05-04 02:04:44 -04:00
|
|
|
lightMax: 80,
|
2019-07-15 18:08:15 -04:00
|
|
|
});
|
2019-07-15 20:13:04 -04:00
|
|
|
return Object.keys(this.digis).reduce((acc, callsign, index) => {
|
|
|
|
acc[callsign] = colors[index];
|
|
|
|
return acc;
|
|
|
|
}, {});
|
2020-05-04 02:04:44 -04:00
|
|
|
},
|
|
|
|
},
|
2019-07-15 18:08:15 -04:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
html,
|
|
|
|
body {
|
|
|
|
height: 100%;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.map {
|
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.ol-control.layer-toggles {
|
|
|
|
top: 0.5em;
|
|
|
|
right: 0.5em;
|
|
|
|
background-color: rgba(70, 115, 164, 0.7);
|
|
|
|
color: #eee;
|
|
|
|
white-space: nowrap;
|
|
|
|
max-height: calc(100vh - 1em);
|
|
|
|
overflow-y: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.layer-toggles > div {
|
|
|
|
margin: 0.5em;
|
|
|
|
margin-right: 1em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.ol-control.layer-toggles:hover {
|
|
|
|
background-color: rgba(0, 60, 136, 0.7);
|
|
|
|
}
|
|
|
|
|
|
|
|
.layer-toggles > div > label {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
|
|
|
|
.expand {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.expand + span::before {
|
2020-05-04 02:04:44 -04:00
|
|
|
content: '\25B6';
|
2019-07-15 18:08:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
.expand:checked + span::before {
|
2020-05-04 02:04:44 -04:00
|
|
|
content: '\25BC';
|
2019-07-15 18:08:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
.expand ~ .collapsible-content {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.expand:checked ~ .collapsible-content {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
|
|
|
|
.collapsible-content {
|
|
|
|
margin-left: 0.8em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.collapsible-content > label {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
</style>
|