Fix an issue where some tagged nodes or existing vertices could not be snapped to (close #5942)

This commit is contained in:
Quincy Morgan
2019-02-25 08:54:30 -05:00
parent 506bb0f953
commit ced652806b
5 changed files with 16 additions and 23 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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());
}
+5 -1
View File
@@ -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);
+1 -1
View File
@@ -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()));
}
+8 -19
View File
@@ -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;
});
};