Select all parent ways, not just common parents

This commit is contained in:
Minh Nguyễn
2020-12-22 11:51:22 -08:00
parent e031ee3aef
commit 5433c8ff42

View File

@@ -23,7 +23,7 @@ import { osmNode, osmWay } from '../osm';
import * as Operations from '../operations/index';
import { uiCmd } from '../ui/cmd';
import {
utilArrayIntersection, utilDeepMemberSelector, utilEntityOrDeepMemberSelector,
utilArrayIntersection, utilArrayUnion, utilDeepMemberSelector, utilEntityOrDeepMemberSelector,
utilEntitySelector, utilKeybinding, utilTotalExtent, utilGetAllNodes
} from '../util';
@@ -85,6 +85,33 @@ export function modeSelect(context, selectedIDs) {
}
// find the common parent ways for nextVertex, previousVertex
function allParents() {
var graph = context.graph();
var allParents = [];
for (var i = 0; i < selectedIDs.length; i++) {
var entity = context.hasEntity(selectedIDs[i]);
if (!entity || entity.geometry(graph) !== 'vertex') {
return []; // selection includes some not vertices
}
var currParents = graph.parentWays(entity).map(function(w) { return w.id; });
if (!allParents.length) {
allParents = currParents;
continue;
}
allParents = utilArrayUnion(allParents, currParents);
if (!allParents.length) {
return [];
}
}
return allParents;
}
// find the common parent ways for nextVertex, previousVertex
function commonParents() {
var graph = context.graph();
@@ -565,7 +592,7 @@ export function modeSelect(context, selectedIDs) {
function selectParent(d3_event) {
d3_event.preventDefault();
var parents = _relatedParent ? [_relatedParent] : commonParents();
var parents = _relatedParent ? [_relatedParent] : allParents();
if (!parents) return;
context.enter(