Skip to content

Instantly share code, notes, and snippets.

@tyrasd
Last active August 16, 2017 10:03
Show Gist options
  • Save tyrasd/5f17d10a5b9ab1c8d2409238a5e0a54b to your computer and use it in GitHub Desktop.
Save tyrasd/5f17d10a5b9ab1c8d2409238a5e0a54b to your computer and use it in GitHub Desktop.
osm-analytics server setup walkthrough

Cruncher

  • install node/npm, curl
  • compile and install tippecanoe (version 1.8.1 works, not sure about newer releases)
  • download run.sh from cruncher repo and chmod +x it
  • replace osmqatiles-planet url with the extract you want
  • adjust paths in run.sh (and mkdir the respective working directories)
  • comment out hotprojects.sh (would fail because it requires valid AWS credentials to upload stuff into a hardcoded bucket).
  • comment out the forever restart … lines (requires a tile-serving script to be already running)
  • execute run.sh -> … -> two .mbtiles files in results directory

Serve Results

There are some options:

  • use mb-util (e.g. mb-util --image_format=pbf buildings.mbtile buildings) to unpack mbtiles file and serve it via a local web server (or upload the data to S3, or …).
  • use mapbox-tile-copy to upload contents directly to S3
  • use a server script like the example in the repo that serves tiles directly from the mbtiles file. (code needs to be adjusted!)

HTTP API schema is:

http://.../.../<feature-type>/<z>/<x>/<y>.pbf

where feature-type is buildings,highways, etc.

The web server needs to return proper CORS headers, the Content-Encoding=gzip header (!) and the Content-Type header needs to be either application/x-protobuf or application/octet-stream.

Run frontend

  • clone repo git clone https://github.com/hotosm/osm-analytics
  • run npm install
  • adjust base-url setting in ./app/settings/settings.js
  • run npm start (for a development-server) or npm run build to build a production build (results as HTML5 in ./static)

Add a new feature type

(not yet tested, sorry)

  • on frontend side: add new type in ./app/settings/options.js (as entry in filters array)
  • on backend:
    • add new type definition json file (like buildings.json) (use "objects" as a generic user-experience field)
    • add a new crunching section in run.sh for the newly created feature type
    • serve results (see above)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment