From 47dc43abf3e2642939a96e16b8db9420117c7afb Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Tue, 3 Dec 2019 15:46:08 +0100 Subject: [PATCH] Adaptation to jalhyd#181 : convert Jet fall to elevations --- src/app/calculators/jet/jet.config.json | 2 +- src/app/calculators/jet/jet.en.json | 9 ++++ src/app/calculators/jet/jet.fr.json | 9 ++++ .../jet-trajectory-chart.component.ts | 42 ++++++++++++++++--- src/locale/messages.en.json | 6 +++ src/locale/messages.fr.json | 6 +++ 6 files changed, 68 insertions(+), 6 deletions(-) diff --git a/src/app/calculators/jet/jet.config.json b/src/app/calculators/jet/jet.config.json index 79da824b6..8d74f46f4 100644 --- a/src/app/calculators/jet/jet.config.json +++ b/src/app/calculators/jet/jet.config.json @@ -2,7 +2,7 @@ { "id": "fs_jet", "type": "fieldset", - "fields": [ "V0", "S", "D", "H" ] + "fields": [ "V0", "S", "D", "ZJ", "ZW", "ZF" ] }, { "type": "options", diff --git a/src/app/calculators/jet/jet.en.json b/src/app/calculators/jet/jet.en.json index 4b7b42f43..beaa71924 100644 --- a/src/app/calculators/jet/jet.en.json +++ b/src/app/calculators/jet/jet.en.json @@ -4,7 +4,12 @@ "V0": "Initial speed", "S": "Initial slope", "D": "Impact abscissa", + "ZJ": "Jet start elevation", + "ZW": "Water elevation", + "ZF": "Bottom elevation", "H": "Fall height", + "Y": "Depth", + "YH": "Depth/height ration", "t": "Flight time", "Vx": "Horizontal speed at impact", "Vz": "Vertical speed at impact", @@ -13,7 +18,11 @@ "UNIT_V0": "m/s", "UNIT_S": "m/m", "UNIT_D": "m", + "UNIT_ZJ": "m", + "UNIT_ZW": "m", + "UNIT_ZF": "m", "UNIT_H": "m", + "UNIT_Y": "m", "UNIT_T": "s", "UNIT_VX": "m/s", "UNIT_VZ": "m/s", diff --git a/src/app/calculators/jet/jet.fr.json b/src/app/calculators/jet/jet.fr.json index 022826344..ba180820d 100644 --- a/src/app/calculators/jet/jet.fr.json +++ b/src/app/calculators/jet/jet.fr.json @@ -4,7 +4,12 @@ "V0": "Vitesse initiale", "S": "Pente initiale", "D": "Abscisse de l'impact", + "ZJ": "Cote de départ du jet", + "ZW": "Cote de l'eau", + "ZF": "Cote du fond", "H": "Hauteur de chute", + "Y": "Profondeur", + "YH": "Rapport profondeur/chute", "t": "Temps de vol", "Vx": "Vitesse horizontale à l'impact", "Vz": "Vitesse verticale à l'impact", @@ -13,7 +18,11 @@ "UNIT_V0": "m/s", "UNIT_S": "m/m", "UNIT_D": "m", + "UNIT_ZJ": "m", + "UNIT_ZW": "m", + "UNIT_ZF": "m", "UNIT_H": "m", + "UNIT_Y": "m", "UNIT_T": "s", "UNIT_VX": "m/s", "UNIT_VZ": "m/s", diff --git a/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts b/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts index efde49654..47e2d79e3 100644 --- a/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts +++ b/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts @@ -133,7 +133,7 @@ export class JetTrajectoryChartComponent extends ResultsComponent { } public set results(r: FixedResults | VarResults) { - this.forceRebuild(); // used for (de)activating legend in generateScatterChart() + this.forceRebuild(); // used for forcing redefinition of xAxes[0].ticks.min/max in generateScatterChart() this._results = r; if (this._results && this._results.result) { @@ -179,17 +179,31 @@ export class JetTrajectoryChartComponent extends ResultsComponent { */ private generateScatterChart() { const ySeries = this.getYSeries(); - - // hide legend when there is only 1 series - this.graph_options.legend.display = (ySeries.length > 1); + const nub = (this._results.result.sourceNub as Jet); this.graph_data = { datasets: [] }; + // find greatest abscissa + let greatestAbscissa = 0; + for (const ys of ySeries) { + if (ys.data.length > 0) { + greatestAbscissa = Math.max(greatestAbscissa, ys.data[ys.data.length - 1].x); + } + } + + // adjust chart width + this.graph_options.scales.xAxes[0].ticks.min = 0; + this.graph_options.scales.xAxes[0].ticks.max = greatestAbscissa; + // build Y data series for (const ys of ySeries) { if (ys.data.length > 0) { + // add 2 points for related water line + const lastY = ys.data[ys.data.length - 1].y; + ys.data.push({ x: greatestAbscissa, y: lastY }); + ys.data.push({ x: 0, y: lastY }); // push series config this.graph_data.datasets.push({ label: ys.label, @@ -200,6 +214,22 @@ export class JetTrajectoryChartComponent extends ResultsComponent { }); } } + + // draw bottom line + this.graph_data.datasets.push({ + label: this.intlService.localizeText("INFO_JET_FOND"), + data: [ + { x: 0, y: nub.prms.ZF.singleValue }, + { x: greatestAbscissa, y: nub.prms.ZF.singleValue } + ], + tension: 0, + spanGaps: true, + showLine: "true", + fill: true, + borderColor: "#753F00", + backgroundColor: "#753F00", + pointRadius: 0 + }); } public exportAsImage(element: HTMLDivElement) { @@ -236,7 +266,9 @@ export class JetTrajectoryChartComponent extends ResultsComponent { for (let i = 0; i < trajectories.length; i++) { const traj = trajectories[i]; ret.push({ - label: trajectories.length === 0 ? "" /* legend is hidden */ : this.getLegendForSeries(i), + label: trajectories.length === 1 + ? this.intlService.localizeText("INFO_JET_TITRE_TRAJECTOIRE_ET_COTE_EAU") + : this.getLegendForSeries(i), color: palette[i % palette.length], // map to IYSeries format data: traj.map((t) => { diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 8c5fc725f..2a642341e 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -181,6 +181,8 @@ "INFO_WALLS_AND_DEVICES_REMOVED": "%s wall(s) and %s device(s) removed", "INFO_WALLS_REMOVED": "%s wall(s) removed", "INFO_JET_TITRE_TRAJECTOIRE": "Trajectory", + "INFO_JET_TITRE_TRAJECTOIRE_ET_COTE_EAU": "Trajectory and water elevation", + "INFO_JET_FOND": "Bottom", "INFO_LECHAPTCALMON_TITRE_COURT": "Lechapt-C.", "INFO_LECHAPTCALMON_TITRE": "Lechapt-Calmon", "INFO_LIB_ABSCISSE": "Abscissa (m)", @@ -480,6 +482,10 @@ "INFO_TRIGO_TITRE": "Trigonometric function", "INFO_TRIGO_TITRE_COURT": "Trigo. f.", "WARNING_WARNINGS_ABSTRACT": "%nb% warnings occurred during calculation", + "ERROR_JET_SUBMERGED_NO_SOLUTION": "There is no solution", + "WARNING_JET_START_SUBMERGED": "Water elevation is greater than jet start elevation", + "WARNING_JET_START_ELEVATION_UNDERGROUND": "Bottom elevation cannot be higher than jet start elevation", + "WARNING_JET_WATER_ELEVATION_UNDERGROUND": "Bottom elevation cannot be higher than water elevation", "WARNING_REMOUS_ARRET_CRITIQUE": "Calculation stopped: critical elevation reached at abscissa %x%", "WARNING_STRUCTUREKIVI_HP_TROP_ELEVE": "h/p must not be greater than 2.5. h/p is forced to 2.5", "WARNING_STRUCTUREKIVI_PELLE_TROP_FAIBLE": "Threshold height should be greater than 0.1 m. Beta coefficient is forced to 0", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index 95fed3dca..35b5a744b 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -183,6 +183,8 @@ "INFO_LECHAPTCALMON_TITRE_COURT": "Lechapt-C.", "INFO_LECHAPTCALMON_TITRE": "Lechapt-Calmon", "INFO_JET_TITRE_TRAJECTOIRE": "Trajectoire", + "INFO_JET_TITRE_TRAJECTOIRE_ET_COTE_EAU": "Trajectoire et cote de l'eau", + "INFO_JET_FOND": "Fond", "INFO_LIB_ABSCISSE": "Abscisse (m)", "INFO_LIB_ALTITUDE": "Altitude (m)", "INFO_LIB_LENGTHS": "Toutes les longueurs", @@ -479,6 +481,10 @@ "INFO_TRIGO_TITRE": "Fonction trigonométrique", "INFO_TRIGO_TITRE_COURT": "F. trigo.", "WARNING_WARNINGS_ABSTRACT": "%nb% avertissements rencontrés lors du calcul", + "ERROR_JET_SUBMERGED_NO_SOLUTION": "Il n'y a pas de solution", + "WARNING_JET_START_SUBMERGED": "La cote de l'eau est supérieure à la cote de départ du jet", + "WARNING_JET_START_ELEVATION_UNDERGROUND": "La cote de fond ne peut pas être supérieure à la cote de départ du jet", + "WARNING_JET_WATER_ELEVATION_UNDERGROUND": "La cote de fond ne peut pas être supérieure à la cote de l'eau", "WARNING_REMOUS_ARRET_CRITIQUE": "Arrêt du calcul : hauteur critique atteinte à l'abscisse %x%", "WARNING_STRUCTUREKIVI_HP_TROP_ELEVE": "h/p ne doit pas être supérieur à 2,5. h/p est forcé à 2,5", "WARNING_STRUCTUREKIVI_PELLE_TROP_FAIBLE": "La pelle du seuil doit mesurer au moins 0,1 m. Le coefficient béta est forcé à 0", -- GitLab