diff --git a/src/components/FunctionalArea/Modal/LayerImageObjectModal/LayerImageObjectEditFactoryModal.component.tsx b/src/components/FunctionalArea/Modal/LayerImageObjectModal/LayerImageObjectEditFactoryModal.component.tsx index 3e8d27b6eb573aa4de2d36cf287679a63d15907f..655bb8d9c70c13f7e103b19c6103809e4afd99d8 100644 --- a/src/components/FunctionalArea/Modal/LayerImageObjectModal/LayerImageObjectEditFactoryModal.component.tsx +++ b/src/components/FunctionalArea/Modal/LayerImageObjectModal/LayerImageObjectEditFactoryModal.component.tsx @@ -14,7 +14,7 @@ import { showToast } from '@/utils/showToast'; import { closeModal } from '@/redux/modal/modal.slice'; import { SerializedError } from '@reduxjs/toolkit'; import { useMapInstance } from '@/utils/context/mapInstanceContext'; -import updateGlyph from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/updateGlyph'; +import updateGlyph from '@/components/Map/MapViewer/utils/shapes/elements/Glyph/updateGlyph'; import { mapEditToolsSetLayerObject } from '@/redux/mapEditTools/mapEditTools.slice'; export const LayerImageObjectEditFactoryModal: React.FC = () => { diff --git a/src/components/FunctionalArea/NavBar/NavBar.component.tsx b/src/components/FunctionalArea/NavBar/NavBar.component.tsx index edd141705ef7e16676be211c13ed76e90f6b3a97..eafb96e3b0f955c3a557bf68551b89e96a7b3ff1 100644 --- a/src/components/FunctionalArea/NavBar/NavBar.component.tsx +++ b/src/components/FunctionalArea/NavBar/NavBar.component.tsx @@ -11,16 +11,11 @@ import { store } from '@/redux/store'; import Image from 'next/image'; import { useAppSelector } from '@/redux/hooks/useAppSelector'; import { projectIdSelector } from '@/redux/project/project.selectors'; -import { Switch } from '@/shared/Switch'; -import { currentModelIdSelector, vectorRenderingSelector } from '@/redux/models/models.selectors'; -import { setModelVectorRendering } from '@/redux/models/models.slice'; export const NavBar = (): JSX.Element => { const dispatch = useAppDispatch(); const projectId = useAppSelector(projectIdSelector); - const vectorRendering = useAppSelector(vectorRenderingSelector); - const currentModelId = useAppSelector(currentModelIdSelector); const toggleDrawerInfo = (): void => { if (store.getState().drawer.isOpen && store.getState().drawer.drawerName === 'project-info') { @@ -91,15 +86,6 @@ export const NavBar = (): JSX.Element => { <IconButton icon="legend" onClick={toggleDrawerLegend} title="Legend" /> </div> </div> - <div className="flex flex-col items-center gap-[10px] text-center text-[12px]"> - <span>Vector rendering</span> - <Switch - isChecked={vectorRendering} - onToggle={value => - dispatch(setModelVectorRendering({ vectorRendering: value, mapId: currentModelId })) - } - /> - </div> <div className="flex flex-col items-center gap-[20px]" data-testid="nav-logos-and-powered-by"> <a href="https://www.uni.lu/en/" target="_blank"> <Image diff --git a/src/components/Map/Map.component.tsx b/src/components/Map/Map.component.tsx index 0a57b1fb832379e00a7edaecf18749cf386b60e8..df0e5eac330e382b22ebb4ec72a74eead31b5206 100644 --- a/src/components/Map/Map.component.tsx +++ b/src/components/Map/Map.component.tsx @@ -6,16 +6,13 @@ import { MapLoader } from '@/components/Map/MapLoader/MapLoader.component'; import { MapVectorBackgroundSelector } from '@/components/Map/MapVectorBackgroundSelector/MapVectorBackgroundSelector.component'; import { MapActiveLayerSelector } from '@/components/Map/MapActiveLayerSelector/MapActiveLayerSelector.component'; import { useAppSelector } from '@/redux/hooks/useAppSelector'; -import { vectorRenderingSelector } from '@/redux/models/models.selectors'; import { MapAdditionalLogos } from '@/components/Map/MapAdditionalLogos'; import { MapDrawActions } from '@/components/Map/MapDrawActions/MapDrawActions.component'; import { layersActiveLayerSelector } from '@/redux/layers/layers.selectors'; import { MapAdditionalActions } from './MapAdditionalActions'; -import { MapAdditionalOptions } from './MapAdditionalOptions'; import { PluginsDrawer } from './PluginsDrawer'; export const Map = (): JSX.Element => { - const vectorRendering = useAppSelector(vectorRenderingSelector); const activeLayer = useAppSelector(layersActiveLayerSelector); return ( @@ -24,14 +21,9 @@ export const Map = (): JSX.Element => { data-testid="map-container" > <MapViewer /> - {!vectorRendering && <MapAdditionalOptions />} - {vectorRendering && ( - <> - <MapVectorBackgroundSelector /> - <MapActiveLayerSelector /> - {activeLayer && <MapDrawActions />} - </> - )} + <MapVectorBackgroundSelector /> + <MapActiveLayerSelector /> + {activeLayer && <MapDrawActions />} <Drawer /> <PluginsDrawer /> <Legend /> diff --git a/src/components/Map/MapDrawActions/MapDrawEditActions.component.tsx b/src/components/Map/MapDrawActions/MapDrawEditActions.component.tsx index 1782e00ee62a5476298575ce94597d4eecea3f86..01ebfff1765a9bf0de482ff60118819bcea71676 100644 --- a/src/components/Map/MapDrawActions/MapDrawEditActions.component.tsx +++ b/src/components/Map/MapDrawActions/MapDrawEditActions.component.tsx @@ -10,12 +10,12 @@ import { layersActiveLayerSelector } from '@/redux/layers/layers.selectors'; import { layerDeleteImage, layerUpdateImage } from '@/redux/layers/layers.slice'; import { useMapInstance } from '@/utils/context/mapInstanceContext'; import { mapEditToolsSetLayerObject } from '@/redux/mapEditTools/mapEditTools.slice'; -import updateGlyph from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/updateGlyph'; +import updateGlyph from '@/components/Map/MapViewer/utils/shapes/elements/Glyph/updateGlyph'; import QuestionModal from '@/components/FunctionalArea/Modal/QuestionModal/QustionModal.component'; import { useState } from 'react'; import { showToast } from '@/utils/showToast'; import { SerializedError } from '@reduxjs/toolkit'; -import removeElementFromLayer from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/removeElementFromLayer'; +import removeElementFromLayer from '@/components/Map/MapViewer/utils/shapes/elements/removeElementFromLayer'; type MapDrawEditActionsComponentProps = { toggleMapEditAction: () => void; diff --git a/src/components/Map/MapLoader/MapLoader.component.test.tsx b/src/components/Map/MapLoader/MapLoader.component.test.tsx index eb35db6b6bfbafe153929763e5b5dffbe9e5069a..7f8fb00b2bb18a3bbcf71ba26ca4a7c0f7c6783f 100644 --- a/src/components/Map/MapLoader/MapLoader.component.test.tsx +++ b/src/components/Map/MapLoader/MapLoader.component.test.tsx @@ -9,7 +9,6 @@ import { useAppSelector } from '@/redux/hooks/useAppSelector'; import { newReactionsLoadingSelector } from '@/redux/newReactions/newReactions.selectors'; import { modelElementsLoadingSelector } from '@/redux/modelElements/modelElements.selector'; import { isDrawerOpenSelector } from '@/redux/drawer/drawer.selectors'; -import { vectorRenderingSelector } from '@/redux/models/models.selectors'; import { arrowTypesLoadingSelector, bioShapesLoadingSelector, @@ -50,7 +49,6 @@ describe('MapLoader', () => { const selectorMap = new Map<SelectorFunction, string | boolean>([ [newReactionsLoadingSelector, 'succeeded'], [modelElementsLoadingSelector, 'succeeded'], - [vectorRenderingSelector, true], [bioShapesLoadingSelector, 'succeeded'], [lineTypesLoadingSelector, 'succeeded'], [arrowTypesLoadingSelector, 'succeeded'], @@ -65,12 +63,11 @@ describe('MapLoader', () => { expect(screen.queryByTestId('loading-indicator')).not.toBeInTheDocument(); }); - it('should render the LoadingIndicator when vectorRendering is true and data is loading', () => { + it('should render the LoadingIndicator when data is loading', () => { mockUseAppSelector.mockImplementation(selector => { const selectorMap = new Map<SelectorFunction, string | boolean>([ [newReactionsLoadingSelector, 'pending'], [modelElementsLoadingSelector, 'succeeded'], - [vectorRenderingSelector, true], [bioShapesLoadingSelector, 'succeeded'], [lineTypesLoadingSelector, 'succeeded'], [arrowTypesLoadingSelector, 'succeeded'], @@ -84,24 +81,4 @@ describe('MapLoader', () => { expect(screen.queryByTestId('loading-indicator')).toBeInTheDocument(); }); - - it('should not render the LoadingIndicator when vectorRendering is false even when data is loading', () => { - mockUseAppSelector.mockImplementation(selector => { - const selectorMap = new Map<SelectorFunction, string | boolean>([ - [newReactionsLoadingSelector, 'pending'], - [modelElementsLoadingSelector, 'succeeded'], - [vectorRenderingSelector, false], - [bioShapesLoadingSelector, 'succeeded'], - [lineTypesLoadingSelector, 'succeeded'], - [arrowTypesLoadingSelector, 'succeeded'], - [layersLoadingSelector, 'succeeded'], - [isDrawerOpenSelector, false], - ]); - - return selectorMap.get(selector) ?? false; - }); - renderComponent(); - - expect(screen.queryByTestId('loading-indicator')).not.toBeInTheDocument(); - }); }); diff --git a/src/components/Map/MapLoader/MapLoader.component.tsx b/src/components/Map/MapLoader/MapLoader.component.tsx index fc457e0b62d735e95569b41fdbe41b598638f15c..a521a7f5462b8cef8050535f74bb9ed29f359b8c 100644 --- a/src/components/Map/MapLoader/MapLoader.component.tsx +++ b/src/components/Map/MapLoader/MapLoader.component.tsx @@ -2,7 +2,6 @@ import { LoadingIndicator } from '@/shared/LoadingIndicator'; import { useMemo } from 'react'; import { newReactionsLoadingSelector } from '@/redux/newReactions/newReactions.selectors'; import { modelElementsLoadingSelector } from '@/redux/modelElements/modelElements.selector'; -import { vectorRenderingSelector } from '@/redux/models/models.selectors'; import { arrowTypesLoadingSelector, bioShapesLoadingSelector, @@ -16,7 +15,6 @@ import { useAppSelector } from '@/redux/hooks/useAppSelector'; export const MapLoader = (): JSX.Element => { const reactionsFetching = useAppSelector(newReactionsLoadingSelector); const modelElementsFetching = useAppSelector(modelElementsLoadingSelector); - const vectorRendering = useAppSelector(vectorRenderingSelector); const bioShapesFetching = useAppSelector(bioShapesLoadingSelector); const lineTypesFetching = useAppSelector(lineTypesLoadingSelector); const arrowTypesFetching = useAppSelector(arrowTypesLoadingSelector); @@ -44,7 +42,7 @@ export const MapLoader = (): JSX.Element => { return ( <div className={`map-loader transition-all duration-500 ${isDrawerOpen ? 'move-right' : ''}`}> - {vectorRendering && showLoader && <LoadingIndicator width={48} height={48} />} + {showLoader && <LoadingIndicator width={48} height={48} />} </div> ); }; diff --git a/src/components/Map/MapViewer/MapViewer.constants.ts b/src/components/Map/MapViewer/MapViewer.constants.ts index 41924be9b55e2192a7fe0ef80256f5fa991bd88b..2d0472651331df088b3e3a81f628c7de4b004580 100644 --- a/src/components/Map/MapViewer/MapViewer.constants.ts +++ b/src/components/Map/MapViewer/MapViewer.constants.ts @@ -1 +1,203 @@ +import { Color, ShapeRelAbs, ShapeRelAbsBezierPoint } from '@/types/models'; + export const MAP_VIEWER_ROLE = 'map-viewer'; + +export const VECTOR_MAP_LAYER_TYPE = 'vectorMapLayer'; + +export const COMPLEX_SBO_TERMS = ['SBO:0000253', 'SBO:0000297', 'SBO:0000289']; + +export const TEXT_CUTOFF_SCALE = 0.34; +export const OUTLINE_CUTOFF_SCALE = 0.18; +export const COMPLEX_CONTENTS_CUTOFF_SCALE = 0.215; +export const REACTION_ELEMENT_CUTOFF_SCALE = 0.125; + +export const WHITE_COLOR: Color = { + alpha: 255, + rgb: 16777215, +}; + +export const BLACK_COLOR: Color = { + alpha: 255, + rgb: -16777216, +}; + +export const TRANSPARENT_COLOR: Color = { + alpha: 0, + rgb: 0, +}; + +export const REACTION_ELEMENT_TYPES = { + OPERATOR: 'OPERATOR', + SQUARE: 'SQUARE', + LINE: 'LINE', + ARROW: 'ARROW', +}; + +export const MAP_ELEMENT_TYPES = { + TEXT: 'TEXT', + MODIFICATION: 'MODIFICATION', + ACTIVITY_BORDER: 'ACTIVITY_BORDER', + ENTITY: 'ENTITY', + OVERLAY: 'OVERLAY', + COMPARTMENT: 'COMPARTMENT', +}; + +export const LAYER_ELEMENT_TYPES = { + TEXT: 'TEXT', + OVAL: 'OVAL', + RECT: 'RECT', + LINE: 'LINE', + ARROW: 'ARROW', +}; + +export const COMPARTMENT_SQUARE_POINTS: Array<ShapeRelAbs | ShapeRelAbsBezierPoint> = [ + { + type: 'REL_ABS_POINT', + absoluteX: 10.0, + absoluteY: 0.0, + relativeX: 0.0, + relativeY: 0.0, + relativeHeightForX: null, + relativeWidthForY: null, + }, + { + type: 'REL_ABS_POINT', + absoluteX: -10.0, + absoluteY: 0.0, + relativeX: 100.0, + relativeY: 0.0, + relativeHeightForX: null, + relativeWidthForY: null, + }, + { + type: 'REL_ABS_BEZIER_POINT', + absoluteX1: 0.0, + absoluteY1: 10.0, + relativeX1: 100.0, + relativeY1: 0.0, + relativeHeightForX1: null, + relativeWidthForY1: null, + absoluteX2: -5.0, + absoluteY2: 0.0, + relativeX2: 100.0, + relativeY2: 0.0, + relativeHeightForX2: null, + relativeWidthForY2: null, + absoluteX3: 0.0, + absoluteY3: 5.0, + relativeX3: 100.0, + relativeY3: 0.0, + relativeHeightForX3: null, + relativeWidthForY3: null, + }, + { + type: 'REL_ABS_POINT', + absoluteX: 0.0, + absoluteY: -10.0, + relativeX: 100.0, + relativeY: 100.0, + relativeHeightForX: null, + relativeWidthForY: null, + }, + { + type: 'REL_ABS_BEZIER_POINT', + absoluteX1: -10.0, + absoluteY1: 0.0, + relativeX1: 100.0, + relativeY1: 100.0, + relativeHeightForX1: null, + relativeWidthForY1: null, + absoluteX2: 0.0, + absoluteY2: -5.0, + relativeX2: 100.0, + relativeY2: 100.0, + relativeHeightForX2: null, + relativeWidthForY2: null, + absoluteX3: -5.0, + absoluteY3: 0.0, + relativeX3: 100.0, + relativeY3: 100.0, + relativeHeightForX3: null, + relativeWidthForY3: null, + }, + { + type: 'REL_ABS_POINT', + absoluteX: 10.0, + absoluteY: 0.0, + relativeX: 0.0, + relativeY: 100.0, + relativeHeightForX: null, + relativeWidthForY: null, + }, + { + type: 'REL_ABS_BEZIER_POINT', + absoluteX1: 0.0, + absoluteY1: -10.0, + relativeX1: 0.0, + relativeY1: 100.0, + relativeHeightForX1: null, + relativeWidthForY1: null, + absoluteX2: 5.0, + absoluteY2: 0.0, + relativeX2: 0.0, + relativeY2: 100.0, + relativeHeightForX2: null, + relativeWidthForY2: null, + absoluteX3: 0.0, + absoluteY3: -5.0, + relativeX3: 0.0, + relativeY3: 100.0, + relativeHeightForX3: null, + relativeWidthForY3: null, + }, + { + type: 'REL_ABS_POINT', + absoluteX: 0.0, + absoluteY: 10.0, + relativeX: 0.0, + relativeY: 0.0, + relativeHeightForX: null, + relativeWidthForY: null, + }, + { + type: 'REL_ABS_BEZIER_POINT', + absoluteX1: 10.0, + absoluteY1: 0.0, + relativeX1: 0.0, + relativeY1: 0.0, + relativeHeightForX1: null, + relativeWidthForY1: null, + absoluteX2: 0.0, + absoluteY2: 5.0, + relativeX2: 0.0, + relativeY2: 0.0, + relativeHeightForX2: null, + relativeWidthForY2: null, + absoluteX3: 5.0, + absoluteY3: 0.0, + relativeX3: 0.0, + relativeY3: 0.0, + relativeHeightForX3: null, + relativeWidthForY3: null, + }, +]; + +export const COMPARTMENT_CIRCLE_CENTER: ShapeRelAbs = { + type: 'REL_ABS_POINT', + absoluteX: 0.0, + absoluteY: 0.0, + relativeX: 50.0, + relativeY: 50.0, + relativeHeightForX: null, + relativeWidthForY: null, +}; + +export const COMPARTMENT_CIRCLE_RADIUS: ShapeRelAbs = { + type: 'REL_ABS_RADIUS', + absoluteX: 0.0, + absoluteY: 0.0, + relativeX: 50.0, + relativeY: 50.0, + relativeHeightForX: null, + relativeWidthForY: null, +}; diff --git a/src/components/Map/MapViewer/MapViewer.types.ts b/src/components/Map/MapViewer/MapViewer.types.ts index f6750e5cb1b7db0b38c29ba97fc7ca3c5cbd7b26..f10c907015829ddfd27af09b3f307ca1a27957c7 100644 --- a/src/components/Map/MapViewer/MapViewer.types.ts +++ b/src/components/Map/MapViewer/MapViewer.types.ts @@ -1,7 +1,22 @@ import View from 'ol/View'; import BaseLayer from 'ol/layer/Base'; +import { OverlayBioEntityRender } from '@/types/OLrendering'; export type MapConfig = { view: View; layers: BaseLayer[]; }; + +export type VerticalAlign = 'TOP' | 'MIDDLE' | 'BOTTOM'; +export type HorizontalAlign = 'LEFT' | 'RIGHT' | 'CENTER' | 'END' | 'START'; + +export type OverlayBioEntityGroupedElementsType = { + [id: string]: Array<OverlayBioEntityRender & { amount: number }>; +}; + +export type BoundingBox = { + x: number; + y: number; + width: number; + height: number; +}; diff --git a/src/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants.ts b/src/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants.ts deleted file mode 100644 index 614d3dcf06a521ffb3fe170362e760b59905086b..0000000000000000000000000000000000000000 --- a/src/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants.ts +++ /dev/null @@ -1,201 +0,0 @@ -import { Color, ShapeRelAbs, ShapeRelAbsBezierPoint } from '@/types/models'; - -export const VECTOR_MAP_LAYER_TYPE = 'vectorMapLayer'; - -export const COMPLEX_SBO_TERMS = ['SBO:0000253', 'SBO:0000297', 'SBO:0000289']; - -export const TEXT_CUTOFF_SCALE = 0.34; -export const OUTLINE_CUTOFF_SCALE = 0.18; -export const COMPLEX_CONTENTS_CUTOFF_SCALE = 0.215; -export const REACTION_ELEMENT_CUTOFF_SCALE = 0.125; - -export const WHITE_COLOR: Color = { - alpha: 255, - rgb: 16777215, -}; - -export const BLACK_COLOR: Color = { - alpha: 255, - rgb: -16777216, -}; - -export const TRANSPARENT_COLOR: Color = { - alpha: 0, - rgb: 0, -}; - -export const REACTION_ELEMENT_TYPES = { - OPERATOR: 'OPERATOR', - SQUARE: 'SQUARE', - LINE: 'LINE', - ARROW: 'ARROW', -}; - -export const MAP_ELEMENT_TYPES = { - TEXT: 'TEXT', - MODIFICATION: 'MODIFICATION', - ACTIVITY_BORDER: 'ACTIVITY_BORDER', - ENTITY: 'ENTITY', - OVERLAY: 'OVERLAY', - COMPARTMENT: 'COMPARTMENT', -}; - -export const LAYER_ELEMENT_TYPES = { - TEXT: 'TEXT', - OVAL: 'OVAL', - RECT: 'RECT', - LINE: 'LINE', - ARROW: 'ARROW', -}; - -export const COMPARTMENT_SQUARE_POINTS: Array<ShapeRelAbs | ShapeRelAbsBezierPoint> = [ - { - type: 'REL_ABS_POINT', - absoluteX: 10.0, - absoluteY: 0.0, - relativeX: 0.0, - relativeY: 0.0, - relativeHeightForX: null, - relativeWidthForY: null, - }, - { - type: 'REL_ABS_POINT', - absoluteX: -10.0, - absoluteY: 0.0, - relativeX: 100.0, - relativeY: 0.0, - relativeHeightForX: null, - relativeWidthForY: null, - }, - { - type: 'REL_ABS_BEZIER_POINT', - absoluteX1: 0.0, - absoluteY1: 10.0, - relativeX1: 100.0, - relativeY1: 0.0, - relativeHeightForX1: null, - relativeWidthForY1: null, - absoluteX2: -5.0, - absoluteY2: 0.0, - relativeX2: 100.0, - relativeY2: 0.0, - relativeHeightForX2: null, - relativeWidthForY2: null, - absoluteX3: 0.0, - absoluteY3: 5.0, - relativeX3: 100.0, - relativeY3: 0.0, - relativeHeightForX3: null, - relativeWidthForY3: null, - }, - { - type: 'REL_ABS_POINT', - absoluteX: 0.0, - absoluteY: -10.0, - relativeX: 100.0, - relativeY: 100.0, - relativeHeightForX: null, - relativeWidthForY: null, - }, - { - type: 'REL_ABS_BEZIER_POINT', - absoluteX1: -10.0, - absoluteY1: 0.0, - relativeX1: 100.0, - relativeY1: 100.0, - relativeHeightForX1: null, - relativeWidthForY1: null, - absoluteX2: 0.0, - absoluteY2: -5.0, - relativeX2: 100.0, - relativeY2: 100.0, - relativeHeightForX2: null, - relativeWidthForY2: null, - absoluteX3: -5.0, - absoluteY3: 0.0, - relativeX3: 100.0, - relativeY3: 100.0, - relativeHeightForX3: null, - relativeWidthForY3: null, - }, - { - type: 'REL_ABS_POINT', - absoluteX: 10.0, - absoluteY: 0.0, - relativeX: 0.0, - relativeY: 100.0, - relativeHeightForX: null, - relativeWidthForY: null, - }, - { - type: 'REL_ABS_BEZIER_POINT', - absoluteX1: 0.0, - absoluteY1: -10.0, - relativeX1: 0.0, - relativeY1: 100.0, - relativeHeightForX1: null, - relativeWidthForY1: null, - absoluteX2: 5.0, - absoluteY2: 0.0, - relativeX2: 0.0, - relativeY2: 100.0, - relativeHeightForX2: null, - relativeWidthForY2: null, - absoluteX3: 0.0, - absoluteY3: -5.0, - relativeX3: 0.0, - relativeY3: 100.0, - relativeHeightForX3: null, - relativeWidthForY3: null, - }, - { - type: 'REL_ABS_POINT', - absoluteX: 0.0, - absoluteY: 10.0, - relativeX: 0.0, - relativeY: 0.0, - relativeHeightForX: null, - relativeWidthForY: null, - }, - { - type: 'REL_ABS_BEZIER_POINT', - absoluteX1: 10.0, - absoluteY1: 0.0, - relativeX1: 0.0, - relativeY1: 0.0, - relativeHeightForX1: null, - relativeWidthForY1: null, - absoluteX2: 0.0, - absoluteY2: 5.0, - relativeX2: 0.0, - relativeY2: 0.0, - relativeHeightForX2: null, - relativeWidthForY2: null, - absoluteX3: 5.0, - absoluteY3: 0.0, - relativeX3: 0.0, - relativeY3: 0.0, - relativeHeightForX3: null, - relativeWidthForY3: null, - }, -]; - -export const COMPARTMENT_CIRCLE_CENTER: ShapeRelAbs = { - type: 'REL_ABS_POINT', - absoluteX: 0.0, - absoluteY: 0.0, - relativeX: 50.0, - relativeY: 50.0, - relativeHeightForX: null, - relativeWidthForY: null, -}; - -export const COMPARTMENT_CIRCLE_RADIUS: ShapeRelAbs = { - type: 'REL_ABS_RADIUS', - absoluteX: 0.0, - absoluteY: 0.0, - relativeX: 50.0, - relativeY: 50.0, - relativeHeightForX: null, - relativeWidthForY: null, -}; diff --git a/src/components/Map/MapViewer/MapViewerVector/MapViewerVector.types.ts b/src/components/Map/MapViewer/MapViewerVector/MapViewerVector.types.ts deleted file mode 100644 index 709336b14c2a6815994e21ebd1e24e138b5384ce..0000000000000000000000000000000000000000 --- a/src/components/Map/MapViewer/MapViewerVector/MapViewerVector.types.ts +++ /dev/null @@ -1,24 +0,0 @@ -import View from 'ol/View'; -import BaseLayer from 'ol/layer/Base'; -import { OverlayBioEntityRender } from '@/types/OLrendering'; - -export type MapConfig = { - view: View; - layers: BaseLayer[]; -}; - -export type VerticalAlign = 'TOP' | 'MIDDLE' | 'BOTTOM'; -export type HorizontalAlign = 'LEFT' | 'RIGHT' | 'CENTER' | 'END' | 'START'; - -export type ScaleFunction = (resolution: number) => number; - -export type OverlayBioEntityGroupedElementsType = { - [id: string]: Array<OverlayBioEntityRender & { amount: number }>; -}; - -export type BoundingBox = { - x: number; - y: number; - width: number; - height: number; -}; diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners.test.ts b/src/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners.test.ts deleted file mode 100644 index 2821fe918cb9eb8dc9bd2859dd5d4fe130517f58..0000000000000000000000000000000000000000 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners.test.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* eslint-disable @typescript-eslint/explicit-function-return-type */ -import { renderHook } from '@testing-library/react'; -import { View } from 'ol'; -import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; -import { initialMapDataFixture, openedMapsThreeSubmapsFixture } from '@/redux/map/map.fixtures'; -import { useOlMapVectorListeners } from '@/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners'; -import { onMapLeftClick } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; - -jest.mock('./mouseClick/mouseLeftClick/onMapLeftClick', () => ({ - __esModule: true, - onMapLeftClick: jest.fn(), -})); - -jest.mock('use-debounce', () => { - return { - useDebounce: () => {}, - useDebouncedCallback: () => {}, - }; -}); - -describe('useOlMapVectorListeners - util', () => { - const { Wrapper } = getReduxWrapperWithStore({ - map: { - data: { ...initialMapDataFixture }, - loading: 'succeeded', - error: { message: '', name: '' }, - openedMaps: openedMapsThreeSubmapsFixture, - backgroundType: MapBackgroundsEnum.SEMANTIC, - }, - }); - - beforeEach(() => { - jest.clearAllMocks(); - }); - - describe('on left click event', () => { - it('should run onMapLeftClick event', () => { - const CALLED_ONCE = 1; - const view = new View(); - - renderHook(() => useOlMapVectorListeners({ mapInstance: undefined }), { - wrapper: Wrapper, - }); - view.dispatchEvent('singleclick'); - - expect(onMapLeftClick).toBeCalledTimes(CALLED_ONCE); - }); - }); -}); diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners.ts b/src/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners.ts deleted file mode 100644 index 444cf47bc8ed2d4bfccf05076b7536f9a1a1b7ac..0000000000000000000000000000000000000000 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { OPTIONS } from '@/constants/map'; -import { resultDrawerOpen } from '@/redux/drawer/drawer.selectors'; -import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; -import { mapDataSizeSelector } from '@/redux/map/map.selectors'; -import { currentModelIdSelector, vectorRenderingSelector } from '@/redux/models/models.selectors'; -import { MapInstance } from '@/types/map'; -import { unByKey } from 'ol/Observable'; -import { useEffect, useRef } from 'react'; -import { useSelector } from 'react-redux'; -import { useDebouncedCallback } from 'use-debounce'; -import { allCommentsSelectorOfCurrentMap } from '@/redux/comment/comment.selectors'; -import { onMapLeftClick } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick'; -import { useAppSelector } from '@/redux/hooks/useAppSelector'; -import { Coordinate } from 'ol/coordinate'; -import { Pixel } from 'ol/pixel'; -import { onMapRightClick } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/onMapRightClick'; -import { modelElementsForCurrentModelSelector } from '@/redux/modelElements/modelElements.selector'; -import { newReactionsForCurrentModelSelector } from '@/redux/newReactions/newReactions.selectors'; - -interface UseOlMapVectorListenersInput { - mapInstance: MapInstance; -} - -export const useOlMapVectorListeners = ({ mapInstance }: UseOlMapVectorListenersInput): void => { - const mapSize = useSelector(mapDataSizeSelector); - const modelId = useSelector(currentModelIdSelector); - const isResultDrawerOpen = useSelector(resultDrawerOpen); - const modelElementsForCurrentModel = useSelector(modelElementsForCurrentModelSelector); - const newReactionsForCurrentModel = useSelector(newReactionsForCurrentModelSelector); - const dispatch = useAppDispatch(); - const coordinate = useRef<Coordinate>([]); - const pixel = useRef<Pixel>([]); - - const comments = useSelector(allCommentsSelectorOfCurrentMap); - const vectorRendering = useAppSelector(vectorRenderingSelector); - - const handleMapLeftClick = useDebouncedCallback( - onMapLeftClick( - mapSize, - modelId, - dispatch, - isResultDrawerOpen, - comments, - modelElementsForCurrentModel || [], - newReactionsForCurrentModel, - ), - OPTIONS.clickPersistTime, - { leading: false }, - ); - - const handleRightClick = useDebouncedCallback( - onMapRightClick( - mapSize, - modelId, - dispatch, - modelElementsForCurrentModel || [], - newReactionsForCurrentModel, - ), - OPTIONS.clickPersistTime, - { - leading: false, - }, - ); - - useEffect(() => { - if (!mapInstance || !vectorRendering) { - return; - } - - const key = mapInstance.on('singleclick', event => - handleMapLeftClick({ coordinate: event.coordinate, pixel: event.pixel }, mapInstance), - ); - - // eslint-disable-next-line consistent-return - return () => unByKey(key); - }, [mapInstance, handleMapLeftClick, vectorRendering]); - - useEffect(() => { - if (!mapInstance || !vectorRendering) { - return; - } - - const rightClickEvent = (e: MouseEvent): Promise<void> | undefined => { - e.preventDefault(); - - coordinate.current = mapInstance.getEventCoordinate(e); - pixel.current = mapInstance.getEventPixel(e); - - return handleRightClick( - { coordinate: coordinate.current, pixel: pixel.current }, - mapInstance, - ); - }; - - mapInstance.getViewport().addEventListener('contextmenu', rightClickEvent); - - // eslint-disable-next-line consistent-return - return () => mapInstance.getViewport().removeEventListener('contextmenu', rightClickEvent); - }, [mapInstance, handleRightClick, vectorRendering]); -}; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers.test.ts b/src/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers.test.ts deleted file mode 100644 index 9ec7e61450fa2c2176760f600ba4bca508566bef..0000000000000000000000000000000000000000 --- a/src/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers.test.ts +++ /dev/null @@ -1,85 +0,0 @@ -/* eslint-disable no-magic-numbers */ -import { MAP_DATA_INITIAL_STATE, OPENED_MAPS_INITIAL_STATE } from '@/redux/map/map.constants'; -import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; -import { renderHook } from '@testing-library/react'; -import BaseLayer from 'ol/layer/Base'; -import VectorLayer from 'ol/layer/Vector'; -import React from 'react'; -import { useOlMap } from '@/components/Map/MapViewer/utils/useOlMap'; -import { useOlMapVectorLayers } from '@/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; - -const useRefValue = { - current: null, -}; - -Object.defineProperty(useRefValue, 'current', { - get: jest.fn(() => ({ - innerHTML: '', - appendChild: jest.fn(), - addEventListener: jest.fn(), - getRootNode: jest.fn(), - })), - set: jest.fn(() => ({ - innerHTML: '', - appendChild: jest.fn(), - addEventListener: jest.fn(), - getRootNode: jest.fn(), - })), -}); - -jest.spyOn(React, 'useRef').mockReturnValue(useRefValue); - -describe('useOlMapLayers - util', () => { - const getRenderedHookResults = (): BaseLayer[] => { - const { Wrapper } = getReduxWrapperWithStore({ - map: { - data: { - ...MAP_DATA_INITIAL_STATE, - size: { - width: 256, - height: 256, - tileSize: 256, - minZoom: 1, - maxZoom: 1, - }, - position: { - initial: { - x: 256, - y: 256, - }, - last: { - x: 256, - y: 256, - }, - }, - }, - loading: 'idle', - error: { - name: '', - message: '', - }, - openedMaps: OPENED_MAPS_INITIAL_STATE, - backgroundType: MapBackgroundsEnum.SEMANTIC, - }, - }); - const dummyElement = document.createElement('div'); - const { result: hohResult } = renderHook(() => useOlMap({ target: dummyElement }), { - wrapper: Wrapper, - }); - - const { result } = renderHook( - () => useOlMapVectorLayers({ mapInstance: hohResult.current.mapInstance }), - { - wrapper: Wrapper, - }, - ); - return result.current; - }; - - it('should return valid VectorLayer instance [1]', () => { - const result = getRenderedHookResults(); - expect(result[0]).toBeInstanceOf(VectorLayer); - expect(result[0].getSourceState()).toBe('ready'); - }); -}); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers.ts b/src/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers.ts deleted file mode 100644 index 253c3a38954dac9549948a3c3e5f7536fc9399e6..0000000000000000000000000000000000000000 --- a/src/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* eslint-disable no-magic-numbers */ -import { MapInstance } from '@/types/map'; -import { useOlMapAdditionalLayers } from '@/components/Map/MapViewer/MapViewerVector/utils/config/additionalLayers/useOlMapAdditionalLayers'; -import { useMemo } from 'react'; -import { useOlMapCardLayer } from '@/components/Map/MapViewer/MapViewerVector/utils/config/mapCardLayer/useOlMapCardLayer'; -import { useOlMapReactionsLayer } from './reactionsLayer/useOlMapReactionsLayer'; -import { MapConfig } from '../../MapViewerVector.types'; - -interface UseOlMapLayersInput { - mapInstance: MapInstance; -} - -export const useOlMapVectorLayers = ({ mapInstance }: UseOlMapLayersInput): MapConfig['layers'] => { - const reactionsLayer = useOlMapReactionsLayer({ mapInstance }); - const additionalLayers = useOlMapAdditionalLayers(mapInstance); - const mapCardLayer = useOlMapCardLayer(); - - return useMemo(() => { - return [mapCardLayer, reactionsLayer, ...additionalLayers]; - }, [mapCardLayer, reactionsLayer, additionalLayers]); -}; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/additionalLayers/useOlMapAdditionalLayers.test.ts b/src/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers.test.ts similarity index 92% rename from src/components/Map/MapViewer/MapViewerVector/utils/config/additionalLayers/useOlMapAdditionalLayers.test.ts rename to src/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers.test.ts index 68151ba06537964a865a132937e502a0c894dc08..eba9fde5e0faab891f30e7dd987e3a5a4907b7eb 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/config/additionalLayers/useOlMapAdditionalLayers.test.ts +++ b/src/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers.test.ts @@ -5,7 +5,7 @@ import VectorLayer from 'ol/layer/Vector'; import { initialMapStateFixture } from '@/redux/map/map.fixtures'; import { BACKGROUND_INITIAL_STATE_MOCK } from '@/redux/backgrounds/background.mock'; import { Map } from 'ol'; -import { useOlMapAdditionalLayers } from '@/components/Map/MapViewer/MapViewerVector/utils/config/additionalLayers/useOlMapAdditionalLayers'; +import { useOlMapAdditionalLayers } from '@/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers'; describe('useOlMapAdditionalLayers - util', () => { it('should return VectorLayer', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/additionalLayers/useOlMapAdditionalLayers.ts b/src/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers.ts similarity index 89% rename from src/components/Map/MapViewer/MapViewerVector/utils/config/additionalLayers/useOlMapAdditionalLayers.ts rename to src/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers.ts index 01518c934442680b2e42cc1182325d59aa04490d..537df192eab6b59430d5c3ec0c325404f029fdb2 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/config/additionalLayers/useOlMapAdditionalLayers.ts +++ b/src/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers.ts @@ -4,7 +4,7 @@ import VectorLayer from 'ol/layer/Vector'; import VectorSource from 'ol/source/Vector'; import { useEffect, useMemo, useState } from 'react'; import { useSelector } from 'react-redux'; -import { currentModelIdSelector, vectorRenderingSelector } from '@/redux/models/models.selectors'; +import { currentModelIdSelector } from '@/redux/models/models.selectors'; import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; import { getLayersForModel } from '@/redux/layers/layers.thunks'; import { @@ -17,16 +17,16 @@ import { usePointToProjection } from '@/utils/map/usePointToProjection'; import { MapInstance } from '@/types/map'; import { Geometry, LineString, MultiPolygon, Point } from 'ol/geom'; import Polygon from 'ol/geom/Polygon'; -import Layer from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/Layer'; +import Layer from '@/components/Map/MapViewer/utils/shapes/layer/Layer'; import { arrowTypesSelector, lineTypesSelector } from '@/redux/shapes/shapes.selectors'; import { useAppSelector } from '@/redux/hooks/useAppSelector'; import { mapDataSizeSelector } from '@/redux/map/map.selectors'; -import getDrawImageInteraction from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getDrawImageInteraction'; +import getDrawImageInteraction from '@/components/Map/MapViewer/utils/shapes/layer/getDrawImageInteraction'; import { LayerState } from '@/redux/layers/layers.types'; import { mapEditToolsActiveActionSelector } from '@/redux/mapEditTools/mapEditTools.selectors'; import { MAP_EDIT_ACTIONS } from '@/redux/mapEditTools/mapEditTools.constants'; import { Extent } from 'ol/extent'; -import getTransformImageInteraction from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getTransformImageInteraction'; +import getTransformImageInteraction from '@/components/Map/MapViewer/utils/shapes/layer/getTransformImageInteraction'; import { mapEditToolsSetLayerObject } from '@/redux/mapEditTools/mapEditTools.slice'; export const useOlMapAdditionalLayers = ( @@ -45,7 +45,6 @@ export const useOlMapAdditionalLayers = ( const layersLoading = useAppSelector(layersLoadingSelector); const layersVisibilityForCurrentModel = useAppSelector(layersVisibilityForCurrentModelSelector); const activeLayer = useAppSelector(layersActiveLayerSelector); - const vectorRendering = useAppSelector(vectorRenderingSelector); const [layersState, setLayersState] = useState<Array<LayerState>>([]); const [layersLoadingState, setLayersLoadingState] = useState(false); @@ -164,7 +163,7 @@ export const useOlMapAdditionalLayers = ( if (!transformInteraction) { return () => {}; } - if (!activeLayer || !vectorRendering || activeAction !== MAP_EDIT_ACTIONS.TRANSFORM_IMAGE) { + if (!activeLayer || activeAction !== MAP_EDIT_ACTIONS.TRANSFORM_IMAGE) { return () => {}; } mapInstance?.addInteraction(transformInteraction); @@ -172,25 +171,18 @@ export const useOlMapAdditionalLayers = ( dispatch(mapEditToolsSetLayerObject(null)); mapInstance?.removeInteraction(transformInteraction); }; - }, [activeAction, activeLayer, dispatch, mapInstance, transformInteraction, vectorRendering]); + }, [activeAction, activeLayer, dispatch, mapInstance, transformInteraction]); useEffect(() => { if (!drawImageInteraction) { return; } mapInstance?.removeInteraction(drawImageInteraction); - if (!activeLayer || !vectorRendering || activeAction !== MAP_EDIT_ACTIONS.DRAW_IMAGE) { + if (!activeLayer || activeAction !== MAP_EDIT_ACTIONS.DRAW_IMAGE) { return; } mapInstance?.addInteraction(drawImageInteraction); - }, [ - activeAction, - activeLayer, - currentModelId, - drawImageInteraction, - mapInstance, - vectorRendering, - ]); + }, [activeAction, activeLayer, currentModelId, drawImageInteraction, mapInstance]); return vectorLayers; }; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/mapCardLayer/useOlMapCardLayer.test.ts b/src/components/Map/MapViewer/utils/config/mapCardLayer/useOlMapCardLayer.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/config/mapCardLayer/useOlMapCardLayer.test.ts rename to src/components/Map/MapViewer/utils/config/mapCardLayer/useOlMapCardLayer.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/mapCardLayer/useOlMapCardLayer.ts b/src/components/Map/MapViewer/utils/config/mapCardLayer/useOlMapCardLayer.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/config/mapCardLayer/useOlMapCardLayer.ts rename to src/components/Map/MapViewer/utils/config/mapCardLayer/useOlMapCardLayer.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/processModelElements.ts b/src/components/Map/MapViewer/utils/config/processLayer/processModelElements.ts similarity index 87% rename from src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/processModelElements.ts rename to src/components/Map/MapViewer/utils/config/processLayer/processModelElements.ts index d832a64bbe2456c5da73901820fec74292a8d52d..25aa20784b0fed050637308f74b25987820ecd71 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/processModelElements.ts +++ b/src/components/Map/MapViewer/utils/config/processLayer/processModelElements.ts @@ -1,13 +1,5 @@ import { ModelElement } from '@/types/models'; -import MapElement from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement'; -import CompartmentCircle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentCircle'; -import CompartmentSquare from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentSquare'; -import CompartmentPathway from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentPathway'; -import Glyph from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph'; -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; import { MapInstance } from '@/types/map'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { BioShapesDict, LineTypeDict } from '@/redux/shapes/shapes.types'; @@ -16,6 +8,11 @@ import { OverlayBioEntityRender } from '@/types/OLrendering'; import { GetOverlayBioEntityColorByAvailableProperties } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useGetOverlayColor'; import VectorSource from 'ol/source/Vector'; import { MapSize } from '@/redux/map/map.types'; +import Glyph from '@/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph'; +import CompartmentPathway from '@/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway'; +import CompartmentSquare from '@/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare'; +import CompartmentCircle from '@/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle'; +import MapElement from '@/components/Map/MapViewer/utils/shapes/elements/MapElement'; export default function processModelElements( modelElements: Array<ModelElement>, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer.test.ts b/src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.test.ts similarity index 79% rename from src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer.test.ts rename to src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.test.ts index b54a29b43672e2c9e8a34749bf856ade5079e463..c8e961ed2b0f75e12873768570cc1d04a3ed8224 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer.test.ts +++ b/src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.test.ts @@ -4,7 +4,7 @@ import VectorLayer from 'ol/layer/Vector'; import { initialMapStateFixture } from '@/redux/map/map.fixtures'; import { BACKGROUND_INITIAL_STATE_MOCK } from '@/redux/backgrounds/background.mock'; import { Map } from 'ol'; -import { useOlMapReactionsLayer } from '@/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer'; +import { useOlMapProcessLayer } from '@/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer'; describe('useOlMapReactionsLayer - util', () => { it('should return VectorLayer', () => { @@ -15,7 +15,7 @@ describe('useOlMapReactionsLayer - util', () => { const dummyElement = document.createElement('div'); const mapInstance = new Map({ target: dummyElement }); - const { result } = renderHook(() => useOlMapReactionsLayer({ mapInstance }), { + const { result } = renderHook(() => useOlMapProcessLayer({ mapInstance }), { wrapper: Wrapper, }); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer.ts b/src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.ts similarity index 87% rename from src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer.ts rename to src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.ts index fd83ac6fcc695f07df5cf56ffa2b61d3b3f806d6..09d5b04ef0a64e39c0404ccf2a9a36b99921083f 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer.ts +++ b/src/components/Map/MapViewer/utils/config/processLayer/useOlMapProcessLayer.ts @@ -4,7 +4,6 @@ import VectorLayer from 'ol/layer/Vector'; import VectorSource from 'ol/source/Vector'; import { useEffect, useMemo, useState } from 'react'; import { usePointToProjection } from '@/utils/map/usePointToProjection'; -import MapElement from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement'; import { useSelector } from 'react-redux'; import { arrowTypesSelector, @@ -19,17 +18,12 @@ import { import { currentModelIdSelector } from '@/redux/models/models.selectors'; import { getModelElementsForModel } from '@/redux/modelElements/modelElements.thunks'; import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; -import CompartmentSquare from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentSquare'; -import CompartmentCircle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentCircle'; -import Glyph from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph'; -import CompartmentPathway from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentPathway'; -import Reaction from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction'; import { newReactionsForCurrentModelSelector, newReactionsLoadingSelector, } from '@/redux/newReactions/newReactions.selectors'; import { getNewReactionsForModel } from '@/redux/newReactions/newReactions.thunks'; -import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewer.constants'; import { getOverlayOrderSelector, overlayBioEntitiesForCurrentModelSelector, @@ -37,21 +31,27 @@ import { import { groupBy } from '@/utils/array/groupBy'; import { useGetOverlayColor } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useGetOverlayColor'; import { useAppSelector } from '@/redux/hooks/useAppSelector'; -import getOverlays from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/getOverlays'; -import LineOverlay from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/LineOverlay'; import { markersSufraceOfCurrentMapDataSelector } from '@/redux/markers/markers.selectors'; import { parseSurfaceMarkersToBioEntityRender } from '@/components/Map/MapViewer/utils/config/overlaysLayer/parseSurfaceMarkersToBioEntityRender'; -import MarkerOverlay from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/MarkerOverlay'; -import processModelElements from '@/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/processModelElements'; +import processModelElements from '@/components/Map/MapViewer/utils/config/processLayer/processModelElements'; import useDebouncedValue from '@/utils/useDebouncedValue'; import { mapBackgroundTypeSelector, mapDataSizeSelector } from '@/redux/map/map.selectors'; import MapBackgroundsEnum from '@/redux/map/map.enums'; import { setMapBackgroundType } from '@/redux/map/map.slice'; import { ZOOM_RESCALING_FACTOR } from '@/constants/map'; import { OverlayOrder } from '@/redux/overlayBioEntity/overlayBioEntity.utils'; -import areOverlayOrdersNotEqual from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/areOverlayOrdersNotEqual'; +import MarkerOverlay from '@/components/Map/MapViewer/utils/shapes/overlay/MarkerOverlay'; +import LineOverlay from '@/components/Map/MapViewer/utils/shapes/overlay/LineOverlay'; +import getOverlays from '@/components/Map/MapViewer/utils/shapes/overlay/getOverlays'; +import Reaction from '@/components/Map/MapViewer/utils/shapes/reaction/Reaction'; +import CompartmentPathway from '@/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway'; +import Glyph from '@/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph'; +import CompartmentCircle from '@/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle'; +import CompartmentSquare from '@/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare'; +import MapElement from '@/components/Map/MapViewer/utils/shapes/elements/MapElement'; +import areOverlayOrdersNotEqual from '@/components/Map/MapViewer/utils/shapes/overlay/areOverlayOrdersNotEqual'; -export const useOlMapReactionsLayer = ({ +export const useOlMapProcessLayer = ({ mapInstance, }: { mapInstance: MapInstance; diff --git a/src/components/Map/MapViewer/utils/config/useOlMapCommonLayers.test.ts b/src/components/Map/MapViewer/utils/config/useOlMapCommonLayers.test.ts deleted file mode 100644 index b3117b1f2ef06d1590db2f93e3fa2537f1b1a70d..0000000000000000000000000000000000000000 --- a/src/components/Map/MapViewer/utils/config/useOlMapCommonLayers.test.ts +++ /dev/null @@ -1,93 +0,0 @@ -/* eslint-disable no-magic-numbers */ -import { MAP_DATA_INITIAL_STATE, OPENED_MAPS_INITIAL_STATE } from '@/redux/map/map.constants'; -import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; -import { renderHook } from '@testing-library/react'; -import BaseLayer from 'ol/layer/Base'; -import React from 'react'; -import VectorLayer from 'ol/layer/Vector'; -import { useOlMapCommonLayers } from '@/components/Map/MapViewer/utils/config/useOlMapCommonLayers'; -import MapBackgroundsEnum from '@/redux/map/map.enums'; - -const useRefValue = { - current: null, -}; - -Object.defineProperty(useRefValue, 'current', { - get: jest.fn(() => ({ - innerHTML: '', - appendChild: jest.fn(), - addEventListener: jest.fn(), - getRootNode: jest.fn(), - })), - set: jest.fn(() => ({ - innerHTML: '', - appendChild: jest.fn(), - addEventListener: jest.fn(), - getRootNode: jest.fn(), - })), -}); - -jest.spyOn(React, 'useRef').mockReturnValue(useRefValue); - -describe('useOlMapCommonLayers - util', () => { - const getRenderedHookResults = (): BaseLayer[] => { - const { Wrapper } = getReduxWrapperWithStore({ - map: { - data: { - ...MAP_DATA_INITIAL_STATE, - size: { - width: 256, - height: 256, - tileSize: 256, - minZoom: 1, - maxZoom: 1, - }, - position: { - initial: { - x: 256, - y: 256, - }, - last: { - x: 256, - y: 256, - }, - }, - }, - loading: 'idle', - error: { - name: '', - message: '', - }, - openedMaps: OPENED_MAPS_INITIAL_STATE, - backgroundType: MapBackgroundsEnum.SEMANTIC, - }, - }); - - const { result } = renderHook(() => useOlMapCommonLayers(), { - wrapper: Wrapper, - }); - - return result.current; - }; - - it('should return valid VectorLayer instance [1]', () => { - const result = getRenderedHookResults(); - - expect(result[0]).toBeInstanceOf(VectorLayer); - expect(result[0].getSourceState()).toBe('ready'); - }); - - it('should return valid VectorLayer instance [2]', () => { - const result = getRenderedHookResults(); - - expect(result[1]).toBeInstanceOf(VectorLayer); - expect(result[1].getSourceState()).toBe('ready'); - }); - - it('should return valid VectorLayer instance [3]', () => { - const result = getRenderedHookResults(); - - expect(result[2]).toBeInstanceOf(VectorLayer); - expect(result[2].getSourceState()).toBe('ready'); - }); -}); diff --git a/src/components/Map/MapViewer/utils/config/useOlMapCommonLayers.ts b/src/components/Map/MapViewer/utils/config/useOlMapCommonLayers.ts deleted file mode 100644 index ad70201bb3a2d1eb82a70eff6229a098f885bf78..0000000000000000000000000000000000000000 --- a/src/components/Map/MapViewer/utils/config/useOlMapCommonLayers.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* eslint-disable no-magic-numbers */ -import { useOlMapPinsLayer } from '@/components/Map/MapViewer/utils/config/pinsLayer/useOlMapPinsLayer'; -import { useOlMapReactionsLayer } from '@/components/Map/MapViewer/utils/config/reactionsLayer/useOlMapReactionsLayer'; -import { useOlMapCommentsLayer } from '@/components/Map/MapViewer/utils/config/commentsLayer/useOlMapCommentsLayer'; -import { useMemo } from 'react'; -import { MapConfig } from '../../MapViewer.types'; - -export const useOlMapCommonLayers = (): MapConfig['layers'] => { - const pinsLayer = useOlMapPinsLayer(); - const reactionsLayer = useOlMapReactionsLayer(); - const commentsLayer = useOlMapCommentsLayer(); - - return useMemo(() => { - return [pinsLayer, reactionsLayer, commentsLayer]; - }, [pinsLayer, reactionsLayer, commentsLayer]); -}; diff --git a/src/components/Map/MapViewer/utils/config/useOlMapLayers.test.ts b/src/components/Map/MapViewer/utils/config/useOlMapLayers.test.ts index b4bfec60ab66e106ed33c7a1b64c188ad33ad4de..3fe8e8611d15f028c972e154bd398600067ebd58 100644 --- a/src/components/Map/MapViewer/utils/config/useOlMapLayers.test.ts +++ b/src/components/Map/MapViewer/utils/config/useOlMapLayers.test.ts @@ -3,11 +3,11 @@ import { MAP_DATA_INITIAL_STATE, OPENED_MAPS_INITIAL_STATE } from '@/redux/map/m import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; import { renderHook } from '@testing-library/react'; import BaseLayer from 'ol/layer/Base'; -import TileLayer from 'ol/layer/Tile'; -import React from 'react'; import VectorLayer from 'ol/layer/Vector'; +import React from 'react'; +import { useOlMap } from '@/components/Map/MapViewer/utils/useOlMap'; +import { useOlMapLayers } from '@/components/Map/MapViewer/utils/config/useOlMapLayers'; import MapBackgroundsEnum from '@/redux/map/map.enums'; -import { useOlMapLayers } from './useOlMapLayers'; const useRefValue = { current: null, @@ -63,25 +63,23 @@ describe('useOlMapLayers - util', () => { backgroundType: MapBackgroundsEnum.SEMANTIC, }, }); - - const { result } = renderHook(() => useOlMapLayers(), { + const dummyElement = document.createElement('div'); + const { result: hohResult } = renderHook(() => useOlMap({ target: dummyElement }), { wrapper: Wrapper, }); + const { result } = renderHook( + () => useOlMapLayers({ mapInstance: hohResult.current.mapInstance }), + { + wrapper: Wrapper, + }, + ); return result.current; }; - it('should return valid TileLayer instance [1]', () => { + it('should return valid VectorLayer instance [1]', () => { const result = getRenderedHookResults(); - - expect(result[0]).toBeInstanceOf(TileLayer); + expect(result[0]).toBeInstanceOf(VectorLayer); expect(result[0].getSourceState()).toBe('ready'); }); - - it('should return valid VectorLayer instance [2]', () => { - const result = getRenderedHookResults(); - - expect(result[1]).toBeInstanceOf(VectorLayer); - expect(result[1].getSourceState()).toBe('ready'); - }); }); diff --git a/src/components/Map/MapViewer/utils/config/useOlMapLayers.ts b/src/components/Map/MapViewer/utils/config/useOlMapLayers.ts index 10169c987bf91c24241479ea9a1acb666bd7b64a..ed7dc2fffe149531316a42e416ca58330883eb35 100644 --- a/src/components/Map/MapViewer/utils/config/useOlMapLayers.ts +++ b/src/components/Map/MapViewer/utils/config/useOlMapLayers.ts @@ -1,11 +1,34 @@ /* eslint-disable no-magic-numbers */ -import { useOlMapOverlaysLayer } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useOlMapOverlaysLayer'; +import { MapInstance } from '@/types/map'; +import { useOlMapAdditionalLayers } from '@/components/Map/MapViewer/utils/config/additionalLayers/useOlMapAdditionalLayers'; +import { useMemo } from 'react'; +import { useOlMapCardLayer } from '@/components/Map/MapViewer/utils/config/mapCardLayer/useOlMapCardLayer'; +import { useOlMapPinsLayer } from '@/components/Map/MapViewer/utils/config/pinsLayer/useOlMapPinsLayer'; +import { useOlMapReactionsLayer } from '@/components/Map/MapViewer/utils/config/reactionsLayer/useOlMapReactionsLayer'; +import { useOlMapCommentsLayer } from '@/components/Map/MapViewer/utils/config/commentsLayer/useOlMapCommentsLayer'; import { MapConfig } from '../../MapViewer.types'; -import { useOlMapTileLayer } from './useOlMapTileLayer'; +import { useOlMapProcessLayer } from './processLayer/useOlMapProcessLayer'; -export const useOlMapLayers = (): MapConfig['layers'] => { - const overlaysLayer = useOlMapOverlaysLayer(); - const tileLayer = useOlMapTileLayer(); +interface UseOlMapLayersInput { + mapInstance: MapInstance; +} - return [tileLayer, overlaysLayer]; +export const useOlMapLayers = ({ mapInstance }: UseOlMapLayersInput): MapConfig['layers'] => { + const processLayer = useOlMapProcessLayer({ mapInstance }); + const additionalLayers = useOlMapAdditionalLayers(mapInstance); + const mapCardLayer = useOlMapCardLayer(); + const pinsLayer = useOlMapPinsLayer(); + const reactionsLayer = useOlMapReactionsLayer(); + const commentsLayer = useOlMapCommentsLayer(); + + return useMemo(() => { + return [ + mapCardLayer, + processLayer, + pinsLayer, + reactionsLayer, + commentsLayer, + ...additionalLayers, + ]; + }, [mapCardLayer, processLayer, pinsLayer, reactionsLayer, commentsLayer, additionalLayers]); }; diff --git a/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.ts b/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.ts index 963fc428dadfd5066eb64c9cf20298c281657117..5631573e85adf6ab6c309f3df02cb8e312358117 100644 --- a/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.ts +++ b/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.ts @@ -11,7 +11,7 @@ import { apiPath } from '@/redux/apiPath'; import { validateDataUsingZodSchema } from '@/utils/validateDataUsingZodSchema'; import { getMultiBioEntityByIds } from '@/redux/bioEntity/thunks/getMultiBioEntity'; import { newReactionSchema } from '@/models/newReactionSchema'; -import getModelElementsIdsFromReaction from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/getModelElementsIdsFromReaction'; +import getModelElementsIdsFromReaction from '@/components/Map/MapViewer/utils/listeners/mouseClick/getModelElementsIdsFromReaction'; import { handleReactionSearchClickFailure } from './handleReactionSearchClickFailure'; import { findClosestReactionPoint } from './findClosestReactionPoint'; diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction.test.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/clickHandleReaction.test.ts similarity index 97% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction.test.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/clickHandleReaction.test.ts index 47b21acd073d2ff3528c5fe0fa8ec6d018662ed4..d809149e1e2e92c5a92e5b34be306b6beb6716ff 100644 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction.test.ts +++ b/src/components/Map/MapViewer/utils/listeners/mouseClick/clickHandleReaction.test.ts @@ -6,7 +6,7 @@ import { mockNetworkNewAPIResponse } from '@/utils/mockNetworkResponse'; import { apiPath } from '@/redux/apiPath'; import { HttpStatusCode } from 'axios'; import { bioEntityFixture } from '@/models/fixtures/bioEntityFixture'; -import { clickHandleReaction } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction'; +import { clickHandleReaction } from '@/components/Map/MapViewer/utils/listeners/mouseClick/clickHandleReaction'; import { newReactionFixture } from '@/models/fixtures/newReactionFixture'; const mockedAxiosClient = mockNetworkNewAPIResponse(); diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/clickHandleReaction.ts similarity index 96% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/clickHandleReaction.ts index f9cbc6acdbec7395730b802a229eaac0f3ece550..2cd86bfae5d72887a88c33e33e69252a4b05d0f2 100644 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction.ts +++ b/src/components/Map/MapViewer/utils/listeners/mouseClick/clickHandleReaction.ts @@ -8,7 +8,7 @@ import { setMultipleBioEntityContents } from '@/redux/bioEntity/bioEntity.slice' import { addNumbersToEntityNumberData } from '@/redux/entityNumber/entityNumber.slice'; import { setReactions } from '@/redux/reactions/reactions.slice'; import { mapReactionToBioEntity } from '@/utils/bioEntity/mapReactionToBioEntity'; -import getModelElementsIdsFromReaction from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/getModelElementsIdsFromReaction'; +import getModelElementsIdsFromReaction from '@/components/Map/MapViewer/utils/listeners/mouseClick/getModelElementsIdsFromReaction'; import { mapModelElementToBioEntity } from '@/utils/bioEntity/mapModelElementToBioEntity'; /* prettier-ignore */ diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/getModelElementsIdsFromReaction.test.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/getModelElementsIdsFromReaction.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/getModelElementsIdsFromReaction.test.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/getModelElementsIdsFromReaction.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/getModelElementsIdsFromReaction.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/getModelElementsIdsFromReaction.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/getModelElementsIdsFromReaction.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/getModelElementsIdsFromReaction.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.test.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.test.ts similarity index 96% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.test.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.test.ts index 46ca1e403d44e82a7775861e7204ab3e5e082b18..df86f0a2d5ca95724c7901ea7a24899c8eeea178 100644 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.test.ts +++ b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.test.ts @@ -1,5 +1,5 @@ /* eslint-disable no-magic-numbers */ -import { leftClickHandleAlias } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias'; +import { leftClickHandleAlias } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias'; import { openBioEntityDrawerById, selectTab } from '@/redux/drawer/drawer.slice'; import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus'; import { searchFitBounds } from '@/services/pluginsManager/map/triggerSearch/searchFitBounds'; diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick.test.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick.test.ts similarity index 94% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick.test.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick.test.ts index 11211b8bb13f926f939c3d76935376153149b2b7..2ef85495469d48e4c76d7030b5028ca980e27903 100644 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick.test.ts +++ b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick.test.ts @@ -5,17 +5,17 @@ import { resetReactionsData } from '@/redux/reactions/reactions.slice'; import { clearBioEntities } from '@/redux/bioEntity/bioEntity.slice'; import { handleFeaturesClick } from '@/components/Map/MapViewer/utils/listeners/mapSingleClick/handleFeaturesClick'; import Map from 'ol/Map'; -import { onMapLeftClick } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick'; +import { onMapLeftClick } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick'; import { Comment } from '@/types/models'; import SimpleGeometry from 'ol/geom/SimpleGeometry'; import { Feature } from 'ol'; import { FEATURE_TYPE } from '@/constants/features'; import VectorLayer from 'ol/layer/Vector'; -import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewer.constants'; import * as leftClickHandleAlias from './leftClickHandleAlias'; import * as clickHandleReaction from '../clickHandleReaction'; -jest.mock('../../../../utils/listeners/mapSingleClick/handleFeaturesClick', () => ({ +jest.mock('../../mapSingleClick/handleFeaturesClick', () => ({ handleFeaturesClick: jest.fn(), })); jest.mock('./leftClickHandleAlias', () => ({ diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick.ts similarity index 95% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick.ts index d9a8031ca12b0d5a5abda289469363ff766be43b..fdca7e96d7bbaf36fd5bdf3e3920bb0abe81a36d 100644 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/onMapLeftClick.ts +++ b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick.ts @@ -9,13 +9,13 @@ import { latLngToPoint } from '@/utils/map/latLngToPoint'; import { FeatureLike } from 'ol/Feature'; import { closeDrawer } from '@/redux/drawer/drawer.slice'; import { clearBioEntities } from '@/redux/bioEntity/bioEntity.slice'; -import { leftClickHandleAlias } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias'; +import { leftClickHandleAlias } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/leftClickHandleAlias'; import { handleFeaturesClick } from '@/components/Map/MapViewer/utils/listeners/mapSingleClick/handleFeaturesClick'; import { resetReactionsData } from '@/redux/reactions/reactions.slice'; import { handleDataReset } from '@/components/Map/MapViewer/utils/listeners/mapSingleClick/handleDataReset'; import { FEATURE_TYPE } from '@/constants/features'; -import { clickHandleReaction } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction'; -import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +import { clickHandleReaction } from '@/components/Map/MapViewer/utils/listeners/mouseClick/clickHandleReaction'; +import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewer.constants'; function isFeatureFilledCompartment(feature: FeatureLike): boolean { return feature.get('type') === FEATURE_TYPE.COMPARTMENT && feature.get('filled'); diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/onMapRightClick.test.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/onMapRightClick.test.ts similarity index 95% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/onMapRightClick.test.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/onMapRightClick.test.ts index 4f9a3ade6a6a4c94bffb3123efcbe206494eee75..fa6a3f172e45ad54b22f8a5d9e9a6ef76b95ad01 100644 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/onMapRightClick.test.ts +++ b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/onMapRightClick.test.ts @@ -1,7 +1,7 @@ /* eslint-disable no-magic-numbers */ import { updateLastRightClick } from '@/redux/map/map.slice'; import Map from 'ol/Map'; -import { onMapRightClick } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/onMapRightClick'; +import { onMapRightClick } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/onMapRightClick'; import { Layer } from 'ol/layer'; import { openContextMenu } from '@/redux/contextMenu/contextMenu.slice'; import { Source } from 'ol/source'; @@ -11,7 +11,7 @@ import { Feature } from 'ol'; import { FEATURE_TYPE } from '@/constants/features'; import { modelElementFixture } from '@/models/fixtures/modelElementFixture'; import { newReactionFixture } from '@/models/fixtures/newReactionFixture'; -import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewer.constants'; import * as rightClickHandleAlias from './rightClickHandleAlias'; import * as clickHandleReaction from '../clickHandleReaction'; diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/onMapRightClick.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/onMapRightClick.ts similarity index 94% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/onMapRightClick.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/onMapRightClick.ts index 74e10fc213a8365f5da3c26be566d0e5d405bc5e..9773b48e4f9aaa1ecf91babc44d5e317b832dc18 100644 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/onMapRightClick.ts +++ b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/onMapRightClick.ts @@ -11,9 +11,9 @@ import VectorLayer from 'ol/layer/Vector'; import VectorSource from 'ol/source/Vector'; import { openContextMenu } from '@/redux/contextMenu/contextMenu.slice'; import { ModelElement, NewReaction } from '@/types/models'; -import { rightClickHandleAlias } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/rightClickHandleAlias'; -import { clickHandleReaction } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/clickHandleReaction'; -import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +import { rightClickHandleAlias } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/rightClickHandleAlias'; +import { clickHandleReaction } from '@/components/Map/MapViewer/utils/listeners/mouseClick/clickHandleReaction'; +import { VECTOR_MAP_LAYER_TYPE } from '@/components/Map/MapViewer/MapViewer.constants'; /* prettier-ignore */ export const onMapRightClick = diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.test.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.test.ts similarity index 94% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.test.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.test.ts index 2b9365194092ffc4a085fb5eccf1bb4dad376aea..ae53b95c6010adaab6744b7284e8be76ae7e2932 100644 --- a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.test.ts +++ b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.test.ts @@ -1,5 +1,5 @@ /* eslint-disable no-magic-numbers */ -import { rightClickHandleAlias } from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/rightClickHandleAlias'; +import { rightClickHandleAlias } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/rightClickHandleAlias'; import { modelElementFixture } from '@/models/fixtures/modelElementFixture'; import { setBioEntityContents } from '@/redux/bioEntity/bioEntity.slice'; import { addNumbersToEntityNumberData } from '@/redux/entityNumber/entityNumber.slice'; diff --git a/src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.ts b/src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.ts rename to src/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/rightClickHandleAlias.ts diff --git a/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.test.ts b/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.test.ts index 94a53559e255fb33787f6512b4c4605ddcf69c62..328c827ba3cfceebeb3c7d5b5e71d91443144d30 100644 --- a/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.test.ts +++ b/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.test.ts @@ -4,18 +4,18 @@ import { View } from 'ol'; import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; import { initialMapDataFixture, openedMapsThreeSubmapsFixture } from '@/redux/map/map.fixtures'; import MapBackgroundsEnum from '@/redux/map/map.enums'; -import * as singleClickListener from './mapSingleClick/onMapSingleClick'; -import * as positionListener from './onMapPositionChange'; -import { useOlMapListeners } from './useOlMapListeners'; +import * as positionListener from '@/components/Map/MapViewer/utils/listeners/onMapPositionChange'; +import { useOlMapListeners } from '@/components/Map/MapViewer/utils/listeners/useOlMapListeners'; +import { onMapLeftClick } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick'; jest.mock('./onMapPositionChange', () => ({ __esModule: true, onMapPositionChange: jest.fn(), })); -jest.mock('./mapSingleClick/onMapSingleClick', () => ({ +jest.mock('./mouseClick/mouseLeftClick/onMapLeftClick', () => ({ __esModule: true, - onMapSingleClick: jest.fn(), + onMapLeftClick: jest.fn(), })); jest.mock('use-debounce', () => { @@ -52,15 +52,17 @@ describe('useOlMapListeners - util', () => { }); }); - describe('on singleclick view event', () => { - it('should run onMapPositionChange event', () => { + describe('on left click event', () => { + it('should run onMapLeftClick event', () => { const CALLED_ONCE = 1; const view = new View(); - renderHook(() => useOlMapListeners({ view, mapInstance: undefined }), { wrapper: Wrapper }); + renderHook(() => useOlMapListeners({ view, mapInstance: undefined }), { + wrapper: Wrapper, + }); view.dispatchEvent('singleclick'); - expect(singleClickListener.onMapSingleClick).toBeCalledTimes(CALLED_ONCE); + expect(onMapLeftClick).toBeCalledTimes(CALLED_ONCE); }); }); }); diff --git a/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.ts b/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.ts index e7df6b03219d0710ca3bfc5962234050a6c0b7d8..f2952ea6c15a3295ab906ba2bd6b2a8a7a1ef65a 100644 --- a/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.ts +++ b/src/components/Map/MapViewer/utils/listeners/useOlMapListeners.ts @@ -1,38 +1,24 @@ -import { DEFAULT_ZOOM, OPTIONS } from '@/constants/map'; -import { searchDistanceValSelector } from '@/redux/configuration/configuration.selectors'; +import { OPTIONS } from '@/constants/map'; import { resultDrawerOpen } from '@/redux/drawer/drawer.selectors'; import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; -import { - mapDataLastZoomValue, - mapDataMaxZoomValue, - mapDataSizeSelector, -} from '@/redux/map/map.selectors'; -import { - currentModelSelector, - currentModelIdSelector, - vectorRenderingSelector, -} from '@/redux/models/models.selectors'; +import { mapDataSizeSelector } from '@/redux/map/map.selectors'; +import { currentModelIdSelector } from '@/redux/models/models.selectors'; import { MapInstance } from '@/types/map'; -import { View } from 'ol'; import { unByKey } from 'ol/Observable'; -import { Coordinate } from 'ol/coordinate'; -import { Pixel } from 'ol/pixel'; import { useEffect, useRef } from 'react'; import { useSelector } from 'react-redux'; import { useDebouncedCallback } from 'use-debounce'; import { allCommentsSelectorOfCurrentMap } from '@/redux/comment/comment.selectors'; -import { currentBackgroundSelector } from '@/redux/backgrounds/background.selectors'; -import { - PATHWAYS_AND_COMPARTMENTS_BACKGROUND, - SEMANTIC_BACKGROUND, -} from '@/redux/backgrounds/backgrounds.constants'; -import { TWO } from '@/constants/common'; -import { useAppSelector } from '@/redux/hooks/useAppSelector'; -import { onMapRightClick } from './mapRightClick/onMapRightClick'; -import { onMapSingleClick } from './mapSingleClick/onMapSingleClick'; -import { onMapPositionChange } from './onMapPositionChange'; -import { onPointerMove } from './onPointerMove'; -import { useHandlePinIconClick } from './pinIconClick/useHandlePinIconClick'; +import { onMapLeftClick } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseLeftClick/onMapLeftClick'; +import { Coordinate } from 'ol/coordinate'; +import { Pixel } from 'ol/pixel'; +import { onMapRightClick } from '@/components/Map/MapViewer/utils/listeners/mouseClick/mouseRightClick/onMapRightClick'; +import { modelElementsForCurrentModelSelector } from '@/redux/modelElements/modelElements.selector'; +import { newReactionsForCurrentModelSelector } from '@/redux/newReactions/newReactions.selectors'; +import { useHandlePinIconClick } from '@/components/Map/MapViewer/utils/listeners/pinIconClick/useHandlePinIconClick'; +import { onMapPositionChange } from '@/components/Map/MapViewer/utils/listeners/onMapPositionChange'; +import { onPointerMove } from '@/components/Map/MapViewer/utils/listeners/onPointerMove'; +import { View } from 'ol'; interface UseOlMapListenersInput { view: View; @@ -41,36 +27,17 @@ interface UseOlMapListenersInput { export const useOlMapListeners = ({ view, mapInstance }: UseOlMapListenersInput): void => { const mapSize = useSelector(mapDataSizeSelector); - const model = useSelector(currentModelSelector); const modelId = useSelector(currentModelIdSelector); - const modelMinZoom = model?.minZoom || TWO; - const lastZoom = useSelector(mapDataLastZoomValue) || TWO; - const background = useSelector(currentBackgroundSelector); - const searchDistance = useSelector(searchDistanceValSelector); - const maxZoom = useSelector(mapDataMaxZoomValue); const isResultDrawerOpen = useSelector(resultDrawerOpen); + const modelElementsForCurrentModel = useSelector(modelElementsForCurrentModelSelector); + const newReactionsForCurrentModel = useSelector(newReactionsForCurrentModelSelector); + const dispatch = useAppDispatch(); const coordinate = useRef<Coordinate>([]); const pixel = useRef<Pixel>([]); - const dispatch = useAppDispatch(); const comments = useSelector(allCommentsSelectorOfCurrentMap); - const vectorRendering = useAppSelector(vectorRenderingSelector); - useHandlePinIconClick(); - const handleRightClick = useDebouncedCallback( - onMapRightClick( - mapSize, - modelId, - dispatch, - background?.name === SEMANTIC_BACKGROUND || - background?.name === PATHWAYS_AND_COMPARTMENTS_BACKGROUND, - lastZoom - modelMinZoom, - ), - OPTIONS.clickPersistTime, - { - leading: false, - }, - ); + useHandlePinIconClick(); const handleChangeCenter = useDebouncedCallback( onMapPositionChange(mapSize, dispatch), @@ -78,24 +45,34 @@ export const useOlMapListeners = ({ view, mapInstance }: UseOlMapListenersInput) { leading: false }, ); - const handleMapSingleClick = useDebouncedCallback( - onMapSingleClick( + const handleMapLeftClick = useDebouncedCallback( + onMapLeftClick( mapSize, modelId, dispatch, - searchDistance, - maxZoom, - lastZoom || DEFAULT_ZOOM, isResultDrawerOpen, comments, - background?.name === SEMANTIC_BACKGROUND || - background?.name === PATHWAYS_AND_COMPARTMENTS_BACKGROUND, - lastZoom - modelMinZoom, + modelElementsForCurrentModel || [], + newReactionsForCurrentModel, ), OPTIONS.clickPersistTime, { leading: false }, ); + const handleRightClick = useDebouncedCallback( + onMapRightClick( + mapSize, + modelId, + dispatch, + modelElementsForCurrentModel || [], + newReactionsForCurrentModel, + ), + OPTIONS.clickPersistTime, + { + leading: false, + }, + ); + useEffect(() => { const key = view.on('change:center', handleChangeCenter); return () => unByKey(key); @@ -113,20 +90,20 @@ export const useOlMapListeners = ({ view, mapInstance }: UseOlMapListenersInput) }, [mapInstance]); useEffect(() => { - if (!mapInstance || vectorRendering) { + if (!mapInstance) { return; } const key = mapInstance.on('singleclick', event => - handleMapSingleClick({ coordinate: event.coordinate, pixel: event.pixel }, mapInstance), + handleMapLeftClick({ coordinate: event.coordinate, pixel: event.pixel }, mapInstance), ); // eslint-disable-next-line consistent-return return () => unByKey(key); - }, [mapInstance, handleMapSingleClick, vectorRendering]); + }, [mapInstance, handleMapLeftClick]); useEffect(() => { - if (!mapInstance || vectorRendering) { + if (!mapInstance) { return; } @@ -136,12 +113,15 @@ export const useOlMapListeners = ({ view, mapInstance }: UseOlMapListenersInput) coordinate.current = mapInstance.getEventCoordinate(e); pixel.current = mapInstance.getEventPixel(e); - return handleRightClick(coordinate.current, pixel.current); + return handleRightClick( + { coordinate: coordinate.current, pixel: pixel.current }, + mapInstance, + ); }; mapInstance.getViewport().addEventListener('contextmenu', rightClickEvent); // eslint-disable-next-line consistent-return return () => mapInstance.getViewport().removeEventListener('contextmenu', rightClickEvent); - }, [mapInstance, handleRightClick, vectorRendering]); + }, [mapInstance, handleRightClick]); }; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/findLargestExtent.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/findLargestExtent.test.ts similarity index 76% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/findLargestExtent.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/findLargestExtent.test.ts index 2a41ebad7e443805cc4c5aae43aee00c9f70ae7a..2bd23b66bd872fd729bca5a8799a528b358eff14 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/findLargestExtent.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/findLargestExtent.test.ts @@ -1,6 +1,6 @@ /* eslint-disable no-magic-numbers */ -import findLargestExtent from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/findLargestExtent'; +import findLargestExtent from '@/components/Map/MapViewer/utils/shapes/coords/findLargestExtent'; import { Extent } from 'ol/extent'; describe('findLargestExtent', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/findLargestExtent.ts b/src/components/Map/MapViewer/utils/shapes/coords/findLargestExtent.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/findLargestExtent.ts rename to src/components/Map/MapViewer/utils/shapes/coords/findLargestExtent.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBezierCurve.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getBezierCurve.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBezierCurve.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getBezierCurve.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBezierCurve.ts b/src/components/Map/MapViewer/utils/shapes/coords/getBezierCurve.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBezierCurve.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getBezierCurve.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent.test.ts similarity index 92% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent.test.ts index 532c485dee1ef05dc9e188e3f600cc2c995d7fae..7c44ef3e0ebb70b25c618e29e5e4f25bb2e57288 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent.test.ts @@ -1,6 +1,6 @@ /* eslint-disable no-magic-numbers */ import { Extent } from 'ol/extent'; -import getBoundingBoxFromExtent from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent'; +import getBoundingBoxFromExtent from '@/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent'; describe('getBoundingBoxFromExtent', () => { it('should return a bounding box for extent', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent.ts b/src/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent.ts similarity index 96% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent.ts index efab1e2d7b3cd6d02e193a5a151981854b90cb15..7201ee003db39e8da8401e619231e6e6cee71616 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent.ts @@ -3,7 +3,7 @@ import { MapSize } from '@/redux/map/map.types'; import { toLonLat } from 'ol/proj'; import { latLngToPoint } from '@/utils/map/latLngToPoint'; import { Extent } from 'ol/extent'; -import { BoundingBox } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { BoundingBox } from '@/components/Map/MapViewer/MapViewer.types'; export default function getBoundingBoxFromExtent(extent: Extent, mapSize: MapSize): BoundingBox { const [startLng, startLat] = toLonLat([extent[0], extent[3]]); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCenter.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getCenter.test.ts similarity index 81% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCenter.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getCenter.test.ts index 6373f63b2e3c53ffd6373c505ba794e186d87007..83defeab8eedf5258a04bfae3482f45e69216f05 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCenter.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getCenter.test.ts @@ -1,6 +1,6 @@ /* eslint-disable no-magic-numbers */ import { Coordinate } from 'ol/coordinate'; -import getCenter from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCenter'; +import getCenter from '@/components/Map/MapViewer/utils/shapes/coords/getCenter'; describe('getCenter', () => { it('should return a center for coordinates', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCenter.ts b/src/components/Map/MapViewer/utils/shapes/coords/getCenter.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCenter.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getCenter.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getCoordsX.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getCoordsX.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX.ts b/src/components/Map/MapViewer/utils/shapes/coords/getCoordsX.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getCoordsX.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getCoordsY.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getCoordsY.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY.ts b/src/components/Map/MapViewer/utils/shapes/coords/getCoordsY.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getCoordsY.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCurveCoords.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getCurveCoords.test.ts similarity index 90% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCurveCoords.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getCurveCoords.test.ts index adf5685f81d9437470d9ef4bda1b912013d02833..1c824de06de2f7e0cf09a573232d8a99e56b82d1 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCurveCoords.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getCurveCoords.test.ts @@ -1,6 +1,6 @@ /* eslint-disable no-magic-numbers */ -import getCoordsX from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX'; -import getCoordsY from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY'; +import getCoordsX from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsX'; +import getCoordsY from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsY'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { ShapeRelAbsBezierPoint } from '@/types/models'; import getCurveCoords from './getCurveCoords'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCurveCoords.ts b/src/components/Map/MapViewer/utils/shapes/coords/getCurveCoords.ts similarity index 85% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCurveCoords.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getCurveCoords.ts index 8cd0f0ec0ea71065e977d5920b473871f1a1c3fe..e75d72f20ac8a80a032da870da44290a5de104bb 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCurveCoords.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getCurveCoords.ts @@ -1,7 +1,7 @@ import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { Coordinate } from 'ol/coordinate'; -import getCoordsX from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX'; -import getCoordsY from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY'; +import getCoordsX from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsX'; +import getCoordsY from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsY'; import { ShapeRelAbsBezierPoint } from '@/types/models'; export default function getCurveCoords({ diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getDividedExtents.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getDividedExtents.test.ts similarity index 94% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getDividedExtents.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getDividedExtents.test.ts index ea4a9f8956a28abd4c43c37345688cd668502ce6..302b8f1115f8cabee5bd96383cf57eb58f4c0972 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getDividedExtents.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getDividedExtents.test.ts @@ -1,6 +1,6 @@ /* eslint-disable no-magic-numbers */ import { Extent } from 'ol/extent'; -import getDividedExtents from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getDividedExtents'; +import getDividedExtents from '@/components/Map/MapViewer/utils/shapes/coords/getDividedExtents'; describe('getDividedExtents', () => { it('should return original extents if there is no intersection with dividingExtent', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getDividedExtents.ts b/src/components/Map/MapViewer/utils/shapes/coords/getDividedExtents.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getDividedExtents.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getDividedExtents.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords.test.ts similarity index 89% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords.test.ts index 515eabf45fb9d4b66ebdece53029f287541dabb0..8c4fd4dc66711a872b53d67508b798d9e8c6b1cf 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords.test.ts @@ -1,6 +1,6 @@ /* eslint-disable no-magic-numbers */ -import getCoordsX from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX'; -import getCoordsY from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY'; +import getCoordsX from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsX'; +import getCoordsY from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsY'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { ShapeRelAbs } from '@/types/models'; import getEllipseCoords from './getEllipseCoords'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords.ts b/src/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords.ts similarity index 89% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords.ts index c617ffafb8bc9e0fd2205b5f3a9b9a85d446df43..bd72dd2155766cc7e3d349358b5d49ed44d4339c 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords.ts @@ -1,6 +1,6 @@ /* eslint-disable no-magic-numbers */ -import getCoordsX from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX'; -import getCoordsY from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY'; +import getCoordsX from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsX'; +import getCoordsY from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsY'; import { Coordinate } from 'ol/coordinate'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { ShapeRelAbs } from '@/types/models'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getLineSegments.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getLineSegments.test.ts similarity index 97% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getLineSegments.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getLineSegments.test.ts index ec6d5a70dd0c170083be7e1766888ce3dad41c7c..9ce67a919549ced4ab4794818a73e9ede769f52f 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getLineSegments.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getLineSegments.test.ts @@ -1,6 +1,6 @@ /* eslint-disable no-magic-numbers */ import { Line } from '@/types/models'; -import { BLACK_COLOR } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +import { BLACK_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import getLineSegments from './getLineSegments'; describe('getLineSegments', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getLineSegments.ts b/src/components/Map/MapViewer/utils/shapes/coords/getLineSegments.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getLineSegments.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getLineSegments.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords.test.ts similarity index 88% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords.test.ts index ed84c661f154d568fcc950792f9497e098c60220..6060feff3dc7b5325bd3e35b795a5a5d97ab5c93 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords.test.ts @@ -1,8 +1,8 @@ /* eslint-disable no-magic-numbers */ -import getCoordsX from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX'; -import getCoordsY from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY'; -import getCurveCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCurveCoords'; -import getBezierCurve from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBezierCurve'; +import getCoordsX from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsX'; +import getCoordsY from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsY'; +import getCurveCoords from '@/components/Map/MapViewer/utils/shapes/coords/getCurveCoords'; +import getBezierCurve from '@/components/Map/MapViewer/utils/shapes/coords/getBezierCurve'; import { ShapeRelAbs, ShapeRelAbsBezierPoint } from '@/types/models'; import getPolygonCoords from './getPolygonCoords'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords.ts b/src/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords.ts similarity index 76% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords.ts index d00816b5a3ef7b85e622b32722208a57093db6fb..db3f1b7ca6da67a2953dbbd08dc1951953c0bcaf 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords.ts @@ -1,10 +1,10 @@ /* eslint-disable no-magic-numbers */ import { Coordinate } from 'ol/coordinate'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; -import getBezierCurve from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBezierCurve'; -import getCoordsX from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsX'; -import getCoordsY from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCoordsY'; -import getCurveCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCurveCoords'; +import getBezierCurve from '@/components/Map/MapViewer/utils/shapes/coords/getBezierCurve'; +import getCoordsX from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsX'; +import getCoordsY from '@/components/Map/MapViewer/utils/shapes/coords/getCoordsY'; +import getCurveCoords from '@/components/Map/MapViewer/utils/shapes/coords/getCurveCoords'; import { ShapeRelAbs, ShapeRelAbsBezierPoint } from '@/types/models'; export default function getPolygonCoords({ diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getRotation.test.ts b/src/components/Map/MapViewer/utils/shapes/coords/getRotation.test.ts similarity index 83% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getRotation.test.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getRotation.test.ts index 363add1a3eef27e0422ff5b8f01601c9a7c85f1c..0e26ba924e0112f3e49a8251a8874e81b04c6623 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getRotation.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/coords/getRotation.test.ts @@ -1,5 +1,5 @@ /* eslint-disable no-magic-numbers */ -import getRotation from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getRotation'; +import getRotation from '@/components/Map/MapViewer/utils/shapes/coords/getRotation'; import { Coordinate } from 'ol/coordinate'; const testCases: Array<[Coordinate, Coordinate, number]> = [ diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getRotation.ts b/src/components/Map/MapViewer/utils/shapes/coords/getRotation.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getRotation.ts rename to src/components/Map/MapViewer/utils/shapes/coords/getRotation.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/BaseMultiPolygon.ts b/src/components/Map/MapViewer/utils/shapes/elements/BaseMultiPolygon.ts similarity index 91% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/BaseMultiPolygon.ts rename to src/components/Map/MapViewer/utils/shapes/elements/BaseMultiPolygon.ts index dd541d11a2fa883efd7a50da87b7d5f8ed5a9a77..2327755136b249486f4d4a24f1c781dc75304d0e 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/BaseMultiPolygon.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/BaseMultiPolygon.ts @@ -4,14 +4,8 @@ import { Stroke, Style } from 'ol/style'; import Feature, { FeatureLike } from 'ol/Feature'; import { MultiPolygon } from 'ol/geom'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; import { MapInstance } from '@/types/map'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; import { Color } from '@/types/models'; import { COMPLEX_CONTENTS_CUTOFF_SCALE, @@ -19,13 +13,16 @@ import { MAP_ELEMENT_TYPES, OUTLINE_CUTOFF_SCALE, TEXT_CUTOFF_SCALE, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +} from '@/components/Map/MapViewer/MapViewer.constants'; import VectorSource from 'ol/source/Vector'; import MapBackgroundsEnum from '@/redux/map/map.enums'; import { MapSize } from '@/redux/map/map.types'; -import getCoverStyles from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getCoverStyles'; -import handleSemanticView from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/handleSemanticView'; -import getScaledStrokeStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledStrokeStyle'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; +import getCoverStyles from '@/components/Map/MapViewer/utils/shapes/style/getCoverStyles'; +import handleSemanticView from '@/components/Map/MapViewer/utils/shapes/elements/handleSemanticView'; +import getScaledStrokeStyle from '@/components/Map/MapViewer/utils/shapes/style/getScaledStrokeStyle'; export interface BaseMapElementProps { type: string; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Compartment.ts b/src/components/Map/MapViewer/utils/shapes/elements/Compartment.ts similarity index 89% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Compartment.ts rename to src/components/Map/MapViewer/utils/shapes/elements/Compartment.ts index 75c519ef4b09f649f7d0217756d44c994fff7bbf..10802411741585f4e58b1e926fc5176c7d3609d9 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Compartment.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/Compartment.ts @@ -1,24 +1,21 @@ /* eslint-disable no-magic-numbers */ import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; -import BaseMultiPolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/BaseMultiPolygon'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; import { Coordinate } from 'ol/coordinate'; import Polygon from 'ol/geom/Polygon'; import { Stroke, Style } from 'ol/style'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; import { MapInstance } from '@/types/map'; import { Color } from '@/types/models'; import { MAP_ELEMENT_TYPES, TRANSPARENT_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +} from '@/components/Map/MapViewer/MapViewer.constants'; import VectorSource from 'ol/source/Vector'; import { MapSize } from '@/redux/map/map.types'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import BaseMultiPolygon from '@/components/Map/MapViewer/utils/shapes/elements/BaseMultiPolygon'; export interface CompartmentProps { id: number; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentCircle.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.test.ts similarity index 78% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentCircle.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.test.ts index 7c5956c6be2eeca72fa7078138faf28b4a330367..eb94b525b31a0e851c95be6f9caf2be967e8be9e 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentCircle.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.test.ts @@ -2,24 +2,21 @@ import { Feature, Map } from 'ol'; import { Fill, Stroke, Style, Text } from 'ol/style'; import { Polygon, MultiPolygon } from 'ol/geom'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; -import getShapePolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; import View from 'ol/View'; -import { - WHITE_COLOR, - BLACK_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import CompartmentCircle, { - CompartmentCircleProps, -} from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentCircle'; -import getEllipseCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords'; -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; +import { WHITE_COLOR, BLACK_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import VectorSource from 'ol/source/Vector'; import MapBackgroundsEnum from '@/redux/map/map.enums'; import { DEFAULT_TILE_SIZE } from '@/constants/map'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; +import getShapePolygon from '@/components/Map/MapViewer/utils/shapes/elements/getShapePolygon'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import CompartmentCircle, { + CompartmentCircleProps, +} from '@/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle'; +import getEllipseCoords from '@/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; jest.mock('../text/getTextStyle'); jest.mock('../text/getTextCoords'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentCircle.ts b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.ts similarity index 87% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentCircle.ts rename to src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.ts index 94a65df80c0218061ea17e28e2af846f3842d65a..78915ae4567c4629d0843c24bed61bbb7edff75a 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentCircle.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentCircle.ts @@ -1,21 +1,18 @@ /* eslint-disable no-magic-numbers */ import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { MapInstance } from '@/types/map'; -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; import { BLACK_COLOR, COMPARTMENT_CIRCLE_CENTER, COMPARTMENT_CIRCLE_RADIUS, WHITE_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import getEllipseCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords'; -import Compartment from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Compartment'; +} from '@/components/Map/MapViewer/MapViewer.constants'; import { Color } from '@/types/models'; import VectorSource from 'ol/source/Vector'; import { MapSize } from '@/redux/map/map.types'; +import Compartment from '@/components/Map/MapViewer/utils/shapes/elements/Compartment'; +import getEllipseCoords from '@/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords'; export type CompartmentCircleProps = { id: number; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentPathway.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.test.ts similarity index 78% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentPathway.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.test.ts index 00c1931b89ff0f4a291a1f530ece23c2964a5ed4..05e1801ecdaea7a390812d3dc8e21c3ed4632c2f 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentPathway.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.test.ts @@ -2,24 +2,21 @@ import { Feature, Map } from 'ol'; import { Fill, Stroke, Style, Text } from 'ol/style'; import { Polygon, MultiPolygon } from 'ol/geom'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; -import getShapePolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; import View from 'ol/View'; -import { - WHITE_COLOR, - BLACK_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import CompartmentPathway, { - CompartmentPathwayProps, -} from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentPathway'; -import getEllipseCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords'; -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; +import { WHITE_COLOR, BLACK_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import VectorSource from 'ol/source/Vector'; import MapBackgroundsEnum from '@/redux/map/map.enums'; import { DEFAULT_TILE_SIZE } from '@/constants/map'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; +import getShapePolygon from '@/components/Map/MapViewer/utils/shapes/elements/getShapePolygon'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import CompartmentPathway, { + CompartmentPathwayProps, +} from '@/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway'; +import getEllipseCoords from '@/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; jest.mock('../text/getTextStyle'); jest.mock('../text/getTextCoords'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentPathway.ts b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.ts similarity index 83% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentPathway.ts rename to src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.ts index eef5c0f716975c91569ec3053d79a52f2391a918..940346776d9be8ade9372773a211b59de1aaf870 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentPathway.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentPathway.ts @@ -1,26 +1,23 @@ /* eslint-disable no-magic-numbers */ import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { MapInstance } from '@/types/map'; -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; import { BLACK_COLOR, MAP_ELEMENT_TYPES, TRANSPARENT_COLOR, WHITE_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +} from '@/components/Map/MapViewer/MapViewer.constants'; import Polygon from 'ol/geom/Polygon'; -import BaseMultiPolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/BaseMultiPolygon'; -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; import { Color } from '@/types/models'; import VectorSource from 'ol/source/Vector'; import { Style } from 'ol/style'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; import { MapSize } from '@/redux/map/map.types'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; +import BaseMultiPolygon from '@/components/Map/MapViewer/utils/shapes/elements/BaseMultiPolygon'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; export type CompartmentPathwayProps = { id: number; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentSquare.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.test.ts similarity index 79% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentSquare.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.test.ts index 53fff2ff5581f7accf491dff4c354b4005a37bfd..acf2471c9b9fc637a13f1c8035e3c593b374d7de 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentSquare.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.test.ts @@ -2,23 +2,20 @@ import { Feature, Map } from 'ol'; import { Fill, Stroke, Style, Text } from 'ol/style'; import { MultiPolygon } from 'ol/geom'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; import View from 'ol/View'; -import { - WHITE_COLOR, - BLACK_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import CompartmentSquare, { - CompartmentSquareProps, -} from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentSquare'; -import getPolygonCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords'; -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; +import { WHITE_COLOR, BLACK_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import VectorSource from 'ol/source/Vector'; import MapBackgroundsEnum from '@/redux/map/map.enums'; import { DEFAULT_TILE_SIZE } from '@/constants/map'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import CompartmentSquare, { + CompartmentSquareProps, +} from '@/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare'; +import getPolygonCoords from '@/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; jest.mock('../text/getTextStyle'); jest.mock('../text/getTextCoords'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentSquare.ts b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.ts similarity index 87% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentSquare.ts rename to src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.ts index 8f033df3e9aba3d016d428c63752f3ea4a345f0b..34f956932f2c5a9832946a44fd64aad8cbe06018 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/CompartmentSquare.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/CompartmentSquare.ts @@ -1,20 +1,17 @@ /* eslint-disable no-magic-numbers */ import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { MapInstance } from '@/types/map'; -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; import { BLACK_COLOR, COMPARTMENT_SQUARE_POINTS, WHITE_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import getPolygonCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords'; -import Compartment from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Compartment'; +} from '@/components/Map/MapViewer/MapViewer.constants'; import { Color } from '@/types/models'; import VectorSource from 'ol/source/Vector'; import { MapSize } from '@/redux/map/map.types'; +import Compartment from '@/components/Map/MapViewer/utils/shapes/elements/Compartment'; +import getPolygonCoords from '@/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords'; export type CompartmentSquareProps = { id: number; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph.test.ts similarity index 93% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph.test.ts index ff2a0ac2b62520a7447bdf70d34897e3ed0b23b2..2680f7ef5e570bb062070cb271214e91a6be397d 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph.test.ts @@ -2,9 +2,7 @@ import { Feature, Map, View } from 'ol'; import { Style } from 'ol/style'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; -import Glyph, { - GlyphProps, -} from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph'; +import Glyph, { GlyphProps } from '@/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph'; import { MapInstance } from '@/types/map'; import Polygon from 'ol/geom/Polygon'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph.ts b/src/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph.ts similarity index 95% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph.ts rename to src/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph.ts index a0676acd89b279e3388d8c65e73a7d74cb8a8221..1da2b4fb996db0e2387e7ec7455febce1f067d70 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph.ts @@ -11,13 +11,13 @@ import Polygon from 'ol/geom/Polygon'; import { Point } from 'ol/geom'; import { Coordinate } from 'ol/coordinate'; import { FEATURE_TYPE } from '@/constants/features'; -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; -import { WHITE_COLOR } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; -import getScaledElementStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledElementStyle'; -import getBoundingBoxFromExtent from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent'; +import { WHITE_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import { MapSize } from '@/redux/map/map.types'; import { LayerImage } from '@/types/models'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import getScaledElementStyle from '@/components/Map/MapViewer/utils/shapes/style/getScaledElementStyle'; +import getBoundingBoxFromExtent from '@/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent'; export type GlyphProps = { elementId: number; @@ -249,6 +249,7 @@ export default class Glyph { }), zIndex: this.zIndex, }); + this.feature.changed(); }; img.src = `${BASE_NEW_API_URL}${apiPath.getGlyphImage(this.glyphId)}`; } diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/updateGlyph.ts b/src/components/Map/MapViewer/utils/shapes/elements/Glyph/updateGlyph.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/updateGlyph.ts rename to src/components/Map/MapViewer/utils/shapes/elements/Glyph/updateGlyph.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/MapElement.test.ts similarity index 80% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/MapElement.test.ts index 9dbf5336fcfc8dd1293ca55c43a01ccbfc86f258..744c6529dec3cd6eadf85b9895aec59f27a88c52 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/MapElement.test.ts @@ -2,24 +2,21 @@ import { Feature, Map } from 'ol'; import { Fill, Stroke, Style, Text } from 'ol/style'; import { Polygon, MultiPolygon } from 'ol/geom'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; -import getShapePolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; -import MapElement, { - MapElementProps, -} from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement'; import View from 'ol/View'; -import { - WHITE_COLOR, - BLACK_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; +import { WHITE_COLOR, BLACK_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import { shapesFixture } from '@/models/fixtures/shapesFixture'; import VectorSource from 'ol/source/Vector'; import MapBackgroundsEnum from '@/redux/map/map.enums'; import { DEFAULT_TILE_SIZE } from '@/constants/map'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; +import getShapePolygon from '@/components/Map/MapViewer/utils/shapes/elements/getShapePolygon'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import MapElement, { + MapElementProps, +} from '@/components/Map/MapViewer/utils/shapes/elements/MapElement'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; jest.mock('../text/getTextStyle'); jest.mock('../text/getTextCoords'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement.ts b/src/components/Map/MapViewer/utils/shapes/elements/MapElement.ts similarity index 91% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement.ts rename to src/components/Map/MapViewer/utils/shapes/elements/MapElement.ts index 38b6b16db7194a06f8433b6793015c8373c6cfec..ead1dd13ec0bb1750bd696889f45d26deedeedbc 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/MapElement.ts @@ -1,28 +1,17 @@ /* eslint-disable no-magic-numbers */ import { Style } from 'ol/style'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; import Polygon from 'ol/geom/Polygon'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; import { Color, Modification, Shape } from '@/types/models'; import { MapInstance } from '@/types/map'; -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; import { BLACK_COLOR, COMPLEX_SBO_TERMS, MAP_ELEMENT_TYPES, TRANSPARENT_COLOR, WHITE_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import BaseMultiPolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/BaseMultiPolygon'; -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; -import getShapePolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon'; +} from '@/components/Map/MapViewer/MapViewer.constants'; import { BioShapesDict, LineTypeDict } from '@/redux/shapes/shapes.types'; import { FEATURE_TYPE } from '@/constants/features'; import { OverlayBioEntityRender } from '@/types/OLrendering'; @@ -32,6 +21,14 @@ import { OverlayOrder } from '@/redux/overlayBioEntity/overlayBioEntity.utils'; import { GetOverlayBioEntityColorByAvailableProperties } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useGetOverlayColor'; import VectorSource from 'ol/source/Vector'; import { MapSize } from '@/redux/map/map.types'; +import getShapePolygon from '@/components/Map/MapViewer/utils/shapes/elements/getShapePolygon'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; +import BaseMultiPolygon from '@/components/Map/MapViewer/utils/shapes/elements/BaseMultiPolygon'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; export type MapElementProps = { id: number; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getArrowFeature.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/getArrowFeature.test.ts similarity index 89% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getArrowFeature.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/getArrowFeature.test.ts index 71a6ce39bf3e34118995b962e971d2a58f1f3935..970241b9fde38f5d87c9e4b511e890e7f3663938 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getArrowFeature.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/getArrowFeature.test.ts @@ -2,11 +2,11 @@ import { Feature } from 'ol'; import { Fill, Stroke, Style } from 'ol/style'; import { Polygon, MultiPolygon } from 'ol/geom'; -import getShapePolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon'; -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; -import getArrowFeature from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getArrowFeature'; -import { BLACK_COLOR } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +import { BLACK_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import { ArrowTypeDict } from '@/redux/shapes/shapes.types'; +import getShapePolygon from '@/components/Map/MapViewer/utils/shapes/elements/getShapePolygon'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; +import getArrowFeature from '@/components/Map/MapViewer/utils/shapes/elements/getArrowFeature'; jest.mock('../style/getStyle'); jest.mock('./getShapePolygon'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getArrowFeature.ts b/src/components/Map/MapViewer/utils/shapes/elements/getArrowFeature.ts similarity index 80% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getArrowFeature.ts rename to src/components/Map/MapViewer/utils/shapes/elements/getArrowFeature.ts index c8f46d9d1f37e57a44f43889412f16ff448c114b..0ccc40a259d2f788024db99b370e3fccbb0447e0 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getArrowFeature.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/getArrowFeature.ts @@ -1,16 +1,16 @@ /* eslint-disable no-magic-numbers */ import Style from 'ol/style/Style'; -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; import { Feature } from 'ol'; import { MultiPolygon } from 'ol/geom'; import { Arrow, Color } from '@/types/models'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; -import getShapePolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon'; import Polygon from 'ol/geom/Polygon'; -import { WHITE_COLOR } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +import { WHITE_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import { ArrowTypeDict } from '@/redux/shapes/shapes.types'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; +import getShapePolygon from '@/components/Map/MapViewer/utils/shapes/elements/getShapePolygon'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; export default function getArrowFeature({ arrowTypes, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/getShapePolygon.test.ts similarity index 94% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/getShapePolygon.test.ts index 0074f57be0512f7db5b60f44e7702a0deb85afb6..5254b54eb2784225a7b04f7ae053beddb377d8ff 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/getShapePolygon.test.ts @@ -1,9 +1,9 @@ /* eslint-disable no-magic-numbers */ -import getPolygonCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords'; -import getEllipseCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords'; +import getPolygonCoords from '@/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords'; +import getEllipseCoords from '@/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords'; import Polygon from 'ol/geom/Polygon'; import { Shape } from '@/types/models'; -import getShapePolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon'; +import getShapePolygon from '@/components/Map/MapViewer/utils/shapes/elements/getShapePolygon'; jest.mock('../coords/getPolygonCoords'); jest.mock('../coords/getEllipseCoords'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon.ts b/src/components/Map/MapViewer/utils/shapes/elements/getShapePolygon.ts similarity index 78% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon.ts rename to src/components/Map/MapViewer/utils/shapes/elements/getShapePolygon.ts index 7e2f7a597a09e019725d272c23c424d11645125f..a2082fe3d3a004e9de4abdb09448dc0fbcf28627 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/getShapePolygon.ts @@ -1,11 +1,11 @@ /* eslint-disable no-magic-numbers */ import Polygon from 'ol/geom/Polygon'; import { Coordinate } from 'ol/coordinate'; -import getPolygonCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getPolygonCoords'; -import getEllipseCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords'; +import getPolygonCoords from '@/components/Map/MapViewer/utils/shapes/coords/getPolygonCoords'; +import getEllipseCoords from '@/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords'; import { Shape } from '@/types/models'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; -import getCenter from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getCenter'; +import getCenter from '@/components/Map/MapViewer/utils/shapes/coords/getCenter'; export default function getShapePolygon({ shape, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/handleSemanticView.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/handleSemanticView.test.ts similarity index 89% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/handleSemanticView.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/handleSemanticView.test.ts index f6360b51903d9bd27d0e6e959271b59562328421..c2d9e620468b27f4a5bc7ffea4fc9a8b051af1a4 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/handleSemanticView.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/handleSemanticView.test.ts @@ -1,9 +1,9 @@ /* eslint-disable no-magic-numbers */ import Feature from 'ol/Feature'; import VectorSource from 'ol/source/Vector'; -import getDividedExtents from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getDividedExtents'; -import findLargestExtent from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/findLargestExtent'; -import handleSemanticView from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/handleSemanticView'; +import getDividedExtents from '@/components/Map/MapViewer/utils/shapes/coords/getDividedExtents'; +import findLargestExtent from '@/components/Map/MapViewer/utils/shapes/coords/findLargestExtent'; +import handleSemanticView from '@/components/Map/MapViewer/utils/shapes/elements/handleSemanticView'; import Geometry from 'ol/geom/Geometry'; import { fromExtent } from 'ol/geom/Polygon'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/handleSemanticView.ts b/src/components/Map/MapViewer/utils/shapes/elements/handleSemanticView.ts similarity index 86% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/handleSemanticView.ts rename to src/components/Map/MapViewer/utils/shapes/elements/handleSemanticView.ts index 71c32e6fa89bb7ceb88958845feb10183ddef4fd..cd5aa1f44093b3237e6d2743225bf06ac86009fc 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/handleSemanticView.ts +++ b/src/components/Map/MapViewer/utils/shapes/elements/handleSemanticView.ts @@ -1,14 +1,14 @@ /* eslint-disable no-magic-numbers */ -import getDividedExtents from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getDividedExtents'; -import findLargestExtent from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/findLargestExtent'; import Feature from 'ol/Feature'; import VectorSource from 'ol/source/Vector'; import { Extent } from 'ol/extent'; import { COMPLEX_SBO_TERMS, MAP_ELEMENT_TYPES, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import isFeatureInCompartment from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/isFeatureInCompartment'; +} from '@/components/Map/MapViewer/MapViewer.constants'; +import findLargestExtent from '@/components/Map/MapViewer/utils/shapes/coords/findLargestExtent'; +import getDividedExtents from '@/components/Map/MapViewer/utils/shapes/coords/getDividedExtents'; +import isFeatureInCompartment from '@/components/Map/MapViewer/utils/shapes/elements/isFeatureInCompartment'; export default function handleSemanticView({ vectorSource, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/isFeatureInCompartment.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/isFeatureInCompartment.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/isFeatureInCompartment.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/isFeatureInCompartment.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/isFeatureInCompartment.ts b/src/components/Map/MapViewer/utils/shapes/elements/isFeatureInCompartment.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/isFeatureInCompartment.ts rename to src/components/Map/MapViewer/utils/shapes/elements/isFeatureInCompartment.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/removeElementFromLayer.test.ts b/src/components/Map/MapViewer/utils/shapes/elements/removeElementFromLayer.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/removeElementFromLayer.test.ts rename to src/components/Map/MapViewer/utils/shapes/elements/removeElementFromLayer.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/removeElementFromLayer.ts b/src/components/Map/MapViewer/utils/shapes/elements/removeElementFromLayer.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/removeElementFromLayer.ts rename to src/components/Map/MapViewer/utils/shapes/elements/removeElementFromLayer.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/Layer.test.ts b/src/components/Map/MapViewer/utils/shapes/layer/Layer.test.ts similarity index 84% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/Layer.test.ts rename to src/components/Map/MapViewer/utils/shapes/layer/Layer.test.ts index 9da93414263578fa50ea5684ac1918f78dd1e5b5..d9f3c02274ec29a20175421c034d55d5f9a340f2 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/Layer.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/layer/Layer.test.ts @@ -1,20 +1,15 @@ /* eslint-disable no-magic-numbers */ import { Map } from 'ol'; import { Stroke, Style, Text } from 'ol/style'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; import View from 'ol/View'; -import { - WHITE_COLOR, - BLACK_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; -import Layer, { - LayerProps, -} from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/Layer'; +import { WHITE_COLOR, BLACK_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import VectorSource from 'ol/source/Vector'; import VectorLayer from 'ol/layer/Vector'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; +import Layer, { LayerProps } from '@/components/Map/MapViewer/utils/shapes/layer/Layer'; jest.mock('../text/getTextCoords'); jest.mock('../text/getTextStyle'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/Layer.ts b/src/components/Map/MapViewer/utils/shapes/layer/Layer.ts similarity index 92% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/Layer.ts rename to src/components/Map/MapViewer/utils/shapes/layer/Layer.ts index 84c3f3176b59ffaf4d8194c448e8f04cdf528274..282e25e43c9fe3269bd61a43229208f4165bae05 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/Layer.ts +++ b/src/components/Map/MapViewer/utils/shapes/layer/Layer.ts @@ -4,18 +4,10 @@ import { MapInstance } from '@/types/map'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { Feature } from 'ol'; import { LineString, MultiPolygon, Point } from 'ol/geom'; -import Text from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/Text'; import Polygon from 'ol/geom/Polygon'; import VectorSource from 'ol/source/Vector'; import VectorLayer from 'ol/layer/Vector'; -import getEllipseCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getEllipseCoords'; -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; -import getRotation from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getRotation'; -import getArrowFeature from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getArrowFeature'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; import { FeatureLike } from 'ol/Feature'; import Style from 'ol/style/Style'; import { ArrowTypeDict, LineTypeDict } from '@/redux/shapes/shapes.types'; @@ -23,11 +15,16 @@ import { LAYER_ELEMENT_TYPES, REACTION_ELEMENT_CUTOFF_SCALE, TRANSPARENT_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import getScaledElementStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledElementStyle'; +} from '@/components/Map/MapViewer/MapViewer.constants'; import { Stroke } from 'ol/style'; -import Glyph from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/Glyph/Glyph'; import { MapSize } from '@/redux/map/map.types'; +import getScaledElementStyle from '@/components/Map/MapViewer/utils/shapes/style/getScaledElementStyle'; +import Glyph from '@/components/Map/MapViewer/utils/shapes/elements/Glyph/Glyph'; +import getArrowFeature from '@/components/Map/MapViewer/utils/shapes/elements/getArrowFeature'; +import getRotation from '@/components/Map/MapViewer/utils/shapes/coords/getRotation'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; +import getEllipseCoords from '@/components/Map/MapViewer/utils/shapes/coords/getEllipseCoords'; +import Text from '@/components/Map/MapViewer/utils/shapes/text/Text'; export interface LayerProps { texts: Array<LayerText>; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getDrawImageInteraction.test.ts b/src/components/Map/MapViewer/utils/shapes/layer/getDrawImageInteraction.test.ts similarity index 96% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getDrawImageInteraction.test.ts rename to src/components/Map/MapViewer/utils/shapes/layer/getDrawImageInteraction.test.ts index e0c9fb448df9c02b9c29aa36c12206be8c439216..2e9e3f88be43e4e337a633f93572359cc82705b4 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getDrawImageInteraction.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/layer/getDrawImageInteraction.test.ts @@ -12,7 +12,7 @@ import { DEFAULT_TILE_SIZE } from '@/constants/map'; import { Map } from 'ol'; import getDrawImageInteraction from './getDrawImageInteraction'; -jest.mock('../../../../../../../utils/map/latLngToPoint', () => ({ +jest.mock('../../../../../../utils/map/latLngToPoint', () => ({ latLngToPoint: jest.fn(latLng => ({ x: latLng[0], y: latLng[1] })), })); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getDrawImageInteraction.ts b/src/components/Map/MapViewer/utils/shapes/layer/getDrawImageInteraction.ts similarity index 97% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getDrawImageInteraction.ts rename to src/components/Map/MapViewer/utils/shapes/layer/getDrawImageInteraction.ts index 35bd90a5543d3a96015ac202732164dd55e806fe..8c37bf3677ee1d3a70e08a1fc67bfbd1f5aa540b 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getDrawImageInteraction.ts +++ b/src/components/Map/MapViewer/utils/shapes/layer/getDrawImageInteraction.ts @@ -7,7 +7,7 @@ import { AppDispatch } from '@/redux/store'; import { Coordinate } from 'ol/coordinate'; import { openLayerImageObjectFactoryModal } from '@/redux/modal/modal.slice'; import { Extent } from 'ol/extent'; -import getBoundingBoxFromExtent from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent'; +import getBoundingBoxFromExtent from '@/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent'; export default function getDrawImageInteraction( mapSize: MapSize, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getTransformImageInteraction.test.ts b/src/components/Map/MapViewer/utils/shapes/layer/getTransformImageInteraction.test.ts similarity index 92% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getTransformImageInteraction.test.ts rename to src/components/Map/MapViewer/utils/shapes/layer/getTransformImageInteraction.test.ts index 92a891c86a15ff5806d96c2fc6792868f3899f12..718037ffd3b8625ff598904f2430d8f7d565f3ba 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getTransformImageInteraction.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/layer/getTransformImageInteraction.test.ts @@ -8,11 +8,11 @@ import { import { ModalState } from '@/redux/modal/modal.types'; import { DEFAULT_TILE_SIZE } from '@/constants/map'; import { Collection, Feature } from 'ol'; -import getTransformImageInteraction from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getTransformImageInteraction'; +import getTransformImageInteraction from '@/components/Map/MapViewer/utils/shapes/layer/getTransformImageInteraction'; import Transform from 'ol-ext/interaction/Transform'; import { Geometry } from 'ol/geom'; -jest.mock('../../../../../../../utils/map/latLngToPoint', () => ({ +jest.mock('../../../../../../utils/map/latLngToPoint', () => ({ latLngToPoint: jest.fn(latLng => ({ x: latLng[0], y: latLng[1] })), })); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getTransformImageInteraction.ts b/src/components/Map/MapViewer/utils/shapes/layer/getTransformImageInteraction.ts similarity index 98% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getTransformImageInteraction.ts rename to src/components/Map/MapViewer/utils/shapes/layer/getTransformImageInteraction.ts index eecc366517ef57ca2320438d3a2e15ffcc67aef8..596205e6265c44436940e0204f460eee722fb6e6 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/layer/getTransformImageInteraction.ts +++ b/src/components/Map/MapViewer/utils/shapes/layer/getTransformImageInteraction.ts @@ -7,7 +7,7 @@ import { Collection, Feature } from 'ol'; import BaseEvent from 'ol/events/Event'; import { updateLayerImageObject } from '@/redux/layers/layers.thunks'; import { layerUpdateImage } from '@/redux/layers/layers.slice'; -import getBoundingBoxFromExtent from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getBoundingBoxFromExtent'; +import getBoundingBoxFromExtent from '@/components/Map/MapViewer/utils/shapes/coords/getBoundingBoxFromExtent'; import { MapSize } from '@/redux/map/map.types'; import { Extent } from 'ol/extent'; import { mapEditToolsSetLayerObject } from '@/redux/mapEditTools/mapEditTools.slice'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/LineOverlay.test.ts b/src/components/Map/MapViewer/utils/shapes/overlay/LineOverlay.test.ts similarity index 78% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/LineOverlay.test.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/LineOverlay.test.ts index 4efbc9d6e3f4b4c78f4689ca0ecb77ef8e230ba4..0888de5c33f821595f1ce497a34e957f0d44a9ce 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/LineOverlay.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/overlay/LineOverlay.test.ts @@ -1,13 +1,13 @@ /* eslint-disable no-magic-numbers */ import { Feature, Map } from 'ol'; import { Stroke, Style } from 'ol/style'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; import View from 'ol/View'; import LineOverlay, { LineOverlayProps, -} from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/LineOverlay'; +} from '@/components/Map/MapViewer/utils/shapes/overlay/LineOverlay'; import { Coordinate } from 'ol/coordinate'; jest.mock('../style/getStroke'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/LineOverlay.ts b/src/components/Map/MapViewer/utils/shapes/overlay/LineOverlay.ts similarity index 96% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/LineOverlay.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/LineOverlay.ts index b6d8eecb4099b69fe38221288af470ec2d76554c..adf9beb8067a3a59fb842289411880b68ea6fe27 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/LineOverlay.ts +++ b/src/components/Map/MapViewer/utils/shapes/overlay/LineOverlay.ts @@ -2,7 +2,7 @@ import { OverlayBioEntityRender } from '@/types/OLrendering'; import { GetOverlayBioEntityColorByAvailableProperties } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useGetOverlayColor'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { LineString } from 'ol/geom'; -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; import { Feature } from 'ol'; import { FeatureLike } from 'ol/Feature'; import Style from 'ol/style/Style'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/MarkerOverlay.test.ts b/src/components/Map/MapViewer/utils/shapes/overlay/MarkerOverlay.test.ts similarity index 79% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/MarkerOverlay.test.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/MarkerOverlay.test.ts index 4fe3c4aad5120a9cd322f84b943b40c039195543..19bc84b67770bc9955bf6cf20d582f182ceeab5f 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/MarkerOverlay.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/overlay/MarkerOverlay.test.ts @@ -1,14 +1,14 @@ /* eslint-disable no-magic-numbers */ import { Feature, Map } from 'ol'; import { Stroke, Style } from 'ol/style'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; import View from 'ol/View'; import { Coordinate } from 'ol/coordinate'; import MarkerOverlay, { MarkerOverlayProps, -} from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/MarkerOverlay'; +} from '@/components/Map/MapViewer/utils/shapes/overlay/MarkerOverlay'; jest.mock('../style/getStroke'); jest.mock('../style/getFill'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/MarkerOverlay.ts b/src/components/Map/MapViewer/utils/shapes/overlay/MarkerOverlay.ts similarity index 96% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/MarkerOverlay.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/MarkerOverlay.ts index a0336335d7a158c1d13c8895a59504673eff8f27..e963d76834ae227bf4107e02c81286137c2b4496 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/MarkerOverlay.ts +++ b/src/components/Map/MapViewer/utils/shapes/overlay/MarkerOverlay.ts @@ -1,7 +1,7 @@ import { OverlayBioEntityRender } from '@/types/OLrendering'; import { GetOverlayBioEntityColorByAvailableProperties } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useGetOverlayColor'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; import { Feature } from 'ol'; import { FeatureLike } from 'ol/Feature'; import Style from 'ol/style/Style'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/areOverlayOrdersNotEqual.ts b/src/components/Map/MapViewer/utils/shapes/overlay/areOverlayOrdersNotEqual.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/areOverlayOrdersNotEqual.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/areOverlayOrdersNotEqual.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/calculateOverlayDimensions.test.ts b/src/components/Map/MapViewer/utils/shapes/overlay/calculateOverlayDimensions.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/calculateOverlayDimensions.test.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/calculateOverlayDimensions.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/calculateOverlayDimensions.ts b/src/components/Map/MapViewer/utils/shapes/overlay/calculateOverlayDimensions.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/calculateOverlayDimensions.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/calculateOverlayDimensions.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/findMatchingSubmapLinkRectangle.test.ts b/src/components/Map/MapViewer/utils/shapes/overlay/findMatchingSubmapLinkRectangle.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/findMatchingSubmapLinkRectangle.test.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/findMatchingSubmapLinkRectangle.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/findMatchingSubmapLinkRectangle.ts b/src/components/Map/MapViewer/utils/shapes/overlay/findMatchingSubmapLinkRectangle.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/findMatchingSubmapLinkRectangle.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/findMatchingSubmapLinkRectangle.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/getOverlays.test.ts b/src/components/Map/MapViewer/utils/shapes/overlay/getOverlays.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/getOverlays.test.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/getOverlays.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/getOverlays.ts b/src/components/Map/MapViewer/utils/shapes/overlay/getOverlays.ts similarity index 83% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/getOverlays.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/getOverlays.ts index 8cc7c0043eabf5328a350603e63131357a83f452..687e2e6742186a98087252ebbb32d325047842ba 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/getOverlays.ts +++ b/src/components/Map/MapViewer/utils/shapes/overlay/getOverlays.ts @@ -1,7 +1,7 @@ import { OverlayBioEntityRender } from '@/types/OLrendering'; import { GetOverlayBioEntityColorByAvailableProperties } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useGetOverlayColor'; -import groupOverlayEntities from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/groupOverlayEntities'; -import processOverlayGroupedElements from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/processOverlayGroupedElements'; +import groupOverlayEntities from '@/components/Map/MapViewer/utils/shapes/overlay/groupOverlayEntities'; +import processOverlayGroupedElements from '@/components/Map/MapViewer/utils/shapes/overlay/processOverlayGroupedElements'; export default function getOverlays( groupedOverlays: Record<string, Array<OverlayBioEntityRender>>, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/groupOverlayEntities.test.ts b/src/components/Map/MapViewer/utils/shapes/overlay/groupOverlayEntities.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/groupOverlayEntities.test.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/groupOverlayEntities.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/groupOverlayEntities.ts b/src/components/Map/MapViewer/utils/shapes/overlay/groupOverlayEntities.ts similarity index 88% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/groupOverlayEntities.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/groupOverlayEntities.ts index 984574cfe4b7379ef61f6ff6c592b2ccb32a0f5d..f9a63e9eb5d91d56965983ea5e85ed6ae2003cf9 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/groupOverlayEntities.ts +++ b/src/components/Map/MapViewer/utils/shapes/overlay/groupOverlayEntities.ts @@ -1,6 +1,6 @@ import { OverlayBioEntityRender } from '@/types/OLrendering'; -import findMatchingSubmapLinkRectangle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/findMatchingSubmapLinkRectangle'; -import { OverlayBioEntityGroupedElementsType } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { OverlayBioEntityGroupedElementsType } from '@/components/Map/MapViewer/MapViewer.types'; +import findMatchingSubmapLinkRectangle from '@/components/Map/MapViewer/utils/shapes/overlay/findMatchingSubmapLinkRectangle'; export default function groupOverlayEntities( overlayBioEntities: Array<OverlayBioEntityRender>, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/processOverlayGroupedElements.test.ts b/src/components/Map/MapViewer/utils/shapes/overlay/processOverlayGroupedElements.test.ts similarity index 92% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/processOverlayGroupedElements.test.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/processOverlayGroupedElements.test.ts index 680002ea1ba899f15df25fe9af4fe8227aae5c1c..c3a094e29a033d21f72cbfcc9a4d85693cdbcf0d 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/processOverlayGroupedElements.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/overlay/processOverlayGroupedElements.test.ts @@ -1,8 +1,8 @@ /* eslint-disable no-magic-numbers */ import { OverlayBioEntityRender } from '@/types/OLrendering'; import { GetOverlayBioEntityColorByAvailableProperties } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useGetOverlayColor'; -import processOverlayGroupedElements from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/processOverlayGroupedElements'; -import { OverlayBioEntityGroupedElementsType } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { OverlayBioEntityGroupedElementsType } from '@/components/Map/MapViewer/MapViewer.types'; +import processOverlayGroupedElements from '@/components/Map/MapViewer/utils/shapes/overlay/processOverlayGroupedElements'; describe('processOverlayGroupedElements', () => { it('should correctly process overlay grouped elements and add to entityOverlays', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/processOverlayGroupedElements.ts b/src/components/Map/MapViewer/utils/shapes/overlay/processOverlayGroupedElements.ts similarity index 87% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/processOverlayGroupedElements.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/processOverlayGroupedElements.ts index 7e2a9b434f656123cf48262b0c6ae547f83903b2..48ecc1675ec174d83d10f50ab9129c26b2cf8e04 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/processOverlayGroupedElements.ts +++ b/src/components/Map/MapViewer/utils/shapes/overlay/processOverlayGroupedElements.ts @@ -1,9 +1,9 @@ /* eslint-disable no-magic-numbers */ import { OverlayBioEntityRender } from '@/types/OLrendering'; import { GetOverlayBioEntityColorByAvailableProperties } from '@/components/Map/MapViewer/utils/config/overlaysLayer/useGetOverlayColor'; -import sortElementOverlayByColor from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/sortElementOverlayByColor'; -import calculateOverlayDimensions from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/calculateOverlayDimensions'; -import { OverlayBioEntityGroupedElementsType } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { OverlayBioEntityGroupedElementsType } from '@/components/Map/MapViewer/MapViewer.types'; +import sortElementOverlayByColor from '@/components/Map/MapViewer/utils/shapes/overlay/sortElementOverlayByColor'; +import calculateOverlayDimensions from '@/components/Map/MapViewer/utils/shapes/overlay/calculateOverlayDimensions'; export default function processOverlayGroupedElements( groupedElements: OverlayBioEntityGroupedElementsType, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/sortElementOverlayByColor.test.ts b/src/components/Map/MapViewer/utils/shapes/overlay/sortElementOverlayByColor.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/sortElementOverlayByColor.test.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/sortElementOverlayByColor.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/sortElementOverlayByColor.ts b/src/components/Map/MapViewer/utils/shapes/overlay/sortElementOverlayByColor.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/overlay/sortElementOverlayByColor.ts rename to src/components/Map/MapViewer/utils/shapes/overlay/sortElementOverlayByColor.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.test.ts b/src/components/Map/MapViewer/utils/shapes/reaction/Reaction.test.ts similarity index 94% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.test.ts rename to src/components/Map/MapViewer/utils/shapes/reaction/Reaction.test.ts index 0e6dce2418320aa3460a1067c3e52c82bdad2c8f..4125a80172c567875991cdc6ed814b1325228a29 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/reaction/Reaction.test.ts @@ -1,8 +1,6 @@ /* eslint-disable no-magic-numbers */ import { Feature, Map } from 'ol'; -import Reaction, { - ReactionProps, -} from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction'; +import Reaction, { ReactionProps } from '@/components/Map/MapViewer/utils/shapes/reaction/Reaction'; import { newReactionFixture } from '@/models/fixtures/newReactionFixture'; import { lineTypesFixture } from '@/models/fixtures/lineTypesFixture'; import { arrowTypesFixture } from '@/models/fixtures/arrowTypesFixture'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.ts b/src/components/Map/MapViewer/utils/shapes/reaction/Reaction.ts similarity index 92% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.ts rename to src/components/Map/MapViewer/utils/shapes/reaction/Reaction.ts index ccefcd64da957e5a1ffef93fcb9398108eb54017..a2e786fc5080cc9c174e98dc787b689160962145 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.ts +++ b/src/components/Map/MapViewer/utils/shapes/reaction/Reaction.ts @@ -3,7 +3,6 @@ import { Line, Operator, ReactionProduct, Shape } from '@/types/models'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { Feature } from 'ol'; import { Circle, LineString, MultiLineString, MultiPolygon } from 'ol/geom'; -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; import Polygon from 'ol/geom/Polygon'; import Style from 'ol/style/Style'; import { @@ -11,21 +10,22 @@ import { REACTION_ELEMENT_TYPES, TEXT_CUTOFF_SCALE, WHITE_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +} from '@/components/Map/MapViewer/MapViewer.constants'; import { FeatureLike } from 'ol/Feature'; import { MapInstance } from '@/types/map'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; import { ArrowTypeDict, LineTypeDict } from '@/redux/shapes/shapes.types'; import { FEATURE_TYPE } from '@/constants/features'; -import getScaledElementStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledElementStyle'; import VectorSource from 'ol/source/Vector'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; import { Stroke } from 'ol/style'; -import getLineSegments from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getLineSegments'; -import getRotation from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/coords/getRotation'; -import getArrowFeature from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getArrowFeature'; -import getShapePolygon from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/getShapePolygon'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; +import getScaledElementStyle from '@/components/Map/MapViewer/utils/shapes/style/getScaledElementStyle'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; +import getLineSegments from '@/components/Map/MapViewer/utils/shapes/coords/getLineSegments'; +import getRotation from '@/components/Map/MapViewer/utils/shapes/coords/getRotation'; +import getArrowFeature from '@/components/Map/MapViewer/utils/shapes/elements/getArrowFeature'; +import getShapePolygon from '@/components/Map/MapViewer/utils/shapes/elements/getShapePolygon'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; export interface ReactionProps { id: number; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getCoverStyles.test.ts b/src/components/Map/MapViewer/utils/shapes/style/getCoverStyles.test.ts similarity index 87% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getCoverStyles.test.ts rename to src/components/Map/MapViewer/utils/shapes/style/getCoverStyles.test.ts index 8178ab4a339145fa56fe6965dc97ea3f673f5941..a8ea5c82ba47d7e22d3fd805d2342c8ff3b9059f 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getCoverStyles.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/style/getCoverStyles.test.ts @@ -1,15 +1,15 @@ /* eslint-disable no-magic-numbers */ import Style from 'ol/style/Style'; import { Extent } from 'ol/extent'; -import getWrappedTextWithFontSize from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getWrappedTextWithFontSize'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; +import getWrappedTextWithFontSize from '@/components/Map/MapViewer/utils/shapes/text/getWrappedTextWithFontSize'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; import { latLngToPoint } from '@/utils/map/latLngToPoint'; -import getCoverStyles from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getCoverStyles'; +import getCoverStyles from '@/components/Map/MapViewer/utils/shapes/style/getCoverStyles'; import { DEFAULT_TILE_SIZE } from '@/constants/map'; jest.mock('../text/getWrappedTextWithFontSize'); jest.mock('../text/getTextStyle'); -jest.mock('../../../../../../../utils/map/latLngToPoint'); +jest.mock('../../../../../../utils/map/latLngToPoint'); describe('getCoverStyles', () => { it('should return cover and text styles based on the provided parameters', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getCoverStyles.ts b/src/components/Map/MapViewer/utils/shapes/style/getCoverStyles.ts similarity index 86% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getCoverStyles.ts rename to src/components/Map/MapViewer/utils/shapes/style/getCoverStyles.ts index 78f2ef6b8d27d1283faf6ad89c00bd46636cfcc6..83ad9a718e5ca79a360311e3e686d781682528c5 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getCoverStyles.ts +++ b/src/components/Map/MapViewer/utils/shapes/style/getCoverStyles.ts @@ -3,12 +3,12 @@ import Style from 'ol/style/Style'; import { Extent, getCenter } from 'ol/extent'; import { toLonLat } from 'ol/proj'; import { latLngToPoint } from '@/utils/map/latLngToPoint'; -import getWrappedTextWithFontSize from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getWrappedTextWithFontSize'; +import getWrappedTextWithFontSize from '@/components/Map/MapViewer/utils/shapes/text/getWrappedTextWithFontSize'; import { Point } from 'ol/geom'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; import { MapSize } from '@/redux/map/map.types'; import { Stroke } from 'ol/style'; -import getScaledStrokeStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledStrokeStyle'; +import getScaledStrokeStyle from '@/components/Map/MapViewer/utils/shapes/style/getScaledStrokeStyle'; export default function getCoverStyles({ coverStyle, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill.test.ts b/src/components/Map/MapViewer/utils/shapes/style/getFill.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill.test.ts rename to src/components/Map/MapViewer/utils/shapes/style/getFill.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill.ts b/src/components/Map/MapViewer/utils/shapes/style/getFill.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill.ts rename to src/components/Map/MapViewer/utils/shapes/style/getFill.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledElementStyle.test.ts b/src/components/Map/MapViewer/utils/shapes/style/getScaledElementStyle.test.ts similarity index 92% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledElementStyle.test.ts rename to src/components/Map/MapViewer/utils/shapes/style/getScaledElementStyle.test.ts index 5c22d99435b0030dee701f1c765177e0108d10e3..bd36a7d8b47c169b8d123b40dfd9f44bef7d2d60 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledElementStyle.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/style/getScaledElementStyle.test.ts @@ -1,7 +1,7 @@ /* eslint-disable no-magic-numbers */ import Style from 'ol/style/Style'; import { Stroke, Text } from 'ol/style'; -import getScaledStrokeStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledStrokeStyle'; +import getScaledStrokeStyle from '@/components/Map/MapViewer/utils/shapes/style/getScaledStrokeStyle'; import getScaledElementStyle from './getScaledElementStyle'; jest.mock('./getScaledStrokeStyle'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledElementStyle.ts b/src/components/Map/MapViewer/utils/shapes/style/getScaledElementStyle.ts similarity index 76% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledElementStyle.ts rename to src/components/Map/MapViewer/utils/shapes/style/getScaledElementStyle.ts index a91c03094074ba2531f6af8fbb0c59e185fd28b6..5f2eaa409d80f8c69ba10c61f6757cc8c9763b85 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledElementStyle.ts +++ b/src/components/Map/MapViewer/utils/shapes/style/getScaledElementStyle.ts @@ -1,7 +1,7 @@ /* eslint-disable no-magic-numbers */ import Style from 'ol/style/Style'; import { Stroke } from 'ol/style'; -import getScaledStrokeStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledStrokeStyle'; +import getScaledStrokeStyle from '@/components/Map/MapViewer/utils/shapes/style/getScaledStrokeStyle'; export default function getScaledElementStyle( style: Style, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledStrokeStyle.test.ts b/src/components/Map/MapViewer/utils/shapes/style/getScaledStrokeStyle.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledStrokeStyle.test.ts rename to src/components/Map/MapViewer/utils/shapes/style/getScaledStrokeStyle.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledStrokeStyle.ts b/src/components/Map/MapViewer/utils/shapes/style/getScaledStrokeStyle.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getScaledStrokeStyle.ts rename to src/components/Map/MapViewer/utils/shapes/style/getScaledStrokeStyle.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke.test.ts b/src/components/Map/MapViewer/utils/shapes/style/getStroke.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke.test.ts rename to src/components/Map/MapViewer/utils/shapes/style/getStroke.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke.ts b/src/components/Map/MapViewer/utils/shapes/style/getStroke.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke.ts rename to src/components/Map/MapViewer/utils/shapes/style/getStroke.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle.test.ts b/src/components/Map/MapViewer/utils/shapes/style/getStyle.test.ts similarity index 94% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle.test.ts rename to src/components/Map/MapViewer/utils/shapes/style/getStyle.test.ts index e46f9ef0c2cea4a7ba48e7f338a08918a5c9bb18..974b9272c3c38c4436fee73ac15286ba185a3934 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/style/getStyle.test.ts @@ -1,5 +1,5 @@ /* eslint-disable no-magic-numbers */ -import getStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle'; +import getStyle from '@/components/Map/MapViewer/utils/shapes/style/getStyle'; import Style from 'ol/style/Style'; import Polygon from 'ol/geom/Polygon'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle.ts b/src/components/Map/MapViewer/utils/shapes/style/getStyle.ts similarity index 65% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle.ts rename to src/components/Map/MapViewer/utils/shapes/style/getStyle.ts index 96083434e3f49d298495931f119bcd3b96f314b7..9e121e1a0b8acfbac6656edc517372202e2cd3e4 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStyle.ts +++ b/src/components/Map/MapViewer/utils/shapes/style/getStyle.ts @@ -1,14 +1,11 @@ /* eslint-disable no-magic-numbers */ import Style from 'ol/style/Style'; import { Geometry } from 'ol/geom'; -import getStroke from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getStroke'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; -import { - BLACK_COLOR, - WHITE_COLOR, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import getFill from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/getFill'; +import { BLACK_COLOR, WHITE_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; import { Color } from '@/types/models'; +import getStroke from '@/components/Map/MapViewer/utils/shapes/style/getStroke'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import getFill from '@/components/Map/MapViewer/utils/shapes/style/getFill'; export default function getStyle({ geometry, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex.test.ts b/src/components/Map/MapViewer/utils/shapes/style/rgbToHex.test.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex.test.ts rename to src/components/Map/MapViewer/utils/shapes/style/rgbToHex.test.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex.ts b/src/components/Map/MapViewer/utils/shapes/style/rgbToHex.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex.ts rename to src/components/Map/MapViewer/utils/shapes/style/rgbToHex.ts diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/Text.test.ts b/src/components/Map/MapViewer/utils/shapes/text/Text.test.ts similarity index 80% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/Text.test.ts rename to src/components/Map/MapViewer/utils/shapes/text/Text.test.ts index 68b8d9f8f1a73b0d99e2251282512c5e211d4859..d40cf4593f9bcbd82b8a62d5059d2363d4a3cabb 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/Text.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/text/Text.test.ts @@ -1,12 +1,12 @@ /* eslint-disable no-magic-numbers */ import { Map } from 'ol'; import { Style } from 'ol/style'; -import Text, { TextProps } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/Text'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; import View from 'ol/View'; -import { BLACK_COLOR } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; +import { BLACK_COLOR } from '@/components/Map/MapViewer/MapViewer.constants'; +import Text, { TextProps } from '@/components/Map/MapViewer/utils/shapes/text/Text'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; jest.mock('./getTextCoords'); jest.mock('./getTextStyle'); diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/Text.ts b/src/components/Map/MapViewer/utils/shapes/text/Text.ts similarity index 84% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/Text.ts rename to src/components/Map/MapViewer/utils/shapes/text/Text.ts index 27b8ec6f59260848cfeb6581ee1c8e91b99f61d8..c853b3691f6f2bcc13d998729b4c3c8e02ec208f 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/Text.ts +++ b/src/components/Map/MapViewer/utils/shapes/text/Text.ts @@ -1,19 +1,16 @@ /* eslint-disable no-magic-numbers */ -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; -import { rgbToHex } from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/style/rgbToHex'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import Style from 'ol/style/Style'; import { Point } from 'ol/geom'; import { Feature } from 'ol'; import { FeatureLike } from 'ol/Feature'; import { MapInstance } from '@/types/map'; -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; import { Color } from '@/types/models'; -import { TEXT_CUTOFF_SCALE } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.constants'; +import { TEXT_CUTOFF_SCALE } from '@/components/Map/MapViewer/MapViewer.constants'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; +import { rgbToHex } from '@/components/Map/MapViewer/utils/shapes/style/rgbToHex'; export interface TextProps { x: number; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords.test.ts b/src/components/Map/MapViewer/utils/shapes/text/getTextCoords.test.ts similarity index 85% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords.test.ts rename to src/components/Map/MapViewer/utils/shapes/text/getTextCoords.test.ts index 6121a92d201c129bd1787002439609afdaf38f39..a48c180a291bf6324be668911ea6e98a7ff2ec23 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/text/getTextCoords.test.ts @@ -1,5 +1,5 @@ /* eslint-disable no-magic-numbers */ -import getTextCoords from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords'; +import getTextCoords from '@/components/Map/MapViewer/utils/shapes/text/getTextCoords'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; describe('getTextCoords', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords.ts b/src/components/Map/MapViewer/utils/shapes/text/getTextCoords.ts similarity index 89% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords.ts rename to src/components/Map/MapViewer/utils/shapes/text/getTextCoords.ts index 3dcbb8fa775a7eedc9d4615c565f7d3f6da8afad..e3224fc9f5272d288c53b55a82f0656f81f09a64 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextCoords.ts +++ b/src/components/Map/MapViewer/utils/shapes/text/getTextCoords.ts @@ -1,8 +1,5 @@ /* eslint-disable no-magic-numbers */ -import { - HorizontalAlign, - VerticalAlign, -} from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { HorizontalAlign, VerticalAlign } from '@/components/Map/MapViewer/MapViewer.types'; import { UsePointToProjectionResult } from '@/utils/map/usePointToProjection'; import { Coordinate } from 'ol/coordinate'; diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle.test.ts b/src/components/Map/MapViewer/utils/shapes/text/getTextStyle.test.ts similarity index 88% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle.test.ts rename to src/components/Map/MapViewer/utils/shapes/text/getTextStyle.test.ts index d16623b5d20e27252138ee74dac0f5096c6cfaf9..3d6fc5f4ce0754ebb489505a788887baa9a9a729 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/text/getTextStyle.test.ts @@ -1,5 +1,5 @@ /* eslint-disable no-magic-numbers */ -import getTextStyle from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle'; +import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextStyle'; import Style from 'ol/style/Style'; describe('getTextStyle', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle.ts b/src/components/Map/MapViewer/utils/shapes/text/getTextStyle.ts similarity index 95% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle.ts rename to src/components/Map/MapViewer/utils/shapes/text/getTextStyle.ts index 4858fb21b6fa019b9e0f6c0a9fb77c43dd705542..6558ab9afcb850e8a028874e3969ceb616ae18d1 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getTextStyle.ts +++ b/src/components/Map/MapViewer/utils/shapes/text/getTextStyle.ts @@ -1,6 +1,6 @@ import { Fill, Text } from 'ol/style'; import Style from 'ol/style/Style'; -import { HorizontalAlign } from '@/components/Map/MapViewer/MapViewerVector/MapViewerVector.types'; +import { HorizontalAlign } from '@/components/Map/MapViewer/MapViewer.types'; export default function getTextStyle({ text, diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getWrappedTextWithFontSize.test.ts b/src/components/Map/MapViewer/utils/shapes/text/getWrappedTextWithFontSize.test.ts similarity index 95% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getWrappedTextWithFontSize.test.ts rename to src/components/Map/MapViewer/utils/shapes/text/getWrappedTextWithFontSize.test.ts index 2cfaa2436cd3d07f407c765b96b303702726923f..eba60616ef04ace93ac8f7261bdf1b32936be634 100644 --- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getWrappedTextWithFontSize.test.ts +++ b/src/components/Map/MapViewer/utils/shapes/text/getWrappedTextWithFontSize.test.ts @@ -1,5 +1,5 @@ /* eslint-disable no-magic-numbers */ -import getWrappedTextWithFontSize from '@/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getWrappedTextWithFontSize'; +import getWrappedTextWithFontSize from '@/components/Map/MapViewer/utils/shapes/text/getWrappedTextWithFontSize'; describe('getWrappedTextWithFontSize', () => { it('should return a wrapped text and font size for this text when maxWidth is limited and maxHeight is unlimited', () => { diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getWrappedTextWithFontSize.ts b/src/components/Map/MapViewer/utils/shapes/text/getWrappedTextWithFontSize.ts similarity index 100% rename from src/components/Map/MapViewer/MapViewerVector/utils/shapes/text/getWrappedTextWithFontSize.ts rename to src/components/Map/MapViewer/utils/shapes/text/getWrappedTextWithFontSize.ts diff --git a/src/components/Map/MapViewer/utils/useOlMap.ts b/src/components/Map/MapViewer/utils/useOlMap.ts index 68ec65bdabc7f95366cf0835ef547a515301a6ce..6e372dc36b963820a193dcc2045faf0c78f5b56b 100644 --- a/src/components/Map/MapViewer/utils/useOlMap.ts +++ b/src/components/Map/MapViewer/utils/useOlMap.ts @@ -2,15 +2,9 @@ import { MapInstance } from '@/types/map'; import { useMapInstance } from '@/utils/context/mapInstanceContext'; import Map from 'ol/Map'; import { Zoom } from 'ol/control'; -import React, { MutableRefObject, useEffect, useMemo } from 'react'; -import { useOlMapVectorLayers } from '@/components/Map/MapViewer/MapViewerVector/utils/config/useOlMapVectorLayers'; -import LayerGroup from 'ol/layer/Group'; -import { useAppSelector } from '@/redux/hooks/useAppSelector'; -import { vectorRenderingSelector } from '@/redux/models/models.selectors'; +import React, { MutableRefObject, useEffect } from 'react'; +import { useOlMapLayers } from '@/components/Map/MapViewer/utils/config/useOlMapLayers'; import { defaults, MouseWheelZoom } from 'ol/interaction'; -import { useOlMapVectorListeners } from '@/components/Map/MapViewer/MapViewerVector/listeners/useOlMapVectorListeners'; -import { useOlMapCommonLayers } from '@/components/Map/MapViewer/utils/config/useOlMapCommonLayers'; -import { useOlMapLayers } from './config/useOlMapLayers'; import { useOlMapView } from './config/useOlMapView'; import { useOlMapListeners } from './listeners/useOlMapListeners'; @@ -25,34 +19,13 @@ interface UseOlMapOutput { type UseOlMap = (input?: UseOlMapInput) => UseOlMapOutput; export const useOlMap: UseOlMap = ({ target } = {}) => { - const vectorRendering = useAppSelector(vectorRenderingSelector); const mapRef = React.useRef<null | HTMLDivElement>(null); const { mapInstance, handleSetMapInstance } = useMapInstance(); const view = useOlMapView({ mapInstance }); - const rasterLayers = useOlMapLayers(); - const rasterLayersGroup = useMemo(() => { - return new LayerGroup({ - layers: rasterLayers, - }); - }, [rasterLayers]); - - const vectorLayers = useOlMapVectorLayers({ mapInstance }); - const vectorLayersGroup = useMemo(() => { - return new LayerGroup({ - layers: vectorLayers, - }); - }, [vectorLayers]); - - const commonLayers = useOlMapCommonLayers(); - const commonLayersGroup = useMemo(() => { - return new LayerGroup({ - layers: commonLayers, - }); - }, [commonLayers]); + const mapLayers = useOlMapLayers({ mapInstance }); useOlMapListeners({ view, mapInstance }); - useOlMapVectorListeners({ mapInstance }); useEffect(() => { // checking if innerHTML is empty due to possibility of target element cloning by OpenLayers map instance @@ -86,18 +59,8 @@ export const useOlMap: UseOlMap = ({ target } = {}) => { if (!mapInstance) { return; } - mapInstance.setLayers([vectorLayersGroup, rasterLayersGroup, commonLayersGroup]); - }, [mapInstance, rasterLayersGroup, vectorLayersGroup, commonLayersGroup]); - - useEffect(() => { - if (vectorRendering) { - rasterLayersGroup.setVisible(false); - vectorLayersGroup.setVisible(true); - } else { - vectorLayersGroup.setVisible(false); - rasterLayersGroup.setVisible(true); - } - }, [rasterLayersGroup, vectorLayersGroup, vectorRendering]); + mapInstance.setLayers(mapLayers); + }, [mapInstance, mapLayers]); return { mapRef, diff --git a/src/models/mocks/modelsMock.ts b/src/models/mocks/modelsMock.ts index 85e29299d2ef570b571c45a83bb73eec8e362a02..5c14d13a58857f9004cc7f2bb079d70173b34a20 100644 --- a/src/models/mocks/modelsMock.ts +++ b/src/models/mocks/modelsMock.ts @@ -475,7 +475,6 @@ export const CORE_PD_MODEL_MOCK: MapModel = { modificationDates: [], minZoom: 2, maxZoom: 9, - vectorRendering: true, }; export const MODEL_WITH_DESCRIPTION: MapModel = { diff --git a/src/models/modelSchema.ts b/src/models/modelSchema.ts index feb8817bcdb664796a79c9d55813baca5a44a173..392cda85d877572b3429272eb26e52dc241b5be6 100644 --- a/src/models/modelSchema.ts +++ b/src/models/modelSchema.ts @@ -29,7 +29,6 @@ export const mapModelSchema = z.object({ references: z.array(referenceSchema), creationDate: z.string().nullable(), modificationDates: z.array(z.string()), - vectorRendering: z.boolean().optional(), }); export const mapModelsSchema = pageableSchema(mapModelSchema); diff --git a/src/redux/bioEntity/thunks/utils/fetchReactionsAndGetBioEntitiesIds.ts b/src/redux/bioEntity/thunks/utils/fetchReactionsAndGetBioEntitiesIds.ts index cae4025d558e37db7152454cedd14d1a4358dfe6..a29317ed7c590388c192556d7763505226acf27d 100644 --- a/src/redux/bioEntity/thunks/utils/fetchReactionsAndGetBioEntitiesIds.ts +++ b/src/redux/bioEntity/thunks/utils/fetchReactionsAndGetBioEntitiesIds.ts @@ -5,7 +5,7 @@ import { modelsNameMapSelector } from '@/redux/models/models.selectors'; import { getReactionsByIds } from '@/redux/reactions/reactions.thunks'; import type { AppDispatch, store } from '@/redux/store'; import type { BioEntityContent, NewReaction } from '@/types/models'; -import getModelElementsIdsFromReaction from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/getModelElementsIdsFromReaction'; +import getModelElementsIdsFromReaction from '@/components/Map/MapViewer/utils/listeners/mouseClick/getModelElementsIdsFromReaction'; interface Args { bioEntityContents: BioEntityContent[]; diff --git a/src/redux/layers/layers.reducers.ts b/src/redux/layers/layers.reducers.ts index 715611f1b0d6e56e420ecca95a562762b6edf382..58aa3a23087969559659f2c9f780620e42e3b33d 100644 --- a/src/redux/layers/layers.reducers.ts +++ b/src/redux/layers/layers.reducers.ts @@ -57,6 +57,9 @@ export const setActiveLayerReducer = ( action: PayloadAction<{ modelId: number; layerId: number | null }>, ): void => { const { modelId, layerId } = action.payload; + if (!state[modelId]) { + return; + } const { data } = state[modelId]; if (!data) { return; diff --git a/src/redux/models/models.reducers.ts b/src/redux/models/models.reducers.ts index 054b4c0b1430bed549994d83addc7adb5552fb85..eb65378683bd45efd36c2adc9fe832ed886b1066 100644 --- a/src/redux/models/models.reducers.ts +++ b/src/redux/models/models.reducers.ts @@ -1,5 +1,5 @@ /* eslint-disable no-magic-numbers */ -import { ActionReducerMapBuilder, PayloadAction } from '@reduxjs/toolkit'; +import { ActionReducerMapBuilder } from '@reduxjs/toolkit'; import { getModels } from './models.thunks'; import { ModelsState } from './models.types'; @@ -16,14 +16,3 @@ export const getModelsReducer = (builder: ActionReducerMapBuilder<ModelsState>): // TODO to discuss manage state of failure }); }; - -export const setModelVectorRenderingReducer = ( - state: ModelsState, - action: PayloadAction<{ vectorRendering: boolean; mapId: number }>, -): void => { - const { payload } = action; - const modelIndex = state.data.findIndex(model => model.id === payload.mapId); - if (modelIndex !== -1) { - state.data[modelIndex].vectorRendering = payload.vectorRendering; - } -}; diff --git a/src/redux/models/models.selectors.ts b/src/redux/models/models.selectors.ts index 606aa70ee36712b44b78d45580afa1d80a26c5d3..a26e8e94d87a975d4a51611c6bef94844794bbca 100644 --- a/src/redux/models/models.selectors.ts +++ b/src/redux/models/models.selectors.ts @@ -63,8 +63,3 @@ export const mainMapModelDescriptionSelector = createSelector( mainMapModelSelector, model => model?.description, ); - -export const vectorRenderingSelector = createSelector( - currentModelSelector, - model => model?.vectorRendering || false, -); diff --git a/src/redux/models/models.slice.ts b/src/redux/models/models.slice.ts index 48cf86543d6af1dc4ac35c04e4e4c8e8f85ad260..5c969f3e0e1d6eb2b0e5183d3a5bc7b454248f60 100644 --- a/src/redux/models/models.slice.ts +++ b/src/redux/models/models.slice.ts @@ -1,6 +1,6 @@ import { ModelsState } from '@/redux/models/models.types'; import { createSlice } from '@reduxjs/toolkit'; -import { getModelsReducer, setModelVectorRenderingReducer } from './models.reducers'; +import { getModelsReducer } from './models.reducers'; const initialState: ModelsState = { data: [], @@ -11,14 +11,10 @@ const initialState: ModelsState = { export const modelsSlice = createSlice({ name: 'models', initialState, - reducers: { - setModelVectorRendering: setModelVectorRenderingReducer, - }, + reducers: {}, extraReducers: builder => { getModelsReducer(builder); }, }); -export const { setModelVectorRendering } = modelsSlice.actions; - export default modelsSlice.reducer;