-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilterSource.js
41 lines (39 loc) · 1.07 KB
/
filterSource.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// whitelist of building unit types to include
// other building unit types like carspace we skip
const buildingUnitTypeWhitelist = [
'APT', // apartment
'BLDG', // building
'CHAL', // chalet
'CTGE', // cottage
'FLAT', // flat
'HSE', // house
'OFFC', // office
'SAPT', // studio apartment
'SE', // suite
'SHOP', // shop
'STR', // strata unit
'TNHS', // townhouse
'UNIT', // unit
'VLLA' // villa
]
/**
* Filters features based on the source schema
*
* @param {Object} feature
* @returns {boolean}
*/
module.exports = (feature) => {
// if the address has a building unit type, only allow a few whitelisted types
if ('BLG_UNIT_TYPE' in feature.properties && feature.properties.BLG_UNIT_TYPE !== null) {
if (buildingUnitTypeWhitelist.includes(feature.properties.BLG_UNIT_TYPE)) {
// building unit type in the whitelist, include feature
return true
} else {
// building unit type is set and not in the whitelist, drop feature
return false
}
} else {
// building unit type not set, include feature
return true
}
}