By modifying the common vertex, not all geometries were changed when the geometries were aggregated in the collection
This commit is contained in:
@@ -212,10 +212,21 @@ const geojsonObject = {
|
||||
'type': 'Polygon',
|
||||
'coordinates': [
|
||||
[
|
||||
[1e6, -6e6],
|
||||
[2e6, -4e6],
|
||||
[3e6, -6e6],
|
||||
[1e6, -6e6],
|
||||
[1e6, -5e6],
|
||||
[2e6, -3.5e6],
|
||||
[3e6, -5e6],
|
||||
[1e6, -5e6],
|
||||
],
|
||||
],
|
||||
},
|
||||
{
|
||||
'type': 'Polygon',
|
||||
'coordinates': [
|
||||
[
|
||||
[1e6, -5e6],
|
||||
[2e6, -6.5e6],
|
||||
[3e6, -5e6],
|
||||
[1e6, -5e6],
|
||||
],
|
||||
],
|
||||
},
|
||||
|
||||
@@ -897,7 +897,7 @@ class Modify extends PointerInteraction {
|
||||
for (let i = 0, ii = segmentDataMatches.length; i < ii; ++i) {
|
||||
const segmentDataMatch = segmentDataMatches[i];
|
||||
const segment = segmentDataMatch.segment;
|
||||
let uid = getUid(segmentDataMatch.feature);
|
||||
let uid = getUid(segmentDataMatch.geometry);
|
||||
const depth = segmentDataMatch.depth;
|
||||
if (depth) {
|
||||
uid += '-' + depth.join('-'); // separate feature components
|
||||
|
||||
@@ -2,6 +2,7 @@ import Circle from '../../../../src/ol/geom/Circle.js';
|
||||
import Collection from '../../../../src/ol/Collection.js';
|
||||
import Event from '../../../../src/ol/events/Event.js';
|
||||
import Feature from '../../../../src/ol/Feature.js';
|
||||
import GeometryCollection from '../../../../src/ol/geom/GeometryCollection.js';
|
||||
import LineString from '../../../../src/ol/geom/LineString.js';
|
||||
import Map from '../../../../src/ol/Map.js';
|
||||
import MapBrowserEvent from '../../../../src/ol/MapBrowserEvent.js';
|
||||
@@ -602,6 +603,89 @@ describe('ol.interaction.Modify', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('geometry collection modification', function () {
|
||||
it('all geometries should be modified', function () {
|
||||
const firstPolygon = new Polygon([
|
||||
[
|
||||
[0, 0],
|
||||
[1, 0],
|
||||
[1, 1],
|
||||
[0, 1],
|
||||
[0, 0],
|
||||
],
|
||||
]);
|
||||
const secondPolygon = firstPolygon.clone();
|
||||
|
||||
const firstLineString = new LineString([
|
||||
[-2, 0],
|
||||
[0, 0],
|
||||
[2, 0],
|
||||
]);
|
||||
const secondLineString = new LineString([
|
||||
[0, 2],
|
||||
[0, 0],
|
||||
[0, -2],
|
||||
]);
|
||||
|
||||
const point = new Point([0, 0]);
|
||||
|
||||
const circle = new Circle([0, 0], 1);
|
||||
|
||||
const geometryCollection = new GeometryCollection([
|
||||
firstPolygon,
|
||||
secondPolygon,
|
||||
firstLineString,
|
||||
secondLineString,
|
||||
point,
|
||||
circle,
|
||||
]);
|
||||
|
||||
const feature = new Feature({
|
||||
geometry: geometryCollection,
|
||||
});
|
||||
|
||||
features.length = 0;
|
||||
features.push(feature);
|
||||
|
||||
const modify = new Modify({
|
||||
features: new Collection(features),
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
// Move vertex
|
||||
simulateEvent('pointermove', 0, 0, null, 0);
|
||||
simulateEvent('pointerdown', 0, 0, null, 0);
|
||||
simulateEvent('pointermove', -1, 0, null, 0);
|
||||
simulateEvent('pointerdrag', -1, 0, null, 0);
|
||||
simulateEvent('pointerup', -1, 0, null, 0);
|
||||
|
||||
let geomCoords;
|
||||
geomCoords = firstPolygon.getCoordinates()[0];
|
||||
expect(geomCoords[0][0]).to.equal(-1);
|
||||
expect(geomCoords[0][1]).to.equal(0);
|
||||
|
||||
geomCoords = secondPolygon.getCoordinates()[0];
|
||||
expect(geomCoords[0][0]).to.equal(-1);
|
||||
expect(geomCoords[0][1]).to.equal(0);
|
||||
|
||||
geomCoords = firstLineString.getCoordinates();
|
||||
expect(geomCoords[1][0]).to.equal(-1);
|
||||
expect(geomCoords[1][1]).to.equal(0);
|
||||
|
||||
geomCoords = secondLineString.getCoordinates();
|
||||
expect(geomCoords[1][0]).to.equal(-1);
|
||||
expect(geomCoords[1][1]).to.equal(0);
|
||||
|
||||
geomCoords = point.getCoordinates();
|
||||
expect(geomCoords[0]).to.equal(-1);
|
||||
expect(geomCoords[1]).to.equal(0);
|
||||
|
||||
geomCoords = circle.getCenter();
|
||||
expect(geomCoords[0]).to.equal(-1);
|
||||
expect(geomCoords[1]).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('double click deleteCondition', function () {
|
||||
let modify, feature, events;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user