A tile server for use with the versioned datastore: https://github.com/NaturalHistoryMuseum/ckanext-versioned-datastore.
Currently the best way to install is to:
- Clone the repo
- Inside your clone, create a python (>=3.5) virtualenv:
mkdir venv virtualenv venv -p python3.5 source venv/bin/activate
- Install the requirements into your virtualenv:
pip install -r requirements.txt
And that's it.
The main Flask app is located in maps/web.py
and should be run under uwsgi.
From within the virtualenv, simply run:
uwsgi --ini uwsgi.ini.example
to start the server with the default app and uwsgi settings.
To modify the app settings, create a file containing the overrides and an environment variable called maps_config
that contains the full path to that file.
For example:
export maps_config=/home/josh/work/versioned-datastore-tile-server/maps.cfg
See the Configuration section below for more information about the format of this file and the available settings.
Flask comes with it's own simple server for development work and the maps/web.py
module is setup to start this when it is run.
Hence, for test and development purposes only you can start the server with:
python -m maps.web.py
With the default settings, this will start a server running at 0.0.0.0:4000
.
For production you should run the uwsgi
server, probably behind nginx
.
It is recommended that you use a service like supervisor
to control the uwsgi server.
The app can be configured using a configuration file whose absolute path is stored in an environment variable called maps_config
.
Currently the available options are:
Name | Expected type | Description | Default |
---|---|---|---|
ELASTICSEARCH_HOSTS |
a list of strings | Each element in the list should be the full root HTTP(S) address of an Elasticsearch server | ['http://localhost:9200'] |
ELASTICSEARCH_SNIFF_ON_START |
boolean | Corresponds to the Elasticsearch client's sniff_on_start parameter |
True |
ELASTICSEARCH_SNIFF_ON_CONNECTION_FAIL |
boolean | Corresponds to the Elasticsearch client's sniff_on_connection_fail parameter |
True |
ELASTICSEARCH_SNIFFER_TIMEOUT |
integer | Corresponds to the Elasticsearch client's sniffer_timeout parameter |
60 |
ELASTICSEARCH_SNIFF_TIMEOUT |
integer | Corresponds to the Elasticsearch client's sniff_timeout parameter |
10 |
ELASTICSEARCH_HTTP_COMPRESS |
boolean | Corresponds to the Elasticsearch client's http_compress parameter |
False |
ELASTICSEARCH_TIMEOUT |
integer | Corresponds to the Elasticsearch client's timeout parameter |
60 |
The configuration file can be a Python file. It is read using Flask's from_envvar
function.
All 3 map styles have configuration options available. The defaults are hard coded and are intended to be modified at the request level, not the main app config level (though this could change, it just seemed sensible when creating the project).
Name | Description | Default |
---|---|---|
indexes |
The Elasticsearch indexes that should be searched to produce the points in the rendered tile | |
search |
The Elasticsearch query that should be used to limit the data. This shouldn't include the tile limiting geo-query, but simply any other query that should be used in combination with the queries and filters added by the server. This should be a stringified JSON object | |
query |
A gzipped, base64 encoded, JSON string containing the indexes (key: indexes ) to search and the search too perform (key: search ) |
|
style |
The style of map tile to render, must be either plot , gridded or heatmap |
plot |
The indexes to be searched is the only required variable and must be set either through indexes
itself or in query
.
Requests should be directed at http(s)://<domain>/{z}/{x}/{y}.{request_type}
where:
Name | Description |
---|---|
z |
The z value of the tile |
x |
The x value of the tile |
y |
The y value of the tile |
request_type |
The type of response to get, either png or grid.json |
For example: http://localhost:5000/0/0/0.png
or http://localhost:5000/0/0/0.grid.json
Make sure you've installed the test requirements into your virtualenv - pip install -r tests/requirements.txt
, then:
- To run the tests against the python version installed in your virtualenv, run
pytest
- To run the tests against the python version installed in your virtualenv and get a coverage report too, run
pytest --cov=maps