diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/candidates.js | 26 | ||||
-rwxr-xr-x | bin/upload.sh | 10 |
2 files changed, 23 insertions, 13 deletions
diff --git a/bin/candidates.js b/bin/candidates.js index 95a3ceb..af87f5a 100755 --- a/bin/candidates.js +++ b/bin/candidates.js @@ -39,8 +39,7 @@ if (!fs.existsSync(conflatePath)) { // output GeoJSON Features by layer by suburb ID const outputFeatures = { - 'newAddressWithoutConflicts': {}, - 'addrUnitFromHousenumber': {} + 'newAddressesInBlocksWithoutAnyExisting': {} } for (const layer of Object.keys(outputFeatures)) { @@ -99,9 +98,18 @@ const readSuburbs = new Transform({ } }) +function findSuburb(feature) { + // find which suburb this address is in + const results = lookupSuburbs.search(...feature.geometry.coordinates.slice(0, 2), 1) + const suburb = results ? (results.type === 'FeatureCollection' ? (results.features ? results.features[0] : outsideVicSuburb) : results[0]) : outsideVicSuburb + + return suburb +} + + // produce import candidates let sourceCount = 0 -const candidates = new Transform({ +const candidatesNewAddressesInBlocksWithoutAnyExisting = new Transform({ readableObjectMode: true, writableObjectMode: true, transform(feature, encoding, callback) { @@ -114,11 +122,9 @@ const candidates = new Transform({ // remove tracing properties delete feature.properties._pfi - // find which suburb this address is in - const results = lookupSuburbs.search(...feature.geometry.coordinates.slice(0, 2), 1) - const suburb = results ? (results.type === 'FeatureCollection' ? (results.features ? results.features[0] : outsideVicSuburb) : results[0]) : outsideVicSuburb + const suburb = findSuburb(feature) - outputFeatures['newAddressWithoutConflicts'][suburb.id].push(feature) + outputFeatures['newAddressesInBlocksWithoutAnyExisting'][suburb.id].push(feature) callback() } @@ -168,13 +174,14 @@ pipeline( pipeline( fs.createReadStream(path.join(conflatePath, 'noOSMAddressWithinBlock.geojson')), ndjson.parse(), - candidates, + candidatesNewAddressesInBlocksWithoutAnyExisting, err => { if (err) { console.log(err) process.exit(1) } else { + /* console.log('Step 4/4: noExactMatch') pipeline( fs.createReadStream(path.join(conflatePath, 'noExactMatch.geojson')), @@ -185,12 +192,15 @@ pipeline( console.log(err) process.exit(1) } else { + */ console.log('Output candidate .osm files') outputCandidates() process.exit(0) + /* } } ) + */ } } ) diff --git a/bin/upload.sh b/bin/upload.sh index caf85d0..1144254 100755 --- a/bin/upload.sh +++ b/bin/upload.sh @@ -7,11 +7,11 @@ mkdir -p uploadLog IMPORT_DOC="https://wiki.openstreetmap.org/wiki/Imports/Vicmap_Address" i=0 -totalFiles=`ls -1 dist/candidates/newAddressWithoutConflicts/*.osm | wc -l` -for f in dist/candidates/newAddressWithoutConflicts/*.osm; do +totalFiles=`ls -1 dist/candidates/newAddressesInBlocksWithoutAnyExisting/*.osm | wc -l` +for f in dist/candidates/newAddressesInBlocksWithoutAnyExisting/*.osm; do i=$(($i + 1)) - - categoryMessage="adding new addresses not found in OSM" + categoryMessage="New addresses in blocks without any existing addresses" + stage="Stage 3" d=`dirname "$f"` b=`basename "$f" .osm` id=`echo "$b" | cut -d'_' -f1` @@ -31,7 +31,7 @@ for f in dist/candidates/newAddressWithoutConflicts/*.osm; do -u 'vicmap_import' \ -p "${OSM_DEV_PASSWORD}" \ -c yes \ - -m "Vicmap Import $categoryMessage: $name. See $IMPORT_DOC" \ + -m "Vicmap Address Import - $stage - $categoryMessage: $name. See $IMPORT_DOC" \ -y 'Vicmap Address' \ "$d/$b.osc" echo "$f" >> uploadLog/uploaded.txt |