Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

stamen/toner-carto

Folders and files

NameName
Last commit message
Last commit date
Jul 18, 2014
Jul 18, 2014
Jul 25, 2014
Jul 8, 2014
Aug 12, 2014
Aug 25, 2014
Jul 17, 2014
Aug 25, 2014
Aug 1, 2014
Aug 7, 2014
Aug 25, 2014
Aug 26, 2014
Jul 10, 2014
Jul 3, 2014
Aug 20, 2014
Aug 26, 2014
Aug 21, 2014
Aug 19, 2014
Aug 21, 2014
Aug 20, 2014
Aug 20, 2014
Jul 14, 2014
Aug 20, 2014
Aug 20, 2014
Jul 10, 2014
Aug 20, 2014
Jul 10, 2014
Aug 20, 2014
Aug 11, 2014
Aug 20, 2014
Aug 26, 2014
Aug 13, 2014

Repository files navigation

Developing

  • Install TileMill 1 from HEAD (this has the latest Mapnik): github.com/mapbox/tilemill
  • Install Imposm 3: github.com/omniscale/imposm3
  • Clone this repo
  • Run make install, this will symlink the project into your TM1 project directory
  • run make land to get OSM-derived land polygons
  • run sh download_natural_earth_data.sh to get Natural Earth data
  • Download an OSM pbf extract and do an import. You should use the make task ca as an example.
  • Start TileMill with npm start from the tilemill repo

Deploying

Locally

npm install
npm start

EC2

export AWS_ACCESS_KEY=...
export AWS_SECRET_KEY=...

make baseami
BASEAMI=... make ami

ec2-run-instances <AMI> -t m1.small -z us-east-1d -k <keypair> -p EC2_Instance

Docker

# (locally)
docker build --rm -t mojodna/toner:<version> .
docker run -e "DATABASE_URL=postgres://.../..." -p 80:8080 <image id>
docker tag <image id> mojodna/toner:latest
docker push mojodna/toner:latest

# (on a new EC2 instance using Stamen's Docker AMI)
sudo docker pull mojodna/toner:latest
sudo docker ps
sudo docker stop <container>
sudo docker run --env-file=env -p 80:8080 -d mojodna/toner:latest

Docker with a Data Volume

The advantage of a data volume is that it allows Natural Earth shapefiles to live in a separate contain that doesn't update regularly, reducing the size of the application container (and the number of intermediate layers).

# start the data volume
docker run --name data -v /app/shp bdon/naturalearth:0.0.4

# start the Toner container
docker run --volumes-from data --env-file=env -p 80:8080 -d mojodna/toner:latest

Useful SQL snippets

CREATE OR REPLACE FUNCTION generalize(geom geometry, zoom int) RETURNS geometry
AS $$
BEGIN
  -- generalize to 1/4 pixel (assuming 256x256 tiles)
  RETURN ST_Simplify(geom, 20037508.34 * 2 / 2^(9 + zoom));
END
$$ LANGUAGE plpgsql IMMUTABLE;

SELECT 'GRANT SELECT ON ' || quote_ident(schemaname) || '.' || quote_ident(viewname) || ' TO render;'
FROM pg_views
WHERE schemaname = 'public';
GRANT SELECT ON ALL TABLES IN SCHEMA public TO render;