mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-25 17:37:49 +02:00
Fix an issue where some tagged nodes or existing vertices could not be snapped to (close #5942)
This commit is contained in:
@@ -118,7 +118,7 @@ export function behaviorDraw(context) {
|
||||
}
|
||||
|
||||
function allowsVertex(d) {
|
||||
return _isEmpty(d.tags) || context.presets().allowsVertex(d, context.graph());
|
||||
return d.geometry(context.graph()) === 'vertex' || context.presets().allowsVertex(d, context.graph());
|
||||
}
|
||||
|
||||
// related code
|
||||
|
||||
@@ -65,7 +65,7 @@ export function behaviorDrawWay(context, wayID, index, mode, startGraph, baselin
|
||||
|
||||
|
||||
function allowsVertex(d) {
|
||||
return context.presets().allowsVertex(d, context.graph());
|
||||
return d.geometry(context.graph()) === 'vertex' || context.presets().allowsVertex(d, context.graph());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -103,6 +103,10 @@ export function behaviorHover(context) {
|
||||
.on('mouseup.hover', null, true);
|
||||
}
|
||||
|
||||
function allowsVertex(d) {
|
||||
return d.geometry(context.graph()) === 'vertex' || context.presets().allowsVertex(d, context.graph());
|
||||
}
|
||||
|
||||
function enter(datum) {
|
||||
if (datum === _target) return;
|
||||
_target = datum;
|
||||
@@ -150,7 +154,7 @@ export function behaviorHover(context) {
|
||||
}
|
||||
|
||||
var suppressed = (_altDisables && d3_event && d3_event.altKey) ||
|
||||
(entity.type === 'node' && _ignoreVertex && !context.presets().allowsVertex(entity, context.graph()));
|
||||
(entity.type === 'node' && _ignoreVertex && !allowsVertex(entity));
|
||||
_selection.selectAll(selector)
|
||||
.classed(suppressed ? 'hover-suppressed' : 'hover', true);
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ export function modeDragNode(context) {
|
||||
|
||||
function shouldSnapToNode(target) {
|
||||
return _activeEntity.geometry(context.graph()) !== 'vertex' ||
|
||||
context.presets().allowsVertex(target, context.graph());
|
||||
(target.geometry(context.graph()) === 'vertex' || context.presets().allowsVertex(target, context.graph()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ export function presetIndex() {
|
||||
match = keyMatches[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (address && (!match || match.isFallback())) {
|
||||
@@ -83,34 +83,23 @@ export function presetIndex() {
|
||||
if (_isEmpty(entity.tags)) return true;
|
||||
return resolver.transient(entity, 'vertexMatch', function() {
|
||||
var vertexPresets = _index.vertex;
|
||||
var match;
|
||||
|
||||
if (entity.isOnAddressLine(resolver)) {
|
||||
match = true;
|
||||
return true;
|
||||
} else {
|
||||
var didFindMatches = false;
|
||||
for (var k in entity.tags) {
|
||||
var keyMatches = vertexPresets[k];
|
||||
if (!keyMatches) continue;
|
||||
didFindMatches = true;
|
||||
for (var i = 0; i < keyMatches.length; i++) {
|
||||
var preset = keyMatches[i];
|
||||
if (preset.searchable !== false) {
|
||||
if (preset.matchScore(entity) > -1) {
|
||||
match = preset;
|
||||
break;
|
||||
}
|
||||
var preset = keyMatches[i];
|
||||
if (preset.searchable !== false && preset.matchScore(entity) > -1) {
|
||||
return preset;
|
||||
}
|
||||
}
|
||||
|
||||
if (!match && /^addr:/.test(k) && vertexPresets['addr:*']) {
|
||||
match = true;
|
||||
}
|
||||
|
||||
if (match) break;
|
||||
|
||||
}
|
||||
return !didFindMatches;
|
||||
}
|
||||
|
||||
return match;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user