Skip to content

Commit

Permalink
MAJ données géographiques 2024 (#4291)
Browse files Browse the repository at this point in the history
* Communes script: 2024

* update departements 2024

* Update 2024 EPCI

* Move disabling DB logs from dev to dev.secret.template
  • Loading branch information
vdegove authored Nov 12, 2024
1 parent 42eaded commit b4def25
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
15 changes: 13 additions & 2 deletions apps/transport/lib/mix/tasks/transport/import_communes.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ defmodule Mix.Tasks.Transport.ImportCommunes do
require Logger

# List of communes with their geometry, but lacking additional information
@communes_geojson_url "http://etalab-datasets.geo.data.gouv.fr/contours-administratifs/2023/geojson/communes-100m.geojson"
@communes_geojson_url "http://etalab-datasets.geo.data.gouv.fr/contours-administratifs/2024/geojson/communes-100m.geojson"
# List of official communes with additional information (population, arrondissement, etc.)
# See https://github.com/etalab/decoupage-administratif
@communes_url "https://unpkg.com/@etalab/decoupage-administratif@3.1.1/data/communes.json"
@communes_url "https://unpkg.com/@etalab/decoupage-administratif@4.0.0/data/communes.json"

@doc "Loads regions from the database and returns a list of tuples with INSEE code and id"
def regions_by_insee do
Expand Down Expand Up @@ -86,6 +86,17 @@ defmodule Mix.Tasks.Transport.ImportCommunes do
changeset_change_keys
end

# See https://github.com/datagouv/decoupage-administratif/issues/49 for the 3 communes below
# Population taken on Wikipedia, 2021
def insert_or_update_commune(%{"code" => "60694", "nom" => "Les Hauts-Talican"} = params, regions, geojsons),
do: insert_or_update_commune(params |> Map.put("population", 543), regions, geojsons)

def insert_or_update_commune(%{"code" => "85165", "nom" => "L'Oie"} = params, regions, geojsons),
do: insert_or_update_commune(params |> Map.put("population", 1259), regions, geojsons)

def insert_or_update_commune(%{"code" => "85212", "nom" => "Sainte-Florence"} = params, regions, geojsons),
do: insert_or_update_commune(params |> Map.put("population", 1333), regions, geojsons)

defp get_or_create_commune(insee) do
Commune
|> Repo.get_by(insee: insee)
Expand Down
4 changes: 2 additions & 2 deletions apps/transport/lib/mix/tasks/transport/import_departements.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ defmodule Mix.Tasks.Transport.ImportDepartements do
alias DB.{Departement, Repo}
require Logger

@departements_geojson_url "http://etalab-datasets.geo.data.gouv.fr/contours-administratifs/2023/geojson/departements-100m.geojson"
@departements_geojson_url "http://etalab-datasets.geo.data.gouv.fr/contours-administratifs/2024/geojson/departements-100m.geojson"
# See https://github.com/etalab/decoupage-administratif
@departements_url "https://unpkg.com/@etalab/decoupage-administratif@3.1.1/data/departements.json"
@departements_url "https://unpkg.com/@etalab/decoupage-administratif@4.0.0/data/departements.json"

def insert_or_update_departement(
%{
Expand Down
4 changes: 2 additions & 2 deletions apps/transport/lib/mix/tasks/transport/import_epci.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ defmodule Mix.Tasks.Transport.ImportEPCI do
alias DB.{Commune, EPCI, Repo}
require Logger

@epci_file "https://unpkg.com/@etalab/decoupage-administratif@3.1.1/data/epci.json"
@epci_geojson_url "http://etalab-datasets.geo.data.gouv.fr/contours-administratifs/2023/geojson/epci-100m.geojson"
@epci_file "https://unpkg.com/@etalab/decoupage-administratif@4.0.0/data/epci.json"
@epci_geojson_url "http://etalab-datasets.geo.data.gouv.fr/contours-administratifs/2024/geojson/epci-100m.geojson"

def run(_params) do
Logger.info("Importing EPCIs")
Expand Down
3 changes: 0 additions & 3 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ config :oauth2, Datagouvfr.Authentication,
# Add a dev.secret.exs to use a real email provider
config :transport, Transport.Mailer, adapter: Swoosh.Adapters.Local

# Uncomment if you want to disable all logs from the database
# config :transport, DB.Repo, log: false

extra_config_file = Path.join(__DIR__, "#{config_env()}.secret.exs")

if File.exists?(extra_config_file) do
Expand Down
3 changes: 3 additions & 0 deletions config/dev.secret.template.exs
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ config :ex_aws,
host: "127.0.0.1",
port: 9000
]

# Uncomment if you want to disable all logs from the database
# config :transport, DB.Repo, log: false

0 comments on commit b4def25

Please sign in to comment.