From e425a0322ba5f530e2d19d94fe1f3d8d360fbf30 Mon Sep 17 00:00:00 2001 From: Jiri Pokorny Date: Wed, 2 Oct 2024 19:59:54 +0200 Subject: [PATCH] Merged also elements, where different gas instance is used --- projects/planner/src/app/shared/options.service.ts | 4 ---- projects/scuba-physics/src/lib/Segments.spec.ts | 13 +++++++------ projects/scuba-physics/src/lib/Segments.ts | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/projects/planner/src/app/shared/options.service.ts b/projects/planner/src/app/shared/options.service.ts index 0fa860b8..d490d3e3 100644 --- a/projects/planner/src/app/shared/options.service.ts +++ b/projects/planner/src/app/shared/options.service.ts @@ -278,8 +278,4 @@ export class OptionsService { this.options.maxEND =this.units.toMeters(newValues.maxEND); OptionDefaults.useGeneralRecommended(this.options); } - - // TODO air breaks - // add to recommended options sets? (consider also Gradient factors) - // merge gas switch level with following segment on the same gas } diff --git a/projects/scuba-physics/src/lib/Segments.spec.ts b/projects/scuba-physics/src/lib/Segments.spec.ts index 440800ad..72cb85d8 100644 --- a/projects/scuba-physics/src/lib/Segments.spec.ts +++ b/projects/scuba-physics/src/lib/Segments.spec.ts @@ -38,12 +38,13 @@ describe('Segments', () => { beforeEach(() => { filledSegments = new Segments(); - filledSegments.add(20, StandardGases.air, 15); - filledSegments.add(20, StandardGases.air, 15); - filledSegments.add(20, StandardGases.air, 35); - filledSegments.add(5, StandardGases.air, 35); - filledSegments.add(5, StandardGases.air, 3); - filledSegments.add(5, StandardGases.air, 3); + // use copy to enforce content comparison + filledSegments.add(20, StandardGases.air.copy(), 15); + filledSegments.addFlat(StandardGases.air.copy(), 15); + filledSegments.addFlat(StandardGases.air.copy(), 35); + filledSegments.add(5, StandardGases.air.copy(), 35); + filledSegments.addFlat(StandardGases.air.copy(), 3); + filledSegments.addFlat(StandardGases.air.copy(), 3); }); diff --git a/projects/scuba-physics/src/lib/Segments.ts b/projects/scuba-physics/src/lib/Segments.ts index 443862b4..5e2db9f8 100644 --- a/projects/scuba-physics/src/lib/Segments.ts +++ b/projects/scuba-physics/src/lib/Segments.ts @@ -161,7 +161,7 @@ export class Segment { public contentEquals(toCompare: Segment): boolean { return this.speed === toCompare.speed && - this._gas === toCompare._gas; + this._gas.compositionEquals(toCompare._gas); } /**