## Intro
You've got a GIS dataset, you want to serve a map to visualize it ?
-
A GIS dataset. Here's one
-
A postGIS database to store it.
-
A map server, in order to serve a visible map. We'll use Mapnik
-
A tile server, in order to send the geographic data. We'll use Tilestache.
- I'm running Ubuntu 14.04 64bit.
-
Let's install postgreSQL : tutorial here
- PostgreSQL is a database.
-
Let's install postGIS : tutorial here
- Postgis is a plugin for PostgreSQL that handle geolocalised data
-
Let's install ogr2ogr : tutorial here
- ogr2ogr allows to convert geoJSON, topoJSON, and much more to postGIS
-
Create a PostGIS data base
-
Install the legacy.sql as done here
- Some of TileStache SQL requests are outdated
-
Add your dataset to the database : here
## Part 2 : TileStache
-
Install TileStache : Modified version here, branch zoomInVecTile
-
Install the gdal library :
sudo apt-get install python-gdal
-
Edit the
tilestache.cfg
file.- Add a new layer connected to your database : (in
layers
)
- Add a new layer connected to your database : (in
"NewLayerName": { "allowed origin": "*", "provider": { "name": "vector", "driver": "PostGIS", "parameters": { "dbname": "database Name", "host": "Where the db is hosted (localhost for example)", "user": "the user to access the database (postgres by default)", "password": "its password", "query": "A SQL query returning at least coordinates under the name geometry" } } } ```
-
Install Mapnik 2.1 : see this issue
-
Install shapely :
sudo apt-get install python-shapely
-
Run the default TileStache server : tilestache/scripts/tilestache-server.py (python2)
-
Go on the URL localhost:8080/NewLayerName/{zoom}/{X}/{Y}.geojson
-
clone the cartoDB-postgresql repo : here warning : copyright LICENSE
-
copy the scripts-available in your project folder
-
Add the CDB_Hexagon.sql to your database :
psql -d myDataBaseName -a -f CDB_Hexagon.sql
-
Add the CDB_XYZ.sql to your database :
psql -d myDataBaseName -a -f CDB_XYZ.sql
-
Make a sql query that makes hexagons. Look at the tilestache.cfg and hexagon_request.pgsql
## Part 3.5 : Bonus : Frontend
-
Install node.js
-
Clone this repository
-
Run
npm install
-
Run
node index.js -l trees
-
Go on your browser, on this url : localhost:3000
## Part 4 : Speedups
- Example : caching on disk. Add this to the tilestache.cfg :
"cache":
{
"name": "Disk",
"path": "./cache/",
"umask": "0022",
"dirs": "portable",
"gzip": ["xml", "json"]
},
-
Install Gunicorn, for example :
pip install gunicorn
-
Run TileStache with
gunicorn "TileStache:WSGITileServer('../tilestache.cfg')"
instead of the scripttilestache-server.py
-
For the frontend, use
node index.js -p 8000 -l trees
- Install plpython :
sudo apt-get install postgresql-plpython-9.6