Skip to content

Commit

Permalink
Merge pull request #865 from MTES-MCT/feat-zone-construite
Browse files Browse the repository at this point in the history
Supprime les modèles inutilisés de Zone Contruite
  • Loading branch information
alexisig authored Feb 10, 2025
2 parents e231c11 + e84191a commit 88edd6d
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 142 deletions.
17 changes: 0 additions & 17 deletions airflow/dags/update_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def copy_table_from_dw_to_app(
"copy_public_data_communesol",
"copy_public_data_ocsgediff",
"copy_public_data_communediff",
"copy_public_data_zoneconstruite",
"copy_public_data_zoneurba",
"copy_public_data_epci",
"copy_public_data_scot",
Expand Down Expand Up @@ -236,21 +235,6 @@ def copy_public_data_communediff(**context):
],
)

@task.python
def copy_public_data_zoneconstruite(**context):
return copy_table_from_dw_to_app(
from_table="public_for_app.for_app_zoneconstruite",
to_table="public.public_data_zoneconstruite",
use_subset=context["params"]["use_subset"],
subset_where=f"mpoly && ({context['params']['subset_geom']})",
environment=context["params"]["environment"],
btree_index_columns=[
["millesime"],
["year"],
["departement"],
],
)

@task.python
def copy_public_data_zoneurba(**context):
return copy_table_from_dw_to_app(
Expand Down Expand Up @@ -484,7 +468,6 @@ def copy_public_data_branch(**context):
copy_public_data_communesol(),
copy_public_data_ocsgediff(),
copy_public_data_communediff(),
copy_public_data_zoneconstruite(),
copy_public_data_zoneurba(),
copy_public_data_epci(),
copy_public_data_scot(),
Expand Down

This file was deleted.

18 changes: 0 additions & 18 deletions airflow/include/sql/sparte/models/for_app/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,6 @@ models:
- relationships:
to: ref('for_app_departement')
field: source_id
- name: for_app_zoneconstruite
columns:
- name: mpoly
data_tests:
- not_null
- is_valid_geom
- is_not_empty_geom
- is_srid_4326
- name: srid_source
data_tests:
- not_null
- accepted_values: *valid_srids
- name: departement
data_tests:
- not_null
- relationships:
to: ref('for_app_departement')
field: source_id
- name: for_app_zoneurba
columns:
- name: checksum
Expand Down
8 changes: 0 additions & 8 deletions public_data/admin/OcsgeZoneConstruiteAdmin.py

This file was deleted.

2 changes: 0 additions & 2 deletions public_data/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from .OcsgeCommuneDiffAdmin import OcsgeCommuneDiffAdmin
from .OcsgeCommuneSolAdmin import OcsgeCommuneSolAdmin
from .OcsgeDiffAdmin import OcsgeDiffAdmin
from .OcsgeZoneConstruiteAdmin import OcsgeZoneConstruiteAdmin
from .RegionAdmin import RegionAdmin
from .ScotAdmin import ScotAdmin
from .SudocuhAdmin import SudocuhAdmin
Expand All @@ -21,7 +20,6 @@
"OcsgeCommuneDiffAdmin",
"OcsgeCommuneSolAdmin",
"OcsgeDiffAdmin",
"OcsgeZoneConstruiteAdmin",
"RegionAdmin",
"ScotAdmin",
"SudocuhAdmin",
Expand Down
2 changes: 1 addition & 1 deletion public_data/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
from .demography import * # noqa: F401, F403
from .gpu import * # noqa: F401, F403
from .mixins import * # noqa: F401, F403
from .ocsge import ArtificialArea, Ocsge, OcsgeDiff, ZoneConstruite # noqa: F401, F403
from .ocsge import ArtificialArea, Ocsge, OcsgeDiff # noqa: F401, F403
from .sudocuh import Sudocuh, SudocuhEpci # noqa: F401
from .urbanisme import * # noqa: F401, F403
31 changes: 0 additions & 31 deletions public_data/models/ocsge.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,34 +138,3 @@ class Meta:
models.Index(fields=["city"]),
models.Index(fields=["departement"]),
]


