#115 Better edit of NoseWheel position

This commit is contained in:
Keith Paterson 2021-01-11 13:25:06 +01:00
parent 51d114e6d2
commit 618346d1b1
2 changed files with 49 additions and 24 deletions

View File

@ -210,9 +210,33 @@
},
turfToLatLng: function (turfPoint) {
return '' + turfPoint.geometry.coordinates[1].toFixed(6) + ',' + turfPoint.geometry.coordinates[0].toFixed(6);
},
calcWheel () {
var centerCoords = convert(this.$store.state.Editable.data.parking.coords);
if(this.calculate === 'Nose Wheel') {
// we change center
const centerLatLng = convert(newValue);
const parkingSize = this.validRadii.indexOf(this.$store.state.Editable.data.parking.radius);
if (parkingSize>=0) {
var newNoseWheel = turf.destination(this.latToTurf(centerLatLng), this.validN2M[parkingSize]/1000, this.$store.state.Editable.data.parking.heading - 180, turfOptions);
this.$store.commit('SET_EDIT_PARKING_NOSE_COORDS', this.turfToLatLng(newNoseWheel));
}
}
},
calcCenter () {
var centerCoords = convert(this.$store.state.Editable.data.parking.coords);
if (this.calculate === 'Center') {
// we change center
const noseWheelLatLng = convert(this.noseWheel);
const parkingSize = this.validRadii.indexOf(this.$store.state.Editable.data.parking.radius);
if (parkingSize>=0) {
var newCenter = turf.destination(this.latToTurf(noseWheelLatLng), this.validN2M[parkingSize]/1000, this.$store.state.Editable.data.parking.heading, turfOptions);
this.$store.commit('SET_EDIT_PARKING_COORDS', this.turfToLatLng(newCenter));
}
}
}
},
data () { return {calculate:'Nose Wheel', noseWheel: '', validRadii: [7.5, 10, 14, 18, 26, 33, 40], validN2M: [5, 5, 6, 10, 15, 24, 24] } },
data () { return {_calculate: 'Center', noseWheel: '', validRadii: [7.5, 10, 14, 18, 26, 33, 40], validN2M: [5, 5, 6, 10, 15, 24, 24] } },
computed: {
editing: {
get: function () {
@ -274,6 +298,19 @@
this.$store.commit('SET_EDIT_PARKING_NUMBER', newValue)
}
},
calculate: {
get: function () {
return this._calculate;
},
set: function (newValue) {
this._calculate = newValue;
if (newValue==='Center') {
this.calcWheel();
} else {
this.calcCenter();
}
}
},
coordinates: {
// getter
get: function () {
@ -290,23 +327,14 @@
newValue = newValue.replace(', ', ' ').replace(/,/g, '.').replace(' ', ', ');
}
this.$store.commit('SET_EDIT_PARKING_COORDS', newValue)
this.calcWheel();
}
},
noseCoordinates: {
// getter
get: function () {
if(this.$store.state.Editable.index!==undefined) {
const center = convert(this.$store.state.Editable.data.parking.coords);
const parkingSize = this.validRadii.indexOf(this.$store.state.Editable.data.parking.radius);
if (parkingSize>=0) {
var newWheel = turf.destination(this.latToTurf(center), this.validN2M[parkingSize]/1000, this.normalizeAngle(this.$store.state.Editable.data.parking.heading), turfOptions);
var newValue = this.turfToLatLng(newWheel);
if( newValue.match(/,/g) !== null && newValue.match(/,/g).length === 1) {
newValue = newValue.replace(',', ' ');
}
this.noseWheel = newValue;
return newValue;
}
if(this.$store.state.Editable.index!==undefined) {
return this.$store.state.Editable.data.parking.nosecoords;
}
},
// setter
@ -317,17 +345,8 @@
if( newValue.match(/,/g) !== null && newValue.match(/,/g).length === 3) {
newValue = newValue.replace(', ', ' ').replace(/,/g, '.').replace(' ', ', ');
}
this.noseWheel = newValue;
var centerCoords = convert(this.$store.state.Editable.data.parking.coords);
if(this.calculate === 'Center') {
// we change center
const noseWheelLatLng = convert(this.noseWheel);
const parkingSize = this.validRadii.indexOf(this.$store.state.Editable.data.parking.radius);
if (parkingSize>=0) {
var newCenter = turf.destination(this.latToTurf(noseWheelLatLng), this.validN2M[parkingSize]/1000, this.$store.state.Editable.data.parking.heading, turfOptions);
this.$store.commit('SET_EDIT_PARKING_COORDS', this.turfToLatLng(newCenter));
}
}
this.$store.commit('SET_EDIT_PARKING_NOSE_COORDS', newValue);
this.calcCenter();
}
},
heading: {

View File

@ -131,6 +131,9 @@ const mutations = {
'SET_EDIT_PARKING_COORDS' (state, coords) {
Vue.set(state.data.parking, 'coords', coords)
},
'SET_EDIT_PARKING_NOSE_COORDS' (state, coords) {
Vue.set(state.data.parking, 'nosecoords', coords)
},
'SET_EDIT_ARC_NAME' (state, arcName) {
if (state.type === 'arc') {
Vue.set(state.data.arc, 'name', arcName)
@ -197,6 +200,9 @@ const actions = {
async setParkingCoords (context, coords) {
context.commit('SET_EDIT_PARKING_COORDS', coords)
},
async setParkingNoseCoords (context, coords) {
context.commit('SET_EDIT_PARKING_NOSE_COORDS', coords)
},
async setArc (context, arc) {
context.commit(SET_EDIT_ARC, arc)
},