Skip to content

Commit

Permalink
[Zones Administratives] Ajout des zones administratives (#1156)
Browse files Browse the repository at this point in the history
## Related Pull Requests & Issues
 
  - resolve #857 
  - resolve #861 
  - resolve #862 
  - resolve #863 
  - resolve #803
  • Loading branch information
thoomasbro committed Feb 1, 2024
2 parents 321d184 + 2f93a21 commit 3292be2
Show file tree
Hide file tree
Showing 31 changed files with 427 additions and 385 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ init-geoserver:
. ./infra/.env
set +a
echo ${PROJECT_NAME}
./infra/init/v0.01_geoserver_init_layers.sh
./infra/init/v0.02_geoserver_remove_unused_layers.sh
./infra/init/geoserver_init_layers.sh

.PHONY: register-pipeline-flows
register-pipeline-flows:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
CREATE TABLE IF NOT EXISTS public.transversal_sea_limit_areas (
id integer PRIMARY KEY,
geom public.geometry(MultiLineString,4326),
objnam character varying(254)
);
CREATE INDEX IF NOT EXISTS transversal_sea_limit_areas_geom_sidx ON public.transversal_sea_limit_areas USING gist (geom);


CREATE TABLE IF NOT EXISTS public.saltwater_limit_areas (
id integer PRIMARY KEY,
geom public.geometry(MultiLineString,4326),
objnam character varying(254)
);
CREATE INDEX IF NOT EXISTS saltwater_limit_areas_geom_sidx ON public.saltwater_limit_areas USING gist (geom);

CREATE TABLE IF NOT EXISTS public.territorial_seas (
ogc_fid integer PRIMARY KEY,
inspireid text,
type text,
descriptio text,
surface numeric,
reference text,
beginlifes text,
territory text,
country text,
agency text,
geom geometry(MultiPolygon,4326)
);
CREATE INDEX IF NOT EXISTS territorial_seas_geom_sidx ON public.territorial_seas USING gist (geom);

CREATE TABLE IF NOT EXISTS public.straight_baseline (
ogc_fid integer PRIMARY KEY,
inspireid text,
geom geometry(MultiLineString,4326),
nature text,
type text,
descriptio text,
reference text,
beginlifes text,
territory text,
country text,
agency text
);
CREATE INDEX IF NOT EXISTS straight_baseline_geom_sidx ON public.straight_baseline USING gist (geom);

CREATE TABLE IF NOT EXISTS public.low_water_line (
ogc_fid integer PRIMARY KEY,
gid integer,
gml_id text,
cdlaisseea numeric,
typelaisse text,
geom geometry(MultiLineString,4326)
);
111 changes: 105 additions & 6 deletions datascience/src/pipeline/flows/admin_areas.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@task(checkpoint=False)
def extract_3_miles_areas() -> pd.DataFrame:
return extract("monitorfish_local", "cross/3_miles_areas.sql")
return extract("monitorfish_local", "cross/cnsp/3_miles_areas.sql")


@task(checkpoint=False)
Expand All @@ -28,7 +28,7 @@ def load_3_miles_areas(

@task(checkpoint=False)
def extract_6_miles_areas() -> pd.DataFrame:
return extract("monitorfish_local", "cross/6_miles_areas.sql")
return extract("monitorfish_local", "cross/cnsp/6_miles_areas.sql")


@task(checkpoint=False)
Expand All @@ -47,7 +47,7 @@ def load_6_miles_areas(

@task(checkpoint=False)
def extract_12_miles_areas() -> pd.DataFrame:
return extract("monitorfish_local", "cross/12_miles_areas.sql")
return extract("monitorfish_local", "cross/cnsp/12_miles_areas.sql")


@task(checkpoint=False)
Expand All @@ -66,7 +66,7 @@ def load_12_miles_areas(

@task(checkpoint=False)
def extract_eez_areas() -> pd.DataFrame:
return extract("monitorfish_local", "cross/eez_areas.sql")
return extract("monitorfish_local", "cross/cnsp/eez_areas.sql")


@task(checkpoint=False)
Expand All @@ -85,7 +85,7 @@ def load_eez_areas(

@task(checkpoint=False)
def extract_aem_areas() -> pd.DataFrame:
return extract("monitorfish_local", "cross/aem_areas.sql")
return extract("monitorfish_local", "cross/cnsp/aem_areas.sql")


@task(checkpoint=False)
Expand All @@ -102,7 +102,7 @@ def load_aem_areas(aem_areas: pd.DataFrame):

@task(checkpoint=False)
def extract_departments_areas() -> pd.DataFrame:
return extract("monitorfish_local", "cross/departments_areas.sql")
return extract("monitorfish_local", "cross/cnsp/departments_areas.sql")


@task(checkpoint=False)
Expand All @@ -117,6 +117,89 @@ def load_departments_areas(departments_areas: pd.DataFrame):
)


@task(checkpoint=False)
def extract_saltwater_limit_areas() -> pd.DataFrame:
return extract("monitorfish_local", "cross/cnsp/saltwater_limit_areas.sql")


@task(checkpoint=False)
def load_saltwater_limit_areas(saltwater_limit_areas: pd.DataFrame):
load(
saltwater_limit_areas,
table_name="saltwater_limit_areas",
schema="public",
db_name="monitorenv_remote",
logger=prefect.context.get("logger"),
how="replace",
)


@task(checkpoint=False)
def extract_transversal_sea_limit_areas() -> pd.DataFrame:
return extract("monitorfish_local", "cross/cnsp/transversal_sea_limit_areas.sql")


@task(checkpoint=False)
def load_transversal_sea_limit_areas(transversal_sea_limit_areas: pd.DataFrame):
load(
transversal_sea_limit_areas,
table_name="transversal_sea_limit_areas",
schema="public",
db_name="monitorenv_remote",
logger=prefect.context.get("logger"),
how="replace",
)

@task(checkpoint=False)
def extract_territorial_seas() -> pd.DataFrame:
return extract("cacem_local", "cross/cacem/territorial_seas.sql")


@task(checkpoint=False)
def load_territorial_seas(territorial_seas: pd.DataFrame):
load(
territorial_seas,
table_name="territorial_seas",
schema="public",
db_name="monitorenv_remote",
logger=prefect.context.get("logger"),
how="replace",
)


@task(checkpoint=False)
def extract_straight_baseline() -> pd.DataFrame:
return extract("cacem_local", "cross/cacem/straight_baseline.sql")


@task(checkpoint=False)
def load_straight_baseline(straight_baseline: pd.DataFrame):
load(
straight_baseline,
table_name="straight_baseline",
schema="public",
db_name="monitorenv_remote",
logger=prefect.context.get("logger"),
how="replace",
)

@task(checkpoint=False)
def extract_low_water_line() -> pd.DataFrame:
return extract("cacem_local", "cross/cacem/low_water_line.sql")


@task(checkpoint=False)
def load_low_water_line(low_water_line: pd.DataFrame):
load(
low_water_line,
table_name="low_water_line",
schema="public",
db_name="monitorenv_remote",
logger=prefect.context.get("logger"),
how="replace",
)


with Flow("Administrative areas") as flow:

three_miles_areas = extract_3_miles_areas()
Expand All @@ -137,4 +220,20 @@ def load_departments_areas(departments_areas: pd.DataFrame):
departments_areas = extract_departments_areas()
load_departments_areas(departments_areas)

saltwater_limit_areas = extract_saltwater_limit_areas()
load_saltwater_limit_areas(saltwater_limit_areas)

transversal_sea_limit_areas = extract_transversal_sea_limit_areas()
load_transversal_sea_limit_areas(transversal_sea_limit_areas)

territorial_seas = extract_territorial_seas()
load_territorial_seas(territorial_seas)

straight_baseline = extract_straight_baseline()
load_straight_baseline(straight_baseline)

low_water_line = extract_low_water_line()
load_low_water_line(low_water_line)


flow.file_name = Path(__file__).name
4 changes: 2 additions & 2 deletions datascience/src/pipeline/flows/amp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def extract_local_hashes() -> pd.DataFrame:
pd.DataFrame: GeoDataFrame of amp ids + row_hash
"""
return extract(
db_name="cacem_local", query_filepath="cross/amp_hashes.sql"
db_name="cacem_local", query_filepath="cross/cacem/amp_hashes.sql"
)


Expand Down Expand Up @@ -102,7 +102,7 @@ def delete(ids_to_delete: set):
def extract_new_amp(ids_to_upsert: set) -> pd.DataFrame:
return extract(
"cacem_local",
"cross/amp.sql",
"cross/cacem/amp.sql",
params={"ids": tuple(ids_to_upsert)},
)

Expand Down
2 changes: 1 addition & 1 deletion datascience/src/pipeline/flows/facade_areas.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def extract_facade_areas() -> pd.DataFrame:
"""

return extract(
db_name="monitorfish_local", query_filepath="cross/facade_areas.sql"
db_name="monitorfish_local", query_filepath="cross/cnsp/facade_areas.sql"
)


Expand Down
4 changes: 2 additions & 2 deletions datascience/src/pipeline/flows/regulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def extract_local_hashes() -> pd.DataFrame:
pd.DataFrame: GeoDataFrame of regulation ids + row_hash
"""
return extract(
db_name="cacem_local", query_filepath="cross/regulations_hashes.sql"
db_name="cacem_local", query_filepath="cross/cacem/regulations_hashes.sql"
)


Expand Down Expand Up @@ -102,7 +102,7 @@ def delete(ids_to_delete: set):
def extract_new_regulations(ids_to_update: set) -> pd.DataFrame:
return extract(
"cacem_local",
"cross/regulations.sql",
"cross/cacem/regulations.sql",
params={"ids": tuple(ids_to_update)},
)

Expand Down
2 changes: 1 addition & 1 deletion datascience/src/pipeline/flows/semaphores.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def extract_semaphores() -> pd.DataFrame:
pd.DataFrame: GeoDataFrame of Semaphores
"""

return extract(db_name="cacem_local", query_filepath="cross/semaphore.sql")
return extract(db_name="cacem_local", query_filepath="cross/cacem/semaphore.sql")


@task(checkpoint=False)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SELECT
ogc_fid,
gid,
gml_id,
cdlaisseea,
typelaisse,
geom
FROM prod.low_water_line;
14 changes: 14 additions & 0 deletions datascience/src/pipeline/queries/cross/cacem/straight_baseline.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
SELECT
ogc_fid,
nature,
type,
descriptio,
reference,
beginlifes,
territory,
country,
agency,
inspireid,
geom
FROM prod.straight_baseline
WHERE geom IS NOT NULL;
14 changes: 14 additions & 0 deletions datascience/src/pipeline/queries/cross/cacem/territorial_seas.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
SELECT
ogc_fid,
inspireid,
type,
descriptio,
surface,
reference,
beginlifes,
territory,
country,
agency,
geom
FROM prod.territorial_seas
WHERE geom IS NOT NULL
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT
id,
geom,
objnam
FROM prod.saltwater_limit_areas
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT
id,
geom,
objnam
FROM prod.transversal_sea_limit_areas

This file was deleted.

Loading

0 comments on commit 3292be2

Please sign in to comment.