Skip to content

Commit

Permalink
refactor: move scanned imagery into own basemap category
Browse files Browse the repository at this point in the history
  • Loading branch information
blacha committed Sep 29, 2023
1 parent bc79164 commit a0b4bd0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions packages/landing/src/components/layer.switcher.dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ import { LayerInfo, MapConfig } from '../config.map.js';

type CategoryMap = Map<string, { label: string; options: { label: string; value: string }[] }>;

const CategoryOrder = new Map<string, number>([
['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;
Expand Down Expand Up @@ -118,12 +119,11 @@ export class LayerSwitcherDropdown extends Component<unknown, LayerSwitcherDropd
}
const orderedCategories: CategoryMap = new Map(
[...categories].sort((a, b) => {
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 };
Expand Down
4 changes: 2 additions & 2 deletions packages/landing/src/config.map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,14 @@ function addDefaultLayers(output: Map<string, LayerInfo>): 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',
},
];

Expand Down

0 comments on commit a0b4bd0

Please sign in to comment.