Giter Club home page Giter Club logo

osrm-isochrone's Introduction

osrm-isochrone

Warning: this is experimental

Build Status

Generate drive-time 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, for general use a regional OSM data extract is preferable. 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 Create a file containing something such as:

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

var time = 300; // 300 second drivetime (5 minutes)
var location = [-77.02926635742188,38.90011780426885]; // center point
    // Note: coordinates are E/W , N/S
var options = {
  resolution: 25, // sample resolution
  maxspeed: 70, // in 'unit'/hour
  unit: 'miles', // 'miles' or 'kilometers'
  network: './dc.osrm' // prebuilt dc osrm network file, or use the one just built.
}

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

Run with

node my-file.js

The output will be in GeoJSON format.

###Advanced Alternatively the network parameter can be an OSRM module instance. Allowing setup an OSRM with custom parameters, 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();

osrm-isochrone's People

Contributors

divingdeer avatar fab-girard avatar frodrigo avatar morganherlocker avatar paco-valdez avatar themarex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

osrm-isochrone's Issues

full usage instructions

Can you, from nvm install, provide a full usage recipe please? Having a whale of a time getting this running.

Lines are looking skewed

I'm building the 300 sec polygons around the center of the Berlin
the result is weird image

the second example with the concave polygon is a bit better image. But with the hole.

But I don't understand what is the issue with lines and can I trust this polygon then?

sketch out api

var options = {
  resolution: 20
}
var isochroner = Isochrone('my-data.hrgc', options);
console.log(isochroner.ring(5))
//queries to node-osrm cached in between
console.log(isochroner.ring(15))

grid bbox size

How should this work. I am thinking the max safe speed is ~70mph, so we could go out ~.8 miles in each direction for each minute specified for the ring.

Example "./dc.osrm" issue

Hi,

I have a file up and running according to the OSRM instructions at https://github.com/Project-OSRM/osrm-backend/wiki/Running-OSRM (the '4 steps' section at the top)

This gives me a bunch of california-latest.* files, including a .osrm file. I run osrm-routed, and it gets to "running and waiting for requests" in another prompt.

I then use the example js file you provide in the network tab (in my case, ./california-latest.osrm) and run the file. I'm given an error about invalid fingePrint (sic).

I also ran into discrepancies between the Build section of the README and the steps provided by OSRM; there is no osrm folder inside osrm-isochrone in my node_modules. There is an osrm folder in node_modules, and it does have the lib/binding/osrm-extract executable, but not the osrm-prepare file.

Additionally, where should we get a .osm file? Is that the same as a pbf?

Thanks for the work to get this closer; eagerly awaiting being able to use this!

Dependency @turf/isolines has changed its API so version needs to be fixed

The code calls isolines() at
https://github.com/mapbox/osrm-isochrone/blob/master/index.js#L20

However, that is using the pre-4.5.2 interface to @turf/isolines.

That interface was changed in:
Turfjs/turf@321d0df#diff-ba41233dbd590d55878b1d00a76de5b9
Turfjs/turf#781

Their example shows the difference:

- var isolined = turf.isolines(points, 'z', 15, breaks);
+ var isolines = turf.isolines(points, breaks, 'temperature');

So I think the version of @turf/isolines needs to be fixed as >=3.5.2 <4.5.2 at
https://github.com/mapbox/osrm-isochrone/blob/master/package.json#L32

or the calling code updated to the newer call format.

Subsequently the third parameter has been changed to an object, so is now set as the options.zProperty parameter:
https://github.com/Turfjs/turf/tree/master/packages/turf-isolines#isolines

lines or polygons

Results should be geojson. Should they be linestrings or polygons? If they are polygons, it will be easiest to have them stacked.

NPM install fails on Ubuntu 16.04

Hi,

i just tried to install your package with npm, but the installation fails with:


> [email protected] install /home/albert/node_modules/osrm
> node-pre-gyp install --fallback-to-build=false || ./scripts/node_install.sh

/usr/bin/env: »node“: Datei oder Verzeichnis nicht gefunden
/usr/bin/env: »node“: Datei oder Verzeichnis nicht gefunden
Needs cmake to build from source
npm WARN enoent ENOENT: no such file or directory, open '/home/albert/package.json'
npm WARN albert No description
npm WARN albert No repository field.
npm WARN albert No README data
npm WARN albert No license field.
npm ERR! Linux 4.4.0-77-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "osrm-isochrone"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build=false || ./scripts/node_install.sh`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-pre-gyp install --fallback-to-build=false || ./scripts/node_install.sh'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the osrm package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build=false || ./scripts/node_install.sh
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs osrm
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls osrm
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/albert/npm-debug.log

What can i do?

No Data Returned

Firstly I had a problem with the included binaries not producing all the required files, but that is already noted. Using the Louisiana data from Geofabrik (http://download.geofabrik.de/) I was able to generate all required files.

I copied and pasted your code then changed the file name and coordinates for a nearby business which I received from Google (30.190075, -93.178562). Running the script I get the following output: {"type":"FeatureCollection","features":[]}

Subsequently, I used the osrm-routed server to locate the node:
http://127.0.0.1:5000/locate?loc=30.190075,-93.178562
{"mapped_coordinate":[30.191816,-93.179985],"status":0}

and also the nearest "snapped" node
http://127.0.0.1:5000/nearest?loc=30.190075,-93.178562
{"name":"LA 14","mapped_coordinate":[30.190065,-93.17997],"status":0}

Neither of which worked. I am going to process the entire North America map tonight and try that, but I'm not expecting it to work.

Error: 403 status code downloading tarball https://mapbox-node-binary.s3.amazonaws.com/osrm/v5.14.3/Release/node-v51-linux-x64.tar.gz

Hi all,

when I try to install it, gives me this error:

npm WARN deprecated @turf/[email protected]: Module has been renamed to @turf/boolean-point-in-polygon

[email protected] install /usr/lib/node_modules/osrm-isochrone/node_modules/osrm
node-pre-gyp install --fallback-to-build=false || ./scripts/node_install.sh

node-pre-gyp ERR! install error
node-pre-gyp ERR! stack Error: 403 status code downloading tarball https://mapbox-node-binary.s3.amazonaws.com/osrm/v5.14.3/Release/node-v51-linux-x64.tar.gz
node-pre-gyp ERR! stack at Request. (/usr/lib/node_modules/osrm-isochrone/node_modules/osrm/node_modules/node-pre-gyp/lib/install.js:118:27)
node-pre-gyp ERR! stack at emitOne (events.js:101:20)
node-pre-gyp ERR! stack at Request.emit (events.js:191:7)
node-pre-gyp ERR! stack at Request.onRequestResponse (/usr/lib/node_modules/osrm-isochrone/node_modules/osrm/node_modules/request/request.js:1074:10)
node-pre-gyp ERR! stack at emitOne (events.js:96:13)
node-pre-gyp ERR! stack at ClientRequest.emit (events.js:191:7)
node-pre-gyp ERR! stack at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:522:21)
node-pre-gyp ERR! stack at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
node-pre-gyp ERR! stack at TLSSocket.socketOnData (_http_client.js:411:20)
node-pre-gyp ERR! stack at emitOne (events.js:96:13)
node-pre-gyp ERR! System Linux 4.4.0-51-generic
node-pre-gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/osrm-isochrone/node_modules/osrm/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build=false"
node-pre-gyp ERR! cwd /usr/lib/node_modules/osrm-isochrone/node_modules/osrm
node-pre-gyp ERR! node -v v7.10.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.39
node-pre-gyp ERR! not ok
403 status code downloading tarball https://mapbox-node-binary.s3.amazonaws.com/osrm/v5.14.3/Release/node-v51-linux-x64.tar.gz
/usr/lib/node_modules/osrm-isochrone/node_modules/osrm/build /usr/lib/node_modules/osrm-isochrone/node_modules/osrm
CMake Error: The source directory "/usr/lib/node_modules/osrm-isochrone/node_modules/osrm" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
/usr/lib
└── (empty)

npm ERR! Linux 4.4.0-51-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "osrm-isochrone"
npm ERR! node v7.10.1
npm ERR! npm v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1

npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build=false || ./scripts/node_install.sh
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-pre-gyp install --fallback-to-build=false || ./scripts/node_install.sh'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the osrm package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build=false || ./scripts/node_install.sh
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs osrm
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls osrm
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /root/.npm/_logs/2018-01-05T11_10_07_423Z-debug.log

Do you have any suggestion?

Install error

hi , i'm very new in javascript and nodejs environnement
i can't install osrm-isochrone ( if you have a docker version , that would be perfect )

npm WARN deprecated @turf/[email protected]: Module has been renamed to @turf/boolean-point-in-polygon

> [email protected] install /home/myname/repositories/toto/node_modules/osrm
> node-pre-gyp install --fallback-to-build=false || ./scripts/node_install.sh

node-pre-gyp ERR! install error 
node-pre-gyp ERR! stack Error: 403 status code downloading tarball https://mapbox-node-binary.s3.amazonaws.com/osrm/v5.18.0/Release/node-v64-linux-x64.tar.gz
node-pre-gyp ERR! stack     at Request.<anonymous> (/home/myname/repositories/toto/node_modules/osrm/node_modules/node-pre-gyp/lib/install.js:118:27)
node-pre-gyp ERR! stack     at Request.emit (events.js:187:15)
node-pre-gyp ERR! stack     at Request.onRequestResponse (/home/myname/repositories/toto/node_modules/osrm/node_modules/request/request.js:1074:10)
node-pre-gyp ERR! stack     at ClientRequest.emit (events.js:182:13)
node-pre-gyp ERR! stack     at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:546:21)
node-pre-gyp ERR! stack     at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
node-pre-gyp ERR! stack     at TLSSocket.socketOnData (_http_client.js:432:20)
node-pre-gyp ERR! stack     at TLSSocket.emit (events.js:182:13)
node-pre-gyp ERR! stack     at addChunk (_stream_readable.js:283:12)
node-pre-gyp ERR! stack     at readableAddChunk (_stream_readable.js:264:11)
node-pre-gyp ERR! System Linux 4.13.0-46-generic
node-pre-gyp ERR! command "/usr/bin/node" "/home/raphael/repositories/toto/node_modules/osrm/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build=false"
node-pre-gyp ERR! cwd /home/myname/repositories/toto/node_modules/osrm
node-pre-gyp ERR! node -v v10.6.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.38
node-pre-gyp ERR! not ok 
403 status code downloading tarball https://mapbox-node-binary.s3.amazonaws.com/osrm/v5.18.0/Release/node-v64-linux-x64.tar.gz
Needs cmake to build from source
npm WARN enoent ENOENT: no such file or directory, open '/home/myname/repositories/toto/package.json'
npm WARN toto No description
npm WARN toto No repository field.
npm WARN toto No README data
npm WARN toto No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build=false || ./scripts/node_install.sh`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/myname/.npm/_logs/2018-08-17T12_36_19_171Z-debug.log

