Coordinate Setting

This commit is contained in:
portree_kid 2020-04-02 21:36:33 +02:00
parent 1650b44628
commit 61d9145dd8
4 changed files with 102 additions and 12 deletions

7
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "flightgear-airports",
"version": "0.0.1",
"version": "0.0.4",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -5621,6 +5621,11 @@
"integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=",
"dev": true
},
"coordinate-parser": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/coordinate-parser/-/coordinate-parser-1.0.3.tgz",
"integrity": "sha512-w2UvTABq1acVBbW26XkKZTnDvBF8DN6us24caKYYuQdEl0qAykk46+3IUq+a6CRaB4YtgT/XWMMYre91oNBclQ=="
},
"copy-concurrently": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/copy-concurrently/-/copy-concurrently-1.0.5.tgz",

View File

@ -68,6 +68,7 @@
"dependencies": {
"@turf/turf": "^5.1.6",
"axios": "^0.18.1",
"coordinate-parser": "^1.0.3",
"dijkstrajs": "^1.0.1",
"electron-debug": "^3.0.1",
"element-ui": "^2.12.0",

View File

@ -254,6 +254,84 @@
}
});
},
getPointCoords (index) {
if(this.featureLookup[index]===undefined) {
console.error("Lookup " + index + " failed ");
return;
}
return this.featureLookup[index].map((element, i) => {
if (element instanceof L.Polyline) {
element._latlngs.forEach((e1, index1) => {
console.log(e1);
if (e1.attributes.index===index) {
var latlng = {};
latlng.lat = e1.lat;
latlng.lng = e1.lng;
return latlng;
}
});
} else if (element instanceof L.RunwayNode) {
var latlng = {};
latlng.lat = element._latlng.lat;
latlng.lng = element._latlng.lng;
return latlng;
} else if (element instanceof L.ParkingSpot) {
console.log(element);
var latlng = {};
latlng.lat = element._latlng.lat;
latlng.lng = element._latlng.lng;
return latlng;
}
});
},
setPointCoords (index, coordinates) {
var latlng = {lat: coordinates.latitude, lng: coordinates.longitude };
if(this.featureLookup[index]===undefined) {
console.error("Lookup " + index + " failed ");
return;
}
return this.featureLookup[index].map((element, i) => {
if (element instanceof L.RunwayNode) {
element.setLatLng(latlng);
}
else if (element instanceof L.HoldNode) {
element.setLatLng(latlng);
}
else if (element instanceof L.ParkingSpot) {
// element.disableEdit();
element.setLatLng(latlng);
// element.enableEdit();
// element.extensions();
element.updateMiddleMarker();
element.updateVertexFromDirection();
}
else if (element instanceof L.Polyline) {
if (Number(element.begin) === Number(dragIndex)) {
element.getLatLngs()[0].update(event.latlng);
element.setLatLngs(element.getLatLngs());
element.updateBeginVertex(latlng);
element.updateMiddle();
}
if (Number(element.end) === Number(dragIndex)) {
element.getLatLngs()[element.getLatLngs().length - 1].update(event.latlng);
element.setLatLngs(element.getLatLngs());
element.updateEndVertex(latlng);
element.updateMiddle();
}
} else if (element instanceof L.Editable.VertexMarker) {
console.log(element);
element.setLatLng(latlng);
element.latlngs.forEach((latlng1, index) => {
console.log(latlng1);
if (latlng1.__vertex === element) {
latlng1.update(latlng);
}
});
element.editor.feature.setLatLngs(latlngs);
element.editor.feature.updateMiddle();
}
});
},
getParkings (){
var parkings = []
this.groundnetLayerGroup.eachLayer(l => {

View File

@ -60,7 +60,12 @@
</el-radio-group>
</el-col>
</el-row>
<!--
<el-row>
<el-col :span="7">
<span class="demo-input-label">Aircraft :</span>
</el-col>
<el-col :span="17">{{type}}</el-col>
</el-row>
<el-row>
<el-col :span="7">
<span class="demo-input-label">Coordinates :</span>
@ -69,13 +74,6 @@
<el-input placeholder="Please input" v-model="coordinates"></el-input>
</el-col>
</el-row>
-->
<el-row>
<el-col :span="7">
<span class="demo-input-label">Aircraft :</span>
</el-col>
<el-col :span="17">{{type}}</el-col>
</el-row>
<el-row>
<el-col :span="7">
<span class="demo-input-label">Parking Type :</span>
@ -117,6 +115,9 @@
<script lang="js">
/* eslint-disable */
const convert = require('geo-coordinates-parser');
const Coordinates = require('coordinate-parser');
export default {
methods: {
show (idx) {
@ -180,11 +181,16 @@
coordinates: {
// getter
get: function () {
return ''
if(this.$store.state.Editable.index!==undefined) {
var ret = this.$parent.$parent.$parent.$refs.editLayer.getPointCoords(this.$store.state.Editable.index)
return ret[0].lat + " " + ret[0].lng
}
},
// setter
set: function (newValue) {
set: function (newValue) {
var position = new Coordinates(newValue);
console.log(position);
this.$parent.$parent.$parent.$refs.editLayer.setPointCoords(this.$store.state.Editable.index, position)
}
},
wingspan: {