Pavement loader
This commit is contained in:
parent
7f07026fb7
commit
d6721faceb
@ -11,6 +11,7 @@
|
||||
<!--<l-marker :lat-lng="marker"></l-marker>-->
|
||||
<LeafletSidebar></LeafletSidebar>
|
||||
<EditLayer></EditLayer>
|
||||
<PavementLayer></PavementLayer>
|
||||
<l-layer-group layerType="overlay" name="airports" ref="airportLayer">
|
||||
<l-circle
|
||||
v-for="(item, index) in this.$store.state.Airports.airports"
|
||||
@ -29,6 +30,7 @@
|
||||
import { LMap, LTileLayer, LMarker, LCircle, LLayerGroup } from 'vue2-leaflet'
|
||||
import LeafletSidebar from './LeafletSidebar'
|
||||
import EditLayer from './EditLayer'
|
||||
import PavementLayer from './PavementLayer'
|
||||
import L from 'leaflet'
|
||||
|
||||
// https://github.com/KoRiGaN/Vue2Leaflet/issues/103
|
||||
@ -41,7 +43,7 @@
|
||||
})
|
||||
export default {
|
||||
name: 'flightgear-map',
|
||||
components: { LMap, LTileLayer, LMarker, LCircle, LeafletSidebar, EditLayer, LLayerGroup },
|
||||
components: { LMap, LTileLayer, LMarker, LCircle, LeafletSidebar, EditLayer, PavementLayer, LLayerGroup },
|
||||
props: [],
|
||||
mounted () {
|
||||
this.$store.dispatch('getAirports')
|
||||
|
90
src/renderer/components/PavementLayer.vue
Normal file
90
src/renderer/components/PavementLayer.vue
Normal file
@ -0,0 +1,90 @@
|
||||
<template>
|
||||
<section class="edit-layer">
|
||||
<h1>edit-layer Component</h1>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script lang="js">
|
||||
import { LMap, LMarker } from 'vue2-leaflet'
|
||||
import L from 'leaflet'
|
||||
import LEdit from 'leaflet-editable/src/Leaflet.Editable.js'
|
||||
import {readPavement} from '../loaders/pavement_loader'
|
||||
|
||||
export default {
|
||||
name: 'edit-layer',
|
||||
props: [],
|
||||
created () {
|
||||
this.$store.subscribe((mutation, state) => {
|
||||
if (mutation.type === 'BOUNDS') {
|
||||
// console.log(this.$parent)
|
||||
// console.log(this.$store.state.Settings.bounds)
|
||||
let airportsToLoad = this.$store.state.Airports.airports
|
||||
.filter(feature => this.visible(feature))
|
||||
.map(feature => feature.properties.icao)
|
||||
if (airportsToLoad[0] !== this.editingAirport) {
|
||||
readPavement(this.$store.state.Settings.settings.flightgearDirectory_apt, airportsToLoad[0], this.read)
|
||||
this.editingAirport = airportsToLoad[0]
|
||||
}
|
||||
// console.log(this.groundnet)
|
||||
}
|
||||
})
|
||||
},
|
||||
mounted () {
|
||||
console.log(LMap)
|
||||
console.log(LMarker)
|
||||
console.log(L)
|
||||
console.log(LEdit)
|
||||
},
|
||||
beforeDestroy () {
|
||||
this.remove()
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
read (layer) {
|
||||
this.groundnet = layer
|
||||
if (this.groundnet) {
|
||||
this.groundnet.addTo(this.$parent.mapObject)
|
||||
}
|
||||
},
|
||||
visible (feature) {
|
||||
let bounds = this.$store.state.Settings.bounds
|
||||
let coordinates = feature.geometry.coordinates
|
||||
let ret = bounds.getNorthEast().lat > Number(coordinates[1]) &&
|
||||
bounds.getNorthEast().lng > Number(coordinates[0])
|
||||
let ret2 = bounds.getSouthWest().lat < Number(coordinates[1]) &&
|
||||
bounds.getSouthWest().lng < Number(coordinates[0])
|
||||
return ret && ret2
|
||||
},
|
||||
deferredMountedTo (parent) {
|
||||
this.layerGroup = L.layerGroup()
|
||||
},
|
||||
remove () {
|
||||
if (this.layerGroup) {
|
||||
this.$parent.removeLayer(this.layerGroup)
|
||||
}
|
||||
},
|
||||
add () {
|
||||
if (this.$parent._isMounted) {
|
||||
this.deferredMountedTo(this.$parent.mapObject)
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
edit: function () {
|
||||
console.log('Zoom : ' + this.$store.state.Settings.zoom)
|
||||
if (this.$store.state.Settings.zoom > 12) {
|
||||
console.log()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.edit-layer {
|
||||
|
||||
}
|
||||
</style>
|
@ -21,6 +21,18 @@
|
||||
<directory-select @input="flightgearDirectorySelect"></directory-select>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="7">AI Directory</el-col>
|
||||
<el-col :span="15">{{ AI_directory }}</el-col>
|
||||
<el-col :span="2">
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="7">APT File</el-col>
|
||||
<el-col :span="15">{{ apt_file }}</el-col>
|
||||
<el-col :span="2">
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -53,6 +65,12 @@
|
||||
flightgear_directory: function () {
|
||||
return this.$store.state.Settings.settings.flightgearDirectory
|
||||
},
|
||||
AI_directory: function () {
|
||||
return this.$store.state.Settings.settings.flightgearDirectory_ai
|
||||
},
|
||||
apt_file: function () {
|
||||
return this.$store.state.Settings.settings.flightgearDirectory_apt
|
||||
},
|
||||
airports_directory: function () {
|
||||
return this.$store.state.Settings.settings.airportsDirectory
|
||||
}
|
||||
|
156
src/renderer/loaders/pavement_loader.js
Normal file
156
src/renderer/loaders/pavement_loader.js
Normal file
@ -0,0 +1,156 @@
|
||||
/* eslint-disable */
|
||||
const lineReader = require('readline');
|
||||
const zlib = require('zlib');
|
||||
const turf = require('@turf/turf');
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports.readPavement = function (f, icao, cb) {
|
||||
console.log(f);
|
||||
layerGroup = L.layerGroup();
|
||||
var currentFeature;
|
||||
|
||||
lineReader.createInterface({
|
||||
input: fs.createReadStream(f).pipe(zlib.createGunzip())
|
||||
}).on('line', function (line) {
|
||||
var fields = line.split(/[ ]+/);
|
||||
// var fields = line.match('([0-9]+)');
|
||||
if (fields == null)
|
||||
return;
|
||||
var scanMethod = scanMethods[fields[0]];
|
||||
if (scanMethod != null) {
|
||||
currentFeature = scanMethod(fields, icao, layerGroup, currentFeature);
|
||||
}
|
||||
else {
|
||||
if (fields[0] == '99') {
|
||||
lineReader.close();
|
||||
}
|
||||
// console.log('Ignored:', line);
|
||||
}
|
||||
}).on('error', function (err) {
|
||||
console.log(err);
|
||||
lr.close();
|
||||
}).on('close', function () {
|
||||
console.log("End");
|
||||
cb(layerGroup);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.isScanning = false;
|
||||
|
||||
|
||||
var scanMethods = {
|
||||
1: (line, icao) => {
|
||||
console.log('Airport:', line);
|
||||
if (line[4]===icao){
|
||||
module.exports.isScanning = true;
|
||||
} else {
|
||||
module.exports.isScanning = false;
|
||||
}
|
||||
},
|
||||
// Runway
|
||||
100: (line, icao, layerGroup) => {
|
||||
if (module.exports.isScanning) {
|
||||
console.log('Runway ', line );
|
||||
var point1 = turf.point([line[9], line[10]]);
|
||||
var point2 = turf.point([line[18], line[19]]);
|
||||
|
||||
var runwayPoints = [];
|
||||
|
||||
var bearing = turf.bearing(point1, point2);
|
||||
var runwayEnd1 = [line[9], line[10]];
|
||||
var runwayEnd2 = [line[18], line[19]];
|
||||
var runwayWidth = Number(line[1])/1000;
|
||||
var destination = turf.destination(point1, runwayWidth/2, bearing, {});
|
||||
|
||||
runwayPoints.push(turf.destination(point1, runwayWidth/2, bearing+90, {}));
|
||||
runwayPoints.push(turf.destination(point2, runwayWidth/2, bearing+90, {}));
|
||||
runwayPoints.push(turf.destination(point2, runwayWidth/2, bearing-90, {}));
|
||||
runwayPoints.push(turf.destination(point1, runwayWidth/2, bearing-90, {}));
|
||||
|
||||
runwayPoints = runwayPoints.map(p => p.geometry.coordinates);
|
||||
|
||||
var runwayPoly = new L.Polygon(runwayPoints);
|
||||
runwayPoly.setStyle({color: 'grey'});
|
||||
runwayPoly.addTo(layerGroup);
|
||||
|
||||
console.log(turf.bearing(point1, point2), turf.bearing(point2, point1));
|
||||
console.log(runwayEnd1, runwayEnd2);
|
||||
|
||||
|
||||
// var end = turf.destination([start.lat, start.lng], this.attributes.radius / 1000, this.attributes.heading - 180, options);
|
||||
|
||||
}
|
||||
},
|
||||
// Pavement
|
||||
110: (line, icao, layerGroup, currentFeature) => {
|
||||
if (!module.exports.isScanning)
|
||||
return undefined;
|
||||
if(typeof currentFeature !== 'undefined')
|
||||
{
|
||||
var taxiwayPoly = new L.Polygon(currentFeature);
|
||||
taxiwayPoly.setStyle({color: 'grey'});
|
||||
taxiwayPoly.addTo(layerGroup);
|
||||
}
|
||||
return [[]];
|
||||
},
|
||||
120: (line, icao, layerGroup, currentFeature) => {
|
||||
if (!module.exports.isScanning)
|
||||
return undefined;
|
||||
return [[]];
|
||||
},
|
||||
130: (line, icao, layerGroup, currentFeature) => {
|
||||
if (!module.exports.isScanning)
|
||||
return undefined;
|
||||
return [[]];
|
||||
},
|
||||
111: (line, icao, layerGroup, currentFeature) => {
|
||||
if (!module.exports.isScanning)
|
||||
return;
|
||||
console.log(line);
|
||||
currentFeature.slice(-1)[0].push([line[1], line[2]]);
|
||||
return currentFeature;
|
||||
},
|
||||
112: (line, icao, layerGroup, currentFeature) => {
|
||||
if (!module.exports.isScanning)
|
||||
return;
|
||||
console.log(line);
|
||||
currentFeature.slice(-1)[0].push([line[1], line[2]]);
|
||||
return currentFeature;
|
||||
},
|
||||
113: (line, icao, layerGroup, currentFeature) => {
|
||||
if (!module.exports.isScanning)
|
||||
return;
|
||||
currentFeature.slice(-1)[0].push([line[1], line[2]]);
|
||||
currentFeature.push([]);
|
||||
return currentFeature;
|
||||
},
|
||||
114: (line, icao, layerGroup, currentFeature) => {
|
||||
if (!module.exports.isScanning)
|
||||
return;
|
||||
currentFeature.slice(-1)[0].push([line[1], line[2]]);
|
||||
currentFeature.push([]);
|
||||
return currentFeature;
|
||||
},
|
||||
115: (line, icao, layerGroup, currentFeature) => {
|
||||
if (!module.exports.isScanning)
|
||||
return;
|
||||
currentFeature.slice(-1)[0].push([line[1], line[2]]);
|
||||
var taxiwayLine = new L.Polyline(currentFeature);
|
||||
taxiwayLine.setStyle({color: 'red'});
|
||||
// taxiwayLine.addTo(layerGroup);
|
||||
},
|
||||
116: (line, icao, layerGroup, currentFeature) => {
|
||||
if (!module.exports.isScanning)
|
||||
return;
|
||||
currentFeature.slice(-1)[0].push([line[1], line[2]]);
|
||||
var taxiwayLine = new L.Polyline(currentFeature);
|
||||
taxiwayLine.setStyle({color: 'red'});
|
||||
// taxiwayLine.addTo(layerGroup);
|
||||
},
|
||||
99: (l) => {
|
||||
console.log('Finished');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,6 +9,8 @@ const mutations = {
|
||||
'DELETE_INDEXED_DB' () { },
|
||||
'FLIGHTGEAR_DIRECTORY' (state, flightgearDirectory) {
|
||||
state.settings.flightgearDirectory = flightgearDirectory
|
||||
state.settings.flightgearDirectory_ai = flightgearDirectory + '/data/AI'
|
||||
state.settings.flightgearDirectory_apt = flightgearDirectory + '/data/Airports/apt.dat.gz'
|
||||
},
|
||||
'AIPORTS_DIRECTORY' (state, airportsDirectory) {
|
||||
state.settings.airportsDirectory = airportsDirectory
|
||||
|
Loading…
Reference in New Issue
Block a user