From 27042bde0a780c67c7a6b0e17f6538241d92a7fd Mon Sep 17 00:00:00 2001 From: Florian Amsallem Date: Wed, 25 Sep 2024 18:29:10 +0200 Subject: [PATCH] speedspacechart: add drawing function Signed-off-by: Florian Amsallem --- ui-speedspacechart/src/components/const.ts | 6 +- .../helpers/drawElements/speedLimits.ts | 97 ++++++-- ui-speedspacechart/src/components/utils.ts | 5 +- .../stories/assets/path_properties_PMP_LM.ts | 4 +- .../assets/power_restrictions_PMP_LM.ts | 2 +- .../src/stories/assets/simulation_PMP_LM.ts | 224 +++++++++++------- .../stories/assets/speed_limit_tags_PMP_LM.ts | 2 +- ui-speedspacechart/src/stories/utils.ts | 4 +- 8 files changed, 235 insertions(+), 109 deletions(-) diff --git a/ui-speedspacechart/src/components/const.ts b/ui-speedspacechart/src/components/const.ts index e826a580..40b70c8d 100644 --- a/ui-speedspacechart/src/components/const.ts +++ b/ui-speedspacechart/src/components/const.ts @@ -69,11 +69,13 @@ export const LAYERS_SELECTION: Array = [ // Colors export const BLACK = chroma(0, 0, 0); -export const WHITE = chroma(255, 255, 255); +export const ERROR_30 = chroma(255, 104, 104); +export const ERROR_60 = chroma(217, 28, 28); export const GREY_50 = chroma(121, 118, 113); export const GREY_80 = chroma(49, 46, 43); export const LIGHT_BLUE = chroma(33, 112, 185); -export const ERROR_60 = chroma(217, 28, 28); +export const WARNING_30 = chroma(234, 167, 43); +export const WHITE = chroma(255, 255, 255); /** * COLOR_DICTIONARY maps specific colors to their corresponding secondary colors used for speed limit tags. diff --git a/ui-speedspacechart/src/components/helpers/drawElements/speedLimits.ts b/ui-speedspacechart/src/components/helpers/drawElements/speedLimits.ts index 1c43ba1a..56debddb 100644 --- a/ui-speedspacechart/src/components/helpers/drawElements/speedLimits.ts +++ b/ui-speedspacechart/src/components/helpers/drawElements/speedLimits.ts @@ -1,33 +1,100 @@ import type { DrawFunctionParams } from '../../../types/chartTypes'; -import { ERROR_60, MARGINS } from '../../const'; -import { clearCanvas, positionToPosX, maxPositionValue, maxSpeedValue } from '../../utils'; +import { ERROR_30, ERROR_60, MARGINS, WARNING_30 } from '../../const'; +import { + clearCanvas, + maxPositionValue, + maxSpeedValue, + convertMToKm, + positionToPosX, +} from '../../utils'; -const { CURVE_MARGIN_TOP } = MARGINS; +const { CURVE_MARGIN_TOP, MARGIN_RIGHT, MARGIN_LEFT, MARGIN_BOTTOM, MARGIN_TOP } = MARGINS; +const GRADIENT_HEIGHT = 16; +const TRAIN_LENGTH_MARKER_HEIGHT = 8; export const drawSpeedLimits = ({ ctx, width, height, store }: DrawFunctionParams) => { const { mrsp, trainLength, ratioX, leftOffset } = store; - const maxSpeed = maxSpeedValue(store); + + if (!mrsp) return; clearCanvas(ctx, width, height); ctx.save(); ctx.translate(leftOffset, 0); + const realHeight = height - MARGIN_BOTTOM - MARGIN_TOP; + const maxSpeed = maxSpeedValue(store); const maxPosition = maxPositionValue(store); + // Add the last boundary to the boundaries array + mrsp.boundaries.push(maxPosition); - // TODO: draw speed limits - ctx.beginPath(); - ctx.lineWidth = 1; ctx.lineCap = 'round'; - ctx.strokeStyle = ERROR_60.hex(); - const adjustedHeight = height - CURVE_MARGIN_TOP; - const y = height - (200 / maxSpeed) * adjustedHeight; - const xStart = positionToPosX(0, maxPosition, width, ratioX); - ctx.lineTo(xStart, y); - const xEnd = positionToPosX(maxPosition, maxPosition, width, ratioX); - ctx.lineTo(xEnd, y); - ctx.stroke(); + let previousBoundaryX = positionToPosX(0, maxPosition, width, ratioX); + let previousSpeedY: number | null = null; + for (let i = 0; i < mrsp.values.length; i++) { + const { speed, isTemporary } = mrsp.values[i]; + + const currentBoundaryX = positionToPosX(mrsp.boundaries[i], maxPosition, width, ratioX); + + const speedY = realHeight - (speed / maxSpeed) * (realHeight - CURVE_MARGIN_TOP) + MARGIN_TOP; + // Draw vertical line joining 2 speed limits + if (previousSpeedY !== null) { + ctx.beginPath(); + ctx.strokeStyle = ERROR_30.alpha(0.5).hex(); + ctx.lineWidth = 0.5; + ctx.moveTo(previousBoundaryX, previousSpeedY); + ctx.lineTo(previousBoundaryX, speedY); + ctx.stroke(); + } + + const speedColor = isTemporary ? WARNING_30 : ERROR_60; + + // Draw gradient + const gradient = ctx.createLinearGradient(0, speedY, 0, speedY - GRADIENT_HEIGHT); + if (isTemporary) { + gradient.addColorStop(0, speedColor.alpha(0.23).hex()); + } else { + gradient.addColorStop(0, speedColor.alpha(0.15).hex()); + } + gradient.addColorStop(1, speedColor.alpha(0).hex()); + ctx.fillStyle = gradient; + ctx.rect(previousBoundaryX, speedY, currentBoundaryX - previousBoundaryX, -GRADIENT_HEIGHT); + ctx.fill(); + + // Handle train length (only if next speed is higher than current speed) + let extendedBoundaryX: number | null = null; + if (i < mrsp.values.length - 1 && mrsp.values[i + 1].speed > speed) { + extendedBoundaryX = positionToPosX( + Math.min(mrsp.boundaries[i] + convertMToKm(trainLength), maxPosition), + maxPosition, + width, + ratioX + ); + } + + // Draw main line + ctx.beginPath(); + ctx.lineWidth = 1; + ctx.strokeStyle = speedColor.hex(); + ctx.moveTo(previousBoundaryX, speedY); + ctx.lineTo(extendedBoundaryX ?? currentBoundaryX, speedY); + + // Draw a small vertical line to mark the end of the train's length. + if (extendedBoundaryX !== null) { + ctx.moveTo(extendedBoundaryX, speedY - TRAIN_LENGTH_MARKER_HEIGHT / 2); + ctx.lineTo(extendedBoundaryX, speedY + TRAIN_LENGTH_MARKER_HEIGHT / 2); + } + ctx.stroke(); + + // Update previous values to current ones + previousBoundaryX = currentBoundaryX; + previousSpeedY = speedY; + } ctx.restore(); + + // Prevent overlapping with y axis + ctx.clearRect(0, 0, MARGIN_LEFT, height); + ctx.clearRect(width - MARGIN_RIGHT, 0, MARGIN_RIGHT, height); }; diff --git a/ui-speedspacechart/src/components/utils.ts b/ui-speedspacechart/src/components/utils.ts index fa02343b..f3c272a7 100644 --- a/ui-speedspacechart/src/components/utils.ts +++ b/ui-speedspacechart/src/components/utils.ts @@ -1,9 +1,9 @@ import { + CURSOR_SNAP_DISTANCE, LINEAR_LAYER_SEPARATOR_HEIGHT, LINEAR_LAYERS_HEIGHTS, LINEAR_LAYERS_HEIGHTS_BY_NAME, MARGINS, - CURSOR_SNAP_DISTANCE, type LAYERS_SELECTION, } from './const'; import type { LayerData, Store } from '../types/chartTypes'; @@ -295,6 +295,9 @@ export const binarySearch = (data: T[], element: number, lambda: (element: T) return left; }; +/** Convert meters to kilometers */ +export const convertMToKm = (meters: number) => meters / 1000; + /** Transform a position in km into a position on the x-axis in pixels */ export const positionToPosX = ( position: number, diff --git a/ui-speedspacechart/src/stories/assets/path_properties_PMP_LM.ts b/ui-speedspacechart/src/stories/assets/path_properties_PMP_LM.ts index 54cf41c4..f9e951d3 100644 --- a/ui-speedspacechart/src/stories/assets/path_properties_PMP_LM.ts +++ b/ui-speedspacechart/src/stories/assets/path_properties_PMP_LM.ts @@ -55,7 +55,7 @@ export const pathPropertiesPmpLm: PathProperties = { 191414000, 191514000, 192764000, 193014000, 193464000, 193614000, 193664000, 194564000, 195114000, 195464000, 196014000, 196464000, 197564000, 197934000, 198089000, 198303000, 198464000, 199614000, 199664000, 200014000, 200064000, 200164000, 200464000, 200514000, - 200564000, 200610000, + 200564000, 201649000, ], values: [ 0.0, 7.7, 4.1, 0.0, 3.3, 0.0, 8.4, 4.2, 6.3, 0.0, 9.3, 11.5, 11.3, 0.0, 11.3, 0.0, 6.5, 1.0, @@ -655,7 +655,7 @@ export const pathPropertiesPmpLm: PathProperties = { name: 'Le Mans', }, }, - position: 201544000, + position: 201649000, }, ], }; diff --git a/ui-speedspacechart/src/stories/assets/power_restrictions_PMP_LM.ts b/ui-speedspacechart/src/stories/assets/power_restrictions_PMP_LM.ts index a6d492fd..d146e893 100644 --- a/ui-speedspacechart/src/stories/assets/power_restrictions_PMP_LM.ts +++ b/ui-speedspacechart/src/stories/assets/power_restrictions_PMP_LM.ts @@ -82,6 +82,6 @@ export const powerRestrictionsPmpLm: PowerRestriction[] = [ code: 'BBBB', handled: true, start: 180550965, - stop: 201544000, + stop: 201649000, }, ]; diff --git a/ui-speedspacechart/src/stories/assets/simulation_PMP_LM.ts b/ui-speedspacechart/src/stories/assets/simulation_PMP_LM.ts index 53301827..5f11bf4f 100644 --- a/ui-speedspacechart/src/stories/assets/simulation_PMP_LM.ts +++ b/ui-speedspacechart/src/stories/assets/simulation_PMP_LM.ts @@ -2,107 +2,161 @@ import type { Simulation } from '../../types/simulationTypes'; export const simulationPmpLm: Simulation = { mrsp: { - boundaries: [1000000, 1200000, 1800000, 3550000, 4500000], - values: [16.667, 27.778, 16.667, 27.778, 8.333, 83.333], + boundaries: [ + 781000, 791000, 1591000, 5151000, 15379000, 15529000, 15541000, 179183000, 199589000, + 199688000, 200589000, 201417000, + ], + values: [ + 16.667, 25.0, 30.556, 41.667, 55.556, 61.111, 75.0, 80.0, 61.111, 38.889, 44.444, 27.778, + 33.333, + ], }, base: { positions: [ - 0, 819, 3276, 7366, 29415, 52245, 98601, 159332, 207711, 357262, 1019000, 1142973, 1228000, - 1824000, 2045659, 2261312, 2497848, 2825866, 2894000, 2992439, 3204008, 3317006, 3412004, - 3489002, 3548000, 4465000, 4522176, 4620529, 4710584, 4844967, 4924000, 5207650, 5333336, - 5378668, 5416000, 5739000, 5796102, 5893958, 5983119, 6121946, 6625083, 7180711, 7389193, - 7735989, 8165643, 8706668, 9199058, 9720027, 10566852, 11618700, 12137568, 12523344, 12877120, - 13198896, 13488672, 13746448, 13972224, 14166000, 14479000, 14716144, 15616007, 16143158, - 16639502, 17075412, 18169737, 19023656, 19512662, 20968092, 22331292, 23688832, 24075129, - 24849220, 26149552, 26943644, 28308499, 29764217, 30689791, 31005860, 31802586, 32597688, - 35506619, 36000581, 36490094, 36652247, 37302856, 37821354, 41169673, 42162679, 42491313, - 42980836, 43305683, 44754350, 45554988, 46967099, 48134211, 48659862, 63835840, 64334558, - 66046412, 94101941, 94434451, 94875229, 107554635, 108386722, 109184345, 110347195, 111334228, - 113130701, 129783733, 130783103, 131281652, 131854011, 132189586, 132867698, 136079509, - 136576657, 136741379, 137601032, 159267612, 159766144, 161497905, 162161466, 163155637, - 163998194, 175664814, 176032779, 176663004, 178006002, 179187000, 197261800, 197872774, - 198507442, 198981332, 199484000, 199743263, 200114664, 200484000, 201544000, + 0, 922, 3688, 14738, 33127, 74410, 132026, 179431, 312522, 1181000, 1288529, 1410584, 1593713, + 1798772, 2269239, 2890597, 3117922, 3510416, 3834614, 5551000, 6349317, 6739144, 7373916, + 7416220, 8025531, 8808000, 9512000, 9816000, 10088000, 10328000, 10536000, 10671000, 10823000, + 10943000, 11031000, 11076000, 11096000, 11108000, 11111000, 11112000, 11112000, 11113088, + 11116349, 11129358, 11150930, 11180914, 11219123, 11265433, 11381785, 11568786, 11798714, + 12013651, 12254170, 12657890, 12952643, 13503835, 14476858, 15700347, 16033578, 16607825, + 16960750, 18275486, 19120373, 19608044, 20857925, 22834388, 24090622, 24939192, 27062068, + 28516852, 29743309, 30076075, 31996055, 32633397, 33134860, 35854859, 36650181, 37394088, + 41234088, 42508153, 42982704, 44865967, 45492495, 46044508, 110499988, 111296050, 111996225, + 123414000, 124914000, 125589000, 126214000, 126789000, 127314000, 127789000, 128214000, + 128589000, 128914000, 129189000, 129414000, 129589000, 129645000, 129714000, 129750000, + 129789000, 129805000, 129810000, 129813000, 129814000, 129814000, 129814849, 129817394, + 129821631, 129827554, 129844432, 129867956, 129898033, 129977359, 130110954, 130244287, + 130399902, 130575472, 130820347, 131948401, 132338926, 133400200, 133994326, 134517412, + 135173978, 135972111, 136205805, 136557173, 136791447, 137387677, 137880354, 138386828, + 139424513, 141185450, 142892157, 143629625, 144535353, 145610761, 147400574, 161623080, + 162261293, 162684553, 175964518, 176092226, 177143000, 177983000, 178751000, 179336000, + 179972000, 180447000, 180951000, 181316000, 181631000, 181896000, 182031000, 182148000, + 182216000, 182303000, 182372000, 182423000, 182456000, 182468000, 182471000, 182472000, + 182472000, 182472922, 182475688, 182486739, 182505132, 182546426, 182604064, 182651492, + 182767655, 182911371, 183036119, 183272731, 183602979, 183917445, 184267422, 184652242, + 185070794, 185903718, 186936483, 187831316, 189004598, 197366800, 197977774, 198612442, + 199086332, 199589000, 199848263, 200219664, 200589000, 200877383, 201073000, 201208000, + 201325000, 201453000, 201528000, 201568000, 201600000, 201633000, 201645000, 201648000, + 201649000, ], speeds: [ - 0.0, 0.8193276858515682, 1.6370531205969674, 2.4532203827665837, 4.895588941788087, - 6.518212686284263, 8.929238295070585, 11.30998688920892, 12.875938245333003, 16.667, 16.667, - 19.047721549225574, 16.667, 16.667, 20.23920847610287, 22.76698685930612, 24.458910825804026, - 26.32743388335132, 25.0, 25.0, 20.333, 17.333, 14.333, 11.333, 8.333, 8.333, - 10.721361056726948, 13.857759760440812, 16.144954753264194, 18.889718480413027, 16.667, - 16.667, 12.333, 10.333, 8.333, 8.333, 10.693292652266194, 13.753009188045892, - 15.950740632799851, 18.728516715402304, 27.499436961322203, 34.40975712630696, - 34.90046459992404, 34.39949724863824, 37.302817387386206, 40.17667902781643, - 41.85116017174606, 45.11670453442099, 48.968327903742065, 55.146323643804664, 50.222, 46.222, - 42.222, 38.222, 34.222, 30.222, 26.222, 22.222, 22.222, 25.1547050547455, 35.446158063677395, - 39.76268596380172, 42.81505496955961, 44.314593791898865, 47.020252198597, 47.927007709190214, - 49.849040581917016, 54.137676830421825, 59.444281632851634, 63.91055025377937, - 64.80876538440599, 64.15616992684251, 65.90441713221648, 66.53353879254925, 69.93323191010307, - 75.76398151313327, 78.63171100574532, 79.29792427559882, 79.98386623512624, 79.13109419448568, - 82.44868366049799, 82.08458516598242, 81.10088078468455, 81.05261117758069, 81.6182858845829, - 83.333, 83.332237703197, 82.18151641588308, 82.06711745020954, 81.18172473564142, - 81.18375843089824, 79.80554700212367, 80.49453282847075, 83.333, 83.05969036962985, 83.333, - 83.333, 82.90811407331347, 83.333, 83.333, 83.04818530215965, 83.333, 83.33287810866707, - 83.09891617972895, 83.3323742257017, 82.94152711120996, 81.69969450509561, 83.333, 83.333, - 83.27887859405045, 82.92342868237502, 83.333, 82.93675075540982, 83.333, 83.33213266367153, - 82.37068954615907, 82.35138946159579, 83.333, 83.333, 82.86118315539963, 83.333, - 82.51792772642341, 83.25165745779844, 83.333, 83.333, 82.99864636979167, 79.11099999999999, - 70.11099999999999, 61.111, 61.111, 55.889, 49.889, 44.889, 38.889, 38.889, 33.778, 27.778, - 0.0, + 0.0, 0.922252864428832, 1.8432032114946648, 3.681032132931539, 5.5128202736486145, + 8.245289212510947, 10.956016119575583, 12.743963061768026, 16.667, 16.667, 19.16127542272484, + 21.47939181176482, 24.289739579280024, 26.944178905714292, 31.825920597414292, + 37.18351310226573, 38.50212797454354, 40.01165452968707, 41.667, 41.667, 47.088203761664126, + 50.4366562404313, 55.333814340659146, 55.556, 55.556, 48.0, 40.0, 36.0, 32.0, 28.0, 24.0, + 21.0, 17.0, 13.0, 9.0, 6.0, 4.0, 2.0, 1.0, 0.0, 0.0, 1.0880796443349603, 2.1731673171715498, + 4.328352917287148, 6.452715501575347, 8.533029368614802, 10.56815383217758, + 12.584805187471066, 16.450744826048936, 20.889894902961235, 25.148492311030772, + 28.52456451174802, 31.55098693743422, 35.64905496613374, 37.927571571668494, + 40.90054537261944, 47.525572064418235, 54.717435952230645, 56.30218312647379, + 58.4364578800575, 59.13546963171487, 60.37131837833933, 60.43382923841525, 61.490902444663654, + 63.4749479936392, 68.38463645699615, 71.04266555407018, 70.25917292885592, 71.22248570722746, + 74.40929429502576, 79.01118488495588, 80.0, 79.97983645720491, 79.44944905955225, 80.0, + 79.99894271354704, 79.06369073938752, 80.0, 80.0, 79.38662048434308, 78.77358104166666, + 78.0138404118927, 78.72410442059248, 80.0, 79.99935183050927, 79.24876040248746, 80.0, 80.0, + 70.0, 65.0, 60.0, 55.0, 50.0, 45.0, 40.0, 35.0, 30.0, 25.0, 20.0, 15.0, 13.0, 10.0, 8.0, 5.0, + 3.0, 2.0, 1.0, 0.0, 0.0, 0.848908853697111, 1.6960342277655154, 2.5407547039829397, + 3.3824517705630495, 5.054202047846467, 6.7051175881546765, 8.329672598534456, + 11.477643323014023, 15.221362678577012, 18.08822561414351, 20.770852318449418, + 23.08705472745882, 25.880770253256077, 37.413505356788704, 40.61124065890666, + 47.88257568194426, 51.08914582393474, 53.460629386473215, 55.922741161350174, + 58.17420202690162, 58.60341345974053, 58.471956424707976, 58.73174830893901, + 60.577612920554664, 62.597072415007176, 63.952572685368914, 65.71082860489605, + 69.72172006798219, 72.65215049118311, 74.7312928117894, 76.22074261441605, 77.39327427819816, + 80.0, 80.0, 79.56756201136442, 80.0, 79.96491092434351, 79.87348712448274, 73.0, 67.0, 61.0, + 56.0, 50.0, 45.0, 39.0, 34.0, 29.0, 24.0, 21.0, 18.0, 16.0, 13.0, 10.0, 7.0, 4.0, 2.0, 1.0, + 0.0, 0.0, 0.9223351135201904, 1.8433844506966532, 3.681528757028122, 5.513899540767509, + 8.2480208016856, 10.960806148165451, 12.751306291994734, 16.271613473834353, + 19.62745820100879, 21.906050415159513, 25.407894805927288, 29.65472236064539, + 33.23145355167369, 36.7544416543863, 40.191456780987146, 43.48752288842326, 48.94875877059886, + 54.16649635536371, 57.58191254927586, 61.111, 61.111, 55.889, 49.889, 44.889, 38.889, 38.889, + 33.778, 27.778, 27.778, 24.0, 21.0, 18.0, 14.0, 11.0, 9.0, 7.0, 4.0, 2.0, 1.0, 0.0, ], }, final_output: { positions: [ - 0, 819, 3276, 7366, 29415, 52245, 98601, 159332, 207711, 357262, 1019000, 1142973, 1228000, - 1824000, 2045659, 2261312, 2497848, 2825866, 2894000, 2992439, 3204008, 3317006, 3412004, - 3489002, 3548000, 4465000, 4522176, 4620529, 4710584, 4844967, 4924000, 5207650, 5333336, - 5378668, 5416000, 5739000, 5796102, 5893958, 5983119, 6121946, 6625083, 7180711, 7389193, - 7735989, 8165643, 8706668, 9199058, 9720027, 9998596, 10641406, 11841510, 12513821, 13042008, - 13488672, 13863336, 14166000, 14479000, 15217987, 15687585, 16064214, 16469958, 16987025, - 18169737, 19023656, 19512662, 20968092, 22450604, 23945766, 24204756, 24849220, 26149552, - 26810771, 28371114, 29312489, 29741152, 30750181, 31899553, 32477300, 32928298, 35865582, - 36323026, 36695974, 37257471, 37397089, 38820498, 41242439, 42109216, 42397342, 42971445, - 43257568, 44684318, 44968708, 45627353, 63908691, 64197822, 64682743, 94121062, 94410271, - 94726810, 110427575, 111292625, 111756816, 131888382, 132177901, 132405490, 136030899, - 136608256, 137120742, 159308244, 159742570, 161642867, 162076625, 162483105, 163212715, - 163970308, 164813592, 166236979, 167543178, 168263531, 169978763, 171505349, 173115545, - 174178241, 174444852, 175626960, 176389607, 178228647, 179565642, 183028817, 187270039, - 190332856, 191679617, 192891110, 195161363, 196601176, 198920943, 199484000, 199743263, - 200114664, 200484000, 201544000, + 0, 922, 3688, 14738, 33127, 74410, 132026, 179431, 312522, 1181000, 1327657, 1454254, 1642974, + 1853292, 2465604, 2816804, 3041292, 3397611, 3774306, 4368938, 6275998, 6482909, 7355262, + 7660603, 8188099, 8772437, 9328398, 9999412, 10328000, 10583000, 10788000, 10856000, 10943000, + 11031000, 11063000, 11096000, 11103000, 11108000, 11111000, 11112000, 11112000, 11113088, + 11116349, 11129358, 11150930, 11180914, 11241269, 11291599, 11415602, 11568786, 11849892, + 12071489, 12317991, 12587241, 12877289, 13503835, 14289072, 15700347, 16260678, 16607825, + 17079182, 18275486, 19120373, 19608044, 20857925, 22834388, 24090622, 24939192, 26777748, + 27062068, 27676951, 28488749, 29799167, 30836020, 31998816, 32592880, 32985597, 35880431, + 36334209, 36735184, 37312865, 37600560, 38920769, 41356536, 42543970, 42986806, 43428243, + 44748249, 45040625, 45709679, 46768094, 104214308, 105060953, 107513525, 108489827, 109306029, + 110489741, 111243592, 111608995, 114805977, 115729732, 116982331, 117653377, 119081999, + 120156307, 120790241, 121527973, 122975640, 124086856, 125080966, 126745286, 127608213, + 128133000, 128589000, 128973000, 129285000, 129490000, 129589000, 129670000, 129733000, + 129778000, 129789000, 129805000, 129810000, 129813000, 129814000, 129814000, 129814849, + 129817394, 129821631, 129835157, 129855368, 129882182, 129915493, 130001075, 130142128, + 130281156, 130442049, 130872662, 131660269, 132023908, 132338926, 133118188, 133792032, + 134410930, 135286168, 136088744, 136791447, 137387677, 137880354, 138386828, 139424513, + 141185450, 142892157, 143629625, 144535353, 145610761, 146622716, 150008300, 151348965, + 152519038, 155836650, 158260084, 159240243, 159925358, 161517744, 162158888, 162409341, + 163152948, 164124863, 164719846, 164956750, 166301425, 167683443, 168441193, 170078398, + 171552102, 173099618, 174521963, 175700414, 176385696, 176941175, 178364890, 179412457, + 180071000, 180708000, 181247000, 181448000, 181688000, 181847000, 182031000, 182148000, + 182276000, 182351000, 182391000, 182423000, 182456000, 182468000, 182471000, 182472000, + 182472000, 182472922, 182475688, 182480295, 182495019, 182517073, 182563829, 182651492, + 182801054, 182951423, 183126563, 183377163, 183724471, 184053206, 184494194, 184899423, + 185337417, 185806392, 186407018, 186923975, 190487986, 191966099, 193121805, 195396353, + 196786662, 199130010, 199589000, 199848263, 200219664, 200589000, 200877383, 201073000, + 201208000, 201325000, 201453000, 201528000, 201568000, 201600000, 201633000, 201645000, + 201648000, 201649000, ], speeds: [ - 0.0, 0.8193276858515682, 1.6370531205969674, 2.4532203827665837, 4.895588941788087, - 6.518212686284263, 8.929238295070585, 11.30998688920892, 12.875938245333003, 16.667, 16.667, - 19.047721549225574, 16.667, 16.667, 20.23920847610287, 22.76698685930612, 24.458910825804026, - 26.32743388335132, 25.0, 25.0, 20.333, 17.333, 14.333, 11.333, 8.333, 8.333, - 10.721361056726948, 13.857759760440812, 16.144954753264194, 18.889718480413027, 16.667, - 16.667, 12.333, 10.333, 8.333, 8.333, 10.693292652266194, 13.753009188045892, - 15.950740632799851, 18.728516715402304, 27.499436961322203, 34.40975712630696, - 34.90046459992404, 34.39949724863824, 37.302817387386206, 40.17667902781643, - 41.85116017174606, 45.11670453442099, 46.46534243824544, 45.562864388534074, - 46.72306057217742, 46.3248970974729, 40.222, 34.222, 28.222, 22.222, 22.222, - 30.964914280560777, 36.131223232056904, 39.1815409157876, 41.91233197102056, - 44.07206047221683, 47.020252198597, 47.927007709190214, 49.849040581917016, - 54.137676830421825, 59.86750220873097, 64.5541781767401, 64.81807839316411, 64.15616992684251, - 65.90441713221648, 66.33880018814382, 70.1563626751266, 71.04365409769373, 71.81480503306115, - 72.50817578125, 72.50677790763203, 71.94546324935283, 72.50817578125, 72.46484274981034, - 71.84160018915712, 70.5767750886725, 69.80702965368909, 69.81127589325979, 72.50817578125, - 72.5057718505642, 71.96707318816192, 72.13219368716605, 71.40532240130521, 71.63231074927187, - 71.04305177613752, 71.23634289474168, 72.50402741277041, 72.50817578125, 72.05813206169648, - 72.50817578125, 72.50817578125, 72.09729246534913, 72.50817578125, 72.50711682109664, - 71.78855038638694, 72.50817578125, 72.50817578125, 72.2348848173799, 72.50817578125, - 72.50817578125, 71.79515373034462, 72.50817578125, 72.50817578125, 72.29742238610794, - 72.50763085047474, 72.08368502417949, 72.50817578125, 72.50817578125, 70.88235795507435, - 69.8385172585307, 72.50817578125, 71.91379635550996, 72.20390339967754, 70.75081551224328, - 67.98111478563315, 66.22138242532739, 66.68686012440817, 66.5528952727489, 64.80843201634688, - 62.31357338520709, 60.3632347343608, 61.111, 61.111, 56.759669697719794, 52.56081529844678, - 51.05725070644447, 49.92318606452205, 48.744157859866114, 47.23663589604562, - 45.55668089746585, 38.889, 38.889, 33.778, 27.778, 0.0, + 0.0, 0.922252864428832, 1.8432032114946648, 3.681032132931539, 5.5128202736486145, + 8.245289212510947, 10.956016119575583, 12.743963061768026, 16.667, 16.667, 19.96623438843976, + 22.19032367921571, 24.971655484612427, 27.576762258088724, 33.62746080828414, + 36.60981884860606, 38.12828024104525, 39.55787770157515, 37.92799059602488, + 36.453736442313776, 34.33650910339113, 34.7214312088513, 38.06659474757526, 38.0739750647878, + 37.27037717588434, 35.85218581090704, 33.71273397822338, 33.3554853428465, 28.0, 23.0, 18.0, + 16.0, 13.0, 9.0, 7.0, 4.0, 3.0, 2.0, 1.0, 0.0, 0.0, 1.0880796443349603, 2.1731673171715498, + 4.328352917287148, 6.452715501575347, 8.533029368614802, 11.578596057614858, + 13.58096360922479, 17.36574452330376, 20.889894902961235, 26.029894976461925, + 29.31316013719301, 32.26954325583691, 34.99977778683216, 37.42642990174668, 40.90054537261944, + 46.36261122129839, 54.717435952230645, 57.23538351577676, 58.4364578800575, 59.29586892871918, + 60.37131837833933, 60.43382923841525, 61.490902444663654, 63.4749479936392, 68.38463645699615, + 71.04266555407018, 70.25917292885592, 70.97525719320242, 71.22248570722746, 72.50156183133969, + 72.05794039396218, 73.68428011013631, 74.52197265625, 74.52106043004683, 74.06222500782611, + 74.52197265625, 74.5213107004081, 73.99258520412121, 72.592664320784, 71.87477788163696, + 72.05700369650262, 74.52197265625, 74.52194857839612, 74.0882925392638, 73.52795860375096, + 73.62572035072239, 73.04454171269623, 73.1976335666956, 74.42452083986733, 74.52197265625, + 74.52197265625, 73.16955532180287, 70.85822150446374, 68.62754753834564, 67.32190600234865, + 64.31528977597556, 61.33109509065274, 60.60910764878786, 57.77672391352349, 57.56068353053685, + 56.41166639399605, 55.46455126023675, 54.416358990456615, 53.05227218757189, + 52.62759158446942, 52.65249993325487, 50.77085713857922, 50.337892372935634, + 49.10568609209091, 48.720536043407456, 46.96580168084646, 41.0, 35.0, 29.0, 23.0, 18.0, 15.0, + 12.0, 9.0, 6.0, 5.0, 3.0, 2.0, 1.0, 0.0, 0.0, 0.848908853697111, 1.6960342277655154, + 2.5407547039829397, 4.220503728530958, 5.882660684018407, 7.520982656302545, + 9.130611416553611, 12.238261565499784, 15.952260406855538, 18.78146376103532, + 21.376886773118464, 26.43418136867685, 34.606654501251455, 38.09363243870024, + 40.61124065890666, 46.09350952460838, 50.05366528911763, 53.02108451278334, + 56.267744414641115, 58.45827400761744, 58.73174830893901, 60.577612920554664, + 62.597072415007176, 63.952572685368914, 65.71082860489605, 69.72172006798219, + 72.65215049118311, 74.7312928117894, 76.22074261441605, 77.39327427819816, 78.93241040756683, + 75.03995748590482, 73.94732500488408, 72.33413451141409, 71.91517798499102, 70.59357643229748, + 69.42904217691606, 67.5834730309205, 65.1241069855928, 62.92886357356531, 62.35624865956813, + 61.61682684694575, 59.84638327137239, 59.183896249663185, 59.337396406944, 62.867948986562006, + 62.8235808925875, 63.402118211404, 62.549669367692466, 60.20049963187712, 58.84308009066301, + 59.656022567418425, 58.16452911881794, 55.960343335684094, 55.26469714105155, + 54.27602459226894, 55.31313494267673, 49.0, 42.0, 35.0, 32.0, 28.0, 25.0, 21.0, 18.0, 14.0, + 11.0, 9.0, 7.0, 4.0, 2.0, 1.0, 0.0, 0.0, 0.9223351135201904, 1.8433844506966532, + 2.7631237027637883, 4.598518656365225, 6.42731470610968, 9.155128943086304, + 12.751306291994734, 17.128120269008537, 20.424574151036634, 23.314004833020167, + 26.80931355311448, 31.090540104686145, 34.64768330085553, 38.83029281724731, + 42.19344549280696, 45.37945363835749, 48.37710619907019, 51.67716314317588, 54.11202327497078, + 49.98481297207787, 48.59850075718484, 47.74483950953814, 46.961127407046085, 45.7290216956976, + 44.39981947518151, 38.889, 38.889, 33.778, 27.778, 27.778, 24.0, 21.0, 18.0, 14.0, 11.0, 9.0, + 7.0, 4.0, 2.0, 1.0, 0.0, ], }, electrical_profiles: { boundaries: [ 7179000, 7767000, 63981000, 64172000, 94149000, 94341000, 131940000, 132132000, 180517000, - 180617000, 181341000, 201544000, + 180617000, 181341000, 201649000, ], values: [ { diff --git a/ui-speedspacechart/src/stories/assets/speed_limit_tags_PMP_LM.ts b/ui-speedspacechart/src/stories/assets/speed_limit_tags_PMP_LM.ts index a3c8e4df..bba2cdc9 100644 --- a/ui-speedspacechart/src/stories/assets/speed_limit_tags_PMP_LM.ts +++ b/ui-speedspacechart/src/stories/assets/speed_limit_tags_PMP_LM.ts @@ -4,7 +4,7 @@ export type SpeedLimitTags = { }; export const speedLimitTags: SpeedLimitTags = { - boundaries: [0, 25000000, 65000000, 95000000, 125000000, 201408607], + boundaries: [0, 25000000, 65000000, 95000000, 125000000, 201649000], values: [ { speed_limit_tags_type: 'tag', tag_name: 'MA100', color: '#494641' }, { speed_limit_tags_type: 'tag', tag_name: 'EVO', color: '#216482' }, diff --git a/ui-speedspacechart/src/stories/utils.ts b/ui-speedspacechart/src/stories/utils.ts index fd23ea14..a867cfe2 100644 --- a/ui-speedspacechart/src/stories/utils.ts +++ b/ui-speedspacechart/src/stories/utils.ts @@ -32,9 +32,9 @@ const formatMrsp = (mrsp: Simulation['mrsp']) => { const { boundaries, values } = mrsp; return { boundaries: boundaries.map(convertMmToKM), - values: values.map((speed) => ({ + values: values.map((speed, index) => ({ speed: convertMsToKmh(speed), - isTemporary: false, + isTemporary: (index + 1) % 4 == 0, })), }; };