Skip to content

A data pipeline, a tile and api server, and a distribution script

Notifications You must be signed in to change notification settings

hackoregon/earthquake-heroes-offline

Repository files navigation

Earthquake Heroes Offline

Build Status

This repo has three things.

  1. A data pipeline for generating offline map tiles
  2. A simple web server for serving tiles and some API endpoints
  3. A bundling and distribution script for both the web server and the game

⚠️ If you are looking for source code for the Earthquake Heroes game, checkout the Civic repo.

Data pipeline for generating offline map tiles

The data pipeline uses a combination of tl, @mapbox/mbtiles, and tilelive-http to scrape a Mapbox tileset.

To run the pipeline first install all three dependencies:

$ npm i -g tl @mapbox/mbtiles tilelive-http

Then make sure to have a MAPBOX_TOKEN in your env.

$ export MAPBOX_TOKEN=<token>

Then run pipeline.sh

$ ./pipeline.sh

This will create a tiles.mbtiles file which is used by the web server.

Web server for serving tiles and some API endpoints

The web server is a simple express server with some endpoints serving static JSON (for the API responses) and protobuf-based vector tiles out of the tiles.mbtiles file that is generated from the data pipeline.

To start the web server run index.js:

$ node index.js

The output of index.js will include the API address.

To use this tile server with Civic's BaseMap, set the low-level mapGlOptions to override theme and API urls:

<BaseMap
  mapGLOptions={{
    mapboxApiUrl: "http://localhost:3456/tiles",
    mapStyle: "mapbox://styles/disaster"
  }}
/>

Bundling script for the offline server and game

This is handled with docker-compose.

Both this repo and the Civic repo continuously deliver docker images to Hack Oregon's Elastic Container Registry. The docker-compose.yml file in this repo references those images by name, but expects you to provide the registry url.

Distribution script for the offline server and game

MacOS & Linux

To make it as easy as possible to get and start the docker images, the get-game.sh script is available on S3. Running the latest build of the game and web server takes three steps:

  1. Download the script
$ curl -sO https://hacko-cdn.s3-us-west-2.amazonaws.com/earthquake-heroes/get-game.sh
  1. Edit the script to provide values for the AWS environment variables. If you are meant to run the game, you'll have credentials.

  2. Run the script

$ bash get-game.sh

Windows

To make it as easy as possible to get and start the docker images, the get-game.ps1 powershell script is available on S3. Running the latest build of the game and web server takes three steps:

  1. Download the scripts
PS:\> curl -Uri https://hacko-cdn.s3-us-west-2.amazonaws.com/earthquake-heroes/get-game.ps1 -OutFile get-game.ps1
PS:\> curl -Uri https://hacko-cdn.s3-us-west-2.amazonaws.com/earthquake-heroes/start-game.ps1 -OutFile start-game.ps1
  1. Edit the script to provide values for the AWS environment variables. If you are meant to run the game, you'll have credentials.

  2. Run the get-game script to pull docker containers

PS:\> & .\get-game.ps1
  1. Run the start-game script to run the tileserver and the game!
PS:\> & .\start-game.ps1

⚠️ Note! These scripts require Docker, Git and the AWS CLI to be installed already.

About

A data pipeline, a tile and api server, and a distribution script

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published