Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/analysis flow #677

Merged
merged 18 commits into from
Sep 27, 2023
Merged
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
25 changes: 22 additions & 3 deletions app/scripts/components/analysis/constants.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { FeatureCollection, Polygon } from 'geojson';
import { makeFeatureCollection } from '$components/common/aoi/utils';
import { featureCollection } from '@turf/helpers';

export type RegionPreset = 'world';
export type RegionPreset = 'world' | 'north-america';

export const FeatureByRegionPreset: Record<
RegionPreset,
FeatureCollection<Polygon>
> = {
world: makeFeatureCollection([
world: featureCollection([
{
type: 'Feature',
id: 'world',
Expand All @@ -25,6 +25,25 @@ export const FeatureByRegionPreset: Record<
type: 'Polygon'
}
}
]),
'north-america': featureCollection([
{
type: 'Feature',
id: 'north-america',
properties: {},
geometry: {
coordinates: [
[
[-180, 0],
[-180, 89],
[-60, 89],
[-60, 0],
[-180, 0]
]
],
type: 'Polygon'
}
}
])
};

Expand Down
26 changes: 18 additions & 8 deletions app/scripts/components/analysis/define/aoi-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,19 @@
import { Button, ButtonGroup } from '@devseed-ui/button';
import { Dropdown, DropMenu, DropTitle } from '@devseed-ui/dropdown';
import {
CollecticonArrowLoop,
CollecticonTrashBin,
CollecticonHandPan,
CollecticonMarker,
CollecticonPencil,
CollecticonUpload2
} from '@devseed-ui/collecticons';
import { FeatureByRegionPreset, RegionPreset } from '../constants';
import AoIUploadModal from './aoi-upload-modal';
import { FoldWGuideLine, FoldTitleWOAccent } from '.';
import {
Fold,
FoldHeader,
FoldHeadline,
FoldHeadActions,
FoldTitle,
FoldBody
} from '$components/common/fold';
import MapboxMap, { MapboxMapRef } from '$components/common/mapbox';
Expand Down Expand Up @@ -96,7 +95,7 @@
];
mapRef.current?.instance?.fitBounds(fcBbox, { padding: 32 });
},
[onAoiEvent]

Check warning on line 98 in app/scripts/components/analysis/define/aoi-selector.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useCallback has a missing dependency: 'mapRef'. Either include it or remove the dependency array
);

const onRegionPresetClick = useCallback(
Expand All @@ -115,29 +114,33 @@
onAoiEvent('aoi.clear');
mapRef.current?.instance?.flyTo({ zoom: 1, center: [0, 0] });
}
}, [onAoiEvent, qsFc, setFeatureCollection]);

Check warning on line 117 in app/scripts/components/analysis/define/aoi-selector.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'mapRef'. Either include it or remove the dependency array

const [aoiModalRevealed, setAoIModalRevealed] = useState(false);

return (
<Fold>
<FoldWGuideLine number={1}>
<AoIUploadModal
setFeatureCollection={setFeatureCollection}
revealed={aoiModalRevealed}
onCloseClick={() => setAoIModalRevealed(false)}
/>
<FoldHeader>
<FoldHeadline>
<FoldTitle>Area</FoldTitle>
<FoldTitleWOAccent>Select area of interest</FoldTitleWOAccent>
<p>
Use the pencil tool to draw a shape on the map or upload your own
shapefile.
</p>
</FoldHeadline>
<AoiHeadActions>
<Toolbar>
<ToolbarIconButton
variation='primary-fill'
variation='danger-fill'
onClick={() => onAoiEvent('aoi.clear')}
disabled={!featureCollection?.features.length}
>
<CollecticonArrowLoop title='Clear map' meaningful />
<CollecticonTrashBin title='Clear map' meaningful />
</ToolbarIconButton>
<VerticalDivider variation='dark' />
<ButtonGroup variation='primary-fill'>
Expand Down Expand Up @@ -179,6 +182,13 @@
World
</DropMenuItemButton>
</li>
<li>
<DropMenuItemButton
onClick={() => onRegionPresetClick('north-america')}
>
North America
</DropMenuItemButton>
</li>
</DropMenu>
</Dropdown>
</Toolbar>
Expand All @@ -194,6 +204,6 @@
/>
</MapContainer>
</FoldBody>
</Fold>
</FoldWGuideLine>
);
}
Loading
Loading