Skip to content

Commit 34df7ae

Browse files
author
Patrick Qian
authored
Merge pull request #3910 from hove-io/fix_erase_vj_from_dataset
[Kraken] fix erase vj from dataset
2 parents 40e5d9e + 118c2d3 commit 34df7ae

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

source/kraken/apply_disruption.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ www.navitia.io
3838
#include "type/meta_data.h"
3939
#include "type/meta_vehicle_journey.h"
4040
#include "type/pt_data.h"
41+
#include "type/dataset.h"
4142
#include "utils/logger.h"
4243
#include "utils/map_find.h"
4344
#include "utils/functions.h"
@@ -396,7 +397,11 @@ struct add_impacts_visitor : public apply_impacts_visitor {
396397
if (!mvj->get_base_vj().empty()) {
397398
vj->name = mvj->get_base_vj().at(0)->name;
398399
vj->headsign = mvj->get_base_vj().at(0)->headsign;
399-
vj->dataset = mvj->get_base_vj().at(0)->dataset;
400+
auto* dataset = mvj->get_base_vj().at(0)->dataset;
401+
if (dataset) {
402+
vj->dataset = dataset;
403+
vj->dataset->vehiclejourney_list.insert(vj);
404+
}
400405
} else {
401406
// Affect the headsign to vj if present in gtfs-rt
402407
if (!impact->headsign.empty()) {
@@ -407,7 +412,12 @@ struct add_impacts_visitor : public apply_impacts_visitor {
407412

408413
// for protection, use the datasets[0]
409414
// TODO : Create default data set
410-
vj->dataset = pt_data.datasets[0];
415+
if (!pt_data.datasets.empty()) {
416+
if (pt_data.datasets[0]) {
417+
vj->dataset = pt_data.datasets[0];
418+
vj->dataset->vehiclejourney_list.insert(vj);
419+
}
420+
}
411421
LOG4CPLUS_WARN(
412422
log, "[disruption] Associate random dataset to new VJ doesn't work because base VJ doesn't exist");
413423
}

0 commit comments

Comments
 (0)