Skip to content

Commit

Permalink
Also use cista::raw::string in location
Browse files Browse the repository at this point in the history
  • Loading branch information
jbruechert committed May 3, 2024
1 parent 9e1648c commit 7bbcd49
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions include/nigiri/location.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct location {
it_range<vector<location_idx_t>::const_iterator> equivalences);
location_idx_t l_{location_idx_t::invalid()};
std::string_view id_;
std::string_view name_;
cista::raw::string name_;
geo::latlng pos_;
source_idx_t src_;
location_type type_;
Expand All @@ -41,4 +41,4 @@ struct location {
} // namespace nigiri

template <>
struct fmt::formatter<nigiri::location> : ostream_formatter {};
struct fmt::formatter<nigiri::location> : ostream_formatter {};
4 changes: 2 additions & 2 deletions src/abi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ nigiri_location_t* nigiri_get_location(const nigiri_timetable_t* t,
auto location = new nigiri_location_t;
auto l = t->tt->locations_.get(lidx);
location->name = l.name_.data();
location->name_len = static_cast<uint32_t>(l.name_.length());
location->name_len = static_cast<uint32_t>(l.name_.size());
location->id = l.id_.data();
location->id_len = static_cast<uint32_t>(l.id_.length());
location->lat = l.pos_.lat_;
Expand Down Expand Up @@ -237,4 +237,4 @@ void nigiri_update_with_rt(const nigiri_timetable_t* t,
void* context) {
auto const file = cista::mmap{gtfsrt_pb_path, cista::mmap::protection::READ};
return nigiri_update_with_rt_from_buf(t, file.view(), callback, context);
}
}
6 changes: 5 additions & 1 deletion src/loader/gtfs/stop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,11 @@ locations_map read_stops(source_idx_t const src,
locations.emplace(
std::string{id},
s->location_ = tt.locations_.register_location(location{
id, is_track ? s->platform_code_ : s->name_.view(), s->coord_, src,
id,
is_track ? cista::raw::string(s->platform_code_,
cista::raw::string::non_owning)
: s->name_,
s->coord_, src,
is_track ? location_type::kTrack : location_type::kStation,
location_idx_t::invalid(),
s->timezone_.empty() ? timezone_idx_t::invalid()
Expand Down

0 comments on commit 7bbcd49

Please sign in to comment.