diff options
author | Andrew Harvey <andrew@alantgeo.com.au> | 2021-06-10 23:03:38 +1000 |
---|---|---|
committer | Andrew Harvey <andrew@alantgeo.com.au> | 2021-06-10 23:03:38 +1000 |
commit | 73d2dafdf6a6e42784c45d081982e76cb0317370 (patch) | |
tree | 3fa2151f28e07fa15dd24c6300c1c983b9f52a1d /bin/conflate.js | |
parent | fc2b28841d32c52e5ca60d3baca95f06f7a9977c (diff) |
explode unit/number into addr:unit and addr:housenumber
Diffstat (limited to 'bin/conflate.js')
-rwxr-xr-x | bin/conflate.js | 35 |
1 files changed, 33 insertions, 2 deletions
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 = {} |