diff options
author | Andrew Harvey <andrew@alantgeo.com.au> | 2021-05-19 23:22:23 +1000 |
---|---|---|
committer | Andrew Harvey <andrew@alantgeo.com.au> | 2021-05-19 23:22:23 +1000 |
commit | fd1c34c07700b5cc501452a7be7b709bc4dc65d5 (patch) | |
tree | 9d52cea1857c56c85934ad2fb1f6b6d566283fb1 /bin | |
parent | 66ec9f9177a685129e917ff6bb8d503779c668f9 (diff) |
in conflate only match when housenumber and street match AND are both set to some value, and handle units in matching
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/conflate.js | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/bin/conflate.js b/bin/conflate.js index cc39ec0..2330a7a 100755 --- a/bin/conflate.js +++ b/bin/conflate.js @@ -149,8 +149,22 @@ const conflate = new Transform({ if (block.id in osmAddrPoints || block.id in osmAddrPolygonsByBlock) { const osmAddrWithinBlock = [osmAddrPoints[block.id] || [], osmAddrPolygonsByBlock[block.id] || []].flat() const matches = osmAddrWithinBlock.filter(osmAddr => { - return (feature.properties['addr:street'] === osmAddr.properties['addr:street'] && - feature.properties['addr:housenumber'] === osmAddr.properties['addr:housenumber'] ) + const osmStreet = osmAddr.properties['addr:street'] + + // where someone has used unit/number style values for addr:housenumber, only compare the number component + const osmHouseNumber = 'addr:housenumber' in osmAddr.properties ? (osmAddr.properties['addr:housenumber'].split('/').length > 1 ? osmAddr.properties['addr:housenumber'].split('/')[1] : osmAddr.properties['addr:housenumber']) : null + + const osmUnit = 'addr:unit' in osmAddr.properties + ? osmAddr.properties['addr:unit'] + : ( + 'addr:housenumber' in osmAddr.properties && osmAddr.properties['addr:housenumber'].split('/').length > 1 + ? osmAddr.properties['addr:housenumber'].split('/')[0] + : null + ) + + return feature.properties['addr:street'] === osmStreet + && osmHouseNumber !== null && feature.properties['addr:housenumber'] === osmHouseNumber + && (('addr:unit' in feature.properties && osmUnit !== null) ? feature.properties['addr:unit'] === osmUnit : true) }) if (matches.length) { // matching number and street, high confidence |