mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-31 04:09:33 +02:00
adding a lanes() to return lane data
This commit is contained in:
committed by
Bryan Housel
parent
645fcbeea8
commit
4083a0e29e
@@ -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();
|
||||
},
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user