aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Harvey <andrew@alantgeo.com.au>2021-06-10 13:41:37 +1000
committerAndrew Harvey <andrew@alantgeo.com.au>2021-06-10 13:41:37 +1000
commit91fa58f564e4c2fb24b1446e659e47701caea884 (patch)
tree1397438ff9ef45b208eb5378c210524d4f0f6cef
parent70523db4413644c3b10398ffda966786d231905b (diff)
reorder features and set ids for better maproulette tasks
-rw-r--r--README.md2
-rwxr-xr-xbin/building.js23
-rwxr-xr-xbin/complex.js91
3 files changed, 71 insertions, 45 deletions
diff --git a/README.md b/README.md
index 8a24f83..d7dc902 100644
--- a/README.md
+++ b/README.md
@@ -265,6 +265,8 @@ Further processing to conflate Vicmap complex and building names with OSM can be
make dist/vicmap-complex-conflation
make dist/vicmap-building-conflation
+These outputs are described in the [Building Name](#building-name) and [Complex Name](#complex-name) sections.
+
- [ ] we need to deal with addresses represented in OSM as interpolation ways. If there is community consensus to replace these existing interpolation ways with individual point nodes or leave the existing interpolation ways.
- [ ] we need a better way to review matches where some attributes differ, potentially as a quick fix MapRoulette for tricky cases, or done as a bulk import for easy cases (eg. simply adding `addr:suburb`, `addr:state` and `addr:postcode`)
diff --git a/bin/building.js b/bin/building.js
index f991be2..c405cdb 100755
--- a/bin/building.js
+++ b/bin/building.js
@@ -116,12 +116,17 @@ const conflate = new Transform({
const task = {
type: 'FeatureCollection',
features: [
+ ...nearbyMatchedFeatures.map(f => {
+ // MapRoulette uses the first feature id as the task ID
+ f.id = feature.id
+ return f
+ }),
+ // last feature is used as the first one shown in MapRoulette
point(feature.geometry.coordinates, Object.assign({}, feature.properties, {
'marker-color': 'orange',
'marker-size': 'large',
'OSM Name': nearbyMatchedFeatures[0].properties.name
- }, properties)),
- ...nearbyMatchedFeatures
+ }, properties))
]
}
outputStreams.mr_singleNearbySimilarFeature.write(task)
@@ -131,11 +136,16 @@ const conflate = new Transform({
const task = {
type: 'FeatureCollection',
features: [
+ ...nearbyMatchedFeatures.map(f => {
+ // MapRoulette uses the first feature id as the task ID
+ f.id = feature.id
+ return f
+ }),
+ // last feature is used as the first one shown in MapRoulette
point(feature.geometry.coordinates, Object.assign({}, feature.properties, {
'marker-color': 'orange',
'marker-size': 'large'
- }, properties)),
- ...nearbyMatchedFeatures
+ }, properties))
]
}
outputStreams.mr_multipleNearbySimilarFeatures.write(task)
@@ -144,7 +154,10 @@ const conflate = new Transform({
const task = {
type: 'FeatureCollection',
features: [
- point(feature.geometry.coordinates, Object.assign({}, feature.properties, properties))
+ point(feature.geometry.coordinates, Object.assign({}, feature.properties, properties), {
+ // MapRoulette uses the first feature id as the task ID
+ id: feature.id
+ })
]
}
outputStreams.mr_noNearbySimilarFeature.write(task)
diff --git a/bin/complex.js b/bin/complex.js
index b81eefe..67ffabb 100755
--- a/bin/complex.js
+++ b/bin/complex.js
@@ -123,6 +123,7 @@ pipeline(
console.log('Stage 2/2 saving features per complex')
// output complexes as a geometry collection feature with a hull and multipoint
let complexIndex = 0
+ let exactMatchCount = 0
for (const [name, complex] of Object.entries(complexes)) {
complexIndex++
if (process.stdout.isTTY && complexIndex % 50 === 0) {
@@ -160,58 +161,67 @@ pipeline(
const nearby = around(osmIndex, ...centroid.geometry.coordinates, Infinity, maxDistanceInKm)
const nearbyMatches = nearby.filter(i => {
const similarity = lcs.similarity(osmFeatures[i].properties.name.toLowerCase(), name.toLowerCase())
- return similarity > 0.7
+ return similarity > 0.8
})
const nearbyMatchedFeatures = nearbyMatches.map(i => osmFeatures[i])
if (nearbyMatches.length) {
console.log(name)
- console.log(' > ', nearbyMatches.map(i => osmFeatures[i].properties.name))
+ for (const i of nearbyMatches) {
+ const properties = osmFeatures[i].properties
+ console.log(` > ${properties['@type']}/${properties['@id']} ${properties.name} ${properties.name.toLowerCase() === name.toLowerCase() ? '✓' : '⨯'}`)
+ }
+ console.log('')
}
- if (nearbyMatches.length === 1) {
- // a single nearby OSM features found with similar name
- if (nearbyMatchedFeatures[0].properties.name.toLowerCase() === name.toLowerCase()) {
+
+ if (nearbyMatches.length) {
+ const isExactMatch = nearbyMatchedFeatures.map(feature => feature.properties.name.toLowerCase() === name.toLowerCase()).reduce((acc, cur) => acc && cur, true)
+ if (isExactMatch) {
// name exactly matched
- console.log(`Exact match: ${properties.name} = ${nearbyMatchedFeatures[0].properties.name}`)
+ exactMatchCount++
} else {
// name was similar but not an exact match
// create a MapRoulette task to investigate further
- const task = {
- type: 'FeatureCollection',
- features: [
- ...complex.map(feature => {
- feature.properties['marker-color'] = 'orange'
- feature.properties['marker-color'] = 'small'
- return feature
- }),
- point(centroid.geometry.coordinates, Object.assign({}, centroid.properties, {
- 'marker-color': 'orange',
- 'marker-size': 'large',
- 'OSM Name': nearbyMatchedFeatures[0].properties.name
- })),
- ...nearbyMatchedFeatures
- ]
+
+ if (nearbyMatches.length === 1) {
+ // a single nearby OSM features found with similar name
+ const task = {
+ type: 'FeatureCollection',
+ features: [
+ ...nearbyMatchedFeatures,
+ ...complex.map(feature => {
+ feature.properties['marker-color'] = 'orange'
+ feature.properties['marker-color'] = 'small'
+ return feature
+ }),
+ point(centroid.geometry.coordinates, Object.assign({}, centroid.properties, {
+ 'marker-color': 'orange',
+ 'marker-size': 'large',
+ 'OSM Name': nearbyMatchedFeatures[0].properties.name
+ }))
+ ]
+ }
+ outputStreams.mr_singleNearbySimilarFeature.write(task)
+ } else if (nearbyMatches.length > 1) {
+ // multiple nearby OSM features found with similar name, create a MapRoulette task to investigate further
+ const task = {
+ type: 'FeatureCollection',
+ features: [
+ ...nearbyMatchedFeatures,
+ ...complex.map(feature => {
+ feature.properties['marker-color'] = 'orange'
+ feature.properties['marker-color'] = 'small'
+ return feature
+ }),
+ point(centroid.geometry.coordinates, Object.assign({}, centroid.properties, {
+ 'marker-color': 'orange',
+ 'marker-size': 'large'
+ }))
+ ]
+ }
+ outputStreams.mr_multipleNearbySimilarFeatures.write(task)
}
- outputStreams.mr_singleNearbySimilarFeature.write(task)
- }
- } else if (nearbyMatches.length > 1) {
- // multiple nearby OSM features found with similar name, create a MapRoulette task to investigate further
- const task = {
- type: 'FeatureCollection',
- features: [
- ...complex.map(feature => {
- feature.properties['marker-color'] = 'orange'
- feature.properties['marker-color'] = 'small'
- return feature
- }),
- point(centroid.geometry.coordinates, Object.assign({}, centroid.properties, {
- 'marker-color': 'orange',
- 'marker-size': 'large'
- })),
- ...nearbyMatchedFeatures
- ]
}
- outputStreams.mr_multipleNearbySimilarFeatures.write(task)
} else {
// no nearby OSM feature found with similar name, so create a MapRoulette task
const task = {
@@ -221,6 +231,7 @@ pipeline(
outputStreams.mr_noNearbySimilarFeature.write(task)
}
}
+ console.log(`${exactMatchCount} Vicmap distinct complex names exactly matched OSM features`)
outputKeys.forEach(key => {
outputStreams[key].end()