-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
54 lines (50 loc) · 1.36 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const path = require('path')
const tileReduce = require('tile-reduce')
const load = require('load-json-file')
const write = require('write-json-file')
const turf = require('@turf/turf')
// Input variables
const extent = './extents/thailand.geojson'
const qatiles = 'thailand.mbtiles'
const days = 200
const users = []
const overlap = 0.2 // % of duplicate nodes
// Results
const edits = {}
const geojson = load.sync(extent)
const results = turf.featureCollection([])
const options = {
geojson,
zoom: 12,
map: path.join(__dirname, 'reduce.js'),
sources: [{name: 'qatiles', mbtiles: qatiles}],
mapOptions: {
days,
extent: geojson,
users,
overlap
}
}
tileReduce(options)
.on('reduce', (features) => {
features.map(feature => {
results.features.push(feature)
// Store User information
const user = feature.properties['@user']
if (edits[user] === undefined) {
edits[user] = 1
} else {
edits[user] = 1 + edits[user]
}
})
})
.on('end', () => {
console.log('Extent:', extent)
console.log('Past days:', days)
console.log('QA Tiles:', qatiles)
console.log('Duplicate roads total: %d', results.features.length)
console.log('Users:')
const sorted = Object.keys(edits).sort((a, b) => edits[a] - edits[b]).reverse()
sorted.map(user => console.log(`- [${edits[user]}] ${user}`))
write.sync('results.geojson', results)
})