Skip to content

Commit

Permalink
[Mission] Ne pas prendre en compte les signalements pour le calcul de…
Browse files Browse the repository at this point in the history
… la zone de mission (#1311)

## Related Pull Requests & Issues

- Resolve #1228

----

- [ ] Tests E2E (Cypress)
  • Loading branch information
claire2212 committed Apr 4, 2024
2 parents 5def1b9 + 6d455f9 commit 8f86571
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 72 deletions.
130 changes: 65 additions & 65 deletions frontend/cypress/e2e/side_window/mission_form/mission_zone.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,71 +154,71 @@ context('Side Window > Mission Form > Mission zone', () => {
coordinates: [
[
[
[-1.84589767, 46.68538035],
[-1.84332775, 46.68529371],
[-1.84078261, 46.68503463],
[-1.83828678, 46.68460561],
[-1.83586431, 46.68401078],
[-1.83353856, 46.68325587],
[-1.83133194, 46.68234817],
[-1.82926571, 46.68129642],
[-1.82735978, 46.68011075],
[-1.8256325, 46.67880261],
[-1.82410051, 46.67738458],
[-1.82277856, 46.67587035],
[-1.82167936, 46.67427449],
[-1.82081348, 46.67261238],
[-1.82018925, 46.67090004],
[-1.81981266, 46.66915395],
[-1.8196873, 46.66739095],
[-1.81981436, 46.665628],
[-1.82019259, 46.66388209],
[-1.82081833, 46.66217002],
[-1.82168553, 46.66050829],
[-1.82278581, 46.65891288],
[-1.82410857, 46.65739916],
[-1.82564105, 46.6559817],
[-1.8273685, 46.65467413],
[-1.82927426, 46.65348906],
[-1.83133999, 46.65243787],
[-1.83354581, 46.65153068],
[-1.83587048, 46.65077623],
[-1.83829162, 46.65018177],
[-1.84078595, 46.64975302],
[-1.84332945, 46.64949411],
[-1.84589767, 46.64940753],
[-1.84846589, 46.64949411],
[-1.85100939, 46.64975302],
[-1.85350372, 46.65018177],
[-1.85592486, 46.65077623],
[-1.85824953, 46.65153068],
[-1.86045535, 46.65243787],
[-1.86252108, 46.65348906],
[-1.86442684, 46.65467413],
[-1.86615429, 46.6559817],
[-1.86768677, 46.65739916],
[-1.86900953, 46.65891288],
[-1.87010981, 46.66050829],
[-1.87097701, 46.66217002],
[-1.87160275, 46.66388209],
[-1.87198098, 46.665628],
[-1.87210804, 46.66739095],
[-1.87198268, 46.66915395],
[-1.87160609, 46.67090004],
[-1.87098186, 46.67261238],
[-1.87011598, 46.67427449],
[-1.86901678, 46.67587035],
[-1.86769483, 46.67738458],
[-1.86616284, 46.67880261],
[-1.86443556, 46.68011075],
[-1.86252963, 46.68129642],
[-1.8604634, 46.68234817],
[-1.85825678, 46.68325587],
[-1.85593103, 46.68401078],
[-1.85350856, 46.68460561],
[-1.85101273, 46.68503463],
[-1.84846759, 46.68529371],
[-1.84589767, 46.68538035]
[-1.84589767, 46.68088375],
[-1.84397039, 46.68081877],
[-1.84206169, 46.68062448],
[-1.84018995, 46.68030274],
[-1.83837323, 46.67985665],
[-1.83662902, 46.67929051],
[-1.83497413, 46.67860978],
[-1.8334245, 46.67782102],
[-1.83199507, 46.67693183],
[-1.83069959, 46.67595078],
[-1.82955056, 46.67488731],
[-1.82855902, 46.67375168],
[-1.82773452, 46.67255483],
[-1.82708499, 46.67130828],
[-1.82661667, 46.67002405],
[-1.82633407, 46.66871451],
[-1.82623989, 46.66739226],
[-1.82633503, 46.66607004],
[-1.82661855, 46.66476059],
[-1.82708771, 46.66347651],
[-1.82773798, 46.66223018],
[-1.8285631, 46.66103358],
[-1.82955509, 46.65989824],
[-1.83070441, 46.65883509],
[-1.83199997, 46.65785437],
[-1.83342931, 46.6569655],
[-1.83497866, 46.65617706],
[-1.8366331, 46.65549662],
[-1.8383767, 46.65493074],
[-1.84019268, 46.65448486],
[-1.84206357, 46.65416327],
[-1.84397135, 46.65396908],
[-1.84589767, 46.65390413],
[-1.84782399, 46.65396908],
[-1.84973177, 46.65416327],
[-1.85160266, 46.65448486],
[-1.85341864, 46.65493074],
[-1.85516224, 46.65549662],
[-1.85681668, 46.65617706],
[-1.85836603, 46.6569655],
[-1.85979537, 46.65785437],
[-1.86109093, 46.65883509],
[-1.86224025, 46.65989824],
[-1.86323224, 46.66103358],
[-1.86405736, 46.66223018],
[-1.86470763, 46.66347651],
[-1.86517679, 46.66476059],
[-1.86546031, 46.66607004],
[-1.86555545, 46.66739226],
[-1.86546127, 46.66871451],
[-1.86517867, 46.67002405],
[-1.86471035, 46.67130828],
[-1.86406082, 46.67255483],
[-1.86323632, 46.67375168],
[-1.86224478, 46.67488731],
[-1.86109575, 46.67595078],
[-1.85980027, 46.67693183],
[-1.85837084, 46.67782102],
[-1.85682121, 46.67860978],
[-1.85516632, 46.67929051],
[-1.85342211, 46.67985665],
[-1.85160539, 46.68030274],
[-1.84973365, 46.68062448],
[-1.84782495, 46.68081877],
[-1.84589767, 46.68088375]
]
]
],
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/domain/entities/missions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { SeaFrontEnum } from './seaFrontType'
import type { FishMissionAction } from '@features/missions/fishActions.types'
import type { GeoJSON } from 'domain/types/GeoJSON'

export const CIRCULAR_ZONE_RADIUS = 2000
export const CIRCULAR_ZONE_RADIUS = 1500

export enum ActionTypeEnum {
CONTROL = 'CONTROL',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { isEqual } from 'lodash'
import { Feature } from 'ol'
import { MultiPolygon } from 'ol/geom'
import Polygon, { circular } from 'ol/geom/Polygon'
import { useEffect, useState } from 'react'
import { useEffect, useMemo, useState } from 'react'

function computeCircleZone(coordinates) {
const circleGeometry = new Feature({
Expand All @@ -19,7 +19,19 @@ function computeCircleZone(coordinates) {
}

export const useUpdateMissionZone = sortedActions => {
const firstAction = sortedActions[0]
const filteredActions = useMemo(
() =>
sortedActions.filter(
action =>
action.actionSource === ActionSource.MONITORFISH ||
(action.actionSource === ActionSource.MONITORENV &&
(action.actionType === ActionTypeEnum.SURVEILLANCE || action.actionType === ActionTypeEnum.CONTROL))
),
[sortedActions]
)

const firstAction = filteredActions[0]

const listener = useAppSelector(state => state.draw.listener)
const { setFieldValue, values } = useFormikContext<Mission>()
const [actionGeom, setActionGeom] = useState(values.geom && firstAction?.geom ? firstAction?.geom : undefined)
Expand Down Expand Up @@ -69,10 +81,7 @@ export const useUpdateMissionZone = sortedActions => {
setFieldValue('geom', firstAction.geom)
}

if (
!values.isGeometryComputedFromControls &&
(firstAction?.actionType === ActionTypeEnum.CONTROL || firstAction?.actionType === ActionTypeEnum.SURVEILLANCE)
) {
if (!values.isGeometryComputedFromControls) {
setFieldValue('isGeometryComputedFromControls', true)
}

Expand Down

0 comments on commit 8f86571

Please sign in to comment.