-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrailway.js
32 lines (29 loc) · 817 Bytes
/
railway.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
'use strict';
var turf = require('turf');
module.exports = function(tileLayers, tile, writeData, done) {
var largest = {
'length': 0,
'feature': {}
};
var layer = tileLayers.osm.osm;
var result = layer.features.filter(function(val) {
if (val.properties.railway && val.properties.railway === 'station'){
// var length = 0;
// try {
// length = turf.lineDistance(val, 'kilometers');
// val.properties.length = length;
// if (length > largest.length) {
// largest.length = length;
// largest.feature = val;
// }
// } catch(e) {}
return true;
}
});
// write all roundabouts to stdout
if (result.length > 0) {
var fc = turf.featurecollection(result);
writeData(JSON.stringify(fc) + '\n');
}
done(null, largest);
};