diff --git a/src/frontend/src/components/DroneOperatorTask/MapSection/index.tsx b/src/frontend/src/components/DroneOperatorTask/MapSection/index.tsx index 964bc57b..ae60a800 100644 --- a/src/frontend/src/components/DroneOperatorTask/MapSection/index.tsx +++ b/src/frontend/src/components/DroneOperatorTask/MapSection/index.tsx @@ -5,6 +5,7 @@ import { useParams } from 'react-router-dom'; import { FeatureCollection } from 'geojson'; import { useGetTaskWaypointQuery } from '@Api/tasks'; import getBbox from '@turf/bbox'; +import { coordAll } from '@turf/meta'; import { useMapLibreGLMap } from '@Components/common/MapLibreComponents'; import BaseLayerSwitcher from '@Components/common/MapLibreComponents/BaseLayerSwitcher'; import VectorLayer from '@Components/common/MapLibreComponents/Layers/VectorLayer'; @@ -31,44 +32,8 @@ const MapSection = () => { taskId as string, { select: (data: any) => { - // refine data and return geojson points and single line string - const refinedData = data?.data?.reduce( - (acc: any, curr: any) => { - return { - ...acc, - geojsonListOfPoint: [ - ...acc.geojsonListOfPoint, - { - type: 'FeatureCollection', - features: [ - { - type: 'Feature', - properties: { - angle: curr?.angle, - gimbal_angle: curr.gimbal_angle, - }, - geometry: { - type: 'Point', - coordinates: curr?.coordinates, - }, - }, - ], - }, - ], - combinedCoordinates: [ - ...acc.combinedCoordinates, - curr?.coordinates, - ], - }; - }, - { - combinedCoordinates: [], - geojsonListOfPoint: [], - }, - ); - const { geojsonListOfPoint, combinedCoordinates } = refinedData; return { - geojsonListOfPoint, + geojsonListOfPoint: data.data, geojsonAsLineString: { type: 'FeatureCollection', features: [ @@ -77,7 +42,8 @@ const MapSection = () => { properties: {}, geometry: { type: 'LineString', - coordinates: combinedCoordinates, + // get all coordinates + coordinates: coordAll(data.data), }, }, ], @@ -109,6 +75,7 @@ const MapSection = () => { > {taskWayPoints && ( <> + {/* render line */} { symbolPlacement="line" iconAnchor="center" /> - {taskWayPoints?.geojsonListOfPoint?.map( - (point: any, index: number) => { - const lastPoint = - Number(taskWayPoints?.geojsonListOfPoint?.length) - 1; - - return ( - - ); - }, - )} + {/* render points */} + + {/* render image and only if index is 0 */} + )}