From fbf0e5cbab2a1e86514f0e9d3644becd5ad37b4e Mon Sep 17 00:00:00 2001 From: Keith Paterson Date: Wed, 13 Jan 2021 13:22:49 +0100 Subject: [PATCH] #118 --- src/renderer/components/EditLayer.vue | 2 +- src/renderer/components/ParkingEdit.vue | 58 ++++++++++++++++--------- src/renderer/loaders/ParkingSpot.js | 8 +--- 3 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/renderer/components/EditLayer.vue b/src/renderer/components/EditLayer.vue index 70bfa21..8197115 100644 --- a/src/renderer/components/EditLayer.vue +++ b/src/renderer/components/EditLayer.vue @@ -657,10 +657,10 @@ You should have received a copy of the GNU General Public License along with FG } console.debug('Edited Parkings : ' + this.$store.state.Parkings.items) this.$store.state.Parkings.items.forEach( newElement => { - console.debug(newElement); if(this.featureLookup[newElement.index]) { this.featureLookup[newElement.index].forEach((element,index) => { if (element instanceof L.ParkingSpot) { + console.debug(element); element.options.attributes.name = newElement.name element.options.attributes.number = newElement.number element.options.attributes.type = newElement.type diff --git a/src/renderer/components/ParkingEdit.vue b/src/renderer/components/ParkingEdit.vue index 3d22bad..1a5b41e 100644 --- a/src/renderer/components/ParkingEdit.vue +++ b/src/renderer/components/ParkingEdit.vue @@ -132,7 +132,7 @@ Heading : - + + + + + + @@ -193,6 +198,37 @@ export default { methods: { + rotate() { + var heading = this.$store.state.Editable.data.parking.heading + 90; + while (heading>=360) { + heading -= 360 + } + while (heading<0) { + heading += 360 + } + this.headingChange(heading); + }, + headingChange( newValue ) { + while (newValue>=360) { + newValue -= 360 + } + while (newValue<0) { + newValue += 360 + } + if (Number(this.$store.state.Editable.data.parking.heading) !== newValue) { + this.$store.commit('SET_EDIT_PARKING_HEADING', newValue) + } + 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 reverseHeading = this.normalizeAngle(this.$store.state.Editable.data.parking.heading+180); + var newCenter = turf.destination(this.latToTurf(noseWheelLatLng), this.validN2M[parkingSize]/1000, reverseHeading, turfOptions); + this.$store.commit('SET_EDIT_PARKING_COORDS', this.turfToLatLng(newCenter)); + } + } + }, show (idx) { this.$parent.$parent.$parent.$refs.editLayer.show(idx) }, @@ -356,25 +392,7 @@ }, // setter set: function (newValue) { - while (newValue>=360) { - newValue -= 360 - } - while (newValue<0) { - newValue += 360 - } - if (Number(this.$store.state.Editable.data.parking.heading) !== newValue) { - this.$store.commit('SET_EDIT_PARKING_HEADING', newValue) - } - 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 reverseHeading = this.normalizeAngle(this.$store.state.Editable.data.parking.heading+180); - var newCenter = turf.destination(this.latToTurf(noseWheelLatLng), this.validN2M[parkingSize]/1000, reverseHeading, turfOptions); - this.$store.commit('SET_EDIT_PARKING_COORDS', this.turfToLatLng(newCenter)); - } - } + this.headingChange(newValue) } }, wingspan: { diff --git a/src/renderer/loaders/ParkingSpot.js b/src/renderer/loaders/ParkingSpot.js index 636b2c1..55dc2d6 100644 --- a/src/renderer/loaders/ParkingSpot.js +++ b/src/renderer/loaders/ParkingSpot.js @@ -277,7 +277,7 @@ L.ParkingSpot = L.Circle.extend({ } }); this.on('add', function (event) { - console.log(event); + console.debug(event); event.target.updateBox(); if(event.target.box !== undefined) { event.target.box.addTo(event.target._map); @@ -285,7 +285,7 @@ L.ParkingSpot = L.Circle.extend({ event.target.setInteractive(false); }); this.on('remove', function (event) { - console.log(event); + console.debug(event); if(event.target.box !== undefined) { event.target.box.removeFrom(event.target._map); } @@ -351,10 +351,6 @@ L.ParkingSpot = L.Circle.extend({ } }); } - - store.default.dispatch('setParking', this.options.attributes); - store.default.dispatch('setParkingCoords', this.getLatLng().lat.toFixed(6) + ' ' + this.getLatLng().lng.toFixed(6)); - this.select(); }, turfToLatLng: function (turfPoint) {