return d3.rebind(context, dispatch, 'on');
};
-iD.version = '1.5.1';
+iD.version = '1.5.2';
(function() {
var detected = {};
Math.min(obj[1][1], this[1][1])]);
},
+ percentContainedIn: function(obj) {
+ if (!(obj instanceof iD.geo.Extent)) obj = new iD.geo.Extent(obj);
+ var a1 = this.intersection(obj).area(),
+ a2 = this.area();
+
+ if (a1 === Infinity || a2 === Infinity || a1 === 0 || a2 === 0) {
+ return 0;
+ } else {
+ return a1 / a2;
+ }
+ },
+
padByMeters: function(meters) {
var dLat = iD.geo.metersToLat(meters),
dLon = iD.geo.metersToLon(meters, this.center()[1]);
toParam: function() {
return [this[0][0], this[0][1], this[1][0], this[1][1]].join(',');
}
+
});
iD.geo.Turn = function(turn) {
if (!(this instanceof iD.geo.Turn))
var p = point(),
dx = p[0] - origin_[0],
dy = p[1] - origin_[1];
+
+ if (dx === 0 && dy === 0)
+ return;
if (!started) {
started = true;
iD.operations = {};
iD.operations.Circularize = function(selectedIDs, context) {
var entityId = selectedIDs[0],
+ entity = context.entity(entityId),
+ extent = entity.extent(context.graph()),
geometry = context.geometry(entityId),
action = iD.actions.Circularize(entityId, context.projection);
};
operation.available = function() {
- var entity = context.entity(entityId);
return selectedIDs.length === 1 &&
entity.type === 'way' &&
_.uniq(entity.nodes).length > 1;
};
operation.disabled = function() {
- var way = context.entity(entityId),
- wayExtent = way.extent(context.graph()),
- mapExtent = context.extent(),
- intersection = mapExtent.intersection(wayExtent),
- pctVisible = intersection.area() / wayExtent.area();
-
- if (pctVisible < 0.8) {
- return 'too_large';
- } else {
- return action.disabled(context.graph());
+ var reason;
+ if (extent.percentContainedIn(context.extent()) < 0.8) {
+ reason = 'too_large';
}
+ return action.disabled(context.graph()) || reason;
};
operation.tooltip = function() {
return operation;
};
iD.operations.Move = function(selectedIDs, context) {
+ var extent = selectedIDs.reduce(function(extent, id) {
+ return extent.extend(context.entity(id).extent(context.graph()));
+ }, iD.geo.Extent());
+
var operation = function() {
context.enter(iD.modes.Move(context, selectedIDs));
};
};
operation.disabled = function() {
- return iD.actions.Move(selectedIDs)
- .disabled(context.graph());
+ var reason;
+ if (extent.area() && extent.percentContainedIn(context.extent()) < 0.8) {
+ reason = 'too_large';
+ }
+ return iD.actions.Move(selectedIDs).disabled(context.graph()) || reason;
};
operation.tooltip = function() {
};
iD.operations.Orthogonalize = function(selectedIDs, context) {
var entityId = selectedIDs[0],
+ entity = context.entity(entityId),
+ extent = entity.extent(context.graph()),
geometry = context.geometry(entityId),
action = iD.actions.Orthogonalize(entityId, context.projection);
- function operation() {
+ var operation = function() {
var annotation = t('operations.orthogonalize.annotation.' + geometry);
context.perform(action, annotation);
- }
+ };
operation.available = function() {
- var entity = context.entity(entityId);
return selectedIDs.length === 1 &&
entity.type === 'way' &&
entity.isClosed() &&
};
operation.disabled = function() {
- var way = context.entity(entityId),
- wayExtent = way.extent(context.graph()),
- mapExtent = context.extent(),
- intersection = mapExtent.intersection(wayExtent),
- pctVisible = intersection.area() / wayExtent.area();
-
- if (pctVisible < 0.8) {
- return 'too_large';
- } else {
- return action.disabled(context.graph());
+ var reason;
+ if (extent.percentContainedIn(context.extent()) < 0.8) {
+ reason = 'too_large';
}
+ return action.disabled(context.graph()) || reason;
};
operation.tooltip = function() {
return operation;
};
iD.operations.Rotate = function(selectedIDs, context) {
- var entityId = selectedIDs[0];
+ var entityId = selectedIDs[0],
+ entity = context.entity(entityId),
+ extent = entity.extent(context.graph()),
+ geometry = context.geometry(entityId);
var operation = function() {
context.enter(iD.modes.RotateWay(context, entityId));
};
operation.available = function() {
- var graph = context.graph(),
- entity = graph.entity(entityId);
-
- if (selectedIDs.length !== 1 ||
- entity.type !== 'way')
+ if (selectedIDs.length !== 1 || entity.type !== 'way')
return false;
- if (context.geometry(entityId) === 'area')
+ if (geometry === 'area')
return true;
if (entity.isClosed() &&
- graph.parentRelations(entity).some(function(r) { return r.isMultipolygon(); }))
+ context.graph().parentRelations(entity).some(function(r) { return r.isMultipolygon(); }))
return true;
return false;
};
operation.disabled = function() {
- return false;
+ if (extent.percentContainedIn(context.extent()) < 0.8) {
+ return 'too_large';
+ } else {
+ return false;
+ }
};
operation.tooltip = function() {
- return t('operations.rotate.description');
+ var disable = operation.disabled();
+ return disable ?
+ t('operations.rotate.' + disable) :
+ t('operations.rotate.description');
};
operation.id = 'rotate';
if (options) {
for (var k in options) {
values.push(k === 'undefined' ? undefined : k);
- texts.push(field.t('check.' + k, { 'default': options[k] }));
+ texts.push(field.t('options.' + k, { 'default': options[k] }));
}
} else {
values = [undefined, 'yes'];
if (field.id === 'oneway') {
for (var key in entity.tags) {
if (key in iD.oneWayTags && (entity.tags[key] in iD.oneWayTags[key])) {
- texts.shift();
- texts.unshift(t('presets.fields.oneway_yes.check.undefined', { 'default': 'Assumed to be Yes' }));
+ texts[0] = t('presets.fields.oneway_yes.options.undefined');
break;
}
}
"oneway_yes": {
"key": "oneway",
"type": "check",
- "default": "yes",
"label": "One Way",
"strings": {
"options": {
"area": "Moved an area.",
"multiple": "Moved multiple objects."
},
- "incomplete_relation": "This feature can't be moved because it hasn't been fully downloaded."
+ "incomplete_relation": "This feature can't be moved because it hasn't been fully downloaded.",
+ "too_large": "This can't be moved because not enough of it is currently visible."
},
"rotate": {
"title": "Rotate",
"annotation": {
"line": "Rotated a line.",
"area": "Rotated an area."
- }
+ },
+ "too_large": "This can't be rotated because not enough of it is currently visible."
},
"reverse": {
"title": "Reverse",