Merge branch 'master' of github.com:openstreetmap/iD

This commit is contained in:
Bryan Housel
2014-05-28 13:21:26 -04:00
7 changed files with 44 additions and 7 deletions

View File

@@ -1542,6 +1542,11 @@ input[type=number] {
height: 300px;
}
.form-field-restrictions svg {
width: 100%;
height: 100%;
}
.form-field-restrictions .restriction-help {
z-index: 1;
position: absolute;

View File

@@ -112,6 +112,10 @@ iD.Entity.prototype = {
});
},
isHighwayIntersection: function() {
return false;
},
deprecatedTags: function() {
var tags = _.pairs(this.tags);
var deprecated = {};

View File

@@ -37,6 +37,14 @@ _.extend(iD.Node.prototype, {
});
},
isHighwayIntersection: function(resolver) {
return resolver.transient(this, 'isHighwayIntersection', function() {
return resolver.parentWays(this).filter(function(parent) {
return parent.tags.highway && parent.geometry(resolver) === 'line';
}).length > 1;
});
},
asJXON: function(changeset_id) {
var r = {
node: {

View File

@@ -35,7 +35,7 @@ iD.ui.Inspector = function(context) {
entity = context.entity(entityID),
showEditor = state === 'hover' ||
entity.isUsed(graph) ||
(entity.type === 'node' && entity.isIntersection(graph));
entity.isHighwayIntersection(graph);
if (showEditor) {
$wrap.style('right', '0%');

View File

@@ -72,7 +72,7 @@ iD.ui.preset = function(context) {
}
});
if (geometry === 'vertex' && entity.isIntersection(context.graph())) {
if (entity.isHighwayIntersection(context.graph())) {
fields.push(UIField(context.presets().field('restrictions'), entity, true));
}

View File

@@ -119,7 +119,9 @@ iD.ui.preset.restrictions = function(field, context) {
}
function render() {
restrictions(selection);
if (context.hasEntity(vertexID)) {
restrictions(selection);
}
}
}

View File

@@ -52,12 +52,30 @@ describe('iD.Node', function () {
expect(node.isIntersection(graph)).to.equal(true);
});
it("returns true for a node shared by more two non-highways", function () {
it("returns true for a node shared by more than one waterway", function () {
var node = iD.Node(),
w1 = iD.Way({nodes: [node.id]}),
w2 = iD.Way({nodes: [node.id]}),
w1 = iD.Way({nodes: [node.id], tags: {waterway: 'river'}}),
w2 = iD.Way({nodes: [node.id], tags: {waterway: 'river'}}),
graph = iD.Graph([node, w1, w2]);
expect(node.isIntersection(graph)).to.equal(false);
expect(node.isIntersection(graph)).to.equal(true);
});
});
describe("#isHighwayIntersection", function () {
it("returns true for a node shared by more than one highway", function () {
var node = iD.Node(),
w1 = iD.Way({nodes: [node.id], tags: {highway: 'residential'}}),
w2 = iD.Way({nodes: [node.id], tags: {highway: 'residential'}}),
graph = iD.Graph([node, w1, w2]);
expect(node.isHighwayIntersection(graph)).to.equal(true);
});
it("returns false for a node shared by more than one waterway", function () {
var node = iD.Node(),
w1 = iD.Way({nodes: [node.id], tags: {waterway: 'river'}}),
w2 = iD.Way({nodes: [node.id], tags: {waterway: 'river'}}),
graph = iD.Graph([node, w1, w2]);
expect(node.isHighwayIntersection(graph)).to.equal(false);
});
});