mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Make straighten/orthogonalize act like a single operation
- Display only one or the other in the radial menu - Rename "Orthogonalize" to "Square" - Use "S" as shortcut for both Refs #1839
This commit is contained in:
@@ -56,20 +56,20 @@ en:
|
||||
area: Made an area circular.
|
||||
not_closed: This can't be made circular because it's not a loop.
|
||||
orthogonalize:
|
||||
title: Orthogonalize
|
||||
description: Square these corners.
|
||||
key: Q
|
||||
title: Square
|
||||
description:
|
||||
line: Square the corners of this line.
|
||||
area: Square the corners of this area.
|
||||
key: S
|
||||
annotation:
|
||||
line: Squared the corners of a line.
|
||||
area: Squared the corners of an area.
|
||||
not_closed: This can't be made square because it's not a loop.
|
||||
straighten:
|
||||
title: Straighten
|
||||
description: Straighten this line.
|
||||
key: S
|
||||
annotation: Straightened the line.
|
||||
is_closed: This can't be straightened because it's a loop.
|
||||
too_bendy: This can't be straightened because it's too bendy.
|
||||
annotation: Straightened a line.
|
||||
too_bendy: This can't be straightened because it bends too much.
|
||||
delete:
|
||||
title: Delete
|
||||
description: Remove this from the map.
|
||||
|
||||
17
dist/locales/en.json
vendored
17
dist/locales/en.json
vendored
@@ -74,22 +74,23 @@
|
||||
"not_closed": "This can't be made circular because it's not a loop."
|
||||
},
|
||||
"orthogonalize": {
|
||||
"title": "Orthogonalize",
|
||||
"description": "Square these corners.",
|
||||
"key": "Q",
|
||||
"title": "Square",
|
||||
"description": {
|
||||
"line": "Square the corners of this line.",
|
||||
"area": "Square the corners of this area."
|
||||
},
|
||||
"key": "S",
|
||||
"annotation": {
|
||||
"line": "Squared the corners of a line.",
|
||||
"area": "Squared the corners of an area."
|
||||
},
|
||||
"not_closed": "This can't be made square because it's not a loop."
|
||||
}
|
||||
},
|
||||
"straighten": {
|
||||
"title": "Straighten",
|
||||
"description": "Straighten this line.",
|
||||
"key": "S",
|
||||
"annotation": "Straightened the line.",
|
||||
"is_closed": "This can't be straightened because it's a loop.",
|
||||
"too_bendy": "This can't be straightened because it's too bendy."
|
||||
"annotation": "Straightened a line.",
|
||||
"too_bendy": "This can't be straightened because it bends too much."
|
||||
},
|
||||
"delete": {
|
||||
"title": "Delete",
|
||||
|
||||
@@ -128,8 +128,7 @@ iD.actions.Orthogonalize = function(wayId, projection) {
|
||||
};
|
||||
|
||||
action.disabled = function(graph) {
|
||||
if (!graph.entity(wayId).isClosed())
|
||||
return 'not_closed';
|
||||
return false;
|
||||
};
|
||||
|
||||
return action;
|
||||
|
||||
@@ -44,10 +44,6 @@ iD.actions.Straighten = function(wayId, projection) {
|
||||
};
|
||||
|
||||
action.disabled = function(graph) {
|
||||
if (graph.entity(wayId).isClosed()) {
|
||||
return 'is_closed';
|
||||
}
|
||||
|
||||
// check way isn't too bendy
|
||||
var way = graph.entity(wayId),
|
||||
nodes = graph.childNodes(way),
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
iD.operations.Orthogonalize = function(selectedIDs, context) {
|
||||
var entityId = selectedIDs[0],
|
||||
geometry = context.geometry(entityId),
|
||||
action = iD.actions.Orthogonalize(entityId, context.projection);
|
||||
|
||||
var operation = function() {
|
||||
var annotation = t('operations.orthogonalize.annotation.' + context.geometry(entityId));
|
||||
function operation() {
|
||||
var annotation = t('operations.orthogonalize.annotation.' + geometry);
|
||||
context.perform(action, annotation);
|
||||
};
|
||||
}
|
||||
|
||||
operation.available = function() {
|
||||
var entity = context.entity(entityId);
|
||||
return selectedIDs.length === 1 &&
|
||||
context.entity(entityId).type === 'way' &&
|
||||
_.uniq(context.entity(entityId).nodes).length > 2;
|
||||
entity.type === 'way' &&
|
||||
entity.isClosed() &&
|
||||
_.uniq(entity.nodes).length > 2;
|
||||
};
|
||||
|
||||
operation.disabled = function() {
|
||||
@@ -21,13 +24,12 @@ iD.operations.Orthogonalize = function(selectedIDs, context) {
|
||||
var disable = operation.disabled();
|
||||
return disable ?
|
||||
t('operations.orthogonalize.' + disable) :
|
||||
t('operations.orthogonalize.description');
|
||||
t('operations.orthogonalize.description.' + geometry);
|
||||
};
|
||||
|
||||
operation.id = "orthogonalize";
|
||||
operation.keys = [t('operations.orthogonalize.key')];
|
||||
operation.title = t('operations.orthogonalize.title');
|
||||
operation.description = t('operations.orthogonalize.description');
|
||||
|
||||
return operation;
|
||||
};
|
||||
|
||||
@@ -2,15 +2,17 @@ iD.operations.Straighten = function(selectedIDs, context) {
|
||||
var entityId = selectedIDs[0],
|
||||
action = iD.actions.Straighten(entityId, context.projection);
|
||||
|
||||
var operation = function() {
|
||||
function operation() {
|
||||
var annotation = t('operations.straighten.annotation');
|
||||
context.perform(action, annotation);
|
||||
};
|
||||
}
|
||||
|
||||
operation.available = function() {
|
||||
var entity = context.entity(entityId);
|
||||
return selectedIDs.length === 1 &&
|
||||
context.entity(entityId).type === 'way' &&
|
||||
_.uniq(context.entity(entityId).nodes).length > 2;
|
||||
entity.type === 'way' &&
|
||||
!entity.isClosed() &&
|
||||
_.uniq(entity.nodes).length > 2;
|
||||
};
|
||||
|
||||
operation.disabled = function() {
|
||||
@@ -26,8 +28,7 @@ iD.operations.Straighten = function(selectedIDs, context) {
|
||||
|
||||
operation.id = "straighten";
|
||||
operation.keys = [t('operations.straighten.key')];
|
||||
operation.title = "title";
|
||||
operation.description = "description";
|
||||
operation.title = t('operations.straighten.title');
|
||||
|
||||
return operation;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe("iD.actions.Orthogonalize", function () {
|
||||
var projection = d3.geo.mercator();
|
||||
|
||||
it("orthoganalizes a quad", function () {
|
||||
it("orthogonalizes a quad", function () {
|
||||
var graph = iD.Graph({
|
||||
'a': iD.Node({id: 'a', loc: [0, 0]}),
|
||||
'b': iD.Node({id: 'b', loc: [4, 0]}),
|
||||
@@ -15,7 +15,7 @@ describe("iD.actions.Orthogonalize", function () {
|
||||
expect(graph.entity('-').nodes).to.have.length(5);
|
||||
});
|
||||
|
||||
it("orthoganalizes a triangle", function () {
|
||||
it("orthogonalizes a triangle", function () {
|
||||
var graph = iD.Graph({
|
||||
'a': iD.Node({id: 'a', loc: [0, 0]}),
|
||||
'b': iD.Node({id: 'b', loc: [3, 0]}),
|
||||
@@ -28,7 +28,7 @@ describe("iD.actions.Orthogonalize", function () {
|
||||
expect(graph.entity('-').nodes).to.have.length(4);
|
||||
});
|
||||
|
||||
it("should not shrink skinny quads", function () {
|
||||
it("preserves the shape of skinny quads", function () {
|
||||
var tests = [
|
||||
[
|
||||
[-77.0339864831478, 38.8616391227204],
|
||||
|
||||
Reference in New Issue
Block a user