From 73d2dafdf6a6e42784c45d081982e76cb0317370 Mon Sep 17 00:00:00 2001 From: Andrew Harvey Date: Thu, 10 Jun 2021 23:03:38 +1000 Subject: explode unit/number into addr:unit and addr:housenumber --- bin/conflate.js | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'bin/conflate.js') diff --git a/bin/conflate.js b/bin/conflate.js index c2eb813..3cbd11a 100755 --- a/bin/conflate.js +++ b/bin/conflate.js @@ -180,10 +180,41 @@ const conflate = new Transform({ // ignoring whitespace when comparing house numbers // ignoring case // 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 + const isMatched = 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() && (vicmapUnit === osmUnit) + + // if matched but the match came from exploding X/Y into Unit X, Number Y, then automate this to be changed in OSM + if (isMatched && osmAddr.properties['addr:housenumber'].split('/').length > 1) { + // MapRoulette task + const task = { + type: 'FeatureCollection', + features: [ osmAddr ], + cooperativeWork: { + meta: { + version: 2, + type: 1 // tag fix type + }, + operations: [{ + operationType: 'modifyElement', + data: { + id: `${osmAddr.properties['@type']}/${osmAddr.properties['@id']}`, + operations: [{ + operation: 'setTags', + data: { + 'addr:unit': osmUnit, + 'addr:housenumber': osmHouseNumber + } + }] + } + }] + } + } + outputStreams.mr_explodeUnitFromNumber.write(task) + } + + return isMatched }) if (matches.length) { @@ -252,7 +283,7 @@ const conflate = new Transform({ }) // ndjson streams to output features -const outputKeys = ['notFoundInBlocks', 'noExactMatch', 'exactMatch', 'exactMatchLines', 'mr_withinExistingOSMAddressPoly', 'withinExistingOSMAddressPoly', 'noOSMAddressWithinBlock'] +const outputKeys = ['notFoundInBlocks', 'noExactMatch', 'exactMatch', 'exactMatchLines', 'mr_explodeUnitFromNumber', 'mr_withinExistingOSMAddressPoly', 'withinExistingOSMAddressPoly', 'noOSMAddressWithinBlock'] const outputStreams = {} const outputStreamOutputs = {} -- cgit v1.2.3