From 72da1088d0803da3925c55831f0adf7f92e19acf Mon Sep 17 00:00:00 2001 From: Andrew Harvey Date: Wed, 26 May 2021 15:53:44 +1000 Subject: match unit as another solution to #7 --- bin/conflate.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'bin/conflate.js') diff --git a/bin/conflate.js b/bin/conflate.js index 7de1fd6..76edeea 100755 --- a/bin/conflate.js +++ b/bin/conflate.js @@ -167,25 +167,27 @@ const conflate = new Transform({ 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'] + ? osmAddr.properties['addr:unit'].toLowerCase().replaceAll(' ', '') : ( 'addr:housenumber' in osmAddr.properties && osmAddr.properties['addr:housenumber'].split('/').length > 1 - ? osmAddr.properties['addr:housenumber'].split('/')[0] + ? osmAddr.properties['addr:housenumber'].split('/')[0].toLowerCase().replaceAll(' ', '') : null ) - // see if street matches and housenumber matches + const vicmapUnit = 'addr:unit' in feature.properties ? feature.properties['addr:unit'].toLowerCase().replaceAll(' ', '') : null + + // see if unit, number, street matches // ignoring whitespace when comparing house numbers // ignoring case - // ignoring unit for the time being // ignoring differences between "Foo - Bar Street" and "Foo-Bar Street", these kinds of names are common in country victoria return feature.properties['addr:street'] && osmStreet && feature.properties['addr:street'].toLowerCase().replaceAll(' - ', '-') === osmStreet.toLowerCase().replaceAll(' - ', '-') && osmHouseNumber !== null && feature.properties['addr:housenumber'].replaceAll(' ', '').toLowerCase() === osmHouseNumber.replaceAll(' ', '').toLowerCase() - && (('addr:unit' in feature.properties && osmUnit !== null) ? feature.properties['addr:unit'].replaceAll(' ', '') === osmUnit.replaceAll(' ', '') : true) + && (vicmapUnit === osmUnit) }) + if (matches.length) { - // matching unit, number, street, high confidence + // matching unit/number/street => high confidence if (argv.debug) { feature.properties._matches = matches.map(match => `${match.properties['@type']}/${match.properties['@id']}`).join(',') } -- cgit v1.2.3