Skip to content

Commit 28f3f0e

Browse files
route url
1 parent 81f1dd8 commit 28f3f0e

File tree

7 files changed

+31
-0
lines changed

7 files changed

+31
-0
lines changed

include/nigiri/loader/register.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ struct route {
121121
std::string_view id,
122122
translation_idx_t short_name,
123123
translation_idx_t long_name,
124+
translation_idx_t url,
124125
route_type_t,
125126
route_color,
126127
provider_idx_t);
@@ -136,6 +137,10 @@ struct route {
136137
translated_str_t get_long_name_translations() const;
137138
void set_long_name(translated_str_t);
138139

140+
std::string_view get_url() const;
141+
translated_str_t get_url_translations() const;
142+
void set_url(translated_str_t);
143+
139144
std::uint16_t get_route_type() const;
140145
void set_route_type(std::uint16_t);
141146

@@ -154,6 +159,7 @@ struct route {
154159
std::string_view id_;
155160
translation_idx_t short_name_;
156161
translation_idx_t long_name_;
162+
translation_idx_t url_;
157163
route_type_t route_type_;
158164
route_color color_;
159165
provider_idx_t agency_;

include/nigiri/rt/frun.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct run_stop {
4444
std::optional<route_type_t> route_type(event_type) const;
4545
std::string_view route_short_name(event_type, lang_t const&) const;
4646
std::string_view route_long_name(event_type, lang_t const&) const;
47+
std::string_view route_url(event_type, lang_t const&) const;
4748
std::string_view trip_short_name(event_type, lang_t const&) const;
4849
std::string_view display_name(event_type, lang_t const&) const;
4950
run_stop get_first_trip_stop(event_type) const;

include/nigiri/timetable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ struct timetable {
297297
struct route_ids {
298298
vector_map<route_id_idx_t, translation_idx_t> route_id_short_names_;
299299
vector_map<route_id_idx_t, translation_idx_t> route_id_long_names_;
300+
vector_map<route_id_idx_t, translation_idx_t> rotue_id_url_;
300301
vector_map<route_id_idx_t, route_type_t> route_id_type_;
301302
vector_map<route_id_idx_t, provider_idx_t> route_id_provider_;
302303
vector_map<route_id_idx_t, route_color> route_id_colors_;

src/loader/gtfs/route.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ route_map_t read_routes(source_idx_t const src,
159159
utl::csv_col<utl::cstr, UTL_NAME("agency_id")> agency_id_;
160160
utl::csv_col<utl::cstr, UTL_NAME("route_short_name")> route_short_name_;
161161
utl::csv_col<utl::cstr, UTL_NAME("route_long_name")> route_long_name_;
162+
utl::csv_col<utl::cstr, UTL_NAME("route_url")> route_url_;
162163
utl::csv_col<utl::cstr, UTL_NAME("route_desc")> route_desc_;
163164
utl::csv_col<std::uint16_t, UTL_NAME("route_type")> route_type_;
164165
utl::csv_col<utl::cstr, UTL_NAME("route_color")> route_color_;
@@ -206,6 +207,8 @@ route_map_t read_routes(source_idx_t const src,
206207
r.route_short_name_->view(), r.route_id_->view()),
207208
i18n.get(t::kRoutes, f::kRouteLongName,
208209
r.route_long_name_->view(), r.route_id_->view()),
210+
i18n.get(t::kRoutes, f::kRouteURL, r.route_url_->view(),
211+
r.route_id_->view()),
209212
route_type_t{*r.route_type_},
210213
{.color_ = to_color(r.route_color_->view()),
211214
.text_color_ = to_color(r.route_text_color_->view())},

src/loader/netex/load_timetable.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,6 +1405,7 @@ void load_timetable(loader_config const& config,
14051405
line.short_name_.empty() ? line.name_ : line.short_name_),
14061406
tt.register_translation(
14071407
line.product_.empty() ? line.name_ : line.product_),
1408+
kEmptyTranslation,
14081409
route_type_t{get_more_precise_route_type(sj.route_type_,
14091410
line.route_type_)},
14101411
line.color_,

src/loader/register.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,15 @@ route::route(timetable& tt,
191191
std::string_view id,
192192
translation_idx_t short_name,
193193
translation_idx_t long_name,
194+
translation_idx_t url,
194195
route_type_t const route_type,
195196
route_color const color,
196197
provider_idx_t const agency)
197198
: src_{src},
198199
id_{id},
199200
short_name_{short_name},
200201
long_name_{long_name},
202+
url_{url},
201203
route_type_{route_type},
202204
color_{color},
203205
agency_{agency},
@@ -235,6 +237,14 @@ void route::set_long_name(translated_str_t x) {
235237
long_name_ = tt_->register_translation(x);
236238
}
237239

240+
std::string_view route::get_url() const {
241+
return tt_->get_default_translation(url_);
242+
}
243+
translated_str_t route::get_url_translations() const { return tt_->get(url_); }
244+
void route::set_url(translated_str_t x) {
245+
long_name_ = tt_->register_translation(x);
246+
}
247+
238248
route_type_t::value_t route::get_route_type() const {
239249
return static_cast<route_type_t::value_t>(route_type_);
240250
}
@@ -706,6 +716,7 @@ route_id_idx_t register_route(timetable& tt, route const& r) {
706716
auto const idx = route_id.ids_.store(r.id_);
707717
route_id.route_id_short_names_.emplace_back(r.short_name_);
708718
route_id.route_id_long_names_.emplace_back(r.long_name_);
719+
route_id.rotue_id_url_.emplace_back(r.url_);
709720
route_id.route_id_colors_.emplace_back(r.color_);
710721
route_id.route_id_type_.emplace_back(r.route_type_);
711722
route_id.route_id_provider_.emplace_back(r.agency_);

src/rt/frun.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,14 @@ std::string_view run_stop::route_long_name(event_type const ev_type,
290290
route_ids->route_id_long_names_.at(route_id_idx));
291291
}
292292

293+
std::string_view run_stop::route_url(event_type const ev_type,
294+
lang_t const& lang) const {
295+
auto const [route_ids, route_id_idx] = get_route(ev_type);
296+
return route_ids == nullptr
297+
? "?"
298+
: tt().translate(lang, route_ids->rotue_id_url_.at(route_id_idx));
299+
}
300+
293301
std::string_view run_stop::trip_short_name(event_type const ev_type,
294302
lang_t const& lang) const {
295303
if (fr_->is_scheduled()) {

0 commit comments

Comments
 (0)