mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-18 22:48:10 +02:00
Merge pull request #6161 from jguthrie100/fix_closed_way_disconnect
Leave way as closed when disconnecting
This commit is contained in:
@@ -59,6 +59,9 @@ export function actionDisconnect(nodeId, newNodeId) {
|
||||
} else {
|
||||
way.nodes.forEach(function(waynode, index) {
|
||||
if (waynode === nodeId) {
|
||||
if (way.isClosed() && parentWays.length > 1 && wayIds && wayIds.indexOf(way.id) !== -1 && index === way.nodes.length-1) {
|
||||
return;
|
||||
}
|
||||
candidates.push({ wayID: way.id, index: index });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4,8 +4,15 @@ import { behaviorOperation } from '../behavior/index';
|
||||
|
||||
|
||||
export function operationDisconnect(selectedIDs, context) {
|
||||
var vertices = selectedIDs.filter(function(id) {
|
||||
return context.geometry(id) === 'vertex';
|
||||
var vertices = [],
|
||||
ways = [];
|
||||
|
||||
selectedIDs.forEach(function(id) {
|
||||
if (context.geometry(id) === 'vertex') {
|
||||
vertices.push(id);
|
||||
} else {
|
||||
ways.push(id);
|
||||
}
|
||||
});
|
||||
|
||||
var entityID = vertices[0];
|
||||
@@ -23,7 +30,7 @@ export function operationDisconnect(selectedIDs, context) {
|
||||
|
||||
|
||||
operation.available = function() {
|
||||
return vertices.length === 1;
|
||||
return vertices.length === 1 && ways.every(function(way) { return context.graph().entity(way).nodes.includes(vertices[0]); });
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -180,6 +180,35 @@ describe('iD.actionDisconnect', function () {
|
||||
expect(graph.entity('|').nodes).to.eql(['d', 'b']);
|
||||
});
|
||||
|
||||
it('preserves the closed way when part of a larger disconnect operation', function () {
|
||||
// Situation:
|
||||
// a ---- bb === c
|
||||
// = ==
|
||||
// = ==
|
||||
// d
|
||||
// Disconnect - at b (whilst == is selected).
|
||||
//
|
||||
// Expected result:
|
||||
// a ---- b ee === c
|
||||
// = ==
|
||||
// = ==
|
||||
// d
|
||||
//
|
||||
var graph = iD.coreGraph([
|
||||
iD.osmNode({id: 'a'}),
|
||||
iD.osmNode({id: 'b'}),
|
||||
iD.osmNode({id: 'c'}),
|
||||
iD.osmNode({id: 'd'}),
|
||||
iD.osmWay({id: '-', nodes: ['a', 'b']}),
|
||||
iD.osmWay({id: '=', nodes: ['b', 'c', 'd', 'b']})
|
||||
]);
|
||||
|
||||
graph = iD.actionDisconnect('b', 'e').limitWays(['='])(graph);
|
||||
|
||||
expect(graph.entity('-').nodes).to.eql(['a', 'b']);
|
||||
expect(graph.entity('=').nodes).to.eql(['e', 'c', 'd', 'e']);
|
||||
});
|
||||
|
||||
it('replaces later occurrences in a self-intersecting way', function() {
|
||||
// Situtation:
|
||||
// a --- b
|
||||
|
||||
Reference in New Issue
Block a user