Skip to content

Commit

Permalink
Same for criticals. #26
Browse files Browse the repository at this point in the history
Get rid of IDs on the two, because storing that isn't helpful. It should
be computed.
  • Loading branch information
dabreegster committed May 7, 2024
1 parent dc99bd5 commit c64dd32
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 249 deletions.
2 changes: 0 additions & 2 deletions src/routes/route_check/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export interface Scorecard {
}

export interface PolicyConflict {
id: string;
// TODO
conflict: "1" | "2" | "3" | "4" | "5" | "6" | "";
stage: "Existing" | "Design" | "";
Expand All @@ -98,7 +97,6 @@ export interface PolicyConflict {
}

export interface CriticalIssue {
id: string;
// TODO
criticalIssue:
| "1"
Expand Down
2 changes: 0 additions & 2 deletions src/routes/route_check/problems_map/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
$state.criticalIssues = [
...$state.criticalIssues,
{
id: "TODO",
criticalIssue: "",
stage: "",
point: e.lngLat.toArray(),
Expand All @@ -85,7 +84,6 @@
$state.policyConflictLog = [
...$state.policyConflictLog,
{
id: "TODO",
conflict: "",
stage: "",
point: e.lngLat.toArray(),
Expand Down
301 changes: 56 additions & 245 deletions src/routes/route_check/results_export/da_log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export function encode(state: State): [string, any][] {

...jat(state, results),
...policyConflictLog(state),
...criticalIssues(state),
];
}

Expand Down Expand Up @@ -286,253 +287,63 @@ function policyConflictLog(state: State): [string, any][] {
return out;
}

function criticalIssueId(state: State, i: number): string {
let critical = state.criticalIssues[i];

// This critical is what instance of this type?
let count = 0;
for (let j = 0; j <= i; j++) {
if (state.criticalIssues[j].criticalIssue == critical.criticalIssue) {
count++;
}
}

let parts = [
state.summary.schemeReference,
`SA${critical.criticalIssue.padStart(2, "0")}`,
`${count.toString().padStart(2, "0")}P`,
];
return parts.join("_");
}

function criticalIssues(state: State): [string, any][] {
let out: [string, any][] = [];
let numCriticals = 35;

for (let i = 0; i < numCriticals; i++) {
let values;
if (i < state.criticalIssues.length) {
let critical = state.criticalIssues[i];
values = {
Ref: criticalIssueId(state, i),
// TODO n - description
Typ: critical.criticalIssue,
Sta: critical.stage,
LaL: `${critical.point[1]}, ${critical.point[0]}`,
Loc: critical.locationName,
Res: critical.resolved,
Com: critical.notes,
};
} else {
values = {
Ref: "",
Typ: "",
Sta: "",
LaL: "",
Loc: "",
Res: "",
Com: "",
};
}
for (let [k, v] of Object.entries(values)) {
out.push([`${num(i)}SA${k}`, v]);
}
}
return out;
}

/*
[
["01SARef", ],
["01SATyp", ],
["01SASta", ],
["01SALaL", ],
["01SALoc", ],
["01SARes", ],
["01SACom", ],
["02SARef", ],
["02SATyp", ],
["02SASta", ],
["02SALaL", ],
["02SALoc", ],
["02SARes", ],
["02SACom", ],
["03SARef", ],
["03SATyp", ],
["03SASta", ],
["03SALaL", ],
["03SALoc", ],
["03SARes", ],
["03SACom", ],
["04SARef", ],
["04SATyp", ],
["04SASta", ],
["04SALaL", ],
["04SALoc", ],
["04SARes", ],
["04SACom", ],
["05SARef", ],
["05SATyp", ],
["05SASta", ],
["05SALaL", ],
["05SALoc", ],
["05SARes", ],
["05SACom", ],
["06SARef", ],
["06SATyp", ],
["06SASta", ],
["06SALaL", ],
["06SALoc", ],
["06SARes", ],
["06SACom", ],
["07SARef", ],
["07SATyp", ],
["07SASta", ],
["07SALaL", ],
["07SALoc", ],
["07SARes", ],
["07SACom", ],
["08SARef", ],
["08SATyp", ],
["08SASta", ],
["08SALaL", ],
["08SALoc", ],
["08SARes", ],
["08SACom", ],
["09SARef", ],
["09SATyp", ],
["09SASta", ],
["09SALaL", ],
["09SALoc", ],
["09SARes", ],
["09SACom", ],
["10SARef", ],
["10SATyp", ],
["10SASta", ],
["10SALaL", ],
["10SALoc", ],
["10SARes", ],
["10SACom", ],
["11SARef", ],
["11SATyp", ],
["11SASta", ],
["11SALaL", ],
["11SALoc", ],
["11SARes", ],
["11SACom", ],
["12SARef", ],
["12SATyp", ],
["12SASta", ],
["12SALaL", ],
["12SALoc", ],
["12SARes", ],
["12SACom", ],
["13SARef", ],
["13SATyp", ],
["13SASta", ],
["13SALaL", ],
["13SALoc", ],
["13SARes", ],
["13SACom", ],
["14SARef", ],
["14SATyp", ],
["14SASta", ],
["14SALaL", ],
["14SALoc", ],
["14SARes", ],
["14SACom", ],
["15SARef", ],
["15SATyp", ],
["15SASta", ],
["15SALaL", ],
["15SALoc", ],
["15SARes", ],
["15SACom", ],
["16SARef", ],
["16SATyp", ],
["16SASta", ],
["16SALaL", ],
["16SALoc", ],
["16SARes", ],
["16SACom", ],
["17SARef", ],
["17SATyp", ],
["17SASta", ],
["17SALaL", ],
["17SALoc", ],
["17SARes", ],
["17SACom", ],
["18SARef", ],
["18SATyp", ],
["18SASta", ],
["18SALaL", ],
["18SALoc", ],
["18SARes", ],
["18SACom", ],
["19SARef", ],
["19SATyp", ],
["19SASta", ],
["19SALaL", ],
["19SALoc", ],
["19SARes", ],
["19SACom", ],
["20SARef", ],
["20SATyp", ],
["20SASta", ],
["20SALaL", ],
["20SALoc", ],
["20SARes", ],
["20SACom", ],
["21SARef", ],
["21SATyp", ],
["21SASta", ],
["21SALaL", ],
["21SALoc", ],
["21SARes", ],
["21SACom", ],
["22SARef", ],
["22SATyp", ],
["22SASta", ],
["22SALaL", ],
["22SALoc", ],
["22SARes", ],
["22SACom", ],
["23SARef", ],
["23SATyp", ],
["23SASta", ],
["23SALaL", ],
["23SALoc", ],
["23SARes", ],
["23SACom", ],
["24SARef", ],
["24SATyp", ],
["24SASta", ],
["24SALaL", ],
["24SALoc", ],
["24SARes", ],
["24SACom", ],
["25SARef", ],
["25SATyp", ],
["25SASta", ],
["25SALaL", ],
["25SALoc", ],
["25SARes", ],
["25SACom", ],
["26SARef", ],
["26SATyp", ],
["26SASta", ],
["26SALaL", ],
["26SALoc", ],
["26SARes", ],
["26SACom", ],
["27SARef", ],
["27SATyp", ],
["27SASta", ],
["27SALaL", ],
["27SALoc", ],
["27SARes", ],
["27SACom", ],
["28SARef", ],
["28SATyp", ],
["28SASta", ],
["28SALaL", ],
["28SALoc", ],
["28SARes", ],
["28SACom", ],
["29SARef", ],
["29SATyp", ],
["29SASta", ],
["29SALaL", ],
["29SALoc", ],
["29SARes", ],
["29SACom", ],
["30SARef", ],
["30SATyp", ],
["30SASta", ],
["30SALaL", ],
["30SALoc", ],
["30SARes", ],
["30SACom", ],
["31SARef", ],
["31SATyp", ],
["31SASta", ],
["31SALaL", ],
["31SALoc", ],
["31SARes", ],
["31SACom", ],
["32SARef", ],
["32SATyp", ],
["32SASta", ],
["32SALaL", ],
["32SALoc", ],
["32SARes", ],
["32SACom", ],
["33SARef", ],
["33SATyp", ],
["33SASta", ],
["33SALaL", ],
["33SALoc", ],
["33SARes", ],
["33SACom", ],
["34SARef", ],
["34SATyp", ],
["34SASta", ],
["34SALaL", ],
["34SALoc", ],
["34SARes", ],
["34SACom", ],
["35SARef", ],
["35SATyp", ],
["35SASta", ],
["35SALaL", ],
["35SALoc", ],
["35SARes", ],
["35SACom", ],
["Area-E", ],
["Area-D", ],
["Po-WW-E", ],
Expand Down

0 comments on commit c64dd32

Please sign in to comment.