aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Harvey <andrew@alantgeo.com.au>2021-05-20 15:23:46 +1000
committerAndrew Harvey <andrew@alantgeo.com.au>2021-05-20 15:23:46 +1000
commit9c86dbf30863fec1db7f65d422dd07cb700f1d21 (patch)
tree718b76c67b9648f1ee9ddac503604f068405c04e
parenta5f57f9d603aaccaaad35ecd268920e0f3a1fdf4 (diff)
conflate debug output with lines joining matches
-rwxr-xr-xbin/conflate.js7
-rw-r--r--package.json2
-rw-r--r--yarn.lock8
3 files changed, 16 insertions, 1 deletions
diff --git a/bin/conflate.js b/bin/conflate.js
index 0385c18..6a9e036 100755
--- a/bin/conflate.js
+++ b/bin/conflate.js
@@ -10,6 +10,8 @@ const ndjson = require('ndjson')
const PolygonLookup = require('polygon-lookup')
const Flatbush = require('flatbush')
const bbox = require('@turf/bbox').default
+const multiLineString = require('@turf/helpers').multiLineString
+const centroid = require('@turf/centroid').default
const booleanIntersects = require('@turf/boolean-intersects').default
const argv = require('yargs/yargs')(process.argv.slice(2))
@@ -170,6 +172,9 @@ const conflate = new Transform({
// matching number and street, high confidence
feature.properties._matches = matches.map(match => `${match.properties['@type']}/${match.properties['@id']}`).join(',')
outputStreams.exactMatch.write(feature)
+
+ const exactMatchLine = multiLineString(matches.map(match => [feature.geometry.coordinates, centroid(match).geometry.coordinates]), feature.properties)
+ outputStreams.exactMatchLines.write(exactMatchLine)
} else {
// no exact match, probably can import
outputStreams.noExactMatch.write(feature)
@@ -194,7 +199,7 @@ const conflate = new Transform({
})
// ndjson streams to output features
-const outputKeys = ['notFoundInBlocks', 'noExactMatch', 'exactMatch', 'withinExistingOSMAddressPoly', 'noOSMAddressWithinBlock']
+const outputKeys = ['notFoundInBlocks', 'noExactMatch', 'exactMatch', 'exactMatchLines', 'withinExistingOSMAddressPoly', 'noOSMAddressWithinBlock']
const outputStreams = {}
const outputStreamOutputs = {}
diff --git a/package.json b/package.json
index cd684be..a60a9ae 100644
--- a/package.json
+++ b/package.json
@@ -11,6 +11,8 @@
"dependencies": {
"@turf/bbox": "^6.3.0",
"@turf/boolean-intersects": "^6.3.0",
+ "@turf/centroid": "^6.3.0",
+ "@turf/helpers": "^6.3.0",
"capital-case": "^1.0.4",
"cheap-ruler": "^3.0.1",
"clone-deep": "^4.0.1",
diff --git a/yarn.lock b/yarn.lock
index 3aa5569..833de3c 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -38,6 +38,14 @@
"@turf/helpers" "^6.3.0"
"@turf/invariant" "^6.3.0"
+"@turf/centroid@^6.3.0":
+ version "6.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/centroid/-/centroid-6.3.0.tgz#e86611e1e171fb0a38ade30453351a00e04956a3"
+ integrity sha512-7KTyqhUEqXDoyR/nf/jAXiW8ZVszEnrp5XZkgYyrf2GWdSovSO0iCN1J3bE2jkJv7IWyeDmGYL61GGzuTSZS2Q==
+ dependencies:
+ "@turf/helpers" "^6.3.0"
+ "@turf/meta" "^6.3.0"
+
"@turf/helpers@6.x", "@turf/helpers@^6.3.0":
version "6.3.0"
resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-6.3.0.tgz#87f90f806c3f8ad6385ef8d2041d3662bf3c9fb1"