Skip to content

Sysnove/osrm-isochrone

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

osrm-isochrone

Warning: this is experimental

Build Status

Generate drivetime isochrones from OpenStreetMap data using OSRM.

##Install

npm install osrm-isochrone

##Build An osrm file is required for routing. This can be generated using included binaries. (Note: this will take a lot of processing power if you are planning to use the entire planet.osm file. More info here)

#first download an osm file containing the area you need
./node_modules/osrm-isochrone/osrm/lib/binding/osrm-extract mydata.osm -p ./node_modules/osrm-isochrone/osrm/test/data/car.lua
./node_modules/osrm-isochrone/osrm/lib/binding/osrm-prepare mydata.osrm -p ./node_modules/osrm-isochrone/osrm/test/data/car.lua

##Usage

var isochrone = require('osrm-isochrone');

var time = 300; // 300 second drivetime (5 minutes)
var location = [-77.02926635742188,38.90011780426885]; // center point
var options = {
  resolution: 25, // sample resolution
  maxspeed: 70, // in 'unit'/hour
  unit: 'miles', // 'miles' or 'kilometers'
  network: './dc.osrm' // prebuild dc osrm network file
}

isochrone(location, time, options, function(err, drivetime) {
  if(err) throw err;
  // a geojson linestring
  console.log(JSON.stringify(drivetime))
});

Alternativaly the network parameter can be an OSRM module instance. Allowing setup an OSRM with custom paramters, e.g. usage of shared-memory.

You can too define your own function to draw line/polygon instead of default:

var concave = require('turf-concave');
var Isochrone = require('osrm-isochrone');

var time = 300; // 300 second drivetime (5 minutes)
var location = [-77.02926635742188,38.90011780426885]; // center point
var options = {
  resolution: 25, // sample resolution
  maxspeed: 70, // in 'unit'/hour
  unit: 'miles', // 'miles' or 'kilometers'
  network: './dc.osrm' // prebuild dc osrm network file
}

var isochrone = new Isochrone(location, time, options, function(err, drivetime) {
  if(err) throw err;
  // your geojson from draw overload
  console.log(JSON.stringify(drivetime))
});
isochrone.draw = function(destinations) {
  var inside = destinations.features.filter(function(feat) {
    return feat.properties.eta <= time;
  });
  destinations.features = inside;
  return concave(destinations, this.sizeCellGrid, unit);
}
isochrone.getIsochrone();

About

Generate drivetime isochrones from OpenStreetMap data using OSRM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 77.9%
  • Makefile 22.1%