Edit node coordinates bidirectional
This commit is contained in:
parent
23cc742c93
commit
66687bb35f
@ -13,6 +13,7 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import { MessageBox } from 'element-ui';
|
import { MessageBox } from 'element-ui';
|
||||||
|
|
||||||
|
const Coordinates = require('coordinate-parser');
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
|
||||||
@ -343,7 +344,9 @@
|
|||||||
}).filter(n => n);
|
}).filter(n => n);
|
||||||
},
|
},
|
||||||
setPointCoords (index, coordinates) {
|
setPointCoords (index, coordinates) {
|
||||||
var latlng = {lat: coordinates.latitude, lng: coordinates.longitude };
|
var position = new Coordinates(coordinates);
|
||||||
|
|
||||||
|
var latlng = {lat: position.latitude, lng: position.longitude };
|
||||||
if(this.featureLookup[index]===undefined) {
|
if(this.featureLookup[index]===undefined) {
|
||||||
console.error("Lookup " + index + " failed ");
|
console.error("Lookup " + index + " failed ");
|
||||||
return;
|
return;
|
||||||
@ -364,14 +367,14 @@
|
|||||||
element.updateVertexFromDirection();
|
element.updateVertexFromDirection();
|
||||||
}
|
}
|
||||||
else if (element instanceof L.Polyline) {
|
else if (element instanceof L.Polyline) {
|
||||||
if (Number(element.begin) === Number(dragIndex)) {
|
if (Number(element.begin) === Number(index)) {
|
||||||
element.getLatLngs()[0].update(event.latlng);
|
element.getLatLngs()[0].update(latlng);
|
||||||
element.setLatLngs(element.getLatLngs());
|
element.setLatLngs(element.getLatLngs());
|
||||||
element.updateBeginVertex(latlng);
|
element.updateBeginVertex(latlng);
|
||||||
element.updateMiddle();
|
element.updateMiddle();
|
||||||
}
|
}
|
||||||
if (Number(element.end) === Number(dragIndex)) {
|
if (Number(element.end) === Number(index)) {
|
||||||
element.getLatLngs()[element.getLatLngs().length - 1].update(event.latlng);
|
element.getLatLngs()[element.getLatLngs().length - 1].update(latlng);
|
||||||
element.setLatLngs(element.getLatLngs());
|
element.setLatLngs(element.getLatLngs());
|
||||||
element.updateEndVertex(latlng);
|
element.updateEndVertex(latlng);
|
||||||
element.updateMiddle();
|
element.updateMiddle();
|
||||||
@ -606,6 +609,7 @@
|
|||||||
arc.updateStyle();
|
arc.updateStyle();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
//Update Node
|
||||||
editedNode() {
|
editedNode() {
|
||||||
if (this.$store.state.Editable.index === undefined ||
|
if (this.$store.state.Editable.index === undefined ||
|
||||||
this.$store.state.Editable.data.node === undefined ||
|
this.$store.state.Editable.data.node === undefined ||
|
||||||
@ -665,8 +669,10 @@
|
|||||||
}
|
}
|
||||||
} else if (element instanceof L.Polyline) {
|
} else if (element instanceof L.Polyline) {
|
||||||
element._latlngs.forEach(element => {
|
element._latlngs.forEach(element => {
|
||||||
if(element.__vertex && Number(element.glueindex) === Number(nIndex)){
|
if(element.__vertex && Number(element.glueindex) === Number(nIndex)){
|
||||||
latlng = element.latlng;
|
if (this.$store.state.Editable.data.node.coords) {
|
||||||
|
this.setPointCoords(this.$store.state.Editable.index, this.$store.state.Editable.data.node.coords)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -64,12 +64,7 @@
|
|||||||
// getter
|
// getter
|
||||||
get: function () {
|
get: function () {
|
||||||
if(this.$store.state.Editable.index!==undefined) {
|
if(this.$store.state.Editable.index!==undefined) {
|
||||||
var ret = this.$parent.$parent.$parent.$refs.editLayer.getPointCoords(this.$store.state.Editable.index)
|
return this.$store.state.Editable.data.node.coords;
|
||||||
if(ret) {
|
|
||||||
return ret[0].lat + " " + ret[0].lng
|
|
||||||
} else {
|
|
||||||
return 'unknown'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// setter
|
// setter
|
||||||
@ -77,9 +72,7 @@
|
|||||||
if (newValue==='unknown') {
|
if (newValue==='unknown') {
|
||||||
|
|
||||||
}
|
}
|
||||||
var position = new Coordinates(newValue);
|
this.$store.commit('SET_EDIT_COORDS', newValue)
|
||||||
console.log(position);
|
|
||||||
this.$parent.$parent.$parent.$refs.editLayer.setPointCoords(this.$store.state.Editable.index, position)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isOnRunway: {
|
isOnRunway: {
|
||||||
|
@ -132,7 +132,7 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
|
|||||||
console.log(event)
|
console.log(event)
|
||||||
});
|
});
|
||||||
this.on('editable:vertex:clicked', function (event) {
|
this.on('editable:vertex:clicked', function (event) {
|
||||||
store.default.dispatch('setNode', event.vertex.latlng.attributes)
|
store.default.dispatch('setNode', event.vertex.latlng)
|
||||||
if(event.vertex._icon!=null) {
|
if(event.vertex._icon!=null) {
|
||||||
event.vertex._icon.style['background-color'] = 'red';
|
event.vertex._icon.style['background-color'] = 'red';
|
||||||
} else if(event.vertex.icon!=null ) {
|
} else if(event.vertex.icon!=null ) {
|
||||||
@ -152,23 +152,26 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
|
|||||||
function (state) {
|
function (state) {
|
||||||
return state.Editable.data.node;
|
return state.Editable.data.node;
|
||||||
},
|
},
|
||||||
() => {
|
(state) => {
|
||||||
if(event.vertex._icon!=null) {
|
if( state === undefined ||
|
||||||
event.vertex._icon.style['background-color'] = 'white';
|
state.index !== Number(event.vertex.latlng.glueindex)) {
|
||||||
} else if(event.vertex.icon!=null ) {
|
if(event.vertex._icon!=null) {
|
||||||
if(event.vertex.icon.style!=null) {
|
event.vertex._icon.style['background-color'] = 'white';
|
||||||
event.vertex.icon.style['background-color'] = 'white';
|
} else if(event.vertex.icon!=null ) {
|
||||||
} else {
|
if(event.vertex.icon.style!=null) {
|
||||||
event.vertex.setStyle({color : 'white'})
|
event.vertex.icon.style['background-color'] = 'white';
|
||||||
}
|
} else {
|
||||||
} else if(event.vertex.options.icon!=null ) {
|
event.vertex.setStyle({color : 'white'})
|
||||||
if(event.vertex.options.icon.style!=null) {
|
}
|
||||||
event.vertex.options.icon.style['background-color'] = 'white';
|
} else if(event.vertex.options.icon!=null ) {
|
||||||
} else {
|
if(event.vertex.options.icon.style!=null) {
|
||||||
event.vertex.options.icon._setIconStyles({color : 'white'})
|
event.vertex.options.icon.style['background-color'] = 'white';
|
||||||
}
|
} else {
|
||||||
|
event.vertex.options.icon._setIconStyles({color : 'white'})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.unwatch();
|
||||||
}
|
}
|
||||||
this.unwatch();
|
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
{
|
{
|
||||||
@ -196,6 +199,7 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
dragIndex = -1;
|
dragIndex = -1;
|
||||||
|
store.default.dispatch('setNode', event.vertex.latlng)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
|
@ -82,6 +82,9 @@ const mutations = {
|
|||||||
'SET_EDIT_HOLDPOINTTYPE' (state, holdPointType) {
|
'SET_EDIT_HOLDPOINTTYPE' (state, holdPointType) {
|
||||||
Vue.set(state.data.node, 'holdPointType', holdPointType)
|
Vue.set(state.data.node, 'holdPointType', holdPointType)
|
||||||
},
|
},
|
||||||
|
'SET_EDIT_COORDS' (state, coords) {
|
||||||
|
Vue.set(state.data.node, 'coords', coords)
|
||||||
|
},
|
||||||
'SET_EDIT_ISONRUNWAY' (state, isOnRunway) {
|
'SET_EDIT_ISONRUNWAY' (state, isOnRunway) {
|
||||||
Vue.set(state.data.node, 'isOnRunway', isOnRunway)
|
Vue.set(state.data.node, 'isOnRunway', isOnRunway)
|
||||||
}
|
}
|
||||||
@ -101,7 +104,8 @@ const actions = {
|
|||||||
context.commit(SET_EDIT_ARC, arc)
|
context.commit(SET_EDIT_ARC, arc)
|
||||||
},
|
},
|
||||||
async setNode (context, node) {
|
async setNode (context, node) {
|
||||||
context.commit('SET_EDIT_NODE', node)
|
context.commit('SET_EDIT_NODE', node.attributes)
|
||||||
|
context.commit('SET_EDIT_COORDS', node.lat.toFixed(5) + ' ' + node.lng.toFixed(5))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user