aboutsummaryrefslogtreecommitdiff
path: root/lib/filterSource.js
diff options
context:
space:
mode:
authorAndrew Harvey <andrew@alantgeo.com.au>2021-05-05 22:37:28 +1000
committerAndrew Harvey <andrew@alantgeo.com.au>2021-05-05 22:37:28 +1000
commit64fd02be7dff62e9e658cb144c2b2cccfe7e592c (patch)
tree3b6ff1b94bf36e2d97916aa3d3c6d32b2eb971cf /lib/filterSource.js
parent958ce70b91df29690ed9d61b720a9c2f3c34397d (diff)
filter out some unit building types
Diffstat (limited to 'lib/filterSource.js')
-rw-r--r--lib/filterSource.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/filterSource.js b/lib/filterSource.js
new file mode 100644
index 0000000..bf5d113
--- /dev/null
+++ b/lib/filterSource.js
@@ -0,0 +1,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 ('BLGUNTTYP' in feature.properties) {
+ if (buildingUnitTypeWhitelist.includes(feature.properties.BLGUNTTYP)) {
+ // 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
+ }
+}