Created
February 2, 2016 17:12
-
-
Save stepankuzmin/aa005c1a7a0acae4594d to your computer and use it in GitHub Desktop.
OSRM distance matrix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ./osrm-routed --max-table-size 1000000 moscow_russia.osrm | |
| var turf = require('turf') | |
| var request = require('request') | |
| // var extent = [37.35,55.56,37.87,55.94], // moscow | |
| var extent = [37.606,55.731,37.640,55.752], | |
| cellWidth = 0.1, | |
| units = 'kilometers', | |
| url = 'http://127.0.0.1:5000/table?' | |
| var points = [] | |
| var hexGrid = turf.hexGrid(extent, cellWidth, units) | |
| hexGrid.features.forEach(function (feature, index) { | |
| feature.properties = { id: index } | |
| points.push(turf.centroid(feature)) | |
| }) | |
| console.log('[*] points.length', points.length) | |
| var params = points.map(function (point) { | |
| coords = point.geometry.coordinates | |
| return 'loc=' + coords[1] + ',' + coords[0] | |
| }).join('&') | |
| function cb (error, response, body) { | |
| console.log('body', body) | |
| console.timeEnd('request') | |
| } | |
| console.time('request') | |
| request({ url: url + params, json: true }, cb) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment