-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Organize scheme-related components properly
- Loading branch information
1 parent
ad2c0d7
commit 58f0fea
Showing
14 changed files
with
95 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { constructMatchExpression } from "lib/maplibre"; | ||
import type { DataDrivenPropertyValueSpecification } from "maplibre-gl"; | ||
import { fundingProgrammesForColouringAndFiltering } from "./data"; | ||
import { colors } from "../colors"; | ||
|
||
export function styleByFundingProgramme(): [ | ||
DataDrivenPropertyValueSpecification<string>, | ||
[string, string][], | ||
] { | ||
let [colorMapping, legendRows] = getColorMappingAndLegend( | ||
fundingProgrammesForColouringAndFiltering, | ||
colors.funding_programmes, | ||
); | ||
|
||
let color = constructMatchExpression( | ||
["get", "funding_programme"], | ||
colorMapping, | ||
"grey", | ||
); | ||
return [color, legendRows]; | ||
} | ||
|
||
export function styleByCurrentMilestone(): [ | ||
DataDrivenPropertyValueSpecification<string>, | ||
[string, string][], | ||
] { | ||
let stageGates = [ | ||
"removed", | ||
"no data", | ||
"not progressed", | ||
"superseded", | ||
"preliminary design completed", | ||
"feasability design completed", | ||
"detailed design completed", | ||
"consruction started", | ||
"construction completed", | ||
]; | ||
|
||
let [colorMapping, legendRows] = getColorMappingAndLegend( | ||
stageGates, | ||
colors.current_milestone, | ||
); | ||
|
||
let color = constructMatchExpression( | ||
["get", "current_milestone"], | ||
colorMapping, | ||
"grey", | ||
); | ||
return [color, legendRows]; | ||
} | ||
|
||
function getColorMappingAndLegend( | ||
keys: string[], | ||
colorList: string[], | ||
): [{ [key: string]: string }, [string, string][]] { | ||
let legendRows: [string, string][] = []; | ||
let colorMapping: { [key: string]: string } = {}; | ||
let i = 0; | ||
for (let x of keys) { | ||
let color = colorList[i++ % colorList.length]; | ||
colorMapping[x] = color; | ||
legendRows.push([x, color]); | ||
} | ||
|
||
return [colorMapping, legendRows]; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { writable, type Writable } from "svelte/store"; | ||
import type { Schemes, SchemeData } from "types"; | ||
|
||
// TODO Bundle this into one type, so it's easier to plumb around | ||
export const atfSchemesGj: Writable<Schemes> = writable({ | ||
type: "FeatureCollection", | ||
features: [], | ||
schemes: {}, | ||
}); | ||
export const atfSchemes: Writable<Map<string, SchemeData>> = writable( | ||
new Map(), | ||
); | ||
export const filterAtfInterventionText: Writable<string> = writable(""); | ||
export const filterAtfSchemeText: Writable<string> = writable(""); | ||
|
||
export const lcwipSchemesGj: Writable<Schemes> = writable({ | ||
type: "FeatureCollection", | ||
features: [], | ||
schemes: {}, | ||
}); | ||
export const lcwipSchemes: Writable<Map<string, SchemeData>> = writable( | ||
new Map(), | ||
); | ||
export const filterLcwipInterventionText: Writable<string> = writable(""); | ||
export const filterLcwipSchemeText: Writable<string> = writable(""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,4 @@ | ||
import { writable, type Writable } from "svelte/store"; | ||
import type { Schemes, SchemeData } from "types"; | ||
|
||
// TODO Bundle this into one type, so it's easier to plumb around | ||
export const atfSchemesGj: Writable<Schemes> = writable({ | ||
type: "FeatureCollection", | ||
features: [], | ||
schemes: {}, | ||
}); | ||
export const atfSchemes: Writable<Map<string, SchemeData>> = writable( | ||
new Map(), | ||
); | ||
export const filterAtfInterventionText: Writable<string> = writable(""); | ||
export const filterAtfSchemeText: Writable<string> = writable(""); | ||
|
||
export const lcwipSchemesGj: Writable<Schemes> = writable({ | ||
type: "FeatureCollection", | ||
features: [], | ||
schemes: {}, | ||
}); | ||
export const lcwipSchemes: Writable<Map<string, SchemeData>> = writable( | ||
new Map(), | ||
); | ||
export const filterLcwipInterventionText: Writable<string> = writable(""); | ||
export const filterLcwipSchemeText: Writable<string> = writable(""); | ||
|
||
export const interactiveMapLayersEnabled: Writable<boolean> = writable(true); | ||
export let controls: Writable<HTMLDivElement | null> = writable(null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters