Link lines
This commit is contained in:
parent
4b7183c428
commit
70926ed2ff
@ -877,6 +877,87 @@ You should have received a copy of the GNU General Public License along with FG
|
||||
reload (force) {
|
||||
this.load(this.icao, force)
|
||||
},
|
||||
link (index) {
|
||||
var layers = []
|
||||
var centerLatLng = null
|
||||
this.featureLookup[index].forEach(layer => {
|
||||
if (layer instanceof L.Polyline) {
|
||||
// console.log(layer._latlngs)
|
||||
layer._latlngs.forEach(latlng => {
|
||||
if (latlng.__vertex) {
|
||||
if (Number.isNaN(latlng.glueindex)) {
|
||||
console.warn('No glueindex : ' + latlng.__vertex);
|
||||
}
|
||||
|
||||
if (Number(latlng.glueindex) === index) {
|
||||
centerLatLng = latlng;
|
||||
}
|
||||
}
|
||||
})}
|
||||
})
|
||||
var newIndex = index
|
||||
var nearest = [];
|
||||
this.featureLookup.forEach(layers => {
|
||||
layers.forEach(layer => {
|
||||
if (layer instanceof L.ParkingSpot) {
|
||||
let distance = layer.getLatLng().distanceTo(centerLatLng);
|
||||
if (Number(layer.glueindex) !== newIndex && distance < 10) {
|
||||
nearest.push({d: distance, l: layer, glueindex: layer.glueindex })
|
||||
}
|
||||
}
|
||||
else if (layer instanceof L.Polyline) {
|
||||
// console.log(layer._latlngs)
|
||||
layer._latlngs.forEach(latlng => {
|
||||
if (latlng.__vertex) {
|
||||
if (Number.isNaN(latlng.glueindex)) {
|
||||
console.warn('No glueindex : ' + latlng.__vertex);
|
||||
}
|
||||
let distance = latlng.distanceTo(centerLatLng)
|
||||
if (latlng.glueindex !== newIndex && distance < 10) {
|
||||
nearest.push({d: distance, l: layer, latlng: latlng.__vertex.latlng, glueindex: latlng.glueindex })
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
})
|
||||
var featureLookup = this.featureLookup;
|
||||
nearest = nearest.map(e => e.glueindex).filter((v, i, a) => a.indexOf(v) === i).filter(i => Number(i)!==newIndex)
|
||||
nearest.forEach(glueindex => {
|
||||
featureLookup[glueindex].forEach(layer => {
|
||||
featureLookup[newIndex].push(layer);
|
||||
if (layer instanceof L.RunwayNode) {
|
||||
layer.setLatLng(centerLatLng);
|
||||
}
|
||||
else if (layer instanceof L.HoldNode) {
|
||||
layer.setLatLng(centerLatLng);
|
||||
}
|
||||
else if (layer instanceof L.ParkingSpot) {
|
||||
layer.setLatLng(centerLatLng);
|
||||
}
|
||||
else if (layer instanceof L.Polyline) {
|
||||
layer._latlngs.forEach((e1, index1) => {
|
||||
if (e1.attributes.index===Number(glueindex)) {
|
||||
if( Number(layer.begin)===Number(glueindex)) {
|
||||
layer.begin = String(newIndex);
|
||||
}
|
||||
if( Number(layer.end)===Number(glueindex)) {
|
||||
layer.end = String(newIndex);
|
||||
}
|
||||
e1.attributes.index = newIndex;
|
||||
e1.glueindex = newIndex;
|
||||
|
||||
layer.getLatLngs()[index1].update(centerLatLng);
|
||||
layer.editor.refresh();
|
||||
layer.editor.reset();
|
||||
layer.updateMiddle();
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
featureLookup[glueindex] = [];
|
||||
});
|
||||
},
|
||||
save () {
|
||||
var xml = []
|
||||
this.groundnetLayerGroup.eachLayer(l => {
|
||||
|
@ -36,10 +36,12 @@
|
||||
</el-select>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row><el-button @click="link"><i class="fas fa-link"></i></el-button></el-row>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script lang="js">
|
||||
/* eslint-disable */
|
||||
const Coordinates = require('coordinate-parser');
|
||||
@ -56,6 +58,11 @@
|
||||
coordFocussed: false, runwayFocussed: false, holdFocussed: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
link: function () {
|
||||
this.$parent.$parent.$parent.$refs.editLayer.link(this.$store.state.Editable.index)
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
editing: {
|
||||
get: function () {
|
||||
|
@ -135,7 +135,7 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
|
||||
});
|
||||
this.on('editable:drawing:move', function (event) {
|
||||
if (dragIndex >= 0) {
|
||||
console.log('GlueDrag' + event.target);
|
||||
console.log('GlueDrag : '+ dragIndex + '\t' + event.target.dragIndex);
|
||||
this.follow(dragIndex, event);
|
||||
}
|
||||
});
|
||||
@ -217,11 +217,11 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
|
||||
});
|
||||
var dragIndex = -1;
|
||||
this.on('editable:vertex:dragstart', function (event) {
|
||||
console.log("Event Target : ", event.target);
|
||||
console.log("Middle Marker : ", event.vertex == event.vertex.middleMarker);
|
||||
console.log("Middle Marker : ", event.vertex.latlng.glueindex == undefined);
|
||||
console.log("Drag Start : ", event.target);
|
||||
console.log("Middle Marker : ", event.vertex == event.vertex.middleMarker, event.vertex.latlng.glueindex == undefined);
|
||||
if (event.vertex.latlng.glueindex == undefined)
|
||||
return;
|
||||
console.log("Drag Start : ", event.vertex.latlng.glueindex);
|
||||
dragIndex = event.vertex.latlng.glueindex;
|
||||
});
|
||||
this.on('editable:vertex:dragend', function (event) {
|
||||
|
Loading…
Reference in New Issue
Block a user