Skip to content

Commit

Permalink
Merge pull request #3910 from hove-io/fix_erase_vj_from_dataset
Browse files Browse the repository at this point in the history
[Kraken] fix erase vj from dataset
  • Loading branch information
Patrick Qian authored Feb 13, 2023
2 parents 40e5d9e + 118c2d3 commit 34df7ae
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions source/kraken/apply_disruption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ www.navitia.io
#include "type/meta_data.h"
#include "type/meta_vehicle_journey.h"
#include "type/pt_data.h"
#include "type/dataset.h"
#include "utils/logger.h"
#include "utils/map_find.h"
#include "utils/functions.h"
Expand Down Expand Up @@ -396,7 +397,11 @@ struct add_impacts_visitor : public apply_impacts_visitor {
if (!mvj->get_base_vj().empty()) {
vj->name = mvj->get_base_vj().at(0)->name;
vj->headsign = mvj->get_base_vj().at(0)->headsign;
vj->dataset = mvj->get_base_vj().at(0)->dataset;
auto* dataset = mvj->get_base_vj().at(0)->dataset;
if (dataset) {
vj->dataset = dataset;
vj->dataset->vehiclejourney_list.insert(vj);
}
} else {
// Affect the headsign to vj if present in gtfs-rt
if (!impact->headsign.empty()) {
Expand All @@ -407,7 +412,12 @@ struct add_impacts_visitor : public apply_impacts_visitor {

// for protection, use the datasets[0]
// TODO : Create default data set
vj->dataset = pt_data.datasets[0];
if (!pt_data.datasets.empty()) {
if (pt_data.datasets[0]) {
vj->dataset = pt_data.datasets[0];
vj->dataset->vehiclejourney_list.insert(vj);
}
}
LOG4CPLUS_WARN(
log, "[disruption] Associate random dataset to new VJ doesn't work because base VJ doesn't exist");
}
Expand Down

0 comments on commit 34df7ae

Please sign in to comment.