Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
submarcos committed May 24, 2023
1 parent 3510a3b commit 380385d
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 34 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ class Feature(models.Model):
#### Simple Example:

```python
from yourapp.models import Feature

# in a vector_layers.py file
from vectortiles import VectorLayer
from yourapp.models import Feature


class FeatureVectorLayer(VectorLayer):
Expand All @@ -58,9 +59,10 @@ class FeatureVectorLayer(VectorLayer):

# in your view file

from vectortiles.views import MVTView
from yourapp.vector_layers import FeatureVectorLayer

from vectortiles.views import MVTView


class FeatureTileView(MVTView):
layers = [FeatureVectorLayer()]
Expand All @@ -70,7 +72,6 @@ class FeatureTileView(MVTView):
from django.urls import path
from yourapp import views


urlpatterns = [
...
path('tiles/<int:z>/<int:x>/<int:y>', views.FeatureTileView.as_view(), name="feature-tile"),
Expand All @@ -83,9 +84,10 @@ urlpatterns = [
```python
# in your view file

from vectortiles.views import TileJSONView
from django.urls import reverse

from vectortiles.views import TileJSONView


class FeatureTileJSONView(TileJSONView):
"""Simple model TileJSON View"""
Expand Down
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

# -- Path setup --------------------------------------------------------------

import datetime

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
import datetime

sys.path.insert(0, os.path.abspath('..'))

Expand Down
1 change: 1 addition & 0 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import sys


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_vectortiles.settings')
try:
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env python

import os
from setuptools import setup, find_packages

from setuptools import find_packages, setup

HERE = os.path.abspath(os.path.dirname(__file__))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("test_app", "0005_alter_feature_date"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

dependencies = [
("test_app", "0006_auto_20230209_0933"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
("test_app", "0007_fulldatafeature_fulldatalayer"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("test_app", "0008_alter_fulldatafeature_properties"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
("test_app", "0009_alter_fulldatalayer_options"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("test_app", "0010_fulldatafeature_feature_properties_gin"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("test_app", "0011_fulldatalayer_include_in_tilejson"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("test_app", "0012_fulldatalayer_update_datetime"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
("test_app", "0013_alter_fulldatalayer_update_datetime"),
]
Expand Down
3 changes: 2 additions & 1 deletion test_vectortiles/test_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

from test_vectortiles.test_app.models import Feature, FullDataLayer
from test_vectortiles.test_app.vt_layers import (
CityCentroidVectorLayer,
FeatureLayerFilteredByDateVectorLayer,
FeatureVectorLayer,
FullDataFeatureVectorLayer, CityCentroidVectorLayer,
FullDataFeatureVectorLayer,
)
from vectortiles.mixins import BaseVectorTileView
from vectortiles.rest_framework.renderers import MVTRenderer
Expand Down
53 changes: 35 additions & 18 deletions test_vectortiles/test_app/vt_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.db.models.functions import Cast
from django.utils.text import slugify

from test_vectortiles.test_app.models import Feature, Layer, FullDataLayer
from test_vectortiles.test_app.models import Feature, FullDataLayer, Layer
from vectortiles import VectorLayer


Expand Down Expand Up @@ -53,8 +53,6 @@ def get_description(self):
return self.instance.description




class FeatureLayerFilteredByDateVectorLayer(VectorLayer):
name = "features"
tile_fields = ("name",)
Expand All @@ -80,13 +78,16 @@ def get_tile_fields(self):
"chef_lieu_departement",
)
elif self.instance.name == "troncon_hydrographique":
return ("nom", )
return ("nom",)
elif self.instance.name == "parc_ou_reserve":
return ("nom", "nature")
elif self.instance.name == "departement":
return ("nom", "code_insee", "code_insee_region")
elif self.instance.name == "region":
return ("nom", "code_insee",)
return (
"nom",
"code_insee",
)
elif self.instance.name == "troncon_voie_ferree":
return ("nature", "voies", "etat", "position")
elif self.instance.name == "surface_hydrographique":
Expand Down Expand Up @@ -180,23 +181,39 @@ def get_vector_tile_queryset(self, z, x, y):
),
)
elif self.instance.name == "troncon_hydrographique":
qs = qs.exclude(properties__contains={"position_par_rapport_au_sol": "-1", })
qs = qs.annotate(nom=KeyTextTransform("cpx_toponyme_de_cours_d_eau", "properties"))
qs = qs.exclude(
properties__contains={
"position_par_rapport_au_sol": "-1",
}
)
qs = qs.annotate(
nom=KeyTextTransform("cpx_toponyme_de_cours_d_eau", "properties")
)
elif self.instance.name == "parc_ou_reserve":
qs = qs.annotate(nom=KeyTextTransform("toponyme", "properties"),
nature=KeyTextTransform("nature", "properties"))
qs = qs.annotate(
nom=KeyTextTransform("toponyme", "properties"),
nature=KeyTextTransform("nature", "properties"),
)
elif self.instance.name == "departement":
qs = qs.annotate(nom=KeyTextTransform("nom_officiel", "properties"),
code_insee=KeyTextTransform("code_insee", "properties"),
code_insee_region=KeyTextTransform("code_insee_de_la_region", "properties"))
qs = qs.annotate(
nom=KeyTextTransform("nom_officiel", "properties"),
code_insee=KeyTextTransform("code_insee", "properties"),
code_insee_region=KeyTextTransform(
"code_insee_de_la_region", "properties"
),
)
elif self.instance.name == "region":
qs = qs.annotate(nom=KeyTextTransform("nom_officiel", "properties"),
code_insee=KeyTextTransform("code_insee", "properties"))
qs = qs.annotate(
nom=KeyTextTransform("nom_officiel", "properties"),
code_insee=KeyTextTransform("code_insee", "properties"),
)
elif self.instance.name == "troncon_voie_ferree":
qs = qs.annotate(nature=KeyTextTransform("nature", "properties"),
voies=KeyTextTransform("nombre_de_voies", "properties"),
etat=KeyTextTransform("etat_de_l_objet", "properties"),
position=KeyTextTransform("position_par_rapport_au_sol", "properties"))
qs = qs.annotate(
nature=KeyTextTransform("nature", "properties"),
voies=KeyTextTransform("nombre_de_voies", "properties"),
etat=KeyTextTransform("etat_de_l_objet", "properties"),
position=KeyTextTransform("position_par_rapport_au_sol", "properties"),
)
elif self.instance.name == "surface_hydrographique":
qs = qs.annotate(nature=KeyTextTransform("nature", "properties"))
elif self.instance.name == "terrain_de_sport":
Expand Down

0 comments on commit 380385d

Please sign in to comment.