Skip to content

Commit

Permalink
Moved sealevels to ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiri Pokorny committed Dec 3, 2023
1 parent c801846 commit 7daac21
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
10 changes: 1 addition & 9 deletions projects/planner/src/app/altitude/altitude.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ export class AltitudeComponent implements OnInit {
@Input()
public altitudeForm!: FormGroup;

// TODO move to unit defaults
private metricLevels = [0, 300, 800, 1500];
private imperialLevels = [0, 1000, 2600, 5000];

constructor(private fb: NonNullableFormBuilder,
private inputs: InputControls,
private validators: ValidatorGroups,
Expand Down Expand Up @@ -106,10 +102,6 @@ export class AltitudeComponent implements OnInit {
}

private selectLevels(): number[] {
if (this.units.imperialUnits) {
return this.imperialLevels;
}

return this.metricLevels;
return this.units.ranges.altitudeLevels;
}
}
3 changes: 3 additions & 0 deletions projects/planner/src/app/shared/UnitConversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export interface RangeConstants {
duration: [number, number];
durationLabel: string;
altitude: [number, number];
altitudeLevels: [number, number, number, number]
altitudeLabel: string;
altitudePressure: [number, number];
speed: [number, number];
Expand All @@ -185,6 +186,7 @@ const toLabel = (range: [number, number], unit: string): string => `${range[0]}
class MetricRanges implements RangeConstants {
public readonly units = new MetricUnits();
public readonly altitude: [number, number] = [0, 5000];
public readonly altitudeLevels: [number, number, number, number] = [0, 300, 800, 1500];
public readonly altitudeLabel: string = toLabel(this.altitude, this.units.altitudeShortcut);
public readonly altitudePressure: [number, number] = [0.7, 1.2];
public readonly consumed: [number, number] = [0, 350];
Expand Down Expand Up @@ -220,6 +222,7 @@ class MetricRanges implements RangeConstants {
class ImperialRanges implements RangeConstants {
public readonly units = new ImperialUnits();
public readonly altitude: [number, number] = [0, 16500];
public readonly altitudeLevels: [number, number, number, number] = [0, 1000, 2600, 5000];
public readonly altitudeLabel: string = toLabel(this.altitude, this.units.altitudeShortcut);
public readonly altitudePressure: [number, number] = [10, 18];
public readonly consumed: [number, number] = [0, 5100];
Expand Down

0 comments on commit 7daac21

Please sign in to comment.