diff --git a/src/renderer/loaders/ParkingSpot.js b/src/renderer/loaders/ParkingSpot.js index 1c2f141..0ea36f5 100644 --- a/src/renderer/loaders/ParkingSpot.js +++ b/src/renderer/loaders/ParkingSpot.js @@ -99,16 +99,17 @@ L.ParkingSpot = L.Circle.extend({ // Update the direction vertex from the direction updateVertexFromDirection() { if (this.editEnabled()) { - var start = this._latlng; + var center = this._latlng; var options = { units: 'kilometers' }; - var end = turf.destination([start.lng, start.lat], this.options.attributes.radius / 1000, this.options.attributes.heading, options); + var start = turf.destination([center.lng, center.lat], this.options.attributes.radius / 1000, this.normalizeAngle(this.options.attributes.heading+180), options); + var end = turf.destination([center.lng, center.lat], this.options.attributes.radius / 1000, this.normalizeAngle(this.options.attributes.heading), options); // Resize, since leaflet is wrong - var rad2 = start.distanceTo(this.turfToLatLng(end), options); + var rad2 = center.distanceTo(this.turfToLatLng(end), options); this.setRadius(rad2); if(this.editor._resizeLatLng.__vertex!== undefined){ this.editor._resizeLatLng.__vertex.setLatLng(this.turfToLatLng(end)); } - this.direction.setLatLngs([start, this.turfToLatLng(end)]); + this.direction.setLatLngs([this.turfToLatLng(start), this.turfToLatLng(end)]); } }, // Update the direction from the moved direction vertex @@ -175,19 +176,20 @@ L.ParkingSpot = L.Circle.extend({ if(this.box === undefined && this.editor !== undefined) { var latlngs = [leftBack, rightBack, rightMiddle, rightIntermediate, rightFront, leftFront, leftIntermediate, leftMiddle].map(l => this.turfToLatLng(l)); this.box = L.polygon(latlngs); - this.box.addTo(this.editor.editLayer); + this.box.addTo(this.editor.editLayer); + this.box._parkingSpot = this; this.box.on('click', function (event) { - console.debug("Click Parking : " + event.target); + console.debug("Click Parking Box : " + event.target); if (Number(store.default.state.Editable.index) >= 0 && - this.featureLookup !== undefined && - this.featureLookup[store.default.state.Editable.index]!==undefined) { - this.featureLookup[store.default.state.Editable.index].forEach(element => { + event.target._parkingSpot.featureLookup !== undefined && + event.target._parkingSpot.featureLookup[store.default.state.Editable.index]!==undefined) { + event.target._parkingSpot.featureLookup[store.default.state.Editable.index].forEach(element => { if(element.deselect !== undefined) { element.deselect(); } }); } - this.select(); + event.target._parkingSpot.select(); }); } @@ -215,8 +217,10 @@ L.ParkingSpot = L.Circle.extend({ if(this.direction) { this.direction.setStyle(style); this.frontWheel.setStyle(style); - this.box.setStyle(style); - } + if(this.box) { + this.box.setStyle(style); + } + } this.updateWheelPos(); this.updateBox(); }, @@ -227,7 +231,9 @@ L.ParkingSpot = L.Circle.extend({ if(this.direction) { this.direction.setStyle(style); this.frontWheel.setStyle(style); - this.box.setStyle(style); + if(this.box) { + this.box.setStyle(style); + } } this.updateWheelPos(); this.updateBox(); @@ -275,7 +281,7 @@ L.ParkingSpot = L.Circle.extend({ } }); } - this.select(); + event.target.select(); }); this.on('editable:vertex:clicked', function (event) { console.debug(this.featureLookup[event.vertex.glueindex]); diff --git a/src/renderer/loaders/TaxiwaySegmentExtender.js b/src/renderer/loaders/TaxiwaySegmentExtender.js index 69c7b6e..314794f 100644 --- a/src/renderer/loaders/TaxiwaySegmentExtender.js +++ b/src/renderer/loaders/TaxiwaySegmentExtender.js @@ -49,43 +49,43 @@ exports.extendTaxiSegment = function (taxiwaySegment) { }; taxiwaySegment.__proto__.selectVertex = function () { this.getLatLngs().forEach( element => { - if (Number(element.glueindex) === store.default.state.Editable.index) { - if (element.__vertex._icon != null) { - element.__vertex.__proto__.deselect = function () { - if (this._icon != null) { - this._icon.style.setProperty('background-color','white'); - this._icon.style.setProperty('color','white'); - } else if (this.icon != null) { - if (this.icon.style != null) { - this.icon.style['background-color'] = 'white'; - } else { - this.setStyle({ color: 'white' }) - } - } else if (this.options.icon != null) { - if (this.options.icon.style != null) { - this.options.icon.style['background-color'] = 'white'; - } else { - this.options.icon._setIconStyles({ color: 'white' }) - } - } - } - element.__vertex._icon.style.setProperty('background-color','red'); - element.__vertex._icon.style.setProperty('color','red'); - } else if (element.__vertex !== undefined && element.__vertex.icon != null) { - if (element.__vertex.icon.style != null) { - element.__vertex.icon.style['background-color'] = 'red'; + if (Number(element.glueindex) === store.default.state.Editable.index) { + if (element.__vertex._icon != null) { + element.__vertex.__proto__.deselect = function () { + if (this._icon != null) { + this._icon.style.setProperty('background-color','white'); + this._icon.style.setProperty('color','white'); + } else if (this.icon != null) { + if (this.icon.style != null) { + this.icon.style['background-color'] = 'white'; } else { - element.__vertex.setStyle({ color: 'red' }) + this.setStyle({ color: 'white' }) } - } else if (element.__vertex.options.icon != null) { - if (element.__vertex.options.icon.style != null) { - element.__vertex.options.icon.style['background-color'] = 'red'; + } else if (this.options.icon != null) { + if (this.options.icon.style != null) { + this.options.icon.style['background-color'] = 'white'; } else { - element.__vertex.options.icon._setIconStyles({ color: 'red' }) + this.options.icon._setIconStyles({ color: 'white' }) } } } - }); + element.__vertex._icon.style.setProperty('background-color','red'); + element.__vertex._icon.style.setProperty('color','red'); + } else if (element.__vertex !== undefined && element.__vertex.icon != null) { + if (element.__vertex.icon.style != null) { + element.__vertex.icon.style['background-color'] = 'red'; + } else { + element.__vertex.setStyle({ color: 'red' }) + } + } else if (element.__vertex.options.icon != null) { + if (element.__vertex.options.icon.style != null) { + element.__vertex.options.icon.style['background-color'] = 'red'; + } else { + element.__vertex.options.icon._setIconStyles({ color: 'red' }) + } + } + } + }); }; taxiwaySegment.__proto__.deselect = function () { this.options.attributes.selected = false; @@ -239,10 +239,23 @@ exports.extendTaxiSegment = function (taxiwaySegment) { if (parking.length > 0) { parking[0].selectParking(); } else { + if( Number(event.vertex.latlng.glueindex) !== store.default.state.Editable.index) { + if (Number(store.default.state.Editable.index) >= 0 && + this.featureLookup[store.default.state.Editable.index] !== undefined) { + this.featureLookup[store.default.state.Editable.index].forEach(element => { + if(element.deselect !== undefined) { + element.deselect(); + } + }); + } + store.default.dispatch('setNode', event.vertex.latlng) + } + var lines = this.featureLookup[event.vertex.latlng.glueindex].filter(n => n instanceof L.Polyline); Vue.default.nextTick(function () { - store.default.dispatch('setNode', event.vertex.latlng) + lines.forEach( line => { + line.selectVertex() + }); }) - // } }); diff --git a/src/renderer/loaders/groundnet_writer.js b/src/renderer/loaders/groundnet_writer.js index e4383e2..9dae6cb 100644 --- a/src/renderer/loaders/groundnet_writer.js +++ b/src/renderer/loaders/groundnet_writer.js @@ -168,7 +168,7 @@ exports.writeGroundnetXML = function (fDir, icao, featureList) { } catch (error) { console.error(error); } - return layerGroup; + return; } var mapFrequency = function (o) {