mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-20 15:34:49 +02:00
Prevent orthogonalization of <3 node ways. Fixes #776
This commit is contained in:
@@ -27,7 +27,8 @@ iD.actions.Orthogonalize = function(wayId, projection) {
|
||||
points = best;
|
||||
|
||||
for (i = 0; i < points.length - 1; i++) {
|
||||
graph = graph.replace(graph.entity(nodes[i].id).move(projection.invert(points[i])));
|
||||
graph = graph.replace(graph.entity(nodes[i].id)
|
||||
.move(projection.invert(points[i])));
|
||||
}
|
||||
|
||||
return graph;
|
||||
@@ -42,7 +43,7 @@ iD.actions.Orthogonalize = function(wayId, projection) {
|
||||
p = normalizePoint(p, 1.0);
|
||||
q = normalizePoint(q, 1.0);
|
||||
|
||||
var dotp = p[0] *q[0] + p[1] *q[1];
|
||||
var dotp = p[0] * q[0] + p[1] * q[1];
|
||||
// nasty hack to deal with almost-straight segments (angle is closer to 180 than to 90/270).
|
||||
if (dotp < -0.707106781186547) {
|
||||
dotp += 1.0;
|
||||
@@ -87,7 +88,7 @@ iD.actions.Orthogonalize = function(wayId, projection) {
|
||||
|
||||
function normalizePoint(point, thickness) {
|
||||
var vector = [0, 0];
|
||||
var length = Math.sqrt(point[0] * point[0] + point[1] * point[1]);
|
||||
var length = Math.sqrt(point[0] * point[0] + point[1] * point[1]);
|
||||
if (length !== 0) {
|
||||
vector[0] = point[0] / length;
|
||||
vector[1] = point[1] / length;
|
||||
|
||||
@@ -9,7 +9,8 @@ iD.operations.Orthogonalize = function(selection, context) {
|
||||
|
||||
operation.available = function() {
|
||||
return selection.length === 1 &&
|
||||
context.entity(entityId).type === 'way';
|
||||
context.entity(entityId).type === 'way' &&
|
||||
_.uniq(context.entity(entityId).nodes).length > 3;
|
||||
};
|
||||
|
||||
operation.enabled = function() {
|
||||
|
||||
Reference in New Issue
Block a user