Skip to content

Commit

Permalink
Fix classification of "recently demolished buildings"
Browse files Browse the repository at this point in the history
(closes #1403)

This is a continuation of fce5616
It now matches the "Recently Demolished Building" because we need to also
consider tags of the form `demolished:building=yes`, with a colon.

Also fixed the tests and removed an extra console.log
  • Loading branch information
bhousel committed Nov 14, 2024
1 parent fce5616 commit 4df4939
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
11 changes: 7 additions & 4 deletions modules/core/FilterSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,6 @@ export class FilterSystem extends AbstractSystem {
}
}

if (entity.id === 'w513179099') {
console.log('hi');
}
let matches = new Set();
for (const [filterID, filter] of this._filters) {
if (filterID === 'others') { // 'others' matches last
Expand Down Expand Up @@ -759,7 +756,8 @@ if (entity.id === 'w513179099') {
!this._isBuildingPart(tags) &&
!this._isIndoor(tags) &&
!this._isWater(tags) &&
!this._isAerialway(tags);
!this._isAerialway(tags) &&
!this._isPastFuture(tags);
}

_isBoundary(tags) {
Expand Down Expand Up @@ -823,7 +821,12 @@ if (entity.id === 'w513179099') {

for (const [k, v] of Object.entries(tags)) {
if (osmLifecyclePrefixes[k] || osmLifecyclePrefixes[v]) return true;

const parts = k.split(':');
if (parts.length === 1) continue;
if (osmLifecyclePrefixes[parts[0]]) return true;
}

return false;
}

Expand Down
16 changes: 8 additions & 8 deletions test/browser/core/FilterSystem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ describe('FilterSystem', () => {
Rapid.osmWay({id: 'building_yes', tags: {area: 'yes', amenity: 'school', building: 'yes'}, version: 1}),
Rapid.osmWay({id: 'building_no', tags: {area: 'yes', amenity: 'school', building: 'no'}, version: 1}),
Rapid.osmWay({id: 'building_part', tags: { 'building:part': 'yes'}, version: 1}),
Rapid.osmWay({id: 'building_demolished', tags: {'demolished:building': 'yes'}, version: 1}),
Rapid.osmWay({id: 'garage1', tags: {area: 'yes', amenity: 'parking', parking: 'multi-storey'}, version: 1}),
Rapid.osmWay({id: 'garage2', tags: {area: 'yes', amenity: 'parking', parking: 'sheds'}, version: 1}),
Rapid.osmWay({id: 'garage3', tags: {area: 'yes', amenity: 'parking', parking: 'carports'}, version: 1}),
Expand Down Expand Up @@ -349,7 +350,7 @@ describe('FilterSystem', () => {
]);

dontMatch('buildings', [
'building_no', 'point_bar', 'motorway', 'service', 'path',
'building_no', 'building_demolished', 'point_bar', 'motorway', 'service', 'path',
'forest', 'boundary', 'boundary_member', 'water', 'railway', 'power_line',
'motorway_construction', 'fence'
]);
Expand All @@ -364,7 +365,7 @@ describe('FilterSystem', () => {
dontMatch('building_parts', [
'building_yes',
'garage1', 'garage2', 'garage3', 'garage4',
'building_no', 'point_bar', 'motorway', 'service', 'path',
'building_no', 'building_demolished', 'point_bar', 'motorway', 'service', 'path',
'forest', 'boundary', 'boundary_member', 'water', 'railway', 'power_line',
'motorway_construction', 'fence'
]);
Expand Down Expand Up @@ -431,7 +432,7 @@ describe('FilterSystem', () => {
it('matches landuse', () => {
doMatch('landuse', [
'forest', 'scrub', 'industrial', 'parkinglot', 'building_no',
'rail_landuse', 'landuse_construction', 'retail',
'rail_landuse', /*'landuse_construction',*/ 'retail',
'outer', 'inner1', 'inner2' // non-interesting members of landuse multipolygon
]);

Expand Down Expand Up @@ -478,14 +479,13 @@ describe('FilterSystem', () => {

it('matches rail', () => {
doMatch('rail', [
'point_rail_station', 'point_old_rail_station',
'railway', 'rail_landuse', 'rail_disused'
'point_rail_station', 'railway', 'rail_landuse'
]);

dontMatch('rail', [
'rail_streetcar', 'rail_trail', // because rail also used as highway
'point_bar', 'motorway', 'service', 'path', 'building_yes',
'forest', 'boundary', 'boundary_member', 'water', 'power_line',
'rail_disused', 'point_old_rail_station', 'point_bar', 'motorway', 'service', 'path',
'building_yes', 'forest', 'boundary', 'boundary_member', 'water', 'power_line',
'motorway_construction', 'fence'
]);
});
Expand All @@ -506,7 +506,7 @@ describe('FilterSystem', () => {

it('matches past/future', () => {
doMatch('past_future', [
'point_old_rail_station', 'rail_disused',
'building_demolished', 'point_old_rail_station', 'rail_disused',
'motorway_construction', 'cycleway_proposed', 'landuse_construction'
]);

Expand Down

0 comments on commit 4df4939

Please sign in to comment.