From a0b4bd05a9b217c3df299dae278e60fbdc2c5090 Mon Sep 17 00:00:00 2001 From: Blayne Chard Date: Fri, 29 Sep 2023 14:40:10 +1300 Subject: [PATCH] refactor: move scanned imagery into own basemap category --- .../components/layer.switcher.dropdown.tsx | 32 +++++++++---------- packages/landing/src/config.map.ts | 4 +-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/landing/src/components/layer.switcher.dropdown.tsx b/packages/landing/src/components/layer.switcher.dropdown.tsx index fdb793fe3..18353ca96 100644 --- a/packages/landing/src/components/layer.switcher.dropdown.tsx +++ b/packages/landing/src/components/layer.switcher.dropdown.tsx @@ -5,16 +5,17 @@ import { LayerInfo, MapConfig } from '../config.map.js'; type CategoryMap = Map; -const CategoryOrder = new Map([ - ['Basemaps', 1], - ['Satellite Imagery', 2], - ['Urban Aerial Photos', 3], - ['Rural Aerial Photos', 4], - ['Scanned Aerial Imagery', 5], - ['Event', 6], - ['Bathymetry', 7], - ['Elevation', 8], -]); +const Categories = [ + 'Basemaps', + 'Satellite Imagery', + 'Urban Aerial Photos', + 'Rural Aerial Photos', + 'Scanned Aerial Imagery Basemaps', + 'Scanned Aerial Imagery', + 'Event', + 'Bathymetry', + 'Elevation', +]; export interface GroupedOptions { label: string; @@ -118,12 +119,11 @@ export class LayerSwitcherDropdown extends Component { - const fallbackOrder = 999; - const orderA = CategoryOrder.get(a[0]) ?? fallbackOrder; - const orderB = CategoryOrder.get(b[0]) ?? fallbackOrder; - if (orderA > orderB) return 1; - if (orderA < orderB) return -1; - return a[0].localeCompare(b[0]); + const orderA = Categories.indexOf(a[0]); + const orderB = Categories.indexOf(b[0]); + if (orderA === orderB) return a[0].localeCompare(b[0]); + if (orderA === -1 || orderA < orderB) return -1; + return 1; }), ); return { options: [...orderedCategories.values()], current: current }; diff --git a/packages/landing/src/config.map.ts b/packages/landing/src/config.map.ts index 51aab99e5..c3e18e0ba 100644 --- a/packages/landing/src/config.map.ts +++ b/packages/landing/src/config.map.ts @@ -313,14 +313,14 @@ function addDefaultLayers(output: Map): void { id: 'scanned-aerial-imagery-pre-1990-01-01', name: 'Scanned Aerial Imagery pre 1 January 1990', projections: new Set([EpsgCode.Nztm2000, EpsgCode.Google]), - category: 'Scanned Aerial Imagery', + category: 'Scanned Aerial Imagery Basemaps', }, { id: 'scanned-aerial-imagery-post-1989-12-31"', name: 'Scanned Aerial Imagery post 31 December 1989', projections: new Set([EpsgCode.Nztm2000, EpsgCode.Google]), - category: 'Scanned Aerial Imagery', + category: 'Scanned Aerial Imagery Basemaps', }, ];