Use isPoi for determining whether points are pois or not

This commit is contained in:
Tom MacWright
2013-01-23 19:14:54 -05:00
parent 9041e6470f
commit 32ea30c3fb
16 changed files with 55 additions and 33 deletions
+1 -2
View File
@@ -22,7 +22,6 @@ iD.actions.DeleteWay = function(wayId) {
if (!node.hasInterestingTags()) {
graph = graph.remove(node);
} else {
graph = graph.replace(node.update({_poi: true}));
}
}
});
@@ -32,7 +31,7 @@ iD.actions.DeleteWay = function(wayId) {
action.enabled = function(graph) {
return true;
}
};
return action;
};
+12 -4
View File
@@ -154,11 +154,19 @@ iD.Connection = function() {
}
var g = iD.Graph(entities);
var i;
for (var i in wparentsOf) {
if (entities[i]) g.transient(entities[i],
'parentWays', d3.functor(wparentsOf[i]));
if (entities[i]) entities[i].update({ _poi: true });
for (i in wparentsOf) {
if (entities[i]) {
g.transient(entities[i], 'parentWays', d3.functor(wparentsOf[i]));
g.transient(entities[i], 'poi', d3.functor(true));
}
}
for (i in g.entities) {
if (entities[i].type === 'node') {
g.transient(entities[i], 'poi', d3.functor(false));
}
}
for (i in rparentsOf) {
+6 -2
View File
@@ -31,7 +31,7 @@ iD.Graph.prototype = {
transients = this.transients[id] ||
(this.transients[id] = {});
if (transients[key]) {
if (transients[key] !== undefined) {
return transients[key];
}
@@ -60,6 +60,10 @@ iD.Graph.prototype = {
return this._parentWays[entity.id] || [];
},
isPoi: function(entity) {
return this.parentWays(entity).length === 0;
},
parentRelations: function(entity) {
var ent, id, parents;
@@ -141,7 +145,7 @@ iD.Graph.prototype = {
oldentity && oldentity.type === 'way') {
result = result
.concat(_.difference(entity.nodes, oldentity.nodes))
.concat(_.difference(oldentity.nodes, entity.nodes))
.concat(_.difference(oldentity.nodes, entity.nodes));
} else if (entity && entity.type === 'way') {
result = result.concat(entity.nodes);
+2 -2
View File
@@ -15,8 +15,8 @@ _.extend(iD.Node.prototype, {
return iD.geo.Extent(this.loc);
},
geometry: function() {
return this._poi ? 'point' : 'vertex';
geometry: function(graph) {
return graph.isPoi(this) ? 'point' : 'vertex';
},
move: function(loc) {
+5 -5
View File
@@ -1,4 +1,4 @@
iD.validate = function(changes) {
iD.validate = function(changes, graph) {
var warnings = [], change;
// https://github.com/openstreetmap/josm/blob/mirror/src/org/
@@ -19,22 +19,22 @@ iD.validate = function(changes) {
for (var i = 0; i < changes.created.length; i++) {
change = changes.created[i];
if (change.geometry() === 'point' && _.isEmpty(change.tags)) {
if (change.geometry(graph) === 'point' && _.isEmpty(change.tags)) {
warnings.push({
message: 'Untagged point which is not part of a line or area',
entity: change
});
}
if (change.geometry() === 'line' && _.isEmpty(change.tags)) {
if (change.geometry(graph) === 'line' && _.isEmpty(change.tags)) {
warnings.push({ message: 'Untagged line', entity: change });
}
if (change.geometry() === 'area' && _.isEmpty(change.tags)) {
if (change.geometry(graph) === 'area' && _.isEmpty(change.tags)) {
warnings.push({ message: 'Untagged area', entity: change });
}
if (change.geometry() === 'line' && tagSuggestsArea(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',
entity: change
+3 -2
View File
@@ -10,6 +10,7 @@ iD.modes.AddLine = function() {
mode.enter = function() {
var map = mode.map,
graph = map.history().graph(),
node,
history = mode.history,
controller = mode.controller;
@@ -25,8 +26,8 @@ iD.modes.AddLine = function() {
if (datum.type === 'node') {
// continue an existing way
var id = datum.id;
var parents = history.graph().parentWays(datum);
var isLine = parents.length && parents[0].geometry() === 'line';
var parents = history.graph(graph).parentWays(datum);
var isLine = parents.length && parents[0].geometry(graph) === 'line';
if (isLine && parents[0].nodes[0] === id ) {
way = parents[0];
direction = 'backward';
+1 -1
View File
@@ -15,7 +15,7 @@ iD.modes.AddPoint = function() {
map.tail('Click on the map to add a point.');
map.surface.on('click.addpoint', function() {
var node = iD.Node({loc: map.mouseCoordinates(), _poi: true});
var node = iD.Node({loc: map.mouseCoordinates()});
history.perform(
iD.actions.AddNode(node),
+6 -2
View File
@@ -32,7 +32,11 @@ iD.modes.Select = function(entity, initial) {
}
mode.enter = function() {
var surface = mode.map.surface;
var map = mode.map,
graph = map.history().graph(),
surface = mode.map.surface;
inspector.graph(graph);
behaviors = [
iD.behavior.Hover(),
@@ -116,7 +120,7 @@ iD.modes.Select = function(entity, initial) {
function dblclick() {
var datum = d3.select(d3.event.target).datum();
if (datum instanceof iD.Entity &&
(datum.geometry() === 'area' || datum.geometry() === 'line')) {
(datum.geometry(graph) === 'area' || datum.geometry(graph) === 'line')) {
var choice = iD.geo.chooseIndex(datum,
d3.mouse(mode.map.surface.node()), mode.map),
node = iD.Node({ loc: choice.loc });
+1 -1
View File
@@ -31,7 +31,7 @@ iD.svg.Areas = function(projection) {
for (var i = 0; i < entities.length; i++) {
var entity = entities[i];
if (entity.geometry() === 'area') {
if (entity.geometry(graph) === 'area') {
areas.push(entity);
}
}
+1 -1
View File
@@ -66,7 +66,7 @@ iD.svg.Lines = function(projection) {
for (var i = 0; i < entities.length; i++) {
var entity = entities[i];
if (entity.geometry() === 'line') {
if (entity.geometry(graph) === 'line') {
lines.push(entity);
}
}
+2 -2
View File
@@ -4,7 +4,7 @@ iD.svg.Multipolygons = function(projection) {
for (var i = 0; i < entities.length; i++) {
var entity = entities[i];
if (entity.geometry() === 'relation' && entity.tags.type === 'multipolygon') {
if (entity.geometry(graph) === 'relation' && entity.tags.type === 'multipolygon') {
multipolygons.push(entity);
}
}
@@ -17,7 +17,7 @@ iD.svg.Multipolygons = function(projection) {
}
var multipolygon = entity.multipolygon(graph);
if (entity.members.length == 0 || !multipolygon) {
if (entity.members.length === 0 || !multipolygon) {
return (lineStrings[entity.id] = null);
}
+1 -1
View File
@@ -15,7 +15,7 @@ iD.svg.Points = function(projection) {
for (var i = 0; i < entities.length; i++) {
var entity = entities[i];
if (entity.geometry() === 'point') {
if (entity.geometry(graph) === 'point') {
points.push(entity);
}
}
+1 -1
View File
@@ -4,7 +4,7 @@ iD.svg.Vertices = function(projection) {
for (var i = 0; i < entities.length; i++) {
var entity = entities[i];
if (entity.geometry() === 'vertex') {
if (entity.geometry(graph) === 'vertex') {
vertices.push(entity);
}
}
+2 -2
View File
@@ -1,4 +1,4 @@
iD.ui.commit = function() {
iD.ui.commit = function(map) {
var event = d3.dispatch('cancel', 'save', 'fix');
function zipSame(d) {
@@ -89,7 +89,7 @@ iD.ui.commit = function() {
cancelbutton.append('span').attr('class','label').text('Cancel');
var warnings = body.selectAll('div.warning-section')
.data(iD.validate(changes))
.data(iD.validate(changes, map.history().graph()))
.enter()
.append('div').attr('class', 'modal-section warning-section fillL');
+10 -4
View File
@@ -3,6 +3,7 @@ iD.ui.inspector = function() {
'update', 'remove', 'close', 'splitWay', 'unjoin'),
taginfo = iD.taginfo(),
initial = false,
graph,
tagList;
function inspector(selection) {
@@ -50,7 +51,7 @@ iD.ui.inspector = function() {
var h2 = selection.append('h2');
h2.append('span')
.attr('class', 'icon big icon-pre-text big-' + entity.geometry());
.attr('class', 'icon big icon-pre-text big-' + entity.geometry(graph));
h2.append('span')
.text(entity.friendlyName());
@@ -90,7 +91,7 @@ iD.ui.inspector = function() {
.on('click', function() { event.reverseWay(entity); });
}
if (entity.geometry() === 'vertex') {
if (entity.geometry(graph) === 'vertex') {
minorButtons.append('a')
.attr('href', '#')
.text('Split Way')
@@ -155,7 +156,7 @@ iD.ui.inspector = function() {
.attr('class', 'tag-help minor')
.on('click', function(d) {
var params = _.extend({}, d, {
geometry: entity.geometry()
geometry: entity.geometry(graph)
});
if (d.key && d.value) {
taginfo.docs(params, function(err, docs) {
@@ -223,7 +224,7 @@ iD.ui.inspector = function() {
function bindTypeahead() {
var entity = tagList.datum(),
geometry = entity.geometry(),
geometry = entity.geometry(graph),
row = d3.select(this),
key = row.selectAll('.key'),
value = row.selectAll('.value');
@@ -304,5 +305,10 @@ iD.ui.inspector = function() {
return inspector;
};
inspector.graph = function(_) {
graph = _;
return inspector;
};
return d3.rebind(inspector, event, 'on');
};
+1 -1
View File
@@ -51,7 +51,7 @@ iD.ui.save = function() {
modal.select('.content')
.classed('commit-modal', true)
.datum(changes)
.call(iD.ui.commit()
.call(iD.ui.commit(map)
.on('cancel', function() {
modal.remove();
})