Skip to content

Commit

Permalink
[Map] fix bug with measurement tools
Browse files Browse the repository at this point in the history
  • Loading branch information
claire2212 committed Nov 19, 2024
1 parent 69c8cda commit a9f3b51
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 91 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/* INSERT INTO control_plan_themes (id, theme) VALUES
(100,'Mouillage individuel'),
(101,'Zone de mouillage et d''équipement léger (ZMEL)'),
(102,'Rejet'),
(103,'Espèce protégée et leur habitat (faune et flore)'),
(104,'Bien culturel maritime'),
(105,'Épave'),
(106,'Domanialité publique (circulation et dégradation)'),
(107,'Culture marine'),
(108,'Parc national'),
(109,'Réserve naturelle'),
(110,'Arrêté de protection'),
(111,'Autres'),
(112,'Pêche de loisir (autre que PAP)'),
(113,'Surveillance générale');
*/
-- Thématiques existantes pour lesquels une recherche doit être faite pour récupérer l'identifiant
-- Activité et manifestation soumises à évaluation d’incidence Natura 2000
-- Travaux en milieu marin
-- Arrêté à visa environnemental
-- Pêche à pied

/* SELECT setval('control_plan_themes_id_seq', (SELECT max(id) FROM control_plan_themes), true);
INSERT INTO control_plan_tags (id,theme_id,tag) VALUES
(10,103,'Mammifères marins'),
(11,103,'Oiseaux'),
(12,103,'Reptiles'),
(13,103,'Poissons'),
(14,103,'Flore'),
(15,103,'Habitat'),
(16,103,'Autres espèces protégées');
INSERT INTO control_plan_tags (id,tag,theme_id)
SELECT new_tags.*, existing_theme.id FROM (VALUES
(17,'Bichique'),
(18,'Civelle'),
(19,'Filet fixe'),
(20,'Autre')) as new_tags,
(
SELECT id FROM control_plan_themes
WHERE theme = 'Pêche à pied') existing_theme;
SELECT setval('control_plan_tags_id_seq', (SELECT max(id) FROM control_plan_tags), true);
*/
INSERT INTO control_plan_sub_themes (id,theme_id,subtheme,year) VALUES
(178,100,'Mouillage réglementé par arrêté',2025),
(179,100,'Mouillage réglementé par AMP',2025),
(180,100,'Mouillage avec AOT individuelle',2025),
(181,100,'Autre mouillage individuel',2025),
(182,101,'Gestionnaire ZMEL',2025),
(183,101,'Usagers ZMEL',2025),
(184,101,'Autre (ZMEL)',2025),
(185,102,'Jet de déchet (macro déchet)',2025),
(186,102,'Carénage sauvage',2025),
(187,102,'Rejet d''eau grise / eau noire',2025),
(188,102,'Rejet d''hydrocarbure',2025),
(189,102,'Eaux de ballast',2025),
(190,102,'Pollutions associées aux opérations d''exploration, d''exploitation, d''immersion et d''incinération',2025),
(191,102,'Rejets atmosphériques ',2025),
(192,102,'Avitaillement, soutage, transbordement',2025),
(193,102,'Rejet réglementé par AMP',2025),
(194,102,'Autre rejet',2025),
(195,103,'Destruction, capture, arrachage d''espèces protégées',2025),
(196,103,'Atteinte aux habitats d''espèces protégées',2025),
(197,103,'Transport, vente, exportation, commerce d''espèces protégées',2025),
(198,103,'Détention des espèces protégées',2025),
(199,103,'Dérogations relatives aux espèces protégées et aux habitats d''espèces protégées',2025),
(200,103,'Dérangement / perturbation intentionnelle des espèces animales protégées',2025),
(201,103,'Autre (Espèce protégée et leur habitat)',2025),
(202,104,'Prospection d''un bien culturel maritime',2025),
(203,104,'Aliénation/acquisition d''un bien culturel maritime',2025),
(204,104,'Déplacement/prélèvement/atteinte d''un bien culturel maritime',2025),
(205,104,'Autre (Bien culturel maritime)',2025),
(206,105,'Découverte d''une épave maritime',2025),
(207,105,'Recel ou détournement d''une épave maritime',2025),
(208,105,'Épave / Navire abandonné',2025),
(209,105,'Autre (Épave)',2025),
(210,106,'Circulation des VTM sur le DPM',2025),
(211,106,'Respect des espaces balisés',2025),
(212,106,'Dégradation du DPM',2025),
(213,106,'Autre (DPM)',2025),
(214,107,'Prescriptions réglementaires des concessions d''exploitation de culture marine',2025),
(215,107,'Remise en état après occupation du DPM',2025),
(216,107,'Implantation',2025),
(217,107,'Autre (Culture marine)',2025),
(218,108,'Réglementation du parc national',2025),
(219,108,'Autre (Parc national)',2025),
(220,109,'Autre (Réserve naturelle)',2025),
(221,110,'Réglementation de l''arrêté de protection',2025),
(222,110,'Autre (Arrêté de protection)',2025),
(223,111,'Drone',2025),
(224,111,'Introduction d''espèce dans le milieu naturel ',2025),
(225,111,'Dérogation d''introduction d''espèce',2025),
(226,111,'Campagnes scientifiques',2025),
(227,111,'Manifestation sur le DPM avec prescriptions environnementales',2025),
(228,111,'Chasse sur le DPM',2025),
(229,111,'Autre',2025),
(230,112,'Pêche embarquée',2025),
(231,112,'Pêche sous-marine',2025),
(232,112,'Engin non-marqué',2025),
(233,112,'Autre (Pêche de loisir hors PAP)',2025),
(234,113,'Surveillance générale',2025)
;


