diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/conflate.js | 10 | ||||
-rwxr-xr-x | bin/reduceOverlap.js | 6 |
2 files changed, 15 insertions, 1 deletions
diff --git a/bin/conflate.js b/bin/conflate.js index a1b0b60..5af586c 100755 --- a/bin/conflate.js +++ b/bin/conflate.js @@ -15,6 +15,7 @@ const centroid = require('@turf/centroid').default const booleanIntersects = require('@turf/boolean-intersects').default const distance = require('@turf/distance').default const { lcs } = require('string-comparison') +const withinRange = require('../lib/withinRange') const argv = require('yargs/yargs')(process.argv.slice(2)) .option('debug', { @@ -191,7 +192,14 @@ const conflate = new Transform({ // ignoring differences between "Foo - Bar Street" and "Foo-Bar Street", these kinds of names are common in country victoria const isMatched = feature.properties['addr:street'] && osmStreet && feature.properties['addr:street'].toLowerCase().replaceAll(' - ', '-').replaceAll('-', '') === osmStreet.toLowerCase().replaceAll(' - ', '-').replaceAll('-', '') - && osmHouseNumber !== null && feature.properties['addr:housenumber'].replaceAll(' ', '').toLowerCase() === osmHouseNumber.replaceAll(' ', '').toLowerCase() + && osmHouseNumber !== null + && ( + // housenumber can be an exact match + feature.properties['addr:housenumber'].replaceAll(' ', '').toLowerCase() === osmHouseNumber.replaceAll(' ', '').toLowerCase() + // or it can just intersect the range + // eg 182 St Georges Road Fitzroy North + || withinRange(feature, osmAddr, { checkStreet: false, checkHigherOrderAddrKeys: false }) + ) && (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 diff --git a/bin/reduceOverlap.js b/bin/reduceOverlap.js index 0941f49..695d5f6 100755 --- a/bin/reduceOverlap.js +++ b/bin/reduceOverlap.js @@ -120,6 +120,9 @@ const reduce = new Transform({ if (cur && cur.split('-').length === 2) { cur = cur.split('-')[0] } + if (acc && acc.split('-').length === 2) { + acc = acc.split('-')[0] + } return (cur < acc) ? cur : acc }) : null @@ -127,6 +130,9 @@ const reduce = new Transform({ if (cur && cur.split('-').length === 2) { cur = cur.split('-')[1] } + if (acc && acc.split('-').length === 2) { + acc = acc.split('-')[1] + } return (cur > acc) ? cur : acc }) : null |