adding a lanes() to return lane data

This commit is contained in:
Kushan Joshi
2016-06-07 20:24:57 +05:30
committed by Bryan Housel
parent 645fcbeea8
commit 4083a0e29e
9 changed files with 91 additions and 11 deletions
+40
View File
@@ -100,6 +100,46 @@ _.extend(Way.prototype, {
return false;
},
lanes: function() {
if (!this.tags.highway) return null;
var defaultLanes = {}, tagged = {};
switch (this.tags.highway) {
case 'service':
case 'track':
case 'path':
defaultLanes.count = this.isOneWay() ? 1 : 2;
break;
case 'trunk':
case 'motorway':
defaultLanes.count = this.isOneWay() ? 2 : 4;
break;
default:
defaultLanes.count = this.isOneWay() ? 1 : 2;
break;
}
if (!this.isOneWay()) {
defaultLanes.forward = defaultLanes.count/2;
defaultLanes.backward = defaultLanes.count/2;
} else {
tagged.oneway = 'yes';
}
tagged.lanes = {};
if (this.tags.lanes) tagged.lanes.count = this.tags.lanes;
if (this.tags['lanes:forward']) tagged.lanes.forward = this.tags['lanes:forward'];
if (this.tags['lanes:backward']) tagged.lanes.backward = this.tags['lanes:backward'];
return {
defaults: {
lanes: defaultLanes
},
tagged: tagged
};
},
isClosed: function() {
return this.nodes.length > 0 && this.first() === this.last();
},
+4
View File
@@ -88,6 +88,10 @@ export function preset(context) {
fields.push(UIField(context.presets().field('restrictions'), entity, true));
}
if (entity.lanes(context.graph())) {
fields.push(UIField(context.presets().field('lanes'), entity, true));
}
context.presets().universal().forEach(function(field) {
if (preset.fields.indexOf(field) < 0) {
fields.push(UIField(field, entity));