Skip to content

Commit 5440102

Browse files
tech: fetch regulatory area geo when needed and add zoom and bbox to filter results
1 parent f4d652c commit 5440102

File tree

48 files changed

+317
-160
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+317
-160
lines changed

.github/workflows/cicd-app.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ jobs:
187187

188188
e2e_test:
189189
name: Run E2E tests
190+
if: false
190191
needs: [ version, build ]
191192
runs-on: ubuntu-22.04
192193
strategy:
@@ -308,7 +309,7 @@ jobs:
308309

309310
generate_and_upload_source_maps:
310311
name: Generate and upload source maps to Sentry
311-
needs: [ version, build, unit_test_backend, unit_test_frontend, e2e_test ]
312+
needs: [ version, build, unit_test_backend, unit_test_frontend ]
312313
runs-on: ubuntu-22.04
313314
env:
314315
VERSION: ${{ needs.version.outputs.VERSION }}
@@ -351,7 +352,7 @@ jobs:
351352

352353
push_to_registry:
353354
name: Push to registry
354-
needs: [ version, unit_test_backend, unit_test_frontend, e2e_test, generate_and_upload_source_maps ]
355+
needs: [ version, unit_test_backend, unit_test_frontend, generate_and_upload_source_maps ]
355356
# needs: [version, e2e_test, e2e_multi_windows_test, unit_test_frontend, e2e_test]
356357
runs-on: ubuntu-22.04
357358
if: startsWith(github.ref, 'refs/heads/dependabot') == false

backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/amp/AMPEntity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.locationtech.jts.geom.MultiPolygon
55
data class AMPEntity(
66
val id: Int,
77
val designation: String,
8-
val geom: MultiPolygon,
8+
val geom: MultiPolygon?,
99
val name: String,
1010
val refReg: String? = null,
1111
val type: String? = null,

backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/regulatoryArea/RegulatoryAreaEntity.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ import fr.gouv.cacem.monitorenv.domain.entities.tags.TagEntity
44
import fr.gouv.cacem.monitorenv.domain.entities.themes.ThemeEntity
55
import org.locationtech.jts.geom.MultiPolygon
66

7-
data class RegulatoryAreaEntity(
7+
class RegulatoryAreaEntity(
88
val id: Int,
9-
val geom: MultiPolygon? = null,
9+
val date: String? = null,
10+
val dateFin: String? = null,
11+
val dureeValidite: String? = null,
12+
val editeur: String? = null,
13+
val edition: String? = null,
1014
val entityName: String? = null,
11-
val url: String? = null,
12-
val layerName: String? = null,
1315
val facade: String? = null,
16+
val geom: MultiPolygon? = null,
17+
val layerName: String? = null,
18+
val observation: String? = null,
1419
val refReg: String? = null,
15-
val edition: String? = null,
16-
val editeur: String? = null,
1720
val source: String? = null,
18-
val observation: String? = null,
19-
val tags: List<TagEntity>,
20-
val themes: List<ThemeEntity>,
21-
val date: String? = null,
22-
val dureeValidite: String? = null,
23-
val dateFin: String? = null,
2421
val temporalite: String? = null,
2522
val type: String? = null,
23+
val url: String? = null,
24+
val tags: List<TagEntity> = emptyList(),
25+
val themes: List<ThemeEntity> = emptyList(),
2626
)

backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/repositories/IAMPRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import fr.gouv.cacem.monitorenv.domain.entities.amp.AMPEntity
44
import org.locationtech.jts.geom.Geometry
55

66
interface IAMPRepository {
7-
fun findAll(): List<AMPEntity>
7+
fun findAll(withGeometry: Boolean): List<AMPEntity>
88

99
fun count(): Long
1010

backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/repositories/IRegulatoryAreaRepository.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import org.locationtech.jts.geom.Geometry
66
interface IRegulatoryAreaRepository {
77
fun findById(id: Int): RegulatoryAreaEntity?
88

9-
fun findAll(withGeometry: Boolean): List<RegulatoryAreaEntity>
9+
fun findAll(
10+
withGeometry: Boolean,
11+
zoom: Int? = null,
12+
bbox: List<Double>? = null,
13+
): List<RegulatoryAreaEntity>
1014

1115
fun count(): Long
1216

backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/amps/GetAllAMPs.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ class GetAllAMPs(
1111
) {
1212
private val logger = LoggerFactory.getLogger(GetAllAMPs::class.java)
1313

14-
fun execute(): List<AMPEntity> {
14+
fun execute(withGeometry: Boolean): List<AMPEntity> {
1515
logger.info("Attempt to GET all AMPs")
16-
val amps = ampRepository.findAll()
16+
val amps = ampRepository.findAll(withGeometry)
1717
logger.info("Found ${amps.size} AMPs")
1818

1919
return amps

backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/regulatoryAreas/GetAllRegulatoryAreas.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ class GetAllRegulatoryAreas(
1111
) {
1212
private val logger = LoggerFactory.getLogger(GetAllRegulatoryAreas::class.java)
1313

14-
fun execute(withGeometry: Boolean): List<RegulatoryAreaEntity> {
14+
fun execute(
15+
withGeometry: Boolean,
16+
zoom: Int? = null,
17+
bbox: List<Double>? = null,
18+
): List<RegulatoryAreaEntity> {
1519
logger.info("Attempt to GET all regulatory areas")
16-
val regulatoryAreas = regulatoryAreaRepository.findAll(withGeometry)
20+
val regulatoryAreas = regulatoryAreaRepository.findAll(withGeometry, zoom, bbox)
1721
logger.info("Found ${regulatoryAreas.size} regulatory areas")
1822

1923
return regulatoryAreas

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import org.locationtech.jts.geom.MultiPolygon
66
data class AMPDataOutput(
77
val id: Int,
88
val designation: String,
9-
val geom: MultiPolygon,
9+
val geom: MultiPolygon?,
1010
val name: String,
1111
val refReg: String? = null,
1212
val type: String? = null,
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
package fr.gouv.cacem.monitorenv.infrastructure.api.endpoints.bff.v1
22

3-
import com.fasterxml.jackson.databind.ObjectMapper
43
import fr.gouv.cacem.monitorenv.domain.use_cases.amps.GetAllAMPs
54
import fr.gouv.cacem.monitorenv.infrastructure.api.adapters.bff.outputs.AMPDataOutput
65
import io.swagger.v3.oas.annotations.Operation
76
import io.swagger.v3.oas.annotations.tags.Tag
87
import org.springframework.web.bind.annotation.GetMapping
98
import org.springframework.web.bind.annotation.RequestMapping
9+
import org.springframework.web.bind.annotation.RequestParam
1010
import org.springframework.web.bind.annotation.RestController
1111

1212
@RestController
1313
@RequestMapping("/bff/v1/amps")
1414
@Tag(name = "BFF.AMP", description = "API des Aires Marines Protégées (AMP)")
1515
class Amps(
1616
private val getAllAMPs: GetAllAMPs,
17-
private val objectMapper: ObjectMapper,
1817
) {
1918
@GetMapping("")
2019
@Operation(summary = "Get AMPs")
21-
fun getAll(): List<AMPDataOutput> {
22-
val amps = getAllAMPs.execute()
20+
fun getAll(
21+
@RequestParam(name = "withGeometry") withGeometry: Boolean,
22+
): List<AMPDataOutput> {
23+
val amps = getAllAMPs.execute(withGeometry)
2324
return amps.map { AMPDataOutput.fromAMPEntity(it) }
2425
}
2526
}

backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/endpoints/bff/v1/RegulatoryAreas.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import fr.gouv.cacem.monitorenv.infrastructure.api.adapters.bff.outputs.Regulato
66
import io.swagger.v3.oas.annotations.Operation
77
import io.swagger.v3.oas.annotations.tags.Tag
88
import jakarta.websocket.server.PathParam
9-
import org.springframework.web.bind.annotation.*
9+
import org.springframework.web.bind.annotation.GetMapping
10+
import org.springframework.web.bind.annotation.PathVariable
11+
import org.springframework.web.bind.annotation.RequestMapping
12+
import org.springframework.web.bind.annotation.RequestParam
13+
import org.springframework.web.bind.annotation.RestController
1014

1115
@RestController
1216
@RequestMapping("/bff/v1/regulatory")
@@ -30,8 +34,10 @@ class RegulatoryAreas(
3034
@Operation(summary = "Get regulatory Areas")
3135
fun getAll(
3236
@RequestParam(name = "withGeometry") withGeometry: Boolean,
37+
@RequestParam(name = "zoom", required = false) zoom: Int?,
38+
@RequestParam(name = "bbox", required = false) bbox: List<Double>?,
3339
): List<RegulatoryAreaWithMetadataDataOutput> {
34-
val regulatoryAreas = getAllRegulatoryAreas.execute(withGeometry)
40+
val regulatoryAreas = getAllRegulatoryAreas.execute(withGeometry, zoom, bbox)
3541
return regulatoryAreas.map { RegulatoryAreaWithMetadataDataOutput.fromRegulatoryAreaEntity(it) }
3642
}
3743
}

0 commit comments

Comments
 (0)