mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
Differentiate between paved/unpaved roads (closes #2564)
Now `iD.svg.TagClasses` will add the class 'tag-unpaved' for unpaved roads.
This commit is contained in:
@@ -30,6 +30,17 @@ iD.oneWayTags = {
|
||||
}
|
||||
};
|
||||
|
||||
iD.pavedTags = {
|
||||
'surface': {
|
||||
'paved': true,
|
||||
'asphalt': true,
|
||||
'concrete': true
|
||||
},
|
||||
'tracktype': {
|
||||
'grade1': true
|
||||
}
|
||||
};
|
||||
|
||||
iD.interestingTag = function (key) {
|
||||
return key !== 'attribution' &&
|
||||
key !== 'created_by' &&
|
||||
|
||||
@@ -79,6 +79,21 @@ iD.svg.TagClasses = function() {
|
||||
classes += ' tag-' + k + ' tag-' + k + '-' + v;
|
||||
}
|
||||
|
||||
// For highways, look for surface tagging..
|
||||
if (primary === 'highway') {
|
||||
var paved = (t.highway !== 'track');
|
||||
for (k in t) {
|
||||
v = t[k];
|
||||
if (k in iD.pavedTags) {
|
||||
paved = !!iD.pavedTags[k][v];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!paved) {
|
||||
classes += ' tag-unpaved';
|
||||
}
|
||||
}
|
||||
|
||||
classes = classes.trim();
|
||||
|
||||
if (classes !== value) {
|
||||
|
||||
@@ -82,6 +82,85 @@ describe("iD.svg.TagClasses", function () {
|
||||
expect(selection.attr('class')).to.equal(null);
|
||||
});
|
||||
|
||||
it('adds tag-unpaved for highway=track with no surface tagging', function() {
|
||||
selection
|
||||
.datum(iD.Entity({tags: {highway: 'track'}}))
|
||||
.call(iD.svg.TagClasses());
|
||||
expect(selection).to.be.classed('tag-unpaved');
|
||||
});
|
||||
|
||||
it('does not add tag-unpaved for highway=track with explicit paved surface tagging', function() {
|
||||
selection
|
||||
.datum(iD.Entity({tags: {highway: 'track', surface: 'asphalt'}}))
|
||||
.call(iD.svg.TagClasses());
|
||||
expect(selection).not.to.be.classed('tag-unpaved');
|
||||
|
||||
selection
|
||||
.datum(iD.Entity({tags: {highway: 'track', tracktype: 'grade1'}}))
|
||||
.call(iD.svg.TagClasses());
|
||||
expect(selection).not.to.be.classed('tag-unpaved');
|
||||
});
|
||||
|
||||
it('adds tag-unpaved for highway=track with explicit unpaved surface tagging', function() {
|
||||
selection
|
||||
.datum(iD.Entity({tags: {highway: 'track', surface: 'dirt'}}))
|
||||
.call(iD.svg.TagClasses());
|
||||
expect(selection).to.be.classed('tag-unpaved');
|
||||
|
||||
selection
|
||||
.datum(iD.Entity({tags: {highway: 'track', tracktype: 'grade3'}}))
|
||||
.call(iD.svg.TagClasses());
|
||||
expect(selection).to.be.classed('tag-unpaved');
|
||||
});
|
||||
|
||||
it('does not add tag-unpaved for other highway types with no surface tagging', function() {
|
||||
selection
|
||||
.datum(iD.Entity({tags: {highway: 'tertiary'}}))
|
||||
.call(iD.svg.TagClasses());
|
||||
expect(selection).not.to.be.classed('tag-unpaved');
|
||||
|
||||
selection
|
||||
.datum(iD.Entity({tags: {highway: 'foo'}}))
|
||||
.call(iD.svg.TagClasses());
|
||||
expect(selection).not.to.be.classed('tag-unpaved');
|
||||
});
|
||||
|
||||
it('does not add tag-unpaved for other highway types with explicit paved surface tagging', function() {
|
||||
selection
|
||||
.datum(iD.Entity({tags: {highway: 'tertiary', surface: 'asphalt'}}))
|
||||
.call(iD.svg.TagClasses());
|
||||
expect(selection).not.to.be.classed('tag-unpaved');
|
||||
|
||||
selection
|
||||
.datum(iD.Entity({tags: {highway: 'foo', tracktype: 'grade1'}}))
|
||||
.call(iD.svg.TagClasses());
|
||||
expect(selection).not.to.be.classed('tag-unpaved');
|
||||
});
|
||||
|
||||
it('adds tag-unpaved for other highway types with explicit unpaved surface tagging', function() {
|
||||
selection
|
||||
.datum(iD.Entity({tags: {highway: 'tertiary', surface: 'dirt'}}))
|
||||
.call(iD.svg.TagClasses());
|
||||
expect(selection).to.be.classed('tag-unpaved');
|
||||
|
||||
selection
|
||||
.datum(iD.Entity({tags: {highway: 'foo', tracktype: 'grade3'}}))
|
||||
.call(iD.svg.TagClasses());
|
||||
expect(selection).to.be.classed('tag-unpaved');
|
||||
});
|
||||
|
||||
it('does not add tag-unpaved for non-highways', function() {
|
||||
selection
|
||||
.datum(iD.Entity({tags: {railway: 'abandoned', surface: 'gravel'}}))
|
||||
.call(iD.svg.TagClasses());
|
||||
expect(selection).not.to.be.classed('tag-unpaved');
|
||||
|
||||
selection
|
||||
.datum(iD.Entity({tags: {amenity: 'parking', surface: 'dirt'}}))
|
||||
.call(iD.svg.TagClasses());
|
||||
expect(selection).not.to.be.classed('tag-unpaved');
|
||||
});
|
||||
|
||||
it('adds tags based on the result of the `tags` accessor', function() {
|
||||
selection
|
||||
.datum(iD.Entity())
|
||||
|
||||
Reference in New Issue
Block a user