aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/reduceDuplicates.js1
-rwxr-xr-xbin/reduceOverlap.js10
-rwxr-xr-xbin/reduceRangeDuplicates.js23
3 files changed, 29 insertions, 5 deletions
diff --git a/bin/reduceDuplicates.js b/bin/reduceDuplicates.js
index 0880abf..e4373c1 100755
--- a/bin/reduceDuplicates.js
+++ b/bin/reduceDuplicates.js
@@ -45,7 +45,6 @@ const index = new Transform({
}
const key = [
- // feature.properties['addr:unit:prefix'],
feature.properties['addr:unit'],
feature.properties['addr:housenumber'],
feature.properties['addr:street'],
diff --git a/bin/reduceOverlap.js b/bin/reduceOverlap.js
index 90ca036..7414241 100755
--- a/bin/reduceOverlap.js
+++ b/bin/reduceOverlap.js
@@ -1,5 +1,9 @@
#!/usr/bin/env node
+/**
+ * Reduce overlapping features which can be combined together into a single feature.
+ */
+
const fs = require('fs')
const { Readable, Transform, pipeline } = require('stream')
const ndjson = require('ndjson')
@@ -85,7 +89,7 @@ const reduce = new Transform({
// multiple features with the same geometry
// group by housenumber, street, suburb, state, postcode to reduce units into addr:flats
- // groupedFeatures all all the features at the same point
+ // groupedFeatures is all the features at the same point
const featuresGroupByNonUnit = {}
groupedFeatures.forEach(feature => {
const key = [
@@ -175,7 +179,9 @@ const reduce = new Transform({
})
/**
- * limit values
+ * Per https://wiki.openstreetmap.org/wiki/API_v0.6#Maximum_string_lengths
+ * tag values are limited to 255 characters. Because some addr:flats values can
+ * exceed this, they are split into addr:flatsN tags.
*/
let limitValuesIndex = 0
const limitValues = new Transform({
diff --git a/bin/reduceRangeDuplicates.js b/bin/reduceRangeDuplicates.js
index 89f8a11..6fac0b5 100755
--- a/bin/reduceRangeDuplicates.js
+++ b/bin/reduceRangeDuplicates.js
@@ -134,6 +134,9 @@ const reduceRange = new Transform({
let foundStart = false
let foundEnd = false
+ let matchedStart
+ let matchedEnd
+
let startNum
let endNum
let pre = ''
@@ -142,6 +145,7 @@ const reduceRange = new Transform({
for (const matchCandidate of matchCandidates) {
if (!foundStart && start === matchCandidate.properties['addr:housenumber']) {
foundStart = true
+ matchedStart = matchCandidate
const match = start.match(regexp)
if (match && match.groups) {
@@ -152,6 +156,7 @@ const reduceRange = new Transform({
}
if (!foundEnd && end === matchCandidate.properties['addr:housenumber']) {
foundEnd = true
+ matchedEnd = matchCandidate
const match = end.match(regexp)
if (match && match.groups) {
@@ -203,8 +208,22 @@ const reduceRange = new Transform({
// keep track of removed features for filter B, so we don't double remove both range and midpoints
rangesRemovedInFilterA[hash(feature)] = true
} else {
- // since not both start and end found, then still include the range
- this.push(feature)
+ // not both start and end found,
+ // if one of start or end found and that start/end has addr:flats...
+ if (foundStart || foundEnd) {
+ // ...if the range has no flats AND the non-range has addr:flats
+ if (!feature.properties['addr:flats'] && (
+ (matchedStart && matchedStart.properties['addr:flats']) || (matchedEnd && matchedEnd.properties['addr:flats'])
+ )) {
+ // drop the range, eg "112-116 Anderson Street, South Yarra"
+ } else {
+ // then still include the range
+ this.push(feature)
+ }
+ } else {
+ // then still include the range
+ this.push(feature)
+ }
}
} else {
// there are no non-ranges on this street so still include the range