display lane count on sidebar

This commit is contained in:
Kushan Joshi
2016-06-22 16:20:03 +05:30
committed by Bryan Housel
parent d130456393
commit 332200b404
3 changed files with 54 additions and 13 deletions

View File

@@ -101,13 +101,13 @@ _.extend(Way.prototype, {
},
lanes: function() {
function parseTurnLane(str) {
if (!str || str === '') return null;
return str.split('|').map(function(s) {
return s.split(';');
});
}
// function parseTurnLane(str) {
// if (!str || str === '') return null;
//
// return str.split('|').map(function(s) {
// return s.split(';');
// });
// }
if (!this.tags.highway) return null;
var defaultLanes = {}, tagged = {};
@@ -121,13 +121,9 @@ _.extend(Way.prototype, {
break;
}
if (this.isOneWay()) {
tagged.oneway = 'yes';
} else {
tagged.oneway = 'no';
}
tagged.oneway = this.isOneWay();
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'];

View File

@@ -5,6 +5,7 @@ export { combo, typeCombo, multiCombo } from './combo';
export { cycleway } from './cycleway';
export { text, url, number, email, tel } from './input';
export { localized } from './localized';
export { lanes } from './lanes';
export { maxspeed } from './maxspeed';
export { radio } from './radio';
export { restrictions } from './restrictions';

View File

@@ -0,0 +1,44 @@
export function lanes(field, context) {
var dispatch = d3.dispatch('change'),
wayID,
laneData;
function lanes(selection) {
// if form field is hidden or has detached from dom, clean up.
if (!d3.select('.inspector-wrap.inspector-hidden').empty() || !selection.node().parentNode) {
selection.call(lanes.off);
return;
}
laneData = context.entity(wayID).lanes();
var wrap = selection.selectAll('.preset-input-wrap')
.data([0]);
var enter = wrap.enter()
.append('div')
.attr('class', 'preset-input-wrap');
enter
.append('div')
.attr('class', 'lane-count')
.append('span');
selection.selectAll('.lane-count')
.text(laneData.tagged.lanes.count || laneData.defaults.lanes.count);
}
lanes.entity = function(_) {
if (!wayID || wayID !== _.id) {
wayID = _.id;
}
};
lanes.tags = function() {};
lanes.focus = function() {};
lanes.off = function() {};
return d3.rebind(lanes, dispatch, 'on');
}