y-plus / pyOSRD

Python API for OSRD
5 stars 0 forks source link

[space_time_charts] Bug some portions of train paths do not appear #98

Open ed-rhilbert opened 5 months ago

ed-rhilbert commented 5 months ago
num_stations, num_trains = 11, 11

sim = OSRD(dir="tmp", with_delay="multistation_multitrains_randomdelay", params_use_case={"num_stations": num_stations, "num_trains": num_trains, "delay_seed": 22})
sim.space_time_chart(1)

image

BertrandHouzel commented 5 months ago

salut Renan

the bug is solved with this part of code

in the py file is space_time_charts.py

def _data_and_points_to_plot( self, train: int, eco_or_base: str, points_to_show: str, ) -> tuple[list, dict]:

data = []

for i, train_id in enumerate(self.trains):
    t = [
        record['time']
        for record in self._head_position(i, eco_or_base)
    ]

    offset = [
        self.offset_in_path_of_train(
            Point(
                id='',
                track_section=record['track_section'],
                type='record',
                position=record['offset']
            ),
            train_id #bug correction #instead of train
        )
        for record in self._head_position(i)
    ]
    data.append({"x": t, "y": offset, "label": train_id})