Merge pull request #3957 from tschaub/shared-delete
Properly handle vertex deletion with multiple features.
This commit is contained in:
@@ -888,8 +888,10 @@ ol.interaction.Modify.prototype.removeVertex_ = function() {
|
||||
newSegmentData);
|
||||
this.updateSegmentIndices_(geometry, index, segmentData.depth, -1);
|
||||
|
||||
this.overlay_.getSource().removeFeature(this.vertexFeature_);
|
||||
this.vertexFeature_ = null;
|
||||
if (!goog.isNull(this.vertexFeature_)) {
|
||||
this.overlay_.getSource().removeFeature(this.vertexFeature_);
|
||||
this.vertexFeature_ = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,13 @@ describe('ol.interaction.Modify', function() {
|
||||
style.height = height + 'px';
|
||||
document.body.appendChild(target);
|
||||
|
||||
var geometry = new ol.geom.Polygon([
|
||||
[[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]]]);
|
||||
|
||||
features = [];
|
||||
features.push(
|
||||
new ol.Feature({
|
||||
geometry: geometry
|
||||
}));
|
||||
features = [
|
||||
new ol.Feature({
|
||||
geometry: new ol.geom.Polygon([
|
||||
[[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]]
|
||||
])
|
||||
})
|
||||
];
|
||||
|
||||
source = new ol.source.Vector({
|
||||
features: features
|
||||
@@ -93,6 +92,37 @@ describe('ol.interaction.Modify', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('vertex deletion', function() {
|
||||
|
||||
it('works when clicking on a shared vertex', function() {
|
||||
features.push(features[0].clone());
|
||||
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
var first = features[0];
|
||||
var second = features[0];
|
||||
|
||||
expect(first.getGeometry().getRevision()).to.equal(1);
|
||||
expect(first.getGeometry().getCoordinates()[0]).to.have.length(5);
|
||||
expect(second.getGeometry().getRevision()).to.equal(1);
|
||||
expect(second.getGeometry().getCoordinates()[0]).to.have.length(5);
|
||||
|
||||
simulateEvent('pointerdown', 10, -20, false, 0);
|
||||
simulateEvent('pointerup', 10, -20, false, 0);
|
||||
simulateEvent('click', 10, -20, false, 0);
|
||||
simulateEvent('singleclick', 10, -20, false, 0);
|
||||
|
||||
expect(first.getGeometry().getRevision()).to.equal(2);
|
||||
expect(first.getGeometry().getCoordinates()[0]).to.have.length(4);
|
||||
expect(second.getGeometry().getRevision()).to.equal(2);
|
||||
expect(second.getGeometry().getCoordinates()[0]).to.have.length(4);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('boundary modification', function() {
|
||||
|
||||
it('clicking vertex should delete it and +r1', function() {
|
||||
|
||||
Reference in New Issue
Block a user