could you please help me , thank you

TypeError: Cannot read property '24' of undefined

Hi,

I was trying to follow the instructions to get the sample js working and got the error below.
Few details that might help -

  1. I download the following OSM file, and used osm extract and osm contract on it. The instructions mentioned osm prepare, but I saw a tutorial that mentioned osm contract (as osm prepare doesn't exist in the folder anymore).
    http://download.geofabrik.de/asia/israel-and-palestine-latest.osm.bz2
  2. I'm working with Mac OSX 10.11.4.

The error -
/osm/node_modules/osrm-isochrone/node_modules/@turf/isolines/conrec.js:380
temp1 = Math.min(d[i][j], d[i][j + 1]);
^

TypeError: Cannot read property '24' of undefined
at Conrec.contour (/Users/user/Downloads/osm/node_modules/osrm-isochrone/node_modules/@turf/isolines/conrec.js:380:36)
at module.exports (/Users/user/Downloads/osm/node_modules/osrm-isochrone/node_modules/@turf/isolines/index.js:80:7)
at draw (/Users/user/Downloads/osm/node_modules/osrm-isochrone/index.js:20:20)
at /Users/user/Downloads/osm/node_modules/osrm-isochrone/index.js:74:31

Appreciate the help!
Tomer.

Error: .geometry not found

When execute "Usage example", recived error:

/usr/lib/node_modules/osrm-isochrone/index.js:11
var osrm = new OSRM(network);
^
Error: .geometry not found
at module.exports (/usr/lib/node_modules/osrm-isochrone/index.js:11:16)
at Object. (/usr/lib/node_modules/osrm-isochrone/test1/test.js:8:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3


latest osrm-prepare not generate file .geometry, for success need use osrm-extract and osrm-prepare placed in Node.js osrm module

You should update your instructions for usage!

The path to the files:
/node_modules/osrm-isochrone/osrm/lib/binding/osrm-extract
/node_modules/osrm-isochrone/osrm/lib/binding/osrm-prepare
are wrong and do not exist. I found similar files in:

/node_modules/osrm/lib/binding

but i cant find the osrm-prepare file!

I have a osrm file (and many other files from the OSRM Project. I changed the Path to the OSRM File in your Demofile.
When i try to run the demo file i get Errors:

/home/user/node_modules/@turf/isolines/conrec.js:380
              temp1 = Math.min(d[i][j], d[i][j + 1]);
                                   ^

TypeError: Cannot read property '24' of undefined
    at Conrec.contour (/home/user/node_modules/@turf/isolines/conrec.js:380:36)
    at module.exports (/home/user/node_modules/@turf/isolines/index.js:80:7)
    at draw (/home/user/node_modules/osrm-isochrone/index.js:20:20)
    at /home/user/node_modules/osrm-isochrone/index.js:74:31```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.