Don't zoom to the end vertex when continuing a disconnected highway if it is already visible

Add separate fixes for continuing a disconnected highway from the start and end vertices
Highlight the vertex that will be continued
This commit is contained in:
Quincy Morgan
2019-02-11 11:29:34 -05:00
parent 01b0c618d1
commit 47ec58e5fc
5 changed files with 50 additions and 25 deletions
+5 -3
View File
@@ -1249,8 +1249,10 @@ en:
connect_almost_junction:
title: Connect the features
undo_redo: Connected very close features.
continue_feature:
title: Continue this feature
continue_from_start:
title: Continue drawing from start
continue_from_end:
title: Continue drawing from end
delete_feature:
title: Delete this feature
connect_endpoints:
@@ -1642,4 +1644,4 @@ en:
wikidata:
identifier: "Identifier"
label: "Label"
description: "Description"
description: "Description"
+5 -2
View File
@@ -1532,8 +1532,11 @@
"title": "Connect the features",
"undo_redo": "Connected very close features."
},
"continue_feature": {
"title": "Continue this feature"
"continue_from_start": {
"title": "Continue drawing from start"
},
"continue_from_end": {
"title": "Continue drawing from end"
},
"delete_feature": {
"title": "Delete this feature"
+3
View File
@@ -229,6 +229,9 @@ export function validationIssueFix(attrs) {
this.title = attrs.title;
this.onClick = attrs.onClick;
// IDs of fix-specific entities. Used for hover-higlighting.
this.entityIds = attrs.entityIds || [];
// the issue this fix is for
this.issue = null;
}
+10
View File
@@ -147,6 +147,16 @@ export function uiEntityIssues(context) {
})
.on('click', function(d) {
d.onClick();
})
.on('mouseover.highlight', function(d) {
d.entityIds.forEach(function(entityId) {
utilHighlightEntity(entityId, true, context);
});
})
.on('mouseout.highlight', function(d) {
d.entityIds.forEach(function(entityId) {
utilHighlightEntity(entityId, false, context);
});
});
}
});
+27 -20
View File
@@ -45,28 +45,22 @@ export function validationDisconnectedWay() {
entities: [entity],
fixes: [
new validationIssueFix({
title: t('issues.fix.continue_feature.title'),
title: t('issues.fix.continue_from_start.title'),
onClick: function() {
var way = this.issue.entities[0];
var childNodes = context.graph().childNodes(way);
var endNodes = [childNodes[0], childNodes[childNodes.length-1]];
var exclusiveEndNodes = endNodes.filter(function(vertex) {
return graph.parentWays(vertex).length === 1;
});
var vertex;
if (exclusiveEndNodes.length === 1) {
// prefer an endpoint with no connecting ways
vertex = exclusiveEndNodes[0];
} else {
// prefer the terminating node
vertex = endNodes[1];
}
// make sure the vertex is actually visible
context.map().zoomToEase(vertex);
context.enter(
modeDrawLine(context, way.id, context.graph(), way.affix(vertex.id), true)
);
}
var vertex = context.entity(way.nodes[0]);
continueDrawing(way, vertex, context);
},
entityIds: [entity.nodes[0]]
}),
new validationIssueFix({
title: t('issues.fix.continue_from_end.title'),
onClick: function() {
var way = this.issue.entities[0];
var vertex = context.entity(way.nodes[way.nodes.length-1]);
continueDrawing(way, vertex, context);
},
entityIds: [entity.nodes[entity.nodes.length-1]]
}),
new validationIssueFix({
title: t('issues.fix.delete_feature.title'),
@@ -82,6 +76,19 @@ export function validationDisconnectedWay() {
return issues;
};
function continueDrawing(way, vertex, context) {
if (!context.map().editable() ||
!context.map().extent().contains(vertex.loc)) {
// make sure the vertex is actually visible and editable
context.map().zoomToEase(vertex);
}
context.enter(
modeDrawLine(context, way.id, context.graph(), way.affix(vertex.id), true)
);
}
validation.type = type;
return validation;