/* INSERT INTO control_plan_sub_themes (id,subtheme,year,theme_id)
SELECT new_sub_themes.*, existing_theme.id FROM (VALUES
(132,'Existence d''une évaluation d''incidence Natura 2000',2025),
(133,'Prescriptions environnementales des manifestations / activités dans une zone Natura 2000',2025),
(134,'Travaux dans une zone Natura 2000',2025),
(135,'Charte Natura 2000',2025),
(136,'Autre (EIN2000)',2025)) as new_sub_themes,
(
SELECT id FROM control_plan_themes
WHERE theme = 'Activités et manifestations soumises à évaluation d’incidence Natura 2000') existing_theme
;
INSERT INTO control_plan_sub_themes (id,subtheme,year,theme_id)
SELECT new_sub_themes.*, existing_theme.id FROM (VALUES
(145,'Dragage',2025),
(146,'Clapage',2025),
(147,'Extraction de granulats ',2025),
(148,'Chantier marin',2025),
(149,'Chantier portuaire',2025),
(150,'Travaux réglementés par AMP',2025),
(151,'Autres travaux en mer',2025)) as new_sub_themes,
(
SELECT id FROM control_plan_themes
WHERE theme = 'Travaux en milieu marin') existing_theme
;
INSERT INTO control_plan_sub_themes (id,subtheme,year,theme_id)
SELECT new_sub_themes.*, existing_theme.id FROM (VALUES
(152,'Arrêtés municipaux réglementant certaines activités avec un impact sur l''environnement marin ',2025),
(153,'Arrêtés du préfet de département réglementant certaines activités avec un impact sur l''environnement marin',2025),
(154,'Arrêtés du préfet maritime réglementant certaines activités avec un impact sur l''environnement marin ',2025),
(155,'Autres arrêtés réglementant certaines activités avec un impact sur l''environnement marin ',2025)
) as new_sub_themes,
(
SELECT id FROM control_plan_themes
WHERE theme = 'Arrêté à visa environnemental') existing_theme
;
INSERT INTO control_plan_sub_themes (id,subtheme,year,theme_id)
SELECT new_sub_themes.*, existing_theme.id FROM (VALUES
(169,'Pêche à pied de loisir',2025),
(170,'Pêche à pied professionnelle',2025),
(171,'Engin non-marqué',2025),
(172,'Autre (Pêche à pied)',2025)
) as new_sub_themes,
(
SELECT id FROM control_plan_themes
WHERE theme = 'Pêche à pied') existing_theme
;
SELECT setval('control_plan_sub_themes_id_seq', (SELECT max(id) FROM control_plan_sub_themes), true); */
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,11 @@ INSERT INTO public.env_actions (id, mission_id, action_type, value, action_start
is_safety_equipment_and_standards_compliance_control, is_seafarers_control, open_by,
completed_by)
VALUES ('e2257638-ddef-4611-960c-7675a3254c38', 38, 'SURVEILLANCE', '{
"themes": [
{
"theme": "Police des activités de cultures marines",
"subThemes": [
"Contrôle du schéma des structures"
],
"protectedSpecies": []
}
],
"observations": ""
}', '2022-07-30 08:53:31.588693',
'0106000020E61000000300000001030000000100000005000000E1AC900B314306C0DCABC1C17F1C484077EC6F225D5006C0E9C04905DB0A4840C4FDB241475F05C0D322916C64104840C4FDB241475F05C061C3D32BE51E4840E1AC900B314306C0DCABC1C17F1C4840010300000001000000050000001A381C6D873C05C0857E01182A1748407A5824FD283005C06AB86D846A13484012C925C8E7D104C048BD6DC7D014484056F6FAE640DF04C04921B9CACD1748401A381C6D873C05C0857E01182A17484001030000000100000005000000BA44FD4709AE06C0BD44AB4926174840374C3CB9097B06C0416F22E1981148409F7BAC6C615606C0DA75EB0C3E164840F5F0C8CCC36906C01B578E56561A4840BA44FD4709AE06C0BD44AB4926174840',
NULL, '56', '2022-07-30 10:53:31.588693', NULL, NULL, NULL, NULL, 'ABC', NULL),
('f3e90d3a-6ba4-4bb3-805e-d391508aa46d', 38, 'CONTROL', '{
"themes": [
{
"theme": "Police des épaves",
"subThemes": [
"Épave/navire abandonné",
"Contrôle administratif"
],
"protectedSpecies": []
}
],
"infractions": [
{
"id": "6670e718-3ecd-46c1-8149-8b963c6f72dd",
Expand All @@ -60,15 +41,6 @@ VALUES ('e2257638-ddef-4611-960c-7675a3254c38', 38, 'SURVEILLANCE', '{
}', '2022-07-29 11:53:31.588693', '0104000020E6100000010000000101000000399291D4BE1805C09E1A585CD6154840', NULL,
NULL, NULL, NULL, NULL, NULL, NULL, 'ABC', 'DEF'),
('475d2887-5344-46cd-903b-8cb5e42f9a9c', 49, 'SURVEILLANCE', '{
"themes": [
{
"theme": "Police du conservatoire du littoral",
"subThemes": [
"Réglementation du conservatoire du littoral"
],
"protectedSpecies": []
}
],
"duration": 0.0,
"observations": "RAS",
"protectedSpecies": []
Expand All @@ -79,15 +51,6 @@ VALUES ('e2257638-ddef-4611-960c-7675a3254c38', 38, 'SURVEILLANCE', '{
"observations": "Note libre"
}', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('6d4b7d0a-79ce-47cf-ac26-2024d2b27f28', 49, 'CONTROL', '{
"themes": [
{
"theme": "AMP sans réglementation particulière",
"subThemes": [
"Contrôle dans une AMP sans réglementation particulière"
],
"protectedSpecies": []
}
],
"infractions": [
{
"id": "e56648c1-6ca3-4d5e-a5d2-114aa7c17126",
Expand All @@ -114,44 +77,13 @@ VALUES ('e2257638-ddef-4611-960c-7675a3254c38', 38, 'SURVEILLANCE', '{
}', NULL, '0104000020E61000000100000001010000003B0DADC6D4BB01C0A8387A2964714740', NULL, NULL, NULL, NULL, NULL,
NULL, NULL, 'ABC', null),
('c52c6f20-e495-4b29-b3df-d7edfb67fdd7', 34, 'SURVEILLANCE', '{
"themes": [
{
"theme": "Police des espèces protégées et de leurs habitats (faune et flore)",
"subThemes": [
"Destruction, capture, arrachage",
"Atteinte aux habitats d''espèces protégées"
],
"protectedSpecies": [
"FLORA",
"BIRDS"
]
},
{
"theme": "Police des mouillages",
"subThemes": [
"Mouillage individuel",
"ZMEL"
],
"protectedSpecies": []
}
],
"duration": 0.0,
"observations": "RAS",
"protectedSpecies": []
}', '2022-07-16 10:03:12.588693',
'0106000020E61000000100000001030000000100000009000000AD0812BCE168E4BFCCDEEA3227BD4840BE63AEABD812E4BF1C5E8873F8AC484044BD156CA117DABF84C0E2AF49AC48408E16A14DE463CCBFBC9F7168A2A5484008BF4C12D0F97B3F9494F5EA3CAB4840399BF9438A28B43FDC4BF050D9BB48404BAA02B73C2CCCBF24A79C8362CD4840BC46F7A9D24DE1BFA0238D36B2D04840AD0812BCE168E4BFCCDEEA3227BD4840',
'MEMN', NULL, '2022-07-16 12:03:12.588693', NULL, NULL, NULL, NULL, 'ABC', 'DEF'),
('b8007c8a-5135-4bc3-816f-c69c7b75d807', 34, 'CONTROL', '{
"themes": [
{
"theme": "Police des mouillages",
"subThemes": [
"Mouillage individuel",
"ZMEL"
],
"protectedSpecies": []
}
],
"observations": "RAS",
"infractions": [
{
Expand Down Expand Up @@ -179,15 +111,6 @@ VALUES ('e2257638-ddef-4611-960c-7675a3254c38', 38, 'SURVEILLANCE', '{
}', '2022-07-16 09:01:12.588693', '0104000020E610000001000000010100000047A07E6651E3DEBF044620AB65C54840', NULL,
NULL, '2022-07-16 12:03:12.588693', NULL, NULL, NULL, NULL, 'ABC', NULL),
('4d9a3139-6c60-49a5-b443-0e6238a6a120', 41, 'CONTROL', '{
"themes": [
{
"theme": "Police des mouillages",
"subThemes": [
"Contrôle administratif"
],
"protectedSpecies": []
}
],
"infractions": [],
"vehicleType": null,
"observations": "",
Expand Down Expand Up @@ -231,28 +154,28 @@ WHERE mission_id > 20;
;

INSERT INTO public.env_actions_control_plan_themes (env_action_id, theme_id)
VALUES ('b8007c8a-5135-4bc3-816f-c69c7b75d807', 100),
('475d2887-5344-46cd-903b-8cb5e42f9a9c', 16),
VALUES ('b8007c8a-5135-4bc3-816f-c69c7b75d807', 100), /* OK */
('475d2887-5344-46cd-903b-8cb5e42f9a9c', 107), /* OK */
('c52c6f20-e495-4b29-b3df-d7edfb67fdd7', 103),
('c52c6f20-e495-4b29-b3df-d7edfb67fdd7', 100),
('f3e90d3a-6ba4-4bb3-805e-d391508aa46d', 15),
('e2257638-ddef-4611-960c-7675a3254c38', 9),
('f3e90d3a-6ba4-4bb3-805e-d391508aa46d', 112), /* OK */
('e2257638-ddef-4611-960c-7675a3254c38', 107), /* OK */
('4d9a3139-6c60-49a5-b443-0e6238a6a120', 12),
('6d4b7d0a-79ce-47cf-ac26-2024d2b27f28', 1),
('6d4b7d0a-79ce-47cf-ac26-2024d2b27f28', 101),
('5865b619-3280-4c67-94ca-9f15da7d5aa7', 3)
;

INSERT INTO public.env_actions_control_plan_sub_themes(env_action_id, subtheme_id)
VALUES ('e2257638-ddef-4611-960c-7675a3254c38', 51),
('f3e90d3a-6ba4-4bb3-805e-d391508aa46d', 83),
('f3e90d3a-6ba4-4bb3-805e-d391508aa46d', 43),
('475d2887-5344-46cd-903b-8cb5e42f9a9c', 79),
('6d4b7d0a-79ce-47cf-ac26-2024d2b27f28', 48),
VALUES ('e2257638-ddef-4611-960c-7675a3254c38', 214), /* OK */
('f3e90d3a-6ba4-4bb3-805e-d391508aa46d', 231), /* OK */
('f3e90d3a-6ba4-4bb3-805e-d391508aa46d', 232), /* OK */
('475d2887-5344-46cd-903b-8cb5e42f9a9c', 214), /* OK */
('6d4b7d0a-79ce-47cf-ac26-2024d2b27f28', 182),
('c52c6f20-e495-4b29-b3df-d7edfb67fdd7', 100),
('c52c6f20-e495-4b29-b3df-d7edfb67fdd7', 102),
('c52c6f20-e495-4b29-b3df-d7edfb67fdd7', 117),
('c52c6f20-e495-4b29-b3df-d7edfb67fdd7', 118),
('b8007c8a-5135-4bc3-816f-c69c7b75d807', 102),
('c52c6f20-e495-4b29-b3df-d7edfb67fdd7', 195), /* OK */
('c52c6f20-e495-4b29-b3df-d7edfb67fdd7', 196),/* OK */
('b8007c8a-5135-4bc3-816f-c69c7b75d807', 180), /* OK */
('4d9a3139-6c60-49a5-b443-0e6238a6a120', 42),
('5865b619-3280-4c67-94ca-9f15da7d5aa7', 5)
;
Expand Down
29 changes: 29 additions & 0 deletions frontend/cypress/e2e/main_window/measurements_tools.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { FAKE_MAPBOX_RESPONSE } from '../constants'

context('Measurement tools', () => {
beforeEach(() => {
cy.intercept('GET', 'https://api.mapbox.com/**', FAKE_MAPBOX_RESPONSE)
cy.visit('/#@-824534.42,6082993.21,8.70')
})

it('A user measure a distance with line tool', () => {
cy.wait(200)
cy.clickButton('Mesurer une distance')
cy.clickButton("Mesure d'une distance avec lignes brisées")

cy.get('#root').click(490, 580)
cy.get('#root').click(690, 880)
cy.get('#root').click(400, 500)
cy.get('#root').click(400, 500)
cy.getDataCy('measurement-value').should('be.visible')
})
it('A user measure a distance with circle tool', () => {
cy.wait(200)
cy.clickButton('Mesurer une distance')
cy.clickButton("Rayon d'action")

cy.get('#root').click(850, 780)
cy.get('#root').click(1050, 780)
cy.getDataCy('measurement-value').should('be.visible')
})
})
2 changes: 1 addition & 1 deletion frontend/src/features/map/layers/MeasurementLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export function MeasurementLayer({ map }: BaseMapChildrenProps) {
if (measurementsDrawed && map) {
GetVectorSource().clear(true)
measurementsDrawed.forEach(measurement => {
const feature = getFeature(measurement)
const feature = getFeature(measurement.feature)

if (!feature) {
return
Expand Down

0 comments on commit a9f3b51

Please sign in to comment.