diff --git a/README.md b/README.md index 3d79602..6e29704 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,6 @@ class CityTileView(MVTView): # in your urls file -from django.urls import path from yourapp import views urlpatterns = [ @@ -136,246 +135,6 @@ urlpatterns = [ ] ``` -#### Use TileJSON and multiple domains: - -```python -# in your view file - -from django.urls import reverse - -from vectortiles.views import MVTView, TileJSONView -from yourapp.vector_layers import CityVectorLayer, CityCentroidVectorLayer - - -class CityTileBaseView: - layer_classes = [CityVectorLayer, CityCentroidVectorLayer] - - -class CityTileView(CityTileBaseView, MVTView): - pass - - -class CityTileJSONView(CityTileBaseView, TileJSONView): - """Simple model TileJSON View""" - - name = "My city dataset" - attribution = "@JEC Data" - description = "My vity dataset" - - -# in your urls file -from django.urls import path -from yourapp import views - -urlpatterns = [ - ... - CityTileView.get_url(), # serve tiles at default /tiles/// - CityTileJSONView.get_url(name="city-tilejson"), # serve tilejson at /tiles.json - ... -] - -# if you want to use multiple domains, you can set the allowed hosts and vector tiles urls in your settings file -# in your settings file -ALLOWED_HOSTS = [ - "a.tiles.xxxx", - "b.tiles.xxxx", - "c.tiles.xxxx", - ... -] - -VECTOR_TILES_URLS = [ - "https://a.tiles.xxxx", - "https://b.tiles.xxxx", - "https://c.tiles.xxxx", -] - -``` - - - Now, any tile requested at http://you_url/tiles/{z}/{x}/{y} that intersects a city will return a vector tile with two layers, `cities` with border geometries and `city_code` property, and `city_centroïds` with center geometry and `city_name` property. -```html - - - - - - - City map - - - - -
- - - - - -``` - -#### Usage with Django Rest Framework - -django-vectortiles can be used with DRF if `renderer_classes` of the view is overridden (see [DRF docs](https://www.django-rest-framework.org/api-guide/renderers/#custom-renderers)). Simply use the right BaseMixin and action on viewsets, or directly a GET method in an APIView. See [documentation](https://django-vectortiles.readthedocs.io/en/latest/usage.html#django-rest-framework) for more details. - -#### Development - -##### With docker and docker-compose - -Copy ```.env.dist``` to ```.env``` and fill ```SECRET_KEY``` and ```POSTGRES_PASSWORD``` - -```bash -docker-compose build -# docker-compose up -docker-compose run /code/venv/bin/python ./manage.py test -``` - -##### Local - -* Install python and django requirements (python 3.8+, django 3.2+) -* Install geodjango requirements -* Have a postgresql / postgis 2.4+ enabled database -* Use a virtualenv - -```bash -pip install .[dev] -U -``` +Read full documentation for examples, as multiple layers, cache policy, mapblibre integration, etc. \ No newline at end of file diff --git a/docs/development.rst b/docs/development.rst new file mode 100644 index 0000000..233d457 --- /dev/null +++ b/docs/development.rst @@ -0,0 +1,26 @@ +DEVELOPMENT +=========== + +With docker and docker-compose +****************************** + +Copy ```.env.dist``` to ```.env``` and fill ```SECRET_KEY``` and ```POSTGRES_PASSWORD``` + +.. code-block:: bash + + docker-compose build + # docker-compose up + docker-compose run /code/venv/bin/python ./manage.py test + + +Local +***** + +* Install python and django requirements (python 3.8+, django 3.2+) +* Install geodjango requirements +* Have a postgresql / postgis 2.4+ enabled database +* Use a virtualenv + +.. code-block:: bash + + pip install .[dev] -U diff --git a/docs/usage.rst b/docs/usage.rst index dfc3467..4121dec 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -10,6 +10,7 @@ Then, you need to describe how your data will be embed in tiles. Start by creating vector layers for your data... .. code-block:: python + # in your app models.py from django.contrib.gis.db import models @@ -277,5 +278,163 @@ then use http://your-domain/features/tiles/{z}/{x}/{y}.pbf MapLibre Example **************** -.. literalinclude:: ../test_vectortiles/test_app/templates/index.html - :language: html +.. code-block:: html + + + + + + + + MapBox / MapLibre example + + + + +
+ + + + + + + +Cache policy +************ \ No newline at end of file diff --git a/test_vectortiles/test_app/templates/index.html b/test_vectortiles/test_app/templates/index.html index b9223c5..096cf1c 100644 --- a/test_vectortiles/test_app/templates/index.html +++ b/test_vectortiles/test_app/templates/index.html @@ -13,13 +13,11 @@ } - {# #}
-{##}