diff --git a/data/core.yaml b/data/core.yaml index 2c1c29bc3..11f7ad974 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -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. diff --git a/dist/locales/en.json b/dist/locales/en.json index c81984940..eaeba55f1 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -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", diff --git a/js/id/actions/orthogonalize.js b/js/id/actions/orthogonalize.js index 52ca9f42a..d87b03798 100644 --- a/js/id/actions/orthogonalize.js +++ b/js/id/actions/orthogonalize.js @@ -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; diff --git a/js/id/actions/straighten.js b/js/id/actions/straighten.js index c891cbcce..3dc703d8d 100644 --- a/js/id/actions/straighten.js +++ b/js/id/actions/straighten.js @@ -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), diff --git a/js/id/operations/orthogonalize.js b/js/id/operations/orthogonalize.js index 5f7d06564..6ea690702 100644 --- a/js/id/operations/orthogonalize.js +++ b/js/id/operations/orthogonalize.js @@ -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; }; diff --git a/js/id/operations/straighten.js b/js/id/operations/straighten.js index 44d98b95e..ac6ad19ac 100644 --- a/js/id/operations/straighten.js +++ b/js/id/operations/straighten.js @@ -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; }; diff --git a/test/spec/actions/orthogonalize.js b/test/spec/actions/orthogonalize.js index fac0a9226..7a5e2f193 100644 --- a/test/spec/actions/orthogonalize.js +++ b/test/spec/actions/orthogonalize.js @@ -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],