-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(marxan-run): dump pu solutions matrix to geodb 2
- Loading branch information
Showing
17 changed files
with
4,740 additions
and
148 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
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
1 change: 1 addition & 0 deletions
1
...r/adapters/solutions-output/geo-output/solutions/output-file-parsing/pu-to-scenario-pu.ts
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 @@ | ||
export type PuToScenarioPu = Record<string, string>; |
56 changes: 56 additions & 0 deletions
56
...ers/solutions-output/geo-output/solutions/output-file-parsing/solution-row.transformer.ts
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,56 @@ | ||
import { Transform } from 'stronger-typed-streams'; | ||
import { TransformCallback } from 'stream'; | ||
import { PuToScenarioPu } from './pu-to-scenario-pu'; | ||
import { SolutionRowResult } from '../solution-row-result'; | ||
|
||
export class SolutionTransformer extends Transform< | ||
string, | ||
SolutionRowResult[] | ||
> { | ||
#headerAck = false; | ||
|
||
constructor(private readonly solutionPuMapping: PuToScenarioPu) { | ||
super({ | ||
objectMode: true, | ||
}); | ||
} | ||
|
||
_transform( | ||
chunk: string, | ||
encoding: BufferEncoding, | ||
callback: TransformCallback, | ||
) { | ||
if (!this.#headerAck) { | ||
this.#headerAck = true; | ||
return callback(null, []); | ||
} | ||
const [solutionString, ...puValues] = chunk.split(','); | ||
const solutionNumber = +solutionString.replace('S', ''); | ||
|
||
const results: (SolutionRowResult & { | ||
raw: string; | ||
puid: number; | ||
})[] = puValues.map((puValue, index) => ({ | ||
value: +puValue === 1 ? 1 : 0, | ||
runId: solutionNumber, | ||
spdId: this.solutionPuMapping[`${index + 1}`], | ||
raw: `index: ${index + 1} ; puValue: ${puValue}`, | ||
puid: index + 1, | ||
})); | ||
for (const k of results) { | ||
if (!k.spdId) { | ||
console.log(JSON.stringify(this.solutionPuMapping)); | ||
return callback( | ||
new Error( | ||
'spd.id is missing for: ' + | ||
k.raw + | ||
'; mapping yields:' + | ||
this.solutionPuMapping[`${k.puid}`], | ||
), | ||
); | ||
} | ||
} | ||
|
||
callback(null, results); | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
...an-sandboxed-runner/adapters/solutions-output/geo-output/solutions/planning-unit-state.ts
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,6 @@ | ||
export interface PlanningUnitState { | ||
values: boolean[]; | ||
usedCount: number; | ||
} | ||
|
||
export type PlanningUnitsState = Record<string, PlanningUnitState>; |
1 change: 0 additions & 1 deletion
1
...rxan-sandboxed-runner/adapters/solutions-output/geo-output/solutions/pu-to-scenario-pu.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.