class ZoneConstruite(DataColorationMixin, models.Model):
id = models.TextField("ID", primary_key=True)
id_source = models.CharField("ID Source", max_length=200)
millesime = models.CharField("Millesime", max_length=200)
mpoly = models.MultiPolygonField(srid=4326)
srid_source = models.IntegerField(
"SRID",
choices=SRID.choices,
default=SRID.LAMBERT_93,
)

# calculated
year = models.IntegerField(
"Année",
validators=[MinValueValidator(2000), MaxValueValidator(2050)],
)
surface = models.DecimalField("surface", max_digits=15, decimal_places=4)
departement = models.CharField("Département", max_length=15)

objects = IntersectManager()

class Meta:
managed = False
verbose_name = "OCSGE - Zone construite"
verbose_name_plural = verbose_name
indexes = [
models.Index(fields=["year"]),
models.Index(fields=["departement"]),
]
12 changes: 0 additions & 12 deletions public_data/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,6 @@ class Meta:
model = models.Departement


class ZoneConstruiteSerializer(serializers.GeoFeatureModelSerializer):
class Meta:
fields = (
"id",
"id_source",
"millesime",
"year",
)
model = models.ZoneConstruite
geo_field = "mpoly"


class ZoneUrbaSerializer(serializers.GeoFeatureModelSerializer):
class Meta:
fields = (
Expand Down
1 change: 0 additions & 1 deletion public_data/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
router.register(r"ocsge/general", views.OcsgeViewSet)
router.register(r"ocsge/diff", views.OcsgeDiffViewSet)
router.register(r"ocsge/diff-centroids", views.OcsgeDiffCentroidViewSet, basename="ocsgeDiffCentroids")
router.register(r"ocsge/zones-construites", views.ZoneConstruiteViewSet)
router.register(r"ocsge/zones-artificielles", views.ArtificialAreaViewSet)
router.register(r"departements", views.DepartementViewSet)
router.register(r"referentiel/zones-urbaines", views.ZoneUrbaViewSet)
Expand Down
34 changes: 0 additions & 34 deletions public_data/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,40 +315,6 @@ class OcsgeDiffCentroidViewSet(OcsgeDiffViewSet):
optimized_geo_field = "st_AsGeoJSON(St_Centroid(o.mpoly))"


class ZoneConstruiteViewSet(OnlyBoundingBoxMixin, ZoomSimplificationMixin, OptimizedMixins, DataViewSet):
queryset = models.ZoneConstruite.objects.all()
serializer_class = serializers.ZoneConstruiteSerializer
optimized_fields = {
"id": "id",
"surface": "surface",
"year": "year",
}

def get_params(self, request):
bbox = request.query_params.get("in_bbox").split(",")
params = list(map(float, bbox))
if "project_id" in request.query_params:
params.append(request.query_params.get("project_id"))
params.append(int(request.query_params.get("year")))
return params

def get_sql_from(self):
sql_from = [
f"FROM {self.queryset.model._meta.db_table} o",
"INNER JOIN (SELECT ST_MakeEnvelope(%s, %s, %s, %s, 4326) as box) as b",
"ON ST_Intersects(o.mpoly, b.box)",
]
if "project_id" in self.request.query_params:
sql_from += [
"INNER JOIN (SELECT ST_Union(mpoly) as geom FROM project_emprise WHERE project_id = %s) as t",
"ON ST_Intersects(o.mpoly, t.geom)",
]
return " ".join(sql_from)

def get_sql_where(self):
return "WHERE o.year = %s"


class ArtificialAreaViewSet(OnlyBoundingBoxMixin, ZoomSimplificationMixin, OptimizedMixins, DataViewSet):
queryset = models.ArtificialArea.objects.all()
serializer_class = serializers.OcsgeDiffSerializer
Expand Down

0 comments on commit 88edd6d

Please sign in to comment.