Skip to content

Commit

Permalink
Merge pull request #77 from ellenhp/support_arbitrary_extracts
Browse files Browse the repository at this point in the history
Support arbitrary OSM extracts
  • Loading branch information
ellenhp committed Aug 9, 2022
2 parents 00c01e8 + 217c043 commit b47e085
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
21 changes: 20 additions & 1 deletion BUILD.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
### Building Headway
## Supported Build Methods

Headway can be built using a BBBike extract if one exists for a metro area you're interested in, or you can supply your own `.osm.pbf` file to cover larger areas like US states or European countries.

### Building Headway from a supported BBBike extract

1. Pick a metro area from the `Makefile` like "Amsterdam" or "Denver". These values are case-sensitive.
2. (Optional) Set up GTFS feeds for trip planning and multimodal routing capability. This dramatically increases hardware requirements for large metro areas.
Expand All @@ -16,3 +20,18 @@
6. (For https and non-default port use only) reverse-proxy traffic to port 8080.

That's it! In the future I'd like to have a kubernetes config to further productionize this project.

### Building Headway from your own OSM extract

Using a custom OSM extract is a bit more complicated, and less regularly tested. Please report issues if you have any, though. Transit trip planning isn't currently supported for arbitrary OSM extracts, contributions are welcome though!

1. Copy your OSM extract into the `data/` directory, as e.g. `data/california.osm.pbf`.
2. Execute `make california.custom` replacing `california` with the name (no extension) of your OSM extract.
3. Make a `.env` file with configuration. See/copy `.env.example` for defaults. In particular:

1. `HEADWAY_PUBLIC_URL` (Optional for fully local setup that is accessed exclusively via the base URL `http://127.0.0.1`) Pick a base URL for the domain you wish to serve on, paying attention to scheme (http vs https), domain and port (if not default). This will look like "https://example.com", "http://maps.my.cool.intranet" or "https://maps.example.com:8080". Please omit the trailing slash.
2. `HEADWAY_AREA`: This is the name (no extension) of the OSM extract you used. In this example it would be `california`.
3. `HEADWAY_FORCE_BBOX`: This is a space-delimited list of lng/lat pairs describing the bounding box of your OSM extract. The format is `west_lng south_lat east_lng north_lat`. The easiest way to get these pairs is probably to go on google maps and estimate the locations for the southwest and northeast points of your extract. You can long-click on a point on the map and it'll show you coordinates. If you generated your OSM extract yourself using Osmium you can just copy the bounding box from the command you used to create it.

4. Execute `docker-compose up -d` to bring up a headway server on port 8080.
5. (For https and non-default port use only) reverse-proxy traffic to port 8080.
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ CITIES = Aachen Aarhus Adelaide Albuquerque Alexandria Amsterdam Antwerpen Arnhe
Zagreb Zuerich

.DEFAULT_GOAL := help
.SECONDARY:
SHELL := /bin/bash
.SHELLFLAGS := -ec
DATA_DIR := ${PWD}/data
Expand Down Expand Up @@ -49,6 +50,21 @@ $(filter %,$(CITIES)): %: \
tag_images
@echo "Built $@"

%.custom: \
${DATA_DIR}/%.osm.pbf \
${DATA_DIR}/%.gtfs.csv \
${DATA_DIR}/%.gtfs.tar \
${DATA_DIR}/%.nominatim.sql.bz2 \
${DATA_DIR}/%.nominatim_tokenizer.tgz \
${DATA_DIR}/%.photon.tar.bz2 \
${DATA_DIR}/%.mbtiles \
${DATA_DIR}/%.graph.obj \
${DATA_DIR}/%.valhalla.tar.bz2 \
${DATA_DIR}/fonts.tar \
${DATA_DIR}/sprite.tar \
tag_images
@echo "Built $@"

%.osm.pbf:
mkdir -p ${DATA_DIR}
echo "Downloading $(notdir $*) from BBBike."
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ services:
env_file: .env
environment:
HEADWAY_RESOLVER: 127.0.0.11
HEADWAY_FORCE_BBOX: ${HEADWAY_FORCE_BBOX}
HEADWAY_GRAPHHOPPER_URL: http://graphhopper:8989
HEADWAY_NOMINATIM_URL: http://nominatim:8080
HEADWAY_PHOTON_URL: http://photon:2322
Expand Down
5 changes: 4 additions & 1 deletion web/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

set -xe

if [ ! -z ${HEADWAY_AREA} ]
if [ ! -z "${HEADWAY_FORCE_BBOX}" ]
then
echo "${HEADWAY_FORCE_BBOX}" > ${HEADWAY_BBOX_PATH}
elif [ ! -z ${HEADWAY_AREA} ]
then
[[ -e ${HEADWAY_BBOX_PATH} ]] && echo "WARN: overwriting existing ${HEADWAY_BBOX_PATH} with bbox"
grep "^${HEADWAY_AREA}:" /frontend/bboxes.csv | cut -d':' -f2 > ${HEADWAY_BBOX_PATH}
Expand Down

0 comments on commit b47e085

Please sign in to comment.