Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/map/interactions/TransformFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { getCenterOfFirstPointsOfTrajectoriesInWorldCoordinates } from '~/featur
import {
GROSS_CONVEX_HULL_AREA_ID,
globalIdToAreaId,
isHomePositionId,
isOriginId,
} from '~/model/identifiers';
/**
Expand Down Expand Up @@ -141,7 +142,8 @@ export class TransformFeaturesInteraction extends PointerInteraction {
// investigate whether there is a way around it
if (
globalIdToAreaId(this.lastFeature_.getId()) ===
GROSS_CONVEX_HULL_AREA_ID
GROSS_CONVEX_HULL_AREA_ID ||
isHomePositionId(this.lastFeature_.getId())
) {
const state = store.getState();

Expand Down
21 changes: 20 additions & 1 deletion src/features/selection/selectors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { createSelector } from '@reduxjs/toolkit';
import {
areaIdToGlobalId,
GROSS_CONVEX_HULL_AREA_ID,
homePositionIdToGlobalId,
} from '~/model/identifiers';

import { type AppSelector } from '~/store/reducers';
// import { getMissionMapping } from '~/features/mission/selectors';
import { type RootState, type AppSelector } from '~/store/reducers';
import { rejectNullish } from '~/utils/arrays';
import { type Identifier } from '~/utils/collections';

Expand All @@ -14,6 +20,19 @@ import { type Identifier } from '~/utils/collections';
export const getSelection: AppSelector<Identifier[]> = (state) =>
state.selection.ids;

export const getVirtualSelection: AppSelector<Identifier[]> = createSelector(
getSelection,
// getMissionMapping, // TODO: This causes a dependency cycle
(state: RootState) => state.mission.mapping,
(selection, mapping) =>
selection.includes(areaIdToGlobalId(GROSS_CONVEX_HULL_AREA_ID))
? [
...selection,
...mapping.map((_, i) => String(i)).map(homePositionIdToGlobalId),
]
: selection
);

/**
* Selector factory that creates a selector that returns true if and only if a
* feature with the given ID is selected.
Expand Down
7 changes: 6 additions & 1 deletion src/model/openlayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
GROSS_CONVEX_HULL_AREA_ID,
isAreaId,
isFeatureId,
isHomePositionId,
isMissionItemId,
isOriginId,
MAP_ORIGIN_ID,
Expand Down Expand Up @@ -66,7 +67,11 @@ export function isFeatureTransformable(object) {

const id = object.getId();
return (
isFeatureId(id) || isAreaId(id) || isOriginId(id) || isMissionItemId(id)
isFeatureId(id) ||
isAreaId(id) ||
isOriginId(id) ||
isMissionItemId(id) ||
isHomePositionId(id)
);
}

Expand Down
25 changes: 21 additions & 4 deletions src/views/map/MapView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ import { getSelectedTool } from '~/features/map/tools';
import { updateMapViewSettings } from '~/features/map/view';
import { addNewMissionItem } from '~/features/mission/actions';
import { getGeofencePolygonId } from '~/features/mission/selectors';
import { getSelection } from '~/features/selection/selectors';
import {
getSelection,
getVirtualSelection,
} from '~/features/selection/selectors';
import {
addToSelection,
removeFromSelection,
Expand All @@ -49,7 +52,12 @@ import NearestItemTooltip from '~/features/session/NearestItemTooltip';
import { setFeatureIdForTooltip } from '~/features/session/slice';
import { getFollowMapSelectionInUAVDetailsPanel } from '~/features/uavs/selectors';
import mapViewManager from '~/mapViewManager';
import { featureIdToGlobalId } from '~/model/identifiers';
import {
areaIdToGlobalId,
featureIdToGlobalId,
GROSS_CONVEX_HULL_AREA_ID,
isHomePositionId,
} from '~/model/identifiers';
import {
canLayerTriggerTooltip,
getVisibleEditableLayers,
Expand Down Expand Up @@ -646,7 +654,15 @@ class MapViewPresentation extends React.Component {
toggle: toggleInSelection,
};
const action = actionMapping[mode] || setSelection;
const ids = features ? features.map((feature) => feature.getId()) : [];
const rawIds = features ? features.map((feature) => feature.getId()) : [];

const ids = rawIds.some(isHomePositionId)
? [
...rawIds.filter((id) => !isHomePositionId(id)),
areaIdToGlobalId(GROSS_CONVEX_HULL_AREA_ID),
]
: rawIds;

if (action === setSelection || (ids && ids.length > 0)) {
this.props.dispatch(action(ids));
}
Expand Down Expand Up @@ -731,7 +747,8 @@ const MapView = connect(

selectedFeatures: getSelectedFeatureIds(state),
selectedTool: getSelectedTool(state),
selection: getSelection(state),
// selection: getSelection(state),
selection: getVirtualSelection(state),

uavDetailsPanelFollowsSelection:
getFollowMapSelectionInUAVDetailsPanel(state),
Expand Down
9 changes: 7 additions & 2 deletions src/views/map/layers/mission-info.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ import {
getMissionItemsWithCoordinatesInOrder,
getSelectedMissionIndicesForTrajectoryDisplay,
} from '~/features/mission/selectors';
import { getSelection } from '~/features/selection/selectors';
import {
getSelection,
getVirtualSelection,
} from '~/features/selection/selectors';
import {
getConvexHullOfShowInWorldCoordinates,
getOutdoorShowOrientation,
Expand Down Expand Up @@ -638,6 +641,7 @@ const MissionInfoVectorSource = ({
? formatMissionId(homePositions.length - 1).length *
TAKEOFF_LANDING_POSITION_CHARACTER_WIDTH
: 0,
selection,
}),
landingPositionPoints(landingPositions, {
minimumDistanceBetweenPositions: minimumDistanceBetweenLandingPositions,
Expand Down Expand Up @@ -752,7 +756,8 @@ export const MissionInfoLayer = connect(
state,
MissionItemType.RETURN_TO_HOME
),
selection: getSelection(state),
// selection: getSelection(state),
selection: getVirtualSelection(state),
uavIdsForTrajectories: layer?.parameters?.showTrajectoriesOfSelection
? getSelectedUAVIdsForTrajectoryDisplay(state)
: undefined,
Expand Down