Skip to content

Commit b6ece20

Browse files
committed
[Regulatory] display simplified geometry
1 parent 49cce8e commit b6ece20

File tree

6 files changed

+10
-9
lines changed

6 files changed

+10
-9
lines changed

backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/adapters/bff/outputs/RegulatoryAreaWithMetadataDataOutput.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ data class RegulatoryAreaWithMetadataDataOutput(
77
val id: Int,
88
val entity_name: String? = null,
99
val facade: String? = null,
10-
val geom: MultiPolygon? = null,
11-
// val simplify_geom: MultiPolygon? = null,
10+
val geometry_simplified: MultiPolygon? = null,
1211
val layer_name: String? = null,
1312
val ref_reg: String? = null,
1413
val thematique: String? = null,
@@ -21,8 +20,7 @@ data class RegulatoryAreaWithMetadataDataOutput(
2120
id = regulatoryArea.id,
2221
entity_name = regulatoryArea.entity_name,
2322
facade = regulatoryArea.facade,
24-
geom = regulatoryArea.geom,
25-
// simplify_geom = regulatoryArea.simplify_geom,
23+
geometry_simplified = regulatoryArea.geometry_simplified,
2624
layer_name = regulatoryArea.layer_name,
2725
ref_reg = regulatoryArea.ref_reg,
2826
thematique = regulatoryArea.thematique,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
UPDATE public.regulations_cacem
2+
SET geometry_simplified = ST_multi(ST_MakeValid(ST_SimplifyPreserveTopology(ST_CurveToLine(geom), 0.0001)));

frontend/src/api/regulatoryLayersAPI.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const regulatoryLayersAPI = monitorenvPrivateApi.injectEndpoints({
2727
query: id => `/v1/regulatory/${id}`,
2828
transformErrorResponse: response => new FrontendApiError(GET_REGULATORY_LAYER_ERROR_MESSAGE, response),
2929
transformResponse: (response: RegulatoryLayerWithMetadataFromAPI) => {
30-
const bbox = boundingExtent(response.simplify_geom.coordinates.flat().flat() as Coordinate[])
30+
const bbox = boundingExtent(response.geometry_simplified.coordinates.flat().flat() as Coordinate[])
3131

3232
return {
3333
...response,
@@ -42,7 +42,7 @@ export const regulatoryLayersAPI = monitorenvPrivateApi.injectEndpoints({
4242
RegulatoryLayersAdapter.setAll(
4343
regulatoryLayersInitialState,
4444
response.map(regulatoryLayer => {
45-
const bbox = boundingExtent(regulatoryLayer.simplify_geom.coordinates.flat().flat() as Coordinate[])
45+
const bbox = boundingExtent(regulatoryLayer.geometry_simplified.coordinates.flat().flat() as Coordinate[])
4646

4747
return {
4848
...regulatoryLayer,

frontend/src/domain/entities/regulatory.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ export type RegulatoryLayerWithMetadataFromAPI = {
44
entity_name: string
55
facade: string
66
geom: GeoJSON.MultiPolygon
7+
geometry_simplified: GeoJSON.MultiPolygon
78
id: number
89
layer_name: string
910
ref_reg: string
10-
simplify_geom: GeoJSON.MultiPolygon
1111
thematique: string
1212
type: string
1313
url: string
@@ -16,6 +16,7 @@ export type RegulatoryLayerWithMetadataFromAPI = {
1616
export type RegulatoryLayerCompactFromAPI = {
1717
entity_name: string
1818
geom: GeoJSON.MultiPolygon
19+
geometry_simplified: GeoJSON.MultiPolygon
1920
id: number
2021
layer_name: string
2122
ref_reg: string

frontend/src/features/map/layers/Regulatory/RegulatoryPreviewLayer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function RegulatoryPreviewLayer({ map }: BaseMapChildrenProps) {
4848
regulatoryFeatures = regulatoryAreasToDisplay?.reduce((regulatorylayers, id) => {
4949
const layer = regulatoryLayers?.entities[id]
5050

51-
if (layer && layer.geom) {
51+
if (layer && layer.geometry_simplified) {
5252
const feature = getRegulatoryFeature({ code: Layers.REGULATORY_ENV_PREVIEW.code, layer })
5353

5454
if (feature) {

frontend/src/features/map/layers/Regulatory/regulatoryGeometryHelpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getFeature } from '@utils/getFeature'
22
import { getArea } from 'ol/sphere'
33

44
export function getRegulatoryFeature({ code, layer }) {
5-
const feature = getFeature(layer.geom)
5+
const feature = getFeature(layer.geometry_simplified)
66
if (!feature) {
77
return undefined
88
}

0 commit comments

Comments
 (0)