Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Zones administratives] Ajout de la zone de limite à 300 mètres pour La Réunion #2038

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TABLE public.three_hundred_meters_areas
(
id SERIAL PRIMARY KEY,
geom geometry(MultiLineString,4326),
secteur character varying
);

CREATE INDEX sidx_three_hundred_meters_areas_geom ON public.three_hundred_meters_areas USING gist (geom);
35 changes: 35 additions & 0 deletions datascience/src/pipeline/flows/three_hundred_meters_areas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import geopandas as gpd
import prefect
from pathlib import Path
from prefect import Flow, task
from src.pipeline.generic_tasks import extract, load


@task(checkpoint=False)
def extract_three_hundred_meters_areas() -> gpd.GeoDataFrame:
return extract(
db_name="cacem_local",
query_filepath="cross/cacem/three_hundred_meters_areas.sql",
backend="geopandas",
geom_col="geom",
crs=4326,
)


@task(checkpoint=False)
def load_three_hundred_meters_areas(three_hundred_meters_areas: gpd.GeoDataFrame):
load(
three_hundred_meters_areas,
table_name="three_hundred_meters_areas",
schema="public",
db_name="monitorenv_remote",
logger=prefect.context.get("logger"),
how="replace",
)


with Flow("300 meters areas") as flow:
three_hundred_meters_areas = extract_three_hundred_meters_areas()
load_three_hundred_meters_areas(three_hundred_meters_areas)

flow.file_name = Path(__file__).name
2 changes: 2 additions & 0 deletions datascience/src/pipeline/flows_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
regulations,
remove_broken_missions_resources_links,
semaphores,
three_hundred_meters_areas,
update_departments_and_facades,
)

Expand Down Expand Up @@ -97,6 +98,7 @@
regulations.flow,
remove_broken_missions_resources_links.flow,
semaphores.flow,
three_hundred_meters_areas.flow,
update_departments_and_facades.flow,
]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SELECT id, geom, secteur
FROM prod."300_metres";

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from geopandas.testing import assert_geodataframe_equal

from src.pipeline.flows.three_hundred_meters_areas import extract_three_hundred_meters_areas, load_three_hundred_meters_areas, flow
from src.read_query import read_query


def test_load_three_hundred_meters_areas(create_cacem_tables):
three_hundred_meters_areas = extract_three_hundred_meters_areas.run()
assert three_hundred_meters_areas.shape[0] == 1

load_three_hundred_meters_areas.run(three_hundred_meters_areas)
imported_three_hundred_meters_areas = read_query(
db="monitorenv_remote",
query="SELECT id, geom, secteur FROM three_hundred_meters_areas",
backend="geopandas",
geom_col="geom",
crs=4326,
)

assert_geodataframe_equal(three_hundred_meters_areas, imported_three_hundred_meters_areas)

def test_flow_three_hundred_meters_areas(create_cacem_tables):
state = flow.run()
assert state.is_successful()
1 change: 1 addition & 0 deletions frontend/src/domain/entities/administrativeLayers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Layers } from './layers/constants'

export const administrativeLayers = [
[Layers.THREE_HUNDRED_METERS],
[Layers.THREE_MILES],
[Layers.SIX_MILES],
[Layers.TWELVE_MILES],
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/domain/entities/layers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export enum MonitorEnvLayers {
STATIONS = 'STATIONS',
STRAIGHT_BASELINE = 'STRAIGHT_BASELINE',
TERRITORIAL_SEAS = 'TERRITORIAL_SEAS',
THREE_HUNDRED_METERS = 'THREE_HUNDRED_METERS',
THREE_MILES = 'THREE_MILES',
TRANSVERSAL_SEA_LIMIT_AREAS = 'TRANSVERSAL_SEA_LIMIT_AREAS',
TWELVE_MILES = 'TWELVE_MILES',
Expand Down Expand Up @@ -134,6 +135,11 @@ export const Layers: Record<MonitorEnvLayers, Layer> = {
name: 'Limites transversales de mer',
type: LayerType.ADMINISTRATIVE
},
[MonitorEnvLayers.THREE_HUNDRED_METERS]: {
code: 'three_hundred_meters_areas',
name: '300 mètres (hors estuaires)',
type: LayerType.ADMINISTRATIVE
},
[MonitorEnvLayers.THREE_MILES]: {
code: '3_miles_areas',
name: '3 Milles',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const getAdministrativeLayersStyle = (code: String) => {
text: `${feature.get(Layers.MARPOL.subZoneFieldKey) ? feature.get(Layers.MARPOL.subZoneFieldKey) : ''}`
})
})
case Layers.THREE_HUNDRED_METERS.code:
case Layers.THREE_MILES.code:
case Layers.SIX_MILES.code:
case Layers.TWELVE_MILES.code:
Expand Down
14 changes: 14 additions & 0 deletions infra/init/geoserver_init_layers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,17 @@ curl -v -u ${GEOSERVER_ADMIN_USER}:${GEOSERVER_ADMIN_PASSWORD} -X POST http://${
}
}
EOF

curl -v -u ${GEOSERVER_ADMIN_USER}:${GEOSERVER_ADMIN_PASSWORD} -X POST http://${GEOSERVER_HOST}:${GEOSERVER_PORT}/geoserver/rest/workspaces/monitorenv/datastores/monitorenv_postgis/featuretypes -H "accept: text/html" -H "content-type: application/json" -d @- << EOF
{
"featureType": {
"name": "three_hundred_meters_areas",
"nativeName": "three_hundred_meters_areas",
"title": "three_hundred_meters_areas",
"nativeCRS": "EPSG:4326",
"srs": "EPSG:4326",
"enabled": true,
}
}
EOF

1 change: 1 addition & 0 deletions infra/init/postgis_insert_layers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ PGCLIENTENCODING=UTF-8 psql -h 0.0.0.0 -d ${DB_NAME} -U ${DB_USER} -f data/layer
PGCLIENTENCODING=UTF-8 psql -h 0.0.0.0 -d ${DB_NAME} -U ${DB_USER} -f data/layersdata/saltwater_limit_areas.sql
PGCLIENTENCODING=UTF-8 psql -h 0.0.0.0 -d ${DB_NAME} -U ${DB_USER} -f data/layersdata/departments_areas.sql
PGCLIENTENCODING=UTF-8 psql -h 0.0.0.0 -d ${DB_NAME} -U ${DB_USER} -f data/layersdata/competence_cross_areas.sql
PGCLIENTENCODING=UTF-8 psql -h 0.0.0.0 -d ${DB_NAME} -U ${DB_USER} -f data/layersdata/three_hundred_meters_areas.sql

# Regulatory layer
PGCLIENTENCODING=UTF-8 psql -h 0.0.0.0 -d ${DB_NAME} -U ${DB_USER} -f data/layersdata/regulations_cacem.sql
Expand Down
Loading