Don't make connect endpoints fix for tag suggest area actionable if there aren't more than two nodes

This commit is contained in:
Quincy Morgan
2019-02-18 12:51:50 -05:00
parent 10d9f05739
commit 7307beff21
+43 -40
View File
@@ -22,51 +22,54 @@ export function validationTagSuggestsArea() {
if (tagSuggestsArea) {
var tagText = utilTagText({ tags: tagSuggestingArea });
var fixes = [];
var nodes = graph.childNodes(entity), testNodes;
var firstToLastDistanceMeters = geoSphericalDistance(nodes[0].loc, nodes[nodes.length-1].loc);
var connectEndpointsOnClick;
// if the distance is very small, attempt to merge the endpoints
if (firstToLastDistanceMeters < 0.75) {
testNodes = _clone(nodes);
testNodes.pop();
testNodes.push(testNodes[0]);
// make sure this will not create a self-intersection
if (!geoHasSelfIntersections(testNodes, testNodes[0].id)) {
connectEndpointsOnClick = function() {
var way = this.issue.entities[0];
context.perform(
actionMergeNodes([way.nodes[0], way.nodes[way.nodes.length-1]], nodes[0].loc),
t('issues.fix.connect_endpoints.annotation')
);
};
// must have at least three nodes to close this automatically
if (entity.nodes.length >= 3) {
var nodes = graph.childNodes(entity), testNodes;
var firstToLastDistanceMeters = geoSphericalDistance(nodes[0].loc, nodes[nodes.length-1].loc);
// if the distance is very small, attempt to merge the endpoints
if (firstToLastDistanceMeters < 0.75) {
testNodes = _clone(nodes);
testNodes.pop();
testNodes.push(testNodes[0]);
// make sure this will not create a self-intersection
if (!geoHasSelfIntersections(testNodes, testNodes[0].id)) {
connectEndpointsOnClick = function() {
var way = this.issue.entities[0];
context.perform(
actionMergeNodes([way.nodes[0], way.nodes[way.nodes.length-1]], nodes[0].loc),
t('issues.fix.connect_endpoints.annotation')
);
};
}
}
if (!connectEndpointsOnClick) {
// if the points were not merged, attempt to close the way
testNodes = _clone(nodes);
testNodes.push(testNodes[0]);
// make sure this will not create a self-intersection
if (!geoHasSelfIntersections(testNodes, testNodes[0].id)) {
connectEndpointsOnClick = function() {
var way = this.issue.entities[0];
var nodeId = way.nodes[0];
var index = way.nodes.length;
context.perform(
actionAddVertex(way.id, nodeId, index),
t('issues.fix.connect_endpoints.annotation')
);
};
}
}
}
if (!connectEndpointsOnClick) {
// if the points were not merged, attempt to close the way
testNodes = _clone(nodes);
testNodes.push(testNodes[0]);
// make sure this will not create a self-intersection
if (!geoHasSelfIntersections(testNodes, testNodes[0].id)) {
connectEndpointsOnClick = function() {
var way = this.issue.entities[0];
var nodeId = way.nodes[0];
var index = way.nodes.length;
context.perform(
actionAddVertex(way.id, nodeId, index),
t('issues.fix.connect_endpoints.annotation')
);
};
}
}
if (connectEndpointsOnClick) {
fixes.push(new validationIssueFix({
title: t('issues.fix.connect_endpoints.title'),
onClick: connectEndpointsOnClick
}));
}
fixes.push(new validationIssueFix({
title: t('issues.fix.connect_endpoints.title'),
onClick: connectEndpointsOnClick
}));
fixes.push(new validationIssueFix({
icon: 'iD-operation-delete',