Skip to content

Commit

Permalink
Allow csv unescaping for station names (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbruechert authored May 6, 2024
1 parent 9dfe5c7 commit d998a24
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .pkg
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[utl]
url=git@github.com:motis-project/utl.git
branch=master
commit=4e0e1eb2be611da3e286a306317737071aaf92be
commit=fd7425b1a57a4b887318ba8c41a3184f8c4a50c5
[miniz]
url=git@github.com:motis-project/miniz.git
branch=master
Expand Down
11 changes: 5 additions & 6 deletions .pkg.lock
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
281125644813287955
cista 49090f7891d069e6136efef1e730a4f24a190a81
11369675354777302168
cista ed9ea61e4d3e287546f778729fafb5caca574658
res 7d97784ba785ce8a2677ea77164040fde484fb04
date 26d109612ddb8ba331edba7619a6452667f842bb
date 2d2c46a39bbf582dc663be1af926b4d58b2e0c9a
fmt edb385ac526c24bc917ec4a41bb0edb28f0ca59e
zlib fe8e13ffca867612951bc6baf114e5ac8b00f305
boost be5235eb2258d2ec19e32546ab767a62311d9b46
doctest 70e8f76437b76dd5e9c0a2eb9b907df190ab71a0
geo f455b76d5894bb156e3bcb1f85c3e2915820fe3a
geo ee76668f0f0454e4acd3c769e00c6868620e3490
googletest 34a46558609e05865c197f0260ab36daa7cbbb6e
miniz 1edbdece9d71dc65c6ff405572ee37cbdcef7af4
abseil-cpp f2b3825f36e37fddd47c5c395096e9b1e99eca12
protobuf 690e03babf0963d3da9615a2dae0891777842719
unordered_dense 77e91016354e6d8cba24a86c5abb807de2534c02
Catch2 47d56f28a9801911c048d011b375e5631dbb658f
utl 4e0e1eb2be611da3e286a306317737071aaf92be
utl fd7425b1a57a4b887318ba8c41a3184f8c4a50c5
wyhash 1e012b57fc2227a9e583a57e2eacb3da99816d99
2 changes: 1 addition & 1 deletion src/abi.cc
Original file line number Diff line number Diff line change
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);
}
}
10 changes: 5 additions & 5 deletions src/loader/gtfs/stop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct stop {
}

std::string_view id_;
std::string_view name_;
cista::raw::generic_string name_;
std::string_view platform_code_;
geo::latlng coord_;
std::string_view timezone_;
Expand Down Expand Up @@ -176,7 +176,7 @@ locations_map read_stops(source_idx_t const src,

struct csv_stop {
utl::csv_col<utl::cstr, UTL_NAME("stop_id")> id_;
utl::csv_col<utl::cstr, UTL_NAME("stop_name")> name_;
utl::csv_col<cista::raw::generic_string, UTL_NAME("stop_name")> name_;
utl::csv_col<utl::cstr, UTL_NAME("stop_timezone")> timezone_;
utl::csv_col<utl::cstr, UTL_NAME("parent_station")> parent_station_;
utl::csv_col<utl::cstr, UTL_NAME("platform_code")> platform_code_;
Expand All @@ -191,13 +191,13 @@ locations_map read_stops(source_idx_t const src,
progress_tracker->update_fn())} //
| utl::csv<csv_stop>() //
|
utl::for_each([&](csv_stop const& s) {
utl::for_each([&](csv_stop& s) {
auto const new_stop = utl::get_or_create(stops, s.id_->view(), [&]() {
return std::make_unique<stop>();
}).get();

new_stop->id_ = s.id_->view();
new_stop->name_ = s.name_->view();
new_stop->name_ = std::move(*s.name_);
new_stop->coord_ = {utl::parse<double>(s.lat_->trim()),
utl::parse<double>(s.lon_->trim())};
new_stop->platform_code_ = s.platform_code_->view();
Expand All @@ -213,7 +213,7 @@ locations_map read_stops(source_idx_t const src,
new_stop->parent_ = parent;
}

equal_names[s.name_->view()].emplace_back(new_stop);
equal_names[new_stop->name_.view()].emplace_back(new_stop);
});

auto const stop_vec =
Expand Down

0 comments on commit d998a24

Please sign in to comment.