Merge pull request #11803 from MoonE/modify-fix-vertex-insertion
Modify fix vertex insertion
This commit is contained in:
@@ -1097,14 +1097,16 @@ class Modify extends PointerInteraction {
|
|||||||
for (let i = 1, ii = nodes.length; i < ii; ++i) {
|
for (let i = 1, ii = nodes.length; i < ii; ++i) {
|
||||||
const segment = nodes[i].segment;
|
const segment = nodes[i].segment;
|
||||||
if (
|
if (
|
||||||
((coordinatesEqual(closestSegment[0], segment[0]) &&
|
(coordinatesEqual(closestSegment[0], segment[0]) &&
|
||||||
coordinatesEqual(closestSegment[1], segment[1])) ||
|
coordinatesEqual(closestSegment[1], segment[1])) ||
|
||||||
(coordinatesEqual(closestSegment[0], segment[1]) &&
|
(coordinatesEqual(closestSegment[0], segment[1]) &&
|
||||||
coordinatesEqual(closestSegment[1], segment[0]))) &&
|
coordinatesEqual(closestSegment[1], segment[0]))
|
||||||
!(getUid(nodes[i].geometry) in geometries)
|
|
||||||
) {
|
) {
|
||||||
geometries[getUid(nodes[i].geometry)] = true;
|
const geometryUid = getUid(nodes[i].geometry);
|
||||||
vertexSegments[getUid(segment)] = true;
|
if (!(geometryUid in geometries)) {
|
||||||
|
geometries[geometryUid] = true;
|
||||||
|
vertexSegments[getUid(segment)] = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -423,6 +423,37 @@ describe('ol.interaction.Modify', function () {
|
|||||||
|
|
||||||
expect(lineFeature.getGeometry().getCoordinates().length).to.equal(5);
|
expect(lineFeature.getGeometry().getCoordinates().length).to.equal(5);
|
||||||
});
|
});
|
||||||
|
it('inserts one vertex into both linestrings with duplicate segments each', function () {
|
||||||
|
const lineFeature1 = new Feature(
|
||||||
|
new LineString([
|
||||||
|
[-10, -10],
|
||||||
|
[10, 10],
|
||||||
|
[-10, -10],
|
||||||
|
])
|
||||||
|
);
|
||||||
|
const lineFeature2 = new Feature(
|
||||||
|
new LineString([
|
||||||
|
[10, 10],
|
||||||
|
[-10, -10],
|
||||||
|
[10, 10],
|
||||||
|
])
|
||||||
|
);
|
||||||
|
features.length = 0;
|
||||||
|
features.push(lineFeature1, lineFeature2);
|
||||||
|
|
||||||
|
const modify = new Modify({
|
||||||
|
features: new Collection(features),
|
||||||
|
});
|
||||||
|
map.addInteraction(modify);
|
||||||
|
|
||||||
|
// Click on line
|
||||||
|
simulateEvent('pointermove', 0, 0, null, 0);
|
||||||
|
simulateEvent('pointerdown', 0, 0, null, 0);
|
||||||
|
simulateEvent('pointerup', 0, 0, null, 0);
|
||||||
|
|
||||||
|
expect(lineFeature1.getGeometry().getCoordinates().length).to.be(4);
|
||||||
|
expect(lineFeature2.getGeometry().getCoordinates().length).to.be(4);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('circle modification', function () {
|
describe('circle modification', function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user