Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/urbica/galton

Lightweight Node.js isochrone map server
https://github.com/urbica/galton

docker isochrones javascript map nodejs osrm

Last synced: about 2 months ago
JSON representation

Lightweight Node.js isochrone map server

Awesome Lists containing this project

README

        

# Galton

[![npm version](https://img.shields.io/npm/v/galton.svg)](https://www.npmjs.com/package/galton)
[![npm downloads](https://img.shields.io/npm/dt/galton.svg)](https://www.npmjs.com/package/galton)
[![Build Status](https://travis-ci.org/urbica/galton.svg?branch=master)](https://travis-ci.org/urbica/galton)
[![Greenkeeper badge](https://badges.greenkeeper.io/urbica/galton.svg)](https://greenkeeper.io/)

Lightweight Node.js isochrone server. Build isochrones using [OSRM](http://project-osrm.org/), [Turf](http://turfjs.org/) and [concaveman](https://github.com/mapbox/concaveman).

[Francis Galton](https://en.wikipedia.org/wiki/Francis_Galton) is the author of the first known isochrone map.

![Screenshot](https://raw.githubusercontent.com/urbica/galton/master/example.png)

## Installation

Galton requires Node v8.

```
npm install -g galton
```

...or build from source

```shell
git clone https://github.com/urbica/galton.git
cd galton
npm install
```

## Usage

```shell
Usage: galton [filename] [options]

where [filename] is path to OSRM data and [options] is any of:
--radius - distance to draw the buffer (default: 6)
--cellSize - the distance across each cell (default: 0.2)
--concavity - concaveman relative measure of concavity (default: 2)
--deintersect - whether or not to deintersect the final isochrones (default: true)
--intervals - isochrones intervals in minutes (default: 10 20 30)
--lengthThreshold - concaveman length threshold (default: 0)
--pid - save PID to file
--port - port to run on (default: 4000)
--sharedMemory - use shared memory (default: false)
--socket - use Unix socket instead of port
--units - either `kilometers` or `miles` (default: kilometers)
--version - returns running version then exits
```

```
galton berlin-latest.osrm
```

Open `examples/index.html?access_token=`

## Example

```shell
cd galton
wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf
./node_modules/osrm/lib/binding/osrm-extract -p ./node_modules/osrm/profiles/car.lua berlin-latest.osm.pbf
./node_modules/osrm/lib/binding/osrm-contract berlin-latest.osrm
npm start berlin-latest.osrm
```

Build isochrones from point

```shell
curl http://localhost:4000 --get --data 'lng=13.38792&lat=52.51704'
```

Build isochrones for 10, 20 and 30 minute intervals

```
curl http://localhost:4000 --get --data 'lng=13.38792&lat=52.51704&intervals=10&intervals=20&&intervals=30'
```

See the [example](https://github.com/urbica/galton/blob/master/examples/index.html), [API](https://github.com/urbica/galton/blob/master/API.md) and `test/index.js` for more info.

## Examples

### Using existing OSRM graph

This command will run isochrone server using `moscow.osrm`

```shell
galton moscow.osrm
```

### Using existing OSM extract

This command will build OSRM graph with `car` profile using `moscow.osm` extract and start isochrone server.

```shell
galton moscow.osm car
```

### Using geocode to extract from OSM

1. It will look for `moscow.osrm` in the current directory and start isochrone server if found.
2. If it is not found, it will look for `moscow.osm` in the current directory, build OSRM graph with `car` profile, based on this extract, and start isochrone server if found.
3. If there is no `moscow.osm`, galton will geocode `moscow` and extract it from Overpass API, then it will build OSRM from that extract with car profile and start isochrone server.

```shell
galton moscow car
```

## Using with Docker

```shell
docker run -p 4000:4000 urbica/galton
```

Where `OSRM` is a path to OSRM graph.

Examples:

This will download geofabrik extract, extract and build OSRM graph using [official OSRM Docker image](https://hub.docker.com/r/osrm/osrm-backend/), and run galton on that graph.

```shell
wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf
docker run -t -v $(pwd):/data osrm/osrm-backend:v5.18.0 osrm-extract -p /opt/car.lua /data/berlin-latest.osm.pbf
docker run -t -v $(pwd):/data osrm/osrm-backend:v5.18.0 osrm-contract /data/berlin-latest.osrm
docker run -t -i -p 4000:4000 -v $(pwd):/data urbica/galton:v5.18.0 galton /data/berlin-latest.osrm
```

```shell
curl http://localhost:4000 --get --data 'lng=13.38792&lat=52.51704'
```

## Running tests

```shell
make test
```