mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 21:48:20 +02:00
Merge branch 'master' into presets
Conflicts: js/id/modes/select.js
This commit is contained in:
@@ -23,6 +23,7 @@ all: \
|
||||
js/lib/jxon.js \
|
||||
js/lib/lodash.js \
|
||||
js/lib/ohauth.js \
|
||||
js/lib/rtree.js \
|
||||
js/lib/sha.js \
|
||||
js/id/start.js \
|
||||
js/id/id.js \
|
||||
@@ -40,13 +41,14 @@ all: \
|
||||
js/id/modes/*.js \
|
||||
js/id/operations.js \
|
||||
js/id/operations/*.js \
|
||||
js/id/controller/*.js \
|
||||
js/id/controller.js \
|
||||
js/id/graph/*.js \
|
||||
js/id/renderer/*.js \
|
||||
js/id/svg.js \
|
||||
js/id/svg/*.js \
|
||||
js/id/ui.js \
|
||||
js/id/ui/*.js \
|
||||
js/id/validate.js \
|
||||
js/id/end.js \
|
||||
locale/locale.js \
|
||||
locale/en.js
|
||||
|
||||
+6
-11
@@ -16,7 +16,7 @@ g.point .shadow {
|
||||
transition: transform 100ms linear;
|
||||
-moz-transition: fill 100ms linear;
|
||||
}
|
||||
.behavior-hover g.point.hover .shadow {
|
||||
.behavior-hover g.point.hover:not(.selected) .shadow {
|
||||
fill: #E96666;
|
||||
fill-opacity: 0.3;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ g.vertex .shadow {
|
||||
transition: transform 100ms linear;
|
||||
-moz-transition: fill 100ms linear;
|
||||
}
|
||||
.behavior-hover g.vertex.hover .shadow {
|
||||
.behavior-hover g.vertex.hover:not(.selected) .shadow {
|
||||
fill: #E96666;
|
||||
fill-opacity: 0.3;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ g.vertex.selected .shadow {
|
||||
g.midpoint .fill {
|
||||
fill:#aaa;
|
||||
}
|
||||
.behavior-hover g.midpoint .fill.hover {
|
||||
.behavior-hover g.midpoint .fill.hover:not(.selected) {
|
||||
fill:#fff;
|
||||
stroke:#000;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ g.midpoint .shadow {
|
||||
transition: transform 100ms linear;
|
||||
-moz-transition: fill 100ms linear;
|
||||
}
|
||||
.behavior-hover g.midpoint .shadow.hover {
|
||||
.behavior-hover g.midpoint .shadow.hover:not(.selected) {
|
||||
fill:#E96666;
|
||||
fill-opacity: 0.3;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ path.shadow {
|
||||
-webkit-transition: stroke 100ms linear;
|
||||
}
|
||||
|
||||
.behavior-hover path.shadow.hover {
|
||||
.behavior-hover path.shadow.hover:not(.selected) {
|
||||
stroke: #E96666;
|
||||
stroke-opacity: 0.3;
|
||||
}
|
||||
@@ -628,12 +628,7 @@ text.pointlabel {
|
||||
}
|
||||
|
||||
|
||||
text.area.tag-leisure-park {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
text.point.tag-shop,
|
||||
text.point.tag-amenity {
|
||||
text.point {
|
||||
font-size: 9px;
|
||||
}
|
||||
|
||||
|
||||
+16
-8
@@ -24,7 +24,6 @@
|
||||
<script src='js/lib/d3.keybinding.js'></script>
|
||||
<script src='js/lib/d3.tail.js'></script>
|
||||
<script src='js/lib/d3-compat.js'></script>
|
||||
<script src='js/lib/queue.js'></script>
|
||||
<script src='js/lib/bootstrap-tooltip.js'></script>
|
||||
<script src='js/lib/rtree.js'></script>
|
||||
|
||||
@@ -78,10 +77,9 @@
|
||||
|
||||
<script src='js/id/actions.js'></script>
|
||||
<script src="js/id/actions/add_midpoint.js"></script>
|
||||
<script src='js/id/actions/add_node.js'></script>
|
||||
<script src='js/id/actions/add_way.js'></script>
|
||||
<script src='js/id/actions/add_way_node.js'></script>
|
||||
<script src='js/id/actions/change_entity_tags.js'></script>
|
||||
<script src='js/id/actions/add_entity.js'></script>
|
||||
<script src='js/id/actions/add_vertex.js'></script>
|
||||
<script src='js/id/actions/change_tags.js'></script>
|
||||
<script src='js/id/actions/delete_node.js'></script>
|
||||
<script src="js/id/actions/delete_way.js"></script>
|
||||
<script src='js/id/actions/move_node.js'></script>
|
||||
@@ -119,16 +117,15 @@
|
||||
<script src='js/id/operations/split.js'></script>
|
||||
<script src='js/id/operations/unjoin.js'></script>
|
||||
|
||||
<script src='js/id/controller/controller.js'></script>
|
||||
|
||||
<script src='js/id/graph/entity.js'></script>
|
||||
<script src='js/id/graph/graph.js'></script>
|
||||
<script src='js/id/graph/history.js'></script>
|
||||
<script src='js/id/graph/node.js'></script>
|
||||
<script src='js/id/graph/relation.js'></script>
|
||||
<script src='js/id/graph/way.js'></script>
|
||||
<script src='js/id/graph/validate.js'></script>
|
||||
|
||||
<script src='js/id/controller.js'></script>
|
||||
<script src='js/id/validate.js'></script>
|
||||
<script src='js/id/connection.js'></script>
|
||||
|
||||
<script src='locale/locale.js'></script>
|
||||
@@ -147,4 +144,15 @@
|
||||
});
|
||||
});
|
||||
</script></body>
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-38039653-2']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
</script>
|
||||
</html>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
iD.actions.AddWay = function(way) {
|
||||
iD.actions.AddEntity = function(way) {
|
||||
return function(graph) {
|
||||
return graph.replace(way);
|
||||
};
|
||||
@@ -1,6 +0,0 @@
|
||||
// https://github.com/openstreetmap/josm/blob/mirror/src/org/openstreetmap/josm/command/AddCommand.java
|
||||
iD.actions.AddNode = function(node) {
|
||||
return function(graph) {
|
||||
return graph.replace(node);
|
||||
};
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/AddNodeToWayAction.as
|
||||
iD.actions.AddWayNode = function(wayId, nodeId, index) {
|
||||
iD.actions.AddVertex = function(wayId, nodeId, index) {
|
||||
return function(graph) {
|
||||
return graph.replace(graph.entity(wayId).addNode(nodeId, index));
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
iD.actions.ChangeEntityTags = function(entityId, tags) {
|
||||
iD.actions.ChangeTags = function(entityId, tags) {
|
||||
return function(graph) {
|
||||
var entity = graph.entity(entityId);
|
||||
return graph.replace(entity.update({tags: tags}));
|
||||
@@ -25,7 +25,7 @@ iD.behavior.DragMidpoint = function(mode) {
|
||||
.on('end', function() {
|
||||
history.replace(
|
||||
iD.actions.Noop(),
|
||||
'Added a node to a way.');
|
||||
t('operations.add.annotation.vertex'));
|
||||
});
|
||||
|
||||
return behavior;
|
||||
|
||||
@@ -25,6 +25,10 @@ iD.behavior.DragNode = function(mode) {
|
||||
nudgeInterval = null;
|
||||
}
|
||||
|
||||
function annotation(entity) {
|
||||
return t('operations.move.annotation.' + entity.geometry(mode.history.graph()));
|
||||
}
|
||||
|
||||
return iD.behavior.drag()
|
||||
.delegate(".node")
|
||||
.origin(function(entity) {
|
||||
@@ -43,12 +47,12 @@ iD.behavior.DragNode = function(mode) {
|
||||
|
||||
history.replace(
|
||||
iD.actions.MoveNode(entity.id, projection.invert(d3.event.point)),
|
||||
'moved a node');
|
||||
annotation(entity));
|
||||
})
|
||||
.on('end', function() {
|
||||
.on('end', function(entity) {
|
||||
stopNudge();
|
||||
history.replace(
|
||||
iD.actions.Noop(),
|
||||
'moved a node');
|
||||
annotation(entity));
|
||||
});
|
||||
};
|
||||
|
||||
+11
-15
@@ -2,17 +2,19 @@ iD.behavior.DrawWay = function(wayId, index, mode, baseGraph) {
|
||||
var map = mode.map,
|
||||
history = mode.history,
|
||||
controller = mode.controller,
|
||||
way = mode.history.graph().entity(wayId),
|
||||
way = history.graph().entity(wayId),
|
||||
finished = false,
|
||||
annotation = 'Added to a way.',
|
||||
annotation = t((way.isDegenerate() ?
|
||||
'operations.start.annotation.' :
|
||||
'operations.continue.annotation.') + way.geometry(history.graph())),
|
||||
draw = iD.behavior.Draw(map);
|
||||
|
||||
var node = iD.Node({loc: map.mouseCoordinates()}),
|
||||
nodeId = node.id;
|
||||
|
||||
history[way.isDegenerate() ? 'replace' : 'perform'](
|
||||
iD.actions.AddNode(node),
|
||||
iD.actions.AddWayNode(wayId, node.id, index));
|
||||
iD.actions.AddEntity(node),
|
||||
iD.actions.AddVertex(wayId, node.id, index));
|
||||
|
||||
function move(datum) {
|
||||
var loc = map.mouseCoordinates();
|
||||
@@ -71,12 +73,6 @@ iD.behavior.DrawWay = function(wayId, index, mode, baseGraph) {
|
||||
history.on('undone.draw', null);
|
||||
};
|
||||
|
||||
drawWay.annotation = function(_) {
|
||||
if (!arguments.length) return annotation;
|
||||
annotation = _;
|
||||
return drawWay;
|
||||
};
|
||||
|
||||
function ReplaceTemporaryNode(newNode) {
|
||||
return function(graph) {
|
||||
return graph
|
||||
@@ -90,7 +86,7 @@ iD.behavior.DrawWay = function(wayId, index, mode, baseGraph) {
|
||||
var newNode = iD.Node({loc: loc});
|
||||
|
||||
history.replace(
|
||||
iD.actions.AddNode(newNode),
|
||||
iD.actions.AddEntity(newNode),
|
||||
ReplaceTemporaryNode(newNode),
|
||||
annotation);
|
||||
|
||||
@@ -103,8 +99,8 @@ iD.behavior.DrawWay = function(wayId, index, mode, baseGraph) {
|
||||
var newNode = iD.Node({loc: loc});
|
||||
|
||||
history.perform(
|
||||
iD.actions.AddNode(newNode),
|
||||
iD.actions.AddWayNode(way.id, newNode.id, wayIndex),
|
||||
iD.actions.AddEntity(newNode),
|
||||
iD.actions.AddVertex(way.id, newNode.id, wayIndex),
|
||||
ReplaceTemporaryNode(newNode),
|
||||
annotation);
|
||||
|
||||
@@ -143,7 +139,7 @@ iD.behavior.DrawWay = function(wayId, index, mode, baseGraph) {
|
||||
|
||||
var way = history.graph().entity(wayId);
|
||||
if (way) {
|
||||
controller.enter(iD.modes.Select(way, true));
|
||||
controller.enter(iD.modes.Select([way.id], true));
|
||||
} else {
|
||||
controller.enter(iD.modes.Browse());
|
||||
}
|
||||
@@ -153,7 +149,7 @@ iD.behavior.DrawWay = function(wayId, index, mode, baseGraph) {
|
||||
drawWay.cancel = function() {
|
||||
history.perform(
|
||||
d3.functor(baseGraph),
|
||||
'Cancelled drawing.');
|
||||
t('operations.cancel_draw.annotation'));
|
||||
|
||||
finished = true;
|
||||
controller.enter(iD.modes.Browse());
|
||||
|
||||
+25
-30
@@ -235,44 +235,39 @@ iD.Graph.prototype = {
|
||||
},
|
||||
|
||||
difference: function (graph) {
|
||||
var result = [],
|
||||
keys = Object.keys(this.entities),
|
||||
entity, oldentity, id, i;
|
||||
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
id = keys[i];
|
||||
entity = this.entities[id];
|
||||
oldentity = graph.entities[id];
|
||||
if (entity !== oldentity) {
|
||||
function diff(a, b) {
|
||||
var result = [],
|
||||
keys = Object.keys(a.entities),
|
||||
entity, oldentity, id, i;
|
||||
|
||||
if (entity && entity.type === 'way' &&
|
||||
oldentity && oldentity.type === 'way') {
|
||||
result = result
|
||||
.concat(_.difference(entity.nodes, oldentity.nodes))
|
||||
.concat(_.difference(oldentity.nodes, entity.nodes));
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
id = keys[i];
|
||||
entity = a.entities[id];
|
||||
oldentity = b.entities[id];
|
||||
if (entity !== oldentity) {
|
||||
|
||||
} else if (entity && entity.type === 'way') {
|
||||
result = result.concat(entity.nodes);
|
||||
// maybe adding affected children better belongs in renderer/map.js?
|
||||
if (entity && entity.type === 'way' &&
|
||||
oldentity && oldentity.type === 'way') {
|
||||
result = result
|
||||
.concat(_.difference(entity.nodes, oldentity.nodes))
|
||||
.concat(_.difference(oldentity.nodes, entity.nodes));
|
||||
|
||||
} else if (oldentity && oldentity.type === 'way') {
|
||||
result = result.concat(oldentity.nodes);
|
||||
} else if (entity && entity.type === 'way') {
|
||||
result = result.concat(entity.nodes);
|
||||
|
||||
} else if (oldentity && oldentity.type === 'way') {
|
||||
result = result.concat(oldentity.nodes);
|
||||
}
|
||||
|
||||
result.push(id);
|
||||
}
|
||||
|
||||
result.push(id);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
keys = Object.keys(graph.entities);
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
id = keys[i];
|
||||
entity = graph.entities[id];
|
||||
if (entity && !this.entities.hasOwnProperty(id)) {
|
||||
result.push(id);
|
||||
if (entity.type === 'way') result = result.concat(entity.nodes);
|
||||
}
|
||||
}
|
||||
|
||||
return result.sort();
|
||||
return _.unique(diff(this, graph).concat(diff(graph, this)).sort());
|
||||
},
|
||||
|
||||
modified: function() {
|
||||
|
||||
+19
-19
@@ -2,9 +2,9 @@ iD.modes.AddArea = function() {
|
||||
var mode = {
|
||||
id: 'add-area',
|
||||
button: 'area',
|
||||
title: 'Area',
|
||||
description: 'Add parks, buildings, lakes, or other areas to the map.',
|
||||
key: 'a'
|
||||
title: t('modes.add_area.title'),
|
||||
description: t('modes.add_area.description'),
|
||||
key: t('modes.add_area.key')
|
||||
};
|
||||
|
||||
var behavior,
|
||||
@@ -21,10 +21,10 @@ iD.modes.AddArea = function() {
|
||||
way = iD.Way({tags: defaultTags});
|
||||
|
||||
history.perform(
|
||||
iD.actions.AddNode(node),
|
||||
iD.actions.AddWay(way),
|
||||
iD.actions.AddWayNode(way.id, node.id),
|
||||
iD.actions.AddWayNode(way.id, node.id));
|
||||
iD.actions.AddEntity(node),
|
||||
iD.actions.AddEntity(way),
|
||||
iD.actions.AddVertex(way.id, node.id),
|
||||
iD.actions.AddVertex(way.id, node.id));
|
||||
|
||||
controller.enter(iD.modes.DrawArea(way.id, graph));
|
||||
}
|
||||
@@ -35,11 +35,11 @@ iD.modes.AddArea = function() {
|
||||
way = iD.Way({tags: defaultTags});
|
||||
|
||||
history.perform(
|
||||
iD.actions.AddNode(node),
|
||||
iD.actions.AddWay(way),
|
||||
iD.actions.AddWayNode(way.id, node.id),
|
||||
iD.actions.AddWayNode(way.id, node.id),
|
||||
iD.actions.AddWayNode(other.id, node.id, index));
|
||||
iD.actions.AddEntity(node),
|
||||
iD.actions.AddEntity(way),
|
||||
iD.actions.AddVertex(way.id, node.id),
|
||||
iD.actions.AddVertex(way.id, node.id),
|
||||
iD.actions.AddVertex(other.id, node.id, index));
|
||||
|
||||
controller.enter(iD.modes.DrawArea(way.id, graph));
|
||||
}
|
||||
@@ -49,9 +49,9 @@ iD.modes.AddArea = function() {
|
||||
way = iD.Way({tags: defaultTags});
|
||||
|
||||
history.perform(
|
||||
iD.actions.AddWay(way),
|
||||
iD.actions.AddWayNode(way.id, node.id),
|
||||
iD.actions.AddWayNode(way.id, node.id));
|
||||
iD.actions.AddEntity(way),
|
||||
iD.actions.AddVertex(way.id, node.id),
|
||||
iD.actions.AddVertex(way.id, node.id));
|
||||
|
||||
controller.enter(iD.modes.DrawArea(way.id, graph));
|
||||
}
|
||||
@@ -63,9 +63,9 @@ iD.modes.AddArea = function() {
|
||||
|
||||
history.perform(
|
||||
iD.actions.AddMidpoint(midpoint, node),
|
||||
iD.actions.AddWay(way),
|
||||
iD.actions.AddWayNode(way.id, node.id),
|
||||
iD.actions.AddWayNode(way.id, node.id));
|
||||
iD.actions.AddEntity(way),
|
||||
iD.actions.AddVertex(way.id, node.id),
|
||||
iD.actions.AddVertex(way.id, node.id));
|
||||
|
||||
controller.enter(iD.modes.DrawArea(way.id, graph));
|
||||
}
|
||||
@@ -77,7 +77,7 @@ iD.modes.AddArea = function() {
|
||||
.on('startFromMidpoint', startFromMidpoint);
|
||||
|
||||
mode.map.surface.call(behavior);
|
||||
mode.map.tail('Click on the map to start drawing an area, like a park, lake, or building.', true);
|
||||
mode.map.tail(t('modes.add_area.tail'));
|
||||
};
|
||||
|
||||
mode.exit = function() {
|
||||
|
||||
+15
-15
@@ -2,9 +2,9 @@ iD.modes.AddLine = function() {
|
||||
var mode = {
|
||||
id: 'add-line',
|
||||
button: 'line',
|
||||
title: 'Line',
|
||||
description: 'Lines can be highways, streets, pedestrian paths, or even canals.',
|
||||
key: 'l'
|
||||
title: t('modes.add_line.title'),
|
||||
description: t('modes.add_line.description'),
|
||||
key: t('modes.add_line.key')
|
||||
};
|
||||
|
||||
var behavior,
|
||||
@@ -21,9 +21,9 @@ iD.modes.AddLine = function() {
|
||||
way = iD.Way({tags: defaultTags});
|
||||
|
||||
history.perform(
|
||||
iD.actions.AddNode(node),
|
||||
iD.actions.AddWay(way),
|
||||
iD.actions.AddWayNode(way.id, node.id));
|
||||
iD.actions.AddEntity(node),
|
||||
iD.actions.AddEntity(way),
|
||||
iD.actions.AddVertex(way.id, node.id));
|
||||
|
||||
controller.enter(iD.modes.DrawLine(way.id, 'forward', graph));
|
||||
}
|
||||
@@ -34,10 +34,10 @@ iD.modes.AddLine = function() {
|
||||
way = iD.Way({tags: defaultTags});
|
||||
|
||||
history.perform(
|
||||
iD.actions.AddNode(node),
|
||||
iD.actions.AddWay(way),
|
||||
iD.actions.AddWayNode(way.id, node.id),
|
||||
iD.actions.AddWayNode(other.id, node.id, index));
|
||||
iD.actions.AddEntity(node),
|
||||
iD.actions.AddEntity(way),
|
||||
iD.actions.AddVertex(way.id, node.id),
|
||||
iD.actions.AddVertex(other.id, node.id, index));
|
||||
|
||||
controller.enter(iD.modes.DrawLine(way.id, 'forward', graph));
|
||||
}
|
||||
@@ -57,8 +57,8 @@ iD.modes.AddLine = function() {
|
||||
var way = iD.Way({tags: defaultTags});
|
||||
|
||||
history.perform(
|
||||
iD.actions.AddWay(way),
|
||||
iD.actions.AddWayNode(way.id, node.id));
|
||||
iD.actions.AddEntity(way),
|
||||
iD.actions.AddVertex(way.id, node.id));
|
||||
|
||||
controller.enter(iD.modes.DrawLine(way.id, 'forward', graph));
|
||||
}
|
||||
@@ -71,8 +71,8 @@ iD.modes.AddLine = function() {
|
||||
|
||||
history.perform(
|
||||
iD.actions.AddMidpoint(midpoint, node),
|
||||
iD.actions.AddWay(way),
|
||||
iD.actions.AddWayNode(way.id, node.id));
|
||||
iD.actions.AddEntity(way),
|
||||
iD.actions.AddVertex(way.id, node.id));
|
||||
|
||||
controller.enter(iD.modes.DrawLine(way.id, 'forward', graph));
|
||||
}
|
||||
@@ -84,7 +84,7 @@ iD.modes.AddLine = function() {
|
||||
.on('startFromMidpoint', startFromMidpoint);
|
||||
|
||||
mode.map.surface.call(behavior);
|
||||
mode.map.tail('Click on the map to start drawing an road, path, or route.', true);
|
||||
mode.map.tail(t('modes.add_line.tail'));
|
||||
};
|
||||
|
||||
mode.exit = function() {
|
||||
|
||||
+10
-11
@@ -1,29 +1,26 @@
|
||||
iD.modes.AddPoint = function() {
|
||||
var mode = {
|
||||
id: 'add-point',
|
||||
title: 'Point',
|
||||
description: 'Restaurants, monuments, and postal boxes are points.',
|
||||
key: 'p'
|
||||
title: t('modes.add_point.title'),
|
||||
description: t('modes.add_point.description'),
|
||||
key: t('modes.add_point.key')
|
||||
};
|
||||
|
||||
var behavior;
|
||||
|
||||
mode.enter = function() {
|
||||
var map = mode.map,
|
||||
surface = map.surface,
|
||||
history = mode.history,
|
||||
controller = mode.controller;
|
||||
|
||||
map.tail('Click on the map to add a point.', true);
|
||||
|
||||
function add(loc) {
|
||||
var node = iD.Node({loc: loc});
|
||||
|
||||
history.perform(
|
||||
iD.actions.AddNode(node),
|
||||
'Added a point.');
|
||||
iD.actions.AddEntity(node),
|
||||
t('operations.add.annotation.point'));
|
||||
|
||||
controller.enter(iD.modes.Select(node, true));
|
||||
controller.enter(iD.modes.Select([node.id], true));
|
||||
}
|
||||
|
||||
function addWay(way, loc, index) {
|
||||
@@ -44,8 +41,10 @@ iD.modes.AddPoint = function() {
|
||||
.on('clickNode', addNode)
|
||||
.on('clickMidpoint', addNode)
|
||||
.on('cancel', cancel)
|
||||
.on('finish', cancel)
|
||||
(surface);
|
||||
.on('finish', cancel);
|
||||
|
||||
mode.map.surface.call(behavior);
|
||||
mode.map.tail(t('modes.add_point.tail'));
|
||||
};
|
||||
|
||||
mode.exit = function() {
|
||||
|
||||
@@ -2,9 +2,9 @@ iD.modes.Browse = function() {
|
||||
var mode = {
|
||||
button: 'browse',
|
||||
id: 'browse',
|
||||
title: 'Browse',
|
||||
description: 'Pan and zoom the map.',
|
||||
key: 'b'
|
||||
title: t('modes.browse.title'),
|
||||
description: t('modes.browse.description'),
|
||||
key: t('modes.browse.key')
|
||||
};
|
||||
|
||||
var behaviors;
|
||||
@@ -24,7 +24,7 @@ iD.modes.Browse = function() {
|
||||
surface.on('click.browse', function () {
|
||||
var datum = d3.select(d3.event.target).datum();
|
||||
if (datum instanceof iD.Entity) {
|
||||
mode.controller.enter(iD.modes.Select(datum));
|
||||
mode.controller.enter(iD.modes.Select([datum.id]));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -11,8 +11,7 @@ iD.modes.DrawArea = function(wayId, baseGraph) {
|
||||
headId = way.nodes[way.nodes.length - 2],
|
||||
tailId = way.first();
|
||||
|
||||
behavior = iD.behavior.DrawWay(wayId, -1, mode, baseGraph)
|
||||
.annotation(way.isDegenerate() ? 'started an area' : 'continued an area');
|
||||
behavior = iD.behavior.DrawWay(wayId, -1, mode, baseGraph);
|
||||
|
||||
var addNode = behavior.addNode;
|
||||
|
||||
@@ -25,7 +24,7 @@ iD.modes.DrawArea = function(wayId, baseGraph) {
|
||||
};
|
||||
|
||||
mode.map.surface.call(behavior);
|
||||
mode.map.tail('Click to add points to your area. Click the first point to finish the area.', true);
|
||||
mode.map.tail(t('modes.draw_area.tail'));
|
||||
};
|
||||
|
||||
mode.exit = function() {
|
||||
|
||||
@@ -11,8 +11,7 @@ iD.modes.DrawLine = function(wayId, direction, baseGraph) {
|
||||
index = (direction === 'forward') ? undefined : 0,
|
||||
headId = (direction === 'forward') ? way.last() : way.first();
|
||||
|
||||
behavior = iD.behavior.DrawWay(wayId, index, mode, baseGraph)
|
||||
.annotation(way.isDegenerate() ? 'Started a line.' : 'Continued a line.');
|
||||
behavior = iD.behavior.DrawWay(wayId, index, mode, baseGraph);
|
||||
|
||||
var addNode = behavior.addNode;
|
||||
|
||||
@@ -25,9 +24,7 @@ iD.modes.DrawLine = function(wayId, direction, baseGraph) {
|
||||
};
|
||||
|
||||
mode.map.surface.call(behavior);
|
||||
mode.map.tail('Click to add more points to the line. ' +
|
||||
'Click on other lines to connect to them, and double-click to ' +
|
||||
'end the line.', true);
|
||||
mode.map.tail(t('modes.draw_line.tail'));
|
||||
};
|
||||
|
||||
mode.exit = function() {
|
||||
|
||||
@@ -11,14 +11,14 @@ iD.modes.MoveWay = function(wayId) {
|
||||
graph = history.graph(),
|
||||
selection = map.surface,
|
||||
controller = mode.controller,
|
||||
projection = map.projection;
|
||||
|
||||
var way = graph.entity(wayId),
|
||||
origin = d3.mouse(selection.node());
|
||||
projection = map.projection,
|
||||
way = graph.entity(wayId),
|
||||
origin = d3.mouse(selection.node()),
|
||||
annotation = t('operations.move.annotation.' + way.geometry(graph));
|
||||
|
||||
history.perform(
|
||||
iD.actions.Noop(),
|
||||
'Moved a way.');
|
||||
annotation);
|
||||
|
||||
function move() {
|
||||
var p = d3.mouse(selection.node()),
|
||||
@@ -29,17 +29,17 @@ iD.modes.MoveWay = function(wayId) {
|
||||
|
||||
history.replace(
|
||||
iD.actions.MoveWay(wayId, delta, projection),
|
||||
'Moved a way.');
|
||||
annotation);
|
||||
}
|
||||
|
||||
function finish() {
|
||||
d3.event.stopPropagation();
|
||||
controller.enter(iD.modes.Select(way, true));
|
||||
controller.enter(iD.modes.Select([way.id], true));
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
history.pop();
|
||||
controller.enter(iD.modes.Select(way, true));
|
||||
controller.enter(iD.modes.Select([way.id], true));
|
||||
}
|
||||
|
||||
function undone() {
|
||||
|
||||
+68
-55
@@ -1,8 +1,7 @@
|
||||
iD.modes.Select = function(entity, initial) {
|
||||
iD.modes.Select = function(selection, initial) {
|
||||
var mode = {
|
||||
id: 'select',
|
||||
button: 'browse',
|
||||
entity: entity
|
||||
button: 'browse'
|
||||
};
|
||||
|
||||
var inspector = iD.ui.inspector().initial(!!initial),
|
||||
@@ -11,18 +10,29 @@ iD.modes.Select = function(entity, initial) {
|
||||
radialMenu;
|
||||
|
||||
function changeTags(d, tags) {
|
||||
if (!_.isEqual(entity.tags, tags)) {
|
||||
if (!_.isEqual(singular().tags, tags)) {
|
||||
mode.history.perform(
|
||||
iD.actions.ChangeEntityTags(d.id, tags),
|
||||
'Changed tags.');
|
||||
iD.actions.ChangeTags(d.id, tags),
|
||||
t('operations.change_tags.annotation'));
|
||||
}
|
||||
}
|
||||
|
||||
function singular() {
|
||||
if (selection.length === 1) {
|
||||
return mode.map.history().graph().entity(selection[0]);
|
||||
}
|
||||
}
|
||||
|
||||
mode.selection = function() {
|
||||
return selection;
|
||||
};
|
||||
|
||||
mode.enter = function() {
|
||||
var map = mode.map,
|
||||
graph = map.history().graph(),
|
||||
history = map.history(),
|
||||
surface = mode.map.surface;
|
||||
graph = history.graph(),
|
||||
surface = map.surface,
|
||||
entity = singular();
|
||||
|
||||
inspector
|
||||
.graph(graph)
|
||||
@@ -38,7 +48,7 @@ iD.modes.Select = function(entity, initial) {
|
||||
});
|
||||
|
||||
var operations = d3.values(iD.operations)
|
||||
.map(function (o) { return o(entity.id, mode); })
|
||||
.map(function (o) { return o(selection, mode); })
|
||||
.filter(function (o) { return o.available(); });
|
||||
|
||||
operations.forEach(function(operation) {
|
||||
@@ -51,46 +61,51 @@ iD.modes.Select = function(entity, initial) {
|
||||
|
||||
var q = iD.util.stringQs(location.hash.substring(1));
|
||||
location.replace('#' + iD.util.qsString(_.assign(q, {
|
||||
id: entity.id
|
||||
id: selection.join(',')
|
||||
}), true));
|
||||
|
||||
d3.select('.inspector-wrap')
|
||||
.style('display', 'block')
|
||||
.style('opacity', 1)
|
||||
.datum(entity)
|
||||
.call(inspector);
|
||||
if (entity) {
|
||||
inspector.graph(graph);
|
||||
|
||||
if (d3.event) {
|
||||
// Pan the map if the clicked feature intersects with the position
|
||||
// of the inspector
|
||||
var inspector_size = d3.select('.inspector-wrap').size(),
|
||||
map_size = mode.map.size(),
|
||||
offset = 50,
|
||||
shift_left = d3.event.x - map_size[0] + inspector_size[0] + offset,
|
||||
center = (map_size[0] / 2) + shift_left + offset;
|
||||
d3.select('.inspector-wrap')
|
||||
.style('display', 'block')
|
||||
.style('opacity', 1)
|
||||
.datum(entity)
|
||||
.call(inspector);
|
||||
|
||||
if (shift_left > 0 && inspector_size[1] > d3.event.y) {
|
||||
mode.map.centerEase(mode.map.projection.invert([center, map_size[1]/2]));
|
||||
if (d3.event) {
|
||||
// Pan the map if the clicked feature intersects with the position
|
||||
// of the inspector
|
||||
var inspector_size = d3.select('.inspector-wrap').size(),
|
||||
map_size = mode.map.size(),
|
||||
offset = 50,
|
||||
shift_left = d3.event.x - map_size[0] + inspector_size[0] + offset,
|
||||
center = (map_size[0] / 2) + shift_left + offset;
|
||||
|
||||
if (shift_left > 0 && inspector_size[1] > d3.event.y) {
|
||||
mode.map.centerEase(mode.map.projection.invert([center, map_size[1]/2]));
|
||||
}
|
||||
}
|
||||
|
||||
inspector
|
||||
.on('changeTags', changeTags)
|
||||
.on('close', function() { mode.controller.exit(); });
|
||||
|
||||
history.on('change.select', function() {
|
||||
// Exit mode if selected entity gets undone
|
||||
var oldEntity = entity,
|
||||
newEntity = history.graph().entity(selection[0]);
|
||||
|
||||
if (!newEntity) {
|
||||
mode.controller.enter(iD.modes.Browse());
|
||||
} else if (!_.isEqual(oldEntity.tags, newEntity.tags)) {
|
||||
inspector.tags(newEntity.tags);
|
||||
}
|
||||
|
||||
surface.call(radialMenu.close);
|
||||
});
|
||||
}
|
||||
|
||||
inspector
|
||||
.on('changeTags', changeTags)
|
||||
.on('close', function() { mode.controller.exit(); });
|
||||
|
||||
history.on('change.select', function() {
|
||||
// Exit mode if selected entity gets undone
|
||||
var old = entity;
|
||||
entity = history.graph().entity(entity.id);
|
||||
if (!entity) {
|
||||
mode.controller.enter(iD.modes.Browse());
|
||||
} else if(!_.isEqual(entity.tags, old.tags)) {
|
||||
inspector.tags(entity.tags);
|
||||
}
|
||||
|
||||
surface.call(radialMenu.close);
|
||||
});
|
||||
|
||||
map.on('move.select', function() {
|
||||
surface.call(radialMenu.close);
|
||||
});
|
||||
@@ -98,25 +113,25 @@ iD.modes.Select = function(entity, initial) {
|
||||
function click() {
|
||||
var datum = d3.select(d3.event.target).datum();
|
||||
if (datum instanceof iD.Entity) {
|
||||
mode.controller.enter(iD.modes.Select(datum));
|
||||
mode.controller.enter(iD.modes.Select([datum.id]));
|
||||
} else {
|
||||
mode.controller.enter(iD.modes.Browse());
|
||||
}
|
||||
}
|
||||
|
||||
function dblclick() {
|
||||
var selection = d3.select(d3.event.target),
|
||||
datum = selection.datum();
|
||||
var target = d3.select(d3.event.target),
|
||||
datum = target.datum();
|
||||
|
||||
if (datum instanceof iD.Way && !selection.classed('fill')) {
|
||||
if (datum instanceof iD.Way && !target.classed('fill')) {
|
||||
var choice = iD.geo.chooseIndex(datum,
|
||||
d3.mouse(mode.map.surface.node()), mode.map),
|
||||
node = iD.Node({ loc: choice.loc });
|
||||
|
||||
history.perform(
|
||||
iD.actions.AddNode(node),
|
||||
iD.actions.AddWayNode(datum.id, node.id, choice.index),
|
||||
'Added a point to a road.');
|
||||
iD.actions.AddEntity(node),
|
||||
iD.actions.AddVertex(datum.id, node.id, choice.index),
|
||||
t('operations.add.annotation.vertex'));
|
||||
|
||||
d3.event.preventDefault();
|
||||
d3.event.stopPropagation();
|
||||
@@ -130,9 +145,7 @@ iD.modes.Select = function(entity, initial) {
|
||||
.call(keybinding);
|
||||
|
||||
surface.selectAll("*")
|
||||
.filter(function (d) {
|
||||
return d && entity && d.id === entity.id;
|
||||
})
|
||||
.filter(function (d) { return d && selection.indexOf(d.id) >= 0; })
|
||||
.classed('selected', true);
|
||||
|
||||
radialMenu = iD.ui.RadialMenu(operations);
|
||||
@@ -140,7 +153,7 @@ iD.modes.Select = function(entity, initial) {
|
||||
if (d3.event && !initial) {
|
||||
var loc = map.mouseCoordinates();
|
||||
|
||||
if (entity.type === 'node') {
|
||||
if (entity && entity.type === 'node') {
|
||||
loc = entity.loc;
|
||||
}
|
||||
|
||||
@@ -152,8 +165,8 @@ iD.modes.Select = function(entity, initial) {
|
||||
var surface = mode.map.surface,
|
||||
history = mode.history;
|
||||
|
||||
if (entity) {
|
||||
changeTags(entity, inspector.tags());
|
||||
if (singular()) {
|
||||
changeTags(singular(), inspector.tags());
|
||||
}
|
||||
|
||||
d3.select('.inspector-wrap')
|
||||
|
||||
@@ -1,28 +1,20 @@
|
||||
iD.operations.Circularize = function(entityId, mode) {
|
||||
var history = mode.map.history(),
|
||||
iD.operations.Circularize = function(selection, mode) {
|
||||
var entityId = selection[0],
|
||||
history = mode.map.history(),
|
||||
action = iD.actions.Circularize(entityId, mode.map);
|
||||
|
||||
var operation = function() {
|
||||
var graph = history.graph(),
|
||||
entity = graph.entity(entityId),
|
||||
geometry = entity.geometry(graph);
|
||||
annotation = t('operations.circularize.annotation.' + entity.geometry(graph));
|
||||
|
||||
if (geometry === 'line') {
|
||||
history.perform(
|
||||
action,
|
||||
'Made a line circular.');
|
||||
|
||||
} else if (geometry === 'area') {
|
||||
history.perform(
|
||||
action,
|
||||
'Made an area circular.');
|
||||
}
|
||||
history.perform(action, annotation);
|
||||
};
|
||||
|
||||
operation.available = function() {
|
||||
var graph = history.graph(),
|
||||
entity = graph.entity(entityId);
|
||||
return entity.geometry(graph) === 'area' || entity.geometry(graph) === 'line';
|
||||
return selection.length === 1 && entity.type === 'way';
|
||||
};
|
||||
|
||||
operation.enabled = function() {
|
||||
@@ -31,9 +23,9 @@ iD.operations.Circularize = function(entityId, mode) {
|
||||
};
|
||||
|
||||
operation.id = "circularize";
|
||||
operation.key = "O";
|
||||
operation.title = "Circularize";
|
||||
operation.description = "Make this round";
|
||||
operation.key = t('operations.circularize.key');
|
||||
operation.title = t('operations.circularize.title');
|
||||
operation.description = t('operations.circularize.description');
|
||||
|
||||
return operation;
|
||||
};
|
||||
|
||||
+13
-27
@@ -1,37 +1,23 @@
|
||||
iD.operations.Delete = function(entityId, mode) {
|
||||
var history = mode.map.history();
|
||||
iD.operations.Delete = function(selection, mode) {
|
||||
var entityId = selection[0],
|
||||
history = mode.map.history();
|
||||
|
||||
var operation = function() {
|
||||
var graph = history.graph(),
|
||||
entity = graph.entity(entityId),
|
||||
geometry = entity.geometry(graph);
|
||||
action = {way: iD.actions.DeleteWay, node: iD.actions.DeleteNode}[entity.type],
|
||||
annotation = t('operations.delete.annotation.' + entity.geometry(graph));
|
||||
|
||||
if (geometry === 'vertex') {
|
||||
history.perform(
|
||||
iD.actions.DeleteNode(entityId),
|
||||
'Deleted a vertex.');
|
||||
|
||||
} else if (geometry === 'point') {
|
||||
history.perform(
|
||||
iD.actions.DeleteNode(entityId),
|
||||
'Deleted a point.');
|
||||
|
||||
} else if (geometry === 'line') {
|
||||
history.perform(
|
||||
iD.actions.DeleteWay(entityId),
|
||||
'Deleted a line.');
|
||||
|
||||
} else if (geometry === 'area') {
|
||||
history.perform(
|
||||
iD.actions.DeleteWay(entityId),
|
||||
'Deleted an area.');
|
||||
}
|
||||
history.perform(
|
||||
action(entityId),
|
||||
annotation);
|
||||
};
|
||||
|
||||
operation.available = function() {
|
||||
var graph = history.graph(),
|
||||
entity = graph.entity(entityId);
|
||||
return _.contains(['vertex', 'point', 'line', 'area'], entity.geometry(graph));
|
||||
return selection.length === 1 &&
|
||||
(entity.type === 'way' || entity.type === 'node');
|
||||
};
|
||||
|
||||
operation.enabled = function() {
|
||||
@@ -39,9 +25,9 @@ iD.operations.Delete = function(entityId, mode) {
|
||||
};
|
||||
|
||||
operation.id = "delete";
|
||||
operation.key = "⌫";
|
||||
operation.title = "Delete";
|
||||
operation.description = "Remove this from the map.";
|
||||
operation.key = t('operations.delete.key');
|
||||
operation.title = t('operations.delete.title');
|
||||
operation.description = t('operations.delete.description');
|
||||
|
||||
return operation;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
iD.operations.Move = function(entityId, mode) {
|
||||
var history = mode.map.history();
|
||||
iD.operations.Move = function(selection, mode) {
|
||||
var entityId = selection[0],
|
||||
history = mode.map.history();
|
||||
|
||||
var operation = function() {
|
||||
mode.controller.enter(iD.modes.MoveWay(entityId));
|
||||
@@ -7,7 +8,8 @@ iD.operations.Move = function(entityId, mode) {
|
||||
|
||||
operation.available = function() {
|
||||
var graph = history.graph();
|
||||
return graph.entity(entityId).type === 'way';
|
||||
return selection.length === 1 &&
|
||||
graph.entity(entityId).type === 'way';
|
||||
};
|
||||
|
||||
operation.enabled = function() {
|
||||
@@ -15,9 +17,9 @@ iD.operations.Move = function(entityId, mode) {
|
||||
};
|
||||
|
||||
operation.id = "move";
|
||||
operation.key = "M";
|
||||
operation.title = "Move";
|
||||
operation.description = "Move this to a different location";
|
||||
operation.key = t('operations.move.key');
|
||||
operation.title = t('operations.move.title');
|
||||
operation.description = t('operations.move.description');
|
||||
|
||||
return operation;
|
||||
};
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
iD.operations.Reverse = function(entityId, mode) {
|
||||
var history = mode.map.history();
|
||||
iD.operations.Reverse = function(selection, mode) {
|
||||
var entityId = selection[0],
|
||||
history = mode.map.history();
|
||||
|
||||
var operation = function() {
|
||||
history.perform(
|
||||
iD.actions.ReverseWay(entityId),
|
||||
'Reversed a line.');
|
||||
t('operations.reverse.annotation'));
|
||||
};
|
||||
|
||||
operation.available = function() {
|
||||
var graph = history.graph(),
|
||||
entity = graph.entity(entityId);
|
||||
return entity.geometry(graph) === 'line';
|
||||
return selection.length === 1 &&
|
||||
entity.geometry(graph) === 'line';
|
||||
};
|
||||
|
||||
operation.enabled = function() {
|
||||
@@ -18,9 +20,9 @@ iD.operations.Reverse = function(entityId, mode) {
|
||||
};
|
||||
|
||||
operation.id = "reverse";
|
||||
operation.key = "V";
|
||||
operation.title = "Reverse";
|
||||
operation.description = "Make this way go in the opposite direction.";
|
||||
operation.key = t('operations.reverse.key');
|
||||
operation.title = t('operations.reverse.title');
|
||||
operation.description = t('operations.reverse.description');
|
||||
|
||||
return operation;
|
||||
};
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
iD.operations.Split = function(entityId, mode) {
|
||||
var history = mode.map.history(),
|
||||
iD.operations.Split = function(selection, mode) {
|
||||
var entityId = selection[0],
|
||||
history = mode.map.history(),
|
||||
action = iD.actions.SplitWay(entityId);
|
||||
|
||||
var operation = function() {
|
||||
history.perform(action, 'Split a way.');
|
||||
history.perform(action, t('operations.split.annotation'));
|
||||
};
|
||||
|
||||
operation.available = function() {
|
||||
var graph = history.graph(),
|
||||
entity = graph.entity(entityId);
|
||||
return entity.geometry(graph) === 'vertex';
|
||||
return selection.length === 1 &&
|
||||
entity.geometry(graph) === 'vertex';
|
||||
};
|
||||
|
||||
operation.enabled = function() {
|
||||
@@ -18,9 +20,9 @@ iD.operations.Split = function(entityId, mode) {
|
||||
};
|
||||
|
||||
operation.id = "split";
|
||||
operation.key = "X";
|
||||
operation.title = "Split";
|
||||
operation.description = "Split this into two ways at this point.";
|
||||
operation.key = t('operations.split.key');
|
||||
operation.title = t('operations.split.title');
|
||||
operation.description = t('operations.split.description');
|
||||
|
||||
return operation;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
iD.operations.Unjoin = function(entityId, mode) {
|
||||
var history = mode.map.history(),
|
||||
iD.operations.Unjoin = function(selection, mode) {
|
||||
var entityId = selection[0],
|
||||
history = mode.map.history(),
|
||||
action = iD.actions.UnjoinNode(entityId);
|
||||
|
||||
var operation = function() {
|
||||
@@ -9,7 +10,8 @@ iD.operations.Unjoin = function(entityId, mode) {
|
||||
operation.available = function() {
|
||||
var graph = history.graph(),
|
||||
entity = graph.entity(entityId);
|
||||
return entity.geometry(graph) === 'vertex';
|
||||
return selection.length === 1 &&
|
||||
entity.geometry(graph) === 'vertex';
|
||||
};
|
||||
|
||||
operation.enabled = function() {
|
||||
@@ -18,9 +20,9 @@ iD.operations.Unjoin = function(entityId, mode) {
|
||||
};
|
||||
|
||||
operation.id = "unjoin";
|
||||
operation.key = "⇧-J";
|
||||
operation.title = "Unjoin";
|
||||
operation.description = "Disconnect these ways from each other.";
|
||||
operation.key = t('operations.unjoin.key');
|
||||
operation.title = t('operations.unjoin.title');
|
||||
operation.description = t('operations.unjoin.description');
|
||||
|
||||
return operation;
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ iD.Background = function() {
|
||||
var deviceRatio = (window.devicePixelRatio &&
|
||||
window.devicePixelRatio === 2) ? 0.5 : 1;
|
||||
// tileSize = (deviceRatio === 0.5) ? [128,128] : [256,256];
|
||||
tileSize = [256, 256];
|
||||
var tileSize = [256, 256];
|
||||
|
||||
var tile = d3.geo.tile(),
|
||||
projection,
|
||||
|
||||
@@ -49,7 +49,7 @@ iD.Hash = function() {
|
||||
var entity = map.history().graph().entity(id);
|
||||
if (entity === undefined) return;
|
||||
else selectoff();
|
||||
controller.enter(iD.modes.Select(entity));
|
||||
controller.enter(iD.modes.Select([entity.id]));
|
||||
map.on('drawn.hash', null);
|
||||
});
|
||||
controller.on('enter.hash', function() {
|
||||
|
||||
@@ -136,7 +136,7 @@ iD.Map = function() {
|
||||
}
|
||||
|
||||
if (Math.log(d3.event.scale / Math.LN2 - 8) < minzoom + 1) {
|
||||
iD.flash()
|
||||
iD.ui.flash()
|
||||
.select('.content')
|
||||
.text('Cannot zoom out further in current mode.');
|
||||
return map.zoom(16);
|
||||
@@ -361,7 +361,7 @@ iD.Map = function() {
|
||||
};
|
||||
|
||||
var usedTails = {};
|
||||
map.tail = function (_, once) {
|
||||
map.tail = function (_) {
|
||||
if (!_ || usedTails[_] === undefined) {
|
||||
tail.text(_);
|
||||
usedTails[_] = true;
|
||||
|
||||
+24
-6
@@ -2,18 +2,36 @@ iD.svg.Labels = function(projection) {
|
||||
|
||||
// Replace with dict and iterate over entities tags instead?
|
||||
var label_stack = [
|
||||
['line', 'aeroway'],
|
||||
['line', 'highway'],
|
||||
['area', 'building', 'yes'],
|
||||
['area', 'leisure', 'park'],
|
||||
['line', 'railway'],
|
||||
['line', 'waterway'],
|
||||
['area', 'aeroway'],
|
||||
['area', 'amenity'],
|
||||
['area', 'building'],
|
||||
['area', 'historic'],
|
||||
['area', 'leisure'],
|
||||
['area', 'man_made'],
|
||||
['area', 'natural'],
|
||||
['area', 'shop'],
|
||||
['area', 'tourism'],
|
||||
['point', 'aeroway'],
|
||||
['point', 'amenity'],
|
||||
['point', 'shop']
|
||||
['point', 'building'],
|
||||
['point', 'historic'],
|
||||
['point', 'leisure'],
|
||||
['point', 'man_made'],
|
||||
['point', 'natural'],
|
||||
['point', 'shop'],
|
||||
['point', 'tourism'],
|
||||
['line', 'name'],
|
||||
['area', 'name'],
|
||||
['point', 'name']
|
||||
];
|
||||
|
||||
var default_size = 12;
|
||||
var font_sizes = label_stack.map(function(d) {
|
||||
var style = iD.util.getStyle(
|
||||
'text.' + d[0] + '.tag-' + d.slice(1).join('-'));
|
||||
var style = iD.util.getStyle('text.' + d[0] + '.tag-' + d[1]);
|
||||
var m = style && style.cssText.match("font-size: ([0-9]{1,2})px;");
|
||||
if (!m) return default_size;
|
||||
return parseInt(m[1], 10);
|
||||
@@ -210,7 +228,7 @@ iD.svg.Labels = function(projection) {
|
||||
if (hidePoints && entity.geometry(graph) === 'point') continue;
|
||||
for (k = 0; k < label_stack.length; k ++) {
|
||||
if (entity.geometry(graph) === label_stack[k][0] &&
|
||||
entity.tags[label_stack[k][1]] && !entity.tags[label_stack[k][2]]) {
|
||||
entity.tags[label_stack[k][1]]) {
|
||||
labelable[k].push(entity);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
iD.ui.presetsearch = function() {
|
||||
var event = d3.dispatch('choose'),
|
||||
entity,
|
||||
presetData;
|
||||
|
||||
function search(selection) {
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ iD.ui.save = function() {
|
||||
.on('fix', function(d) {
|
||||
map.extent(d.entity.extent(map.history().graph()));
|
||||
if (map.zoom() > 19) map.zoom(19);
|
||||
controller.enter(iD.modes.Select(d.entity));
|
||||
controller.enter(iD.modes.Select([d.entity.id]));
|
||||
modal.remove();
|
||||
})
|
||||
.on('save', commit));
|
||||
|
||||
@@ -21,22 +21,22 @@ iD.validate = function(changes, graph) {
|
||||
|
||||
if (change.geometry(graph) === 'point' && _.isEmpty(change.tags)) {
|
||||
warnings.push({
|
||||
message: 'Untagged point which is not part of a line or area',
|
||||
message: t('validations.untagged_point'),
|
||||
entity: change
|
||||
});
|
||||
}
|
||||
|
||||
if (change.geometry(graph) === 'line' && _.isEmpty(change.tags)) {
|
||||
warnings.push({ message: 'Untagged line', entity: change });
|
||||
warnings.push({ message: t('validations.untagged_line'), entity: change });
|
||||
}
|
||||
|
||||
if (change.geometry(graph) === 'area' && _.isEmpty(change.tags)) {
|
||||
warnings.push({ message: 'Untagged area', entity: change });
|
||||
warnings.push({ message: t('validations.untagged_area'), entity: change });
|
||||
}
|
||||
|
||||
if (change.geometry(graph) === 'line' && tagSuggestsArea(change)) {
|
||||
warnings.push({
|
||||
message: 'The tag ' + tagSuggestsArea(change) + ' suggests line should be area, but it is not and area',
|
||||
message: t('validations.tag_suggests_area', {tag: tagSuggestsArea(change)}),
|
||||
entity: change
|
||||
});
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
(function() {
|
||||
if (typeof module === "undefined") self.queue = queue;
|
||||
else module.exports = queue;
|
||||
|
||||
queue.version = "1.0.0";
|
||||
|
||||
function queue(parallelism) {
|
||||
var queue = {},
|
||||
active = 0, // number of in-flight deferrals
|
||||
remaining = 0, // number of deferrals remaining
|
||||
head, tail, // singly-linked list of deferrals
|
||||
error = null,
|
||||
results = [],
|
||||
await = noop,
|
||||
awaitAll;
|
||||
|
||||
if (arguments.length < 1) parallelism = Infinity;
|
||||
|
||||
queue.defer = function() {
|
||||
if (!error) {
|
||||
var node = arguments;
|
||||
node.index = results.push(undefined) - 1;
|
||||
if (tail) tail.next = node, tail = tail.next;
|
||||
else head = tail = node;
|
||||
++remaining;
|
||||
pop();
|
||||
}
|
||||
return queue;
|
||||
};
|
||||
|
||||
queue.await = function(f) {
|
||||
await = f;
|
||||
awaitAll = false;
|
||||
if (!remaining) notify();
|
||||
return queue;
|
||||
};
|
||||
|
||||
queue.awaitAll = function(f) {
|
||||
await = f;
|
||||
awaitAll = true;
|
||||
if (!remaining) notify();
|
||||
return queue;
|
||||
};
|
||||
|
||||
function pop() {
|
||||
if (head && active < parallelism) {
|
||||
var node = head,
|
||||
f = node[0],
|
||||
a = Array.prototype.slice.call(node, 1),
|
||||
i = node.index;
|
||||
if (head === tail) head = tail = null;
|
||||
else head = head.next;
|
||||
++active;
|
||||
a.push(function(e, r) {
|
||||
--active;
|
||||
if (error != null) return;
|
||||
if (e != null) {
|
||||
// clearing remaining cancels subsequent callbacks
|
||||
// clearing head stops queued tasks from being executed
|
||||
// setting error ignores subsequent calls to defer
|
||||
error = e;
|
||||
remaining = results = head = tail = null;
|
||||
notify();
|
||||
} else {
|
||||
results[i] = r;
|
||||
if (--remaining) pop();
|
||||
else notify();
|
||||
}
|
||||
});
|
||||
f.apply(null, a);
|
||||
}
|
||||
}
|
||||
|
||||
function notify() {
|
||||
if (error != null) await(error);
|
||||
else if (awaitAll) await(null, results);
|
||||
else await.apply(null, [null].concat(results));
|
||||
}
|
||||
|
||||
return queue;
|
||||
}
|
||||
|
||||
function noop() {}
|
||||
})();
|
||||
+115
-5
@@ -1,8 +1,118 @@
|
||||
locale.en = {
|
||||
"browse": "Browse",
|
||||
"point": "Point",
|
||||
"line": "Line",
|
||||
"area": "Area",
|
||||
modes: {
|
||||
add_area: {
|
||||
title: "Area",
|
||||
description: "Add parks, buildings, lakes, or other areas to the map.",
|
||||
tail: "Click on the map to start drawing an area, like a park, lake, or building.",
|
||||
key: "A"
|
||||
},
|
||||
add_line: {
|
||||
title: "Line",
|
||||
description: "Lines can be highways, streets, pedestrian paths, or even canals.",
|
||||
tail: "Click on the map to start drawing an road, path, or route.",
|
||||
key: "L"
|
||||
},
|
||||
add_point: {
|
||||
title: "Point",
|
||||
description: "Restaurants, monuments, and postal boxes are points.",
|
||||
tail: "Click on the map to add a point.",
|
||||
key: "P"
|
||||
},
|
||||
browse: {
|
||||
title: "Browse",
|
||||
description: "Pan and zoom the map.",
|
||||
key: "B"
|
||||
},
|
||||
draw_area: {
|
||||
tail: "Click to add points to your area. Click the first point to finish the area."
|
||||
},
|
||||
draw_line: {
|
||||
tail: "Click to add more points to the line. Click on other lines to connect to them, and double-click to end the line."
|
||||
}
|
||||
},
|
||||
|
||||
operations: {
|
||||
add: {
|
||||
annotation: {
|
||||
point: "Added a point.",
|
||||
vertex: "Added a node to a way."
|
||||
}
|
||||
},
|
||||
start: {
|
||||
annotation: {
|
||||
line: "Started a line.",
|
||||
area: "Started an area."
|
||||
}
|
||||
},
|
||||
continue: {
|
||||
annotation: {
|
||||
line: "Continued a line.",
|
||||
area: "Continued an area."
|
||||
}
|
||||
},
|
||||
cancel_draw: {
|
||||
annotation: "Cancelled drawing."
|
||||
},
|
||||
change_tags: {
|
||||
annotation: "Changed tags."
|
||||
},
|
||||
circularize: {
|
||||
title: "Circularize",
|
||||
description: "Make this round.",
|
||||
key: "O",
|
||||
annotation: {
|
||||
line: "Made a line circular.",
|
||||
area: "Made an area circular."
|
||||
}
|
||||
},
|
||||
delete: {
|
||||
title: "Delete",
|
||||
description: "Remove this from the map.",
|
||||
key: "⌫",
|
||||
annotation: {
|
||||
point: "Deleted a point.",
|
||||
vertex: "Deleted a node from a way.",
|
||||
line: "Deleted a line.",
|
||||
area: "Deleted an area."
|
||||
}
|
||||
},
|
||||
move: {
|
||||
title: "Move",
|
||||
description: "Move this to a different location.",
|
||||
key: "M",
|
||||
annotation: {
|
||||
point: "Moved a point.",
|
||||
vertex: "Moved a node in a way.",
|
||||
line: "Moved a line.",
|
||||
area: "Moved an area."
|
||||
}
|
||||
},
|
||||
reverse: {
|
||||
title: "Reverse",
|
||||
description: "Make this line go in the opposite direction.",
|
||||
key: "V",
|
||||
annotation: "Reversed a line."
|
||||
},
|
||||
split: {
|
||||
title: "Split",
|
||||
description: "Split this into two ways at this point.",
|
||||
key: "X",
|
||||
annotation: "Split a way."
|
||||
},
|
||||
unjoin: {
|
||||
title: "Unjoin",
|
||||
description: "Disconnect these ways from each other.",
|
||||
key: "⇧-J",
|
||||
annotation: "Unjoined ways."
|
||||
}
|
||||
},
|
||||
|
||||
validations: {
|
||||
untagged_point: "Untagged point which is not part of a line or area",
|
||||
untagged_line: "Untagged line",
|
||||
untagged_area: "Untagged area",
|
||||
tag_suggests_area: "The tag {tag} suggests line should be area, but it is not an area"
|
||||
},
|
||||
|
||||
"save": "Save",
|
||||
"save_help": "Save changes to OpenStreetMap, making them visible to other users",
|
||||
@@ -37,4 +147,4 @@ locale.en = {
|
||||
|
||||
"layers": "Layers",
|
||||
"percent_opacity": "{opacity}% opacity"
|
||||
}
|
||||
};
|
||||
|
||||
+6
-2
@@ -1,8 +1,12 @@
|
||||
var locale = { current: 'en' };
|
||||
|
||||
function t(s, o) {
|
||||
if (locale[locale.current][s] !== undefined) {
|
||||
var rep = locale[locale.current][s];
|
||||
var path = s.split(".").reverse(),
|
||||
rep = locale[locale.current];
|
||||
|
||||
while (rep !== undefined && path.length) rep = rep[path.pop()];
|
||||
|
||||
if (rep !== undefined) {
|
||||
if (o) for (var k in o) rep = rep.replace('{' + k + '}', o[k]);
|
||||
return rep;
|
||||
} else {
|
||||
|
||||
+6
-9
@@ -73,10 +73,9 @@
|
||||
|
||||
<script src='../js/id/actions.js'></script>
|
||||
<script src="../js/id/actions/add_midpoint.js"></script>
|
||||
<script src='../js/id/actions/add_node.js'></script>
|
||||
<script src='../js/id/actions/add_way.js'></script>
|
||||
<script src='../js/id/actions/add_way_node.js'></script>
|
||||
<script src='../js/id/actions/change_entity_tags.js'></script>
|
||||
<script src='../js/id/actions/add_entity.js'></script>
|
||||
<script src='../js/id/actions/add_vertex.js'></script>
|
||||
<script src='../js/id/actions/change_tags.js'></script>
|
||||
<script src='../js/id/actions/circularize.js'></script>
|
||||
<script src="../js/id/actions/delete_node.js"></script>
|
||||
<script src="../js/id/actions/delete_way.js"></script>
|
||||
@@ -114,8 +113,6 @@
|
||||
<script src='../js/id/operations/split.js'></script>
|
||||
<script src='../js/id/operations/unjoin.js'></script>
|
||||
|
||||
<script src='../js/id/controller/controller.js'></script>
|
||||
|
||||
<script src='../js/id/graph/entity.js'></script>
|
||||
<script src='../js/id/graph/graph.js'></script>
|
||||
<script src='../js/id/graph/history.js'></script>
|
||||
@@ -124,6 +121,7 @@
|
||||
<script src='../js/id/graph/way.js'></script>
|
||||
|
||||
<script src='../js/id/connection.js'></script>
|
||||
<script src='../js/id/controller.js'></script>
|
||||
|
||||
<script src='../locale/locale.js'></script>
|
||||
<script src='../locale/en.js'></script>
|
||||
@@ -143,9 +141,8 @@
|
||||
<script src="spec/lib/d3.keybinding.js"></script>
|
||||
|
||||
<script src="spec/actions/add_midpoint.js"></script>
|
||||
<script src="spec/actions/add_node.js"></script>
|
||||
<script src="spec/actions/add_way.js"></script>
|
||||
<script src="spec/actions/change_entity_tags.js"></script>
|
||||
<script src="spec/actions/add_entity.js"></script>
|
||||
<script src="spec/actions/change_tags.js"></script>
|
||||
<script src="spec/actions/delete_node.js"></script>
|
||||
<script src="spec/actions/delete_way.js"></script>
|
||||
<script src="spec/actions/move_node.js"></script>
|
||||
|
||||
@@ -33,9 +33,8 @@
|
||||
<script src="spec/lib/d3.keybinding.js"></script>
|
||||
|
||||
<script src="spec/actions/add_midpoint.js"></script>
|
||||
<script src="spec/actions/add_node.js"></script>
|
||||
<script src="spec/actions/add_way.js"></script>
|
||||
<script src="spec/actions/change_entity_tags.js"></script>
|
||||
<script src="spec/actions/add_entity.js"></script>
|
||||
<script src="spec/actions/change_tags.js"></script>
|
||||
<script src="spec/actions/delete_node.js"></script>
|
||||
<script src="spec/actions/delete_way.js"></script>
|
||||
<script src="spec/actions/move_node.js"></script>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
describe("iD.actions.AddEntity", function () {
|
||||
it("adds an entity to the graph", function () {
|
||||
var entity = iD.Entity(),
|
||||
graph = iD.actions.AddEntity(entity)(iD.Graph());
|
||||
expect(graph.entity(entity.id)).to.equal(entity);
|
||||
});
|
||||
});
|
||||
@@ -1,7 +0,0 @@
|
||||
describe("iD.actions.AddNode", function () {
|
||||
it("adds a node to the graph", function () {
|
||||
var node = iD.Node(),
|
||||
graph = iD.actions.AddNode(node)(iD.Graph());
|
||||
expect(graph.entity(node.id)).to.equal(node);
|
||||
});
|
||||
});
|
||||
@@ -1,7 +0,0 @@
|
||||
describe("iD.actions.AddWay", function () {
|
||||
it("adds a way to the graph", function () {
|
||||
var way = iD.Way(),
|
||||
graph = iD.actions.AddWay(way)(iD.Graph());
|
||||
expect(graph.entity(way.id)).to.equal(way);
|
||||
});
|
||||
});
|
||||
@@ -1,8 +1,8 @@
|
||||
describe("iD.actions.ChangeEntityTags", function () {
|
||||
describe("iD.actions.ChangeTags", function () {
|
||||
it("changes an entity's tags", function () {
|
||||
var entity = iD.Entity(),
|
||||
tags = {foo: 'bar'},
|
||||
graph = iD.actions.ChangeEntityTags(entity.id, tags)(iD.Graph([entity]));
|
||||
graph = iD.actions.ChangeTags(entity.id, tags)(iD.Graph([entity]));
|
||||
expect(graph.entity(entity.id).tags).to.eql(tags);
|
||||
});
|
||||
});
|
||||
@@ -345,12 +345,42 @@ describe('iD.Graph', function() {
|
||||
expect(graph2.difference(graph1)).to.eql([created.id, updated.id, deleted.id]);
|
||||
});
|
||||
|
||||
it("includes created entities that were subsequently deleted", function () {
|
||||
|
||||
it("includes created entities, and reverse", function () {
|
||||
var node = iD.Node(),
|
||||
graph1 = iD.Graph([node]),
|
||||
graph2 = graph1.remove(node);
|
||||
graph1 = iD.Graph(),
|
||||
graph2 = graph1.replace(node);
|
||||
expect(graph2.difference(graph1)).to.eql([node.id]);
|
||||
expect(graph1.difference(graph2)).to.eql([node.id]);
|
||||
});
|
||||
|
||||
it("includes entities changed from base, and reverse", function () {
|
||||
var node = iD.Node(),
|
||||
graph1 = iD.Graph(node),
|
||||
graph2 = graph1.replace(node.update());
|
||||
expect(graph2.difference(graph1)).to.eql([node.id]);
|
||||
expect(graph1.difference(graph2)).to.eql([node.id]);
|
||||
});
|
||||
|
||||
it("includes already changed entities that were updated, and reverse", function () {
|
||||
var node = iD.Node(),
|
||||
graph1 = iD.Graph().replace(node),
|
||||
graph2 = graph1.replace(node.update());
|
||||
expect(graph2.difference(graph1)).to.eql([node.id]);
|
||||
expect(graph1.difference(graph2)).to.eql([node.id]);
|
||||
});
|
||||
|
||||
it("includes affected child nodes", function () {
|
||||
var n = iD.Node({id: 'n'}),
|
||||
n2 = iD.Node({id: 'n2'}),
|
||||
w1 = iD.Way({id: 'w1', nodes: ['n']}),
|
||||
w1_ = iD.Way({id: 'w1', nodes: ['n', 'n2']}),
|
||||
graph1 = iD.Graph([n, n2, w1]),
|
||||
graph2 = graph1.replace(w1_);
|
||||
expect(graph2.difference(graph1)).to.eql(['n2', 'w1']);
|
||||
expect(graph1.difference(graph2)).to.eql(['n2', 'w1']);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("#modified", function () {
|
||||
|
||||
@@ -4,7 +4,8 @@ describe("iD.modes.AddPoint", function () {
|
||||
beforeEach(function () {
|
||||
container = d3.select('body').append('div');
|
||||
history = iD.History();
|
||||
map = iD.Map().history(history);
|
||||
var connection = iD.Connection();
|
||||
map = iD.Map().history(history).connection(connection);
|
||||
controller = iD.Controller(map, history);
|
||||
|
||||
container.call(map);
|
||||
@@ -28,7 +29,7 @@ describe("iD.modes.AddPoint", function () {
|
||||
it("selects the node", function () {
|
||||
happen.click(map.surface.node(), {});
|
||||
expect(controller.mode.id).to.equal('select');
|
||||
expect(controller.mode.entity).to.equal(history.changes().created[0]);
|
||||
expect(controller.mode.selection()).to.eql([history.changes().created[0].id]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user