From f85b8241a7648e8b08a2cfae9fb00b75ed0d5850 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Sun, 28 Oct 2012 12:25:38 -0400 Subject: [PATCH] Fix non-loaded way behavior --- NOTES.md | 19 +++++++++++++++++++ css/map.css | 2 ++ js/iD/Connection.js | 16 +++------------- js/iD/Way.js | 1 + 4 files changed, 25 insertions(+), 13 deletions(-) create mode 100644 NOTES.md diff --git a/NOTES.md b/NOTES.md new file mode 100644 index 000000000..08306ab32 --- /dev/null +++ b/NOTES.md @@ -0,0 +1,19 @@ +## Actions + +Actions are operations on OSM data like adding nodes, moving ways, +and so on. They are initiated by controller states, like +`iD.controller.ControllerState` initiates a `CreatePOIAction` and +adds it to the undo stack. + +## Entities + +`iD.Entity` is the door from pure objects like `iD.Node` into a hierarchy +of objects - it provides handling of parents, children, and so on. + +## loaded + +The `.loaded` member of nodes and ways is because of [relations](http://wiki.openstreetmap.org/wiki/Relation), +which refer to elements, so we want to have real references of those +elements, but we don't have the data yet. Thus when the Connection +encounters a new object but has a non-loaded representation of it, +the non-loaded version is replaced. diff --git a/css/map.css b/css/map.css index b1fed127b..563ed6fea 100644 --- a/css/map.css +++ b/css/map.css @@ -102,12 +102,14 @@ circle.handle { } .stroke.highway-footway, +.stroke.highway-cycleway, .stroke.highway-steps { stroke: #ff6257; stroke-width: 3; stroke-dasharray: 6, 6; } .casing.highway-footway, +.casing.highway-cycleway, .casing.highway-steps { stroke-width: 3; stroke: #fff; diff --git a/js/iD/Connection.js b/js/iD/Connection.js index 7783998dd..cebd049f9 100755 --- a/js/iD/Connection.js +++ b/js/iD/Connection.js @@ -20,20 +20,10 @@ iD.Connection = function(apiURL) { function assign(obj) { // summary: Save an entity to the data store. - if (obj.entityType === 'node') { // never reassign nodes - if (!entities[obj.id]) entities[obj.id] = obj; - } else if (obj.entityType === 'way') { - if (!entities[obj.id]) { - entities[obj.id] = obj; - } else { - /* - for (var n = 0; n < obj.nodes.length; n++) { - entities[obj.id].addNode(obj.nodes[n]); - } - */ - } - } else if (obj.entityType === 'relation') { + if (obj.entityType === 'relation') { if (!relations[obj.id]) relations[obj.id] = obj; + } else if (!entities[obj.id] || !entities[obj.id].loaded) { + entities[obj.id] = obj; } } diff --git a/js/iD/Way.js b/js/iD/Way.js index 96f7c1340..3259d3529 100644 --- a/js/iD/Way.js +++ b/js/iD/Way.js @@ -29,6 +29,7 @@ iD.Way = function(id, nodes, tags, loaded) { }; iD.Way.prototype = { + addNode: function(node) { node.entity.addParent(this); this.nodes.push(node);