diff --git a/app/scripts/components/analysis/constants.ts b/app/scripts/components/analysis/constants.ts index bee2fe167..a5605fad5 100644 --- a/app/scripts/components/analysis/constants.ts +++ b/app/scripts/components/analysis/constants.ts @@ -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 > = { - world: makeFeatureCollection([ + world: featureCollection([ { type: 'Feature', id: 'world', @@ -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' + } + } ]) }; diff --git a/app/scripts/components/analysis/define/aoi-selector.tsx b/app/scripts/components/analysis/define/aoi-selector.tsx index e5a353888..fca6fa35d 100644 --- a/app/scripts/components/analysis/define/aoi-selector.tsx +++ b/app/scripts/components/analysis/define/aoi-selector.tsx @@ -183,6 +183,13 @@ export default function AoiSelector({ World +
  • + onRegionPresetClick('north-america')} + > + North America + +
  • diff --git a/app/scripts/components/analysis/define/page-footer.actions.tsx b/app/scripts/components/analysis/define/page-footer.actions.tsx index 3febcada6..cb3f73ecc 100644 --- a/app/scripts/components/analysis/define/page-footer.actions.tsx +++ b/app/scripts/components/analysis/define/page-footer.actions.tsx @@ -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 diff --git a/package.json b/package.json index cec2d9cd4..3006101ee 100644 --- a/package.json +++ b/package.json @@ -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",