diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/building.js | 23 | ||||
| -rwxr-xr-x | bin/complex.js | 91 | 
2 files changed, 69 insertions, 45 deletions
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()  | 
