Skip to content

Commit

Permalink
Feature/analysis flow (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
nerik authored Sep 27, 2023
2 parents c0f6b72 + 9abac3b commit e85073e
Show file tree
Hide file tree
Showing 15 changed files with 631 additions and 363 deletions.
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 {
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 @@ -120,24 +119,28 @@ export default function AoiSelector({
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 @@ export default function AoiSelector({
World
</DropMenuItemButton>
</li>
<li>
<DropMenuItemButton
onClick={() => onRegionPresetClick('north-america')}
>
North America
</DropMenuItemButton>
</li>
</DropMenu>
</Dropdown>
</Toolbar>
Expand All @@ -194,6 +204,6 @@ export default function AoiSelector({
/>
</MapContainer>
</FoldBody>
</Fold>
</FoldWGuideLine>
);
}
Loading

0 comments on commit e85073e

Please sign in to comment.