Skip to content

Commit

Permalink
Added north america preset
Browse files Browse the repository at this point in the history
  • Loading branch information
nerik committed Sep 26, 2023
1 parent a67f413 commit fd884ee
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 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
7 changes: 7 additions & 0 deletions app/scripts/components/analysis/define/aoi-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ export default function AoiSelector({
World
</DropMenuItemButton>
</li>
<li>
<DropMenuItemButton
onClick={() => onRegionPresetClick('north-america')}
>
North America
</DropMenuItemButton>
</li>
</DropMenu>
</Dropdown>
</Toolbar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default function PageFooterActions({
});

const analysisDescription = useMemo(() => {
if (!start || !end || !datasetsLayers || !aoi) return '';
if (!start || !end || !datasetsLayers || !aoi || !datasetsLayers.length) return '';
const dataset =
datasetsLayers.length === 1
? datasetsLayers[0].name
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"@turf/centroid": "^6.5.0",
"@turf/simplify": "^6.5.0",
"@turf/union": "^6.5.0",
"@turf/helpers": "^6.5.0",
"@types/geojson": "^7946.0.10",
"@types/mdx": "^2.0.1",
"@types/react": "^18.2.12",
Expand Down

0 comments on commit fd884ee

Please sign in to comment.