Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate stop to subshape mapping during import #136

Merged
Merged
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
a94ebfa
WIP: Move subshape request into `nigiri`
MichaelKutzner Sep 11, 2024
fd3be09
WIP: Remove `trip_idx_t` from function signature
MichaelKutzner Sep 11, 2024
345bb5c
WIP: Explore wrong shape for merged trips
MichaelKutzner Sep 11, 2024
44fd253
WIP: Fix missing end segment
MichaelKutzner Sep 12, 2024
cff8ca9
Fix trip index on merged trips
MichaelKutzner Sep 12, 2024
b3ae8a9
Add check for stop order on same section
MichaelKutzner Sep 12, 2024
e1d022d
WIP: Create struct to handle shapes data
MichaelKutzner Sep 12, 2024
6f604e7
WIP: Swap to new shapes storage struct
MichaelKutzner Sep 12, 2024
0041108
WIP: Format code
MichaelKutzner Sep 12, 2024
c74b464
WIP: Remove temporary cache
MichaelKutzner Sep 12, 2024
e61f079
WIP: Remove mutable cache
MichaelKutzner Sep 12, 2024
e24c5cc
WIP: Fix array variant
MichaelKutzner Sep 12, 2024
a8d8238
WIP: Parametrize test
MichaelKutzner Sep 13, 2024
f8918a0
Add missing header
MichaelKutzner Sep 13, 2024
26e731b
WIP: Calculate shape offsets per stop during load
MichaelKutzner Sep 13, 2024
4ab6481
WIP: Use cache to improve import duration
MichaelKutzner Sep 16, 2024
24f9cfc
Add test for duplicated shape offsets
MichaelKutzner Sep 16, 2024
62c9a10
Cleanup code
MichaelKutzner Sep 16, 2024
b1da33c
Merge branch 'master' into subshape_preparation
MichaelKutzner Sep 16, 2024
194605a
Fix build errors
MichaelKutzner Sep 16, 2024
c915950
Fix formatting
MichaelKutzner Sep 16, 2024
cffa187
Update progress bar
MichaelKutzner Sep 17, 2024
fe83c16
Remove `constexpr` specifier
MichaelKutzner Sep 17, 2024
f222ff0
Ensure mapping uses correct indices
MichaelKutzner Sep 17, 2024
cdde009
Make `shapes_storage` optional
MichaelKutzner Sep 17, 2024
9f30982
WIP: Avoid creating an additional vector
MichaelKutzner Sep 17, 2024
f930644
Add test for shared shapes
MichaelKutzner Sep 17, 2024
02d5108
Cleanup test input
MichaelKutzner Sep 17, 2024
a4133d5
Move initializer used in `if`
MichaelKutzner Sep 17, 2024
6bc1e71
Simplify cache offset calculation
MichaelKutzner Sep 17, 2024
6c7802f
Remove aliases used only once
MichaelKutzner Sep 18, 2024
8beb0d0
Use lambda expressions for offsets calculation cache
MichaelKutzner Sep 18, 2024
65ceb43
Add vector to store duplicated shape offsets
MichaelKutzner Sep 18, 2024
7d0cbdd
WIP: Store trip to shape mapping in shapes_storage
MichaelKutzner Sep 18, 2024
64bc496
Remove 'trip_shape_indices_' from 'timetable'
MichaelKutzner Sep 18, 2024
9a41916
Revert accidentally applied formatting
MichaelKutzner Sep 18, 2024
7ecb0e3
Fix code style
MichaelKutzner Sep 18, 2024
37f1641
Fix typo
MichaelKutzner Sep 18, 2024
8a1a694
fixup! Revert accidentally applied formatting
MichaelKutzner Sep 18, 2024
84494f0
Fix missing header
MichaelKutzner Sep 18, 2024
2aedbe2
Use uniform formatting library
MichaelKutzner Sep 18, 2024
fbda5f5
Simplify equals and hash functions
MichaelKutzner Sep 18, 2024
ffff9af
Fix progess bar update
MichaelKutzner Sep 18, 2024
9bba2ae
Duplicate alias defined in osr
MichaelKutzner Sep 18, 2024
7f130be
Delete dead code
MichaelKutzner Sep 18, 2024
5d3c8a0
WIP: Add prototype supporting block trips
MichaelKutzner Sep 19, 2024
94ebf76
Fix assertions
MichaelKutzner Sep 19, 2024
63d32df
Update tests for changes function
MichaelKutzner Sep 19, 2024
d5d81f9
Handle trips without shape
MichaelKutzner Sep 19, 2024
5fd774c
WIP: Add support for runs containing a trip subset
MichaelKutzner Sep 19, 2024
3850aed
WIP: Handle offsets of merged sub trips
MichaelKutzner Sep 20, 2024
02ee0fd
WIP: Add support for runs covering multiple trips
MichaelKutzner Sep 20, 2024
212578d
Delete debug output
MichaelKutzner Sep 20, 2024
3a7cbd9
WIP: Add support for shapes covering two trips
MichaelKutzner Sep 20, 2024
75935dd
WIP: Fix duplicated connection stop
MichaelKutzner Sep 20, 2024
717a375
WIP: Add support for many trips
MichaelKutzner Sep 20, 2024
e83320b
Fix offsets
MichaelKutzner Sep 23, 2024
4cbb597
Support merged trips with and without shapes
MichaelKutzner Sep 23, 2024
c8b637a
Simplify some code
MichaelKutzner Sep 23, 2024
d9167ad
Fix includes
MichaelKutzner Sep 23, 2024
5799d2a
Remove previous implementation
MichaelKutzner Sep 23, 2024
e1fdd87
Simplify shape offset calculation
MichaelKutzner Sep 23, 2024
7f3a7e2
Use apropiate loop statement
MichaelKutzner Sep 23, 2024
899dcac
Remove not required namespace
MichaelKutzner Sep 23, 2024
c6637e8
Improve test description
MichaelKutzner Sep 23, 2024
d0c6e93
Reduce duplicated code
MichaelKutzner Sep 23, 2024
37e3554
Fix missing `const`
MichaelKutzner Sep 23, 2024
fa04003
Merge remote-tracking branch 'origin/master' into subshape_preparation
MichaelKutzner Sep 23, 2024
727ba53
Fix formatting
MichaelKutzner Sep 23, 2024
476863b
WIP: Prepare shape offset calculate by distance
MichaelKutzner Sep 23, 2024
c0affc3
Simplify property access
MichaelKutzner Sep 23, 2024
a46c844
Fix test data
MichaelKutzner Sep 23, 2024
4d58c21
Remove stop deduplication for merged trips
MichaelKutzner Sep 23, 2024
fdec56f
Merge branch 'subshape_preparation' into shape_distance
MichaelKutzner Sep 24, 2024
9ca4d28
Calculate offsets based on distance traveled
MichaelKutzner Sep 24, 2024
5b45915
Add test for different traveled distances
MichaelKutzner Sep 24, 2024
300a621
Fix formatting
MichaelKutzner Sep 24, 2024
ef67d8f
Fix out of bounds error
MichaelKutzner Sep 24, 2024
a932391
Remove lambda function
MichaelKutzner Sep 24, 2024
5276e93
Swap checks for performance improvement
MichaelKutzner Sep 24, 2024
99da3ed
Fix assertion
MichaelKutzner Sep 24, 2024
dd82ce1
Prefer algorithms provided by 'utl'
MichaelKutzner Sep 25, 2024
28814e2
Use better variable name
MichaelKutzner Sep 25, 2024
e11e607
Fix missing namespace 'std'
MichaelKutzner Sep 25, 2024
c39aa50
Replace unicode arrows
MichaelKutzner Sep 25, 2024
6e7b341
Use explicit loop to replace 'std::for_each'
MichaelKutzner Sep 25, 2024
f394c64
Move expected values into assertions
MichaelKutzner Sep 25, 2024
644ba87
Remove not needed assertion
MichaelKutzner Sep 25, 2024
319c899
Fix missing type conversion for interval shifts
MichaelKutzner Sep 25, 2024
6101a32
Merge remote-tracking branch 'origin/master' into subshape_preparation
MichaelKutzner Sep 25, 2024
bc96b05
Use operations defined for interval
MichaelKutzner Sep 25, 2024
413ff12
Use enumeration
MichaelKutzner Sep 25, 2024
aff3bd9
Use unsigned integers for initialization
MichaelKutzner Sep 25, 2024
f52ca79
Use base type for offset calculation
MichaelKutzner Sep 25, 2024
0c479d4
Revert "Fix assertion"
MichaelKutzner Sep 25, 2024
f4fa633
Fix variable name
MichaelKutzner Sep 25, 2024
7fabf09
Use 'interval::end()' implementation
MichaelKutzner Sep 25, 2024
45dc1c4
wip
felixguendling Sep 27, 2024
611d6cb
Merge pull request #1 from felixguendling/subshape_preparation
MichaelKutzner Sep 30, 2024
c3e0b6c
Fix code
MichaelKutzner Sep 30, 2024
73fb2ed
Add tests for mixed shape trips
MichaelKutzner Sep 30, 2024
d515557
WIP: Simplify shape processing
MichaelKutzner Sep 30, 2024
91b9e53
Cleanup code
MichaelKutzner Sep 30, 2024
294bc01
Fix behavior for single stops
MichaelKutzner Sep 30, 2024
89d710f
Format code
MichaelKutzner Sep 30, 2024
38cdda8
Replace call to 'std::views::pairwise'
MichaelKutzner Sep 30, 2024
3d757d8
Remove not supported 'std::views::pairwise'
MichaelKutzner Oct 1, 2024
257456b
Use offset cache for shapes with distance traveled
MichaelKutzner Oct 1, 2024
192323c
Remove calls to 'std::make_pair'
MichaelKutzner Oct 1, 2024
67e9741
Change temporary data structure
MichaelKutzner Oct 1, 2024
312b73c
Simplify inserts
MichaelKutzner Oct 1, 2024
68847cd
Store median distance traveled
MichaelKutzner Oct 1, 2024
907a931
Fix formatting
MichaelKutzner Oct 1, 2024
24bff6d
Reduce memory usage
MichaelKutzner Oct 1, 2024
d8901e6
Remove not required headers
MichaelKutzner Oct 1, 2024
127e570
Rename variables to match intended usage
MichaelKutzner Oct 2, 2024
9caf4c1
Simplify check for valid distances traveled
MichaelKutzner Oct 2, 2024
04af537
Fix offset error for multiple data sets
MichaelKutzner Oct 2, 2024
090fe4f
Fix included headers
MichaelKutzner Oct 2, 2024
6062784
Use trailing return type
MichaelKutzner Oct 2, 2024
4a0cbaa
Improve variable names
MichaelKutzner Oct 2, 2024
cbe2d40
Remove no longer used function
MichaelKutzner Oct 2, 2024
f6adf3c
Remove no longer relevant information from test
MichaelKutzner Oct 2, 2024
a79a390
WIP: Change code to operate on segments
MichaelKutzner Oct 2, 2024
0b8f79d
Remove duplicated shape points
MichaelKutzner Oct 2, 2024
9e966f8
Move duplicated code into shared lambda with state
MichaelKutzner Oct 2, 2024
87eb5c8
Add tests for interval intersection
MichaelKutzner Oct 2, 2024
3316b79
Remove not needed variable
MichaelKutzner Oct 2, 2024
0e7c20c
Use lvalue reference instead of rvalue reference
MichaelKutzner Oct 2, 2024
43e4ebc
Remove misleading alias
MichaelKutzner Oct 2, 2024
841d4d5
Use default capture
MichaelKutzner Oct 2, 2024
b791b4a
Update names
MichaelKutzner Oct 2, 2024
caff7fa
Fix naming
MichaelKutzner Oct 2, 2024
b320cb0
Store invalid starting point into constant
MichaelKutzner Oct 2, 2024
7f153af
Replace comment with assert
MichaelKutzner Oct 2, 2024
dcf0fef
Use alias
MichaelKutzner Oct 2, 2024
b160221
Replace 'index' with 'idx'
MichaelKutzner Oct 2, 2024
77b59c4
Remove not needed 'inline'
MichaelKutzner Oct 2, 2024
35e18a3
Add brief explanation for stored median
MichaelKutzner Oct 2, 2024
a62efd9
WIP: Setup tests for missing distances
MichaelKutzner Oct 4, 2024
8341ff9
Avoid zero vectors for 'shape_dist_traveled'
MichaelKutzner Oct 4, 2024
b01dbc8
Move length check to the end
MichaelKutzner Oct 4, 2024
74c4b07
Improve memory usage for empty shape_dist_traveled
MichaelKutzner Oct 4, 2024
6d83538
Update test to use multiple leading `0.0`s
MichaelKutzner Oct 4, 2024
31eea11
Merge branch 'master' into subshape_preparation
MichaelKutzner Oct 4, 2024
8025f98
Simplify check for valid distances
MichaelKutzner Oct 4, 2024
f5d2625
Reduce memory usage when no shapes are used
MichaelKutzner Oct 4, 2024
27b4364
Mark unused variable
MichaelKutzner Oct 4, 2024
48b7d26
Fix data type
MichaelKutzner Oct 4, 2024
b1754bd
Delete obsolete compare function
MichaelKutzner Oct 7, 2024
75a38f8
Merge branch 'master' into subshape_preparation
MichaelKutzner Oct 7, 2024
75b876f
Simplify shape offset calculation
MichaelKutzner Oct 7, 2024
4f58134
Merge branch 'master' into subshape_preparation
MichaelKutzner Oct 8, 2024
7b3e99f
Update cista dependency
MichaelKutzner Oct 8, 2024
eaa9a94
Remove unused include
MichaelKutzner Oct 8, 2024
32033bc
Merge branch 'master' into subshape_preparation
MichaelKutzner Oct 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions exe/import.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,9 @@ int main(int ac, char** av) {
assistance = std::make_unique<assistance_times>(read_assistance(f.view()));
}

auto shapes = std::unique_ptr<shapes_storage_t>();
auto shapes = std::unique_ptr<shapes_storage>{};
if (vm.contains("shapes")) {
shapes =
std::make_unique<shapes_storage_t>(create_shapes_storage(out_shapes));
shapes = std::make_unique<shapes_storage>(out_shapes);
}

auto const start = parse_date(start_date);
Expand Down
5 changes: 3 additions & 2 deletions include/nigiri/loader/gtfs/load_timetable.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "nigiri/loader/dir.h"
#include "nigiri/loader/loader_interface.h"
#include "nigiri/shape.h"
#include "nigiri/types.h"

namespace nigiri {
Expand All @@ -23,14 +24,14 @@ void load_timetable(loader_config const&,
dir const&,
timetable&,
assistance_times* = nullptr,
shapes_storage_t* = nullptr);
shapes_storage* = nullptr);

void load_timetable(loader_config const&,
source_idx_t,
dir const&,
timetable&,
hash_map<bitfield, bitfield_idx_t>&,
assistance_times* = nullptr,
shapes_storage_t* = nullptr);
shapes_storage* = nullptr);

} // namespace nigiri::loader::gtfs
3 changes: 2 additions & 1 deletion include/nigiri/loader/gtfs/loader.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "nigiri/loader/loader_interface.h"
#include "nigiri/shape.h"

namespace nigiri::loader::gtfs {

Expand All @@ -12,7 +13,7 @@ struct gtfs_loader : public loader_interface {
timetable&,
hash_map<bitfield, bitfield_idx_t>&,
assistance_times*,
shapes_storage_t*) const override;
shapes_storage*) const override;
cista::hash_t hash(dir const&) const override;
std::string_view name() const override;
};
Expand Down
5 changes: 4 additions & 1 deletion include/nigiri/loader/gtfs/shape.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
#pragma once

#include <string_view>
#include <vector>

#include "nigiri/shape.h"
#include "nigiri/types.h"

namespace nigiri::loader::gtfs {

struct shape_state {
shape_idx_t index_{};
std::size_t last_seq_{};
std::vector<double> distances_{};
};

using shape_id_map_t = hash_map<std::string, shape_state>;

shape_id_map_t parse_shapes(std::string_view const, shapes_storage_t&);
shape_id_map_t parse_shapes(std::string_view const, shapes_storage&);

} // namespace nigiri::loader::gtfs
15 changes: 15 additions & 0 deletions include/nigiri/loader/gtfs/shape_prepare.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#include "nigiri/loader/gtfs/shape.h"
#include "nigiri/loader/gtfs/trip.h"
#include "nigiri/shape.h"
#include "nigiri/timetable.h"

namespace nigiri::loader::gtfs {

void calculate_shape_offsets(timetable const&,
shapes_storage&,
vector_map<gtfs_trip_idx_t, trip> const&,
shape_id_map_t const&);

} // namespace nigiri::loader::gtfs
2 changes: 2 additions & 0 deletions include/nigiri/loader/gtfs/trip.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "nigiri/loader/gtfs/shape.h"
#include "nigiri/loader/gtfs/stop.h"
#include "nigiri/timetable.h"
#include "nigiri/types.h"

namespace nigiri::loader::gtfs {

Expand Down Expand Up @@ -98,6 +99,7 @@ struct trip {
std::vector<std::uint16_t> seq_numbers_;
std::vector<stop_events> event_times_;
std::vector<trip_direction_idx_t> stop_headsigns_;
std::vector<double> distance_traveled_;

std::optional<std::vector<frequency>> frequency_;
bool requires_interpolation_{false};
Expand Down
3 changes: 2 additions & 1 deletion include/nigiri/loader/hrd/loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "nigiri/loader/hrd/parser_config.h"
#include "nigiri/loader/loader_interface.h"
#include "nigiri/shape.h"

namespace nigiri::loader::hrd {

Expand All @@ -14,7 +15,7 @@ struct hrd_loader : public loader_interface {
timetable& tt,
hash_map<bitfield, bitfield_idx_t>&,
assistance_times*,
shapes_storage_t*) const override;
shapes_storage*) const override;
cista::hash_t hash(dir const&) const override;
nigiri::loader::hrd::config config_;
};
Expand Down
3 changes: 2 additions & 1 deletion include/nigiri/loader/load.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "nigiri/loader/assistance.h"
#include "nigiri/common/interval.h"
#include "nigiri/shape.h"
#include "nigiri/timetable.h"
#include "nigiri/types.h"

Expand All @@ -18,7 +19,7 @@ timetable load(std::vector<std::filesystem::path> const&,
loader_config const&,
interval<date::sys_days> const&,
assistance_times*,
shapes_storage_t*,
shapes_storage*,
bool ignore = false);

} // namespace nigiri::loader
3 changes: 2 additions & 1 deletion include/nigiri/loader/loader_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "nigiri/loader/assistance.h"
#include "nigiri/loader/dir.h"
#include "nigiri/shape.h"
#include "nigiri/types.h"

namespace nigiri {
Expand Down Expand Up @@ -34,7 +35,7 @@ struct loader_interface {
timetable&,
hash_map<bitfield, bitfield_idx_t>&,
assistance_times*,
shapes_storage_t*) const = 0;
shapes_storage*) const = 0;
virtual cista::hash_t hash(dir const&) const = 0;
virtual std::string_view name() const = 0;
};
Expand Down
12 changes: 12 additions & 0 deletions include/nigiri/rt/frun.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
#pragma once

#include <functional>
#include <iosfwd>
#include <span>

#include "geo/latlng.h"

#include "nigiri/common/interval.h"
#include "nigiri/location.h"
#include "nigiri/rt/run.h"
#include "nigiri/shape.h"
#include "nigiri/stop.h"
#include "nigiri/types.h"

namespace nigiri {
struct rt_timetable;
Expand Down Expand Up @@ -136,6 +143,11 @@ struct frun : public run {
trip_idx_t trip_idx() const;
clasz get_clasz() const noexcept;

void for_each_shape_point(
shapes_storage const*,
interval<stop_idx_t> const&,
std::function<void(geo::latlng const&)> const&) const;

void print(std::ostream&, interval<stop_idx_t>);
friend std::ostream& operator<<(std::ostream&, frun const&);

Expand Down
34 changes: 21 additions & 13 deletions include/nigiri/shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,32 @@
#include <filesystem>
#include <span>

#include "cista/containers/pair.h"

#include "geo/latlng.h"

#include "nigiri/types.h"

namespace nigiri {
struct timetable;
}

namespace nigiri {

shapes_storage_t create_shapes_storage(
std::filesystem::path const&,
cista::mmap::protection = cista::mmap::protection::WRITE);

std::span<geo::latlng const> get_shape(timetable const&,
shapes_storage_t const&,
trip_idx_t);

std::span<geo::latlng const> get_shape(shapes_storage_t const&, shape_idx_t);
struct shapes_storage {
explicit shapes_storage(
std::filesystem::path const&,
cista::mmap::protection = cista::mmap::protection::WRITE);
std::span<geo::latlng const> get_shape(shape_idx_t) const;
std::span<geo::latlng const> get_shape(trip_idx_t) const;
std::span<geo::latlng const> get_shape(trip_idx_t,
interval<stop_idx_t> const&) const;
std::pair<std::span<geo::latlng const>, int> get_shape_with_stop_count(
trip_idx_t, stop_idx_t) const;
shape_offset_idx_t add_offsets(std::vector<shape_offset_t> const&);
void add_trip_shape_offsets(
trip_idx_t, cista::pair<shape_idx_t, shape_offset_idx_t> const&);

mm_vecvec<shape_idx_t, geo::latlng> data_;
mm_vecvec<shape_offset_idx_t, shape_offset_t> offsets_;
mm_vec_map<trip_idx_t, cista::pair<shape_idx_t, shape_offset_idx_t>>
trip_offset_indices_;
};

} // namespace nigiri
3 changes: 0 additions & 3 deletions include/nigiri/timetable.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,6 @@ struct timetable {
// Trip index -> all transports with a stop interval
paged_vecvec<trip_idx_t, transport_range_t> trip_transport_ranges_;

// Trip index -> shape per trip
vector_map<trip_idx_t, shape_idx_t> trip_shape_indices_;

// Transport -> stop sequence numbers (relevant for GTFS-RT stop matching)
// Compaction:
// - empty = zero-based sequence 0,1,2,...
Expand Down
7 changes: 6 additions & 1 deletion include/nigiri/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ using optional = cista::optional<T>;
template <typename Key, typename T, std::size_t N>
using nvec = cista::raw::nvec<Key, T, N>;

template <typename K, typename V>
using mm_vec_map = cista::basic_mmap_vec<V, K>;

template <typename T>
using mm_vec = cista::basic_mmap_vec<T, std::uint64_t>;

Expand All @@ -134,6 +137,9 @@ using route_idx_t = cista::strong<std::uint32_t, struct _route_idx>;
using section_idx_t = cista::strong<std::uint32_t, struct _section_idx>;
using section_db_idx_t = cista::strong<std::uint32_t, struct _section_db_idx>;
using shape_idx_t = cista::strong<std::uint32_t, struct _shape_idx>;
using shape_offset_t = cista::strong<std::uint32_t, struct _shape_offset>;
using shape_offset_idx_t =
cista::strong<std::uint32_t, struct _shape_offset_idx>;
using trip_idx_t = cista::strong<std::uint32_t, struct _trip_idx>;
using trip_id_idx_t = cista::strong<std::uint32_t, struct _trip_id_str_idx>;
using transport_idx_t = cista::strong<std::uint32_t, struct _transport_idx>;
Expand Down Expand Up @@ -171,7 +177,6 @@ using attribute_combination_idx_t =
cista::strong<std::uint32_t, struct _attribute_combination>;
using provider_idx_t = cista::strong<std::uint32_t, struct _provider_idx>;

using shapes_storage_t = mm_vecvec<shape_idx_t, geo::latlng>;
using transport_range_t = pair<transport_idx_t, interval<stop_idx_t>>;

struct trip_debug {
Expand Down
1 change: 1 addition & 0 deletions src/abi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "nigiri/rt/create_rt_timetable.h"
#include "nigiri/rt/gtfsrt_update.h"
#include "nigiri/rt/rt_timetable.h"
#include "nigiri/shape.h"
#include "nigiri/timetable.h"
#include "nigiri/types.h"

Expand Down
28 changes: 16 additions & 12 deletions src/loader/gtfs/load_timetable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "nigiri/loader/gtfs/route_key.h"
#include "nigiri/loader/gtfs/services.h"
#include "nigiri/loader/gtfs/shape.h"
#include "nigiri/loader/gtfs/shape_prepare.h"
#include "nigiri/loader/gtfs/stop.h"
#include "nigiri/loader/gtfs/stop_seq_number_encoding.h"
#include "nigiri/loader/gtfs/stop_time.h"
Expand Down Expand Up @@ -84,10 +85,10 @@ void load_timetable(loader_config const& config,
dir const& d,
timetable& tt,
assistance_times* assistance,
shapes_storage_t* shapes) {
shapes_storage* shapes_data) {
auto local_bitfield_indices = hash_map<bitfield, bitfield_idx_t>{};
load_timetable(config, src, d, tt, local_bitfield_indices, assistance,
shapes);
shapes_data);
}

void load_timetable(loader_config const& config,
Expand All @@ -96,7 +97,7 @@ void load_timetable(loader_config const& config,
timetable& tt,
hash_map<bitfield, bitfield_idx_t>& bitfield_indices,
assistance_times* assistance,
shapes_storage_t* shapes) {
shapes_storage* shapes_data) {
nigiri::scoped_timer const global_timer{"gtfs parser"};

auto const load = [&](std::string_view file_name) -> file {
Expand All @@ -116,8 +117,9 @@ void load_timetable(loader_config const& config,
auto const service =
merge_traffic_days(tt.internal_interval_days(), calendar, dates);
auto const shape_indices =
(shapes != nullptr) ? parse_shapes(load(kShapesFile).data(), *shapes)
: shape_id_map_t{};
(shapes_data != nullptr)
? parse_shapes(load(kShapesFile).data(), *shapes_data)
: shape_id_map_t{};
auto trip_data =
read_trips(tt, routes, service, shape_indices, load(kTripsFile).data(),
config.bikes_allowed_default_);
Expand All @@ -129,10 +131,10 @@ void load_timetable(loader_config const& config,
for (auto& t : trip_data.data_) {
if (t.requires_sorting_) {
t.stop_headsigns_.resize(t.seq_numbers_.size());
std::tie(t.seq_numbers_, t.stop_seq_, t.event_times_,
t.stop_headsigns_) =
std::tie(t.seq_numbers_, t.stop_seq_, t.event_times_, t.stop_headsigns_,
t.distance_traveled_) =
sort_by(t.seq_numbers_, t.stop_seq_, t.event_times_,
t.stop_headsigns_);
t.stop_headsigns_, t.distance_traveled_);
}
}
}
Expand Down Expand Up @@ -203,7 +205,7 @@ void load_timetable(loader_config const& config,

{
progress_tracker->status("Expand Trips")
.out_bounds(70.F, 85.F)
.out_bounds(68.F, 83.F)
.in_high(trip_data.data_.size());
auto const timer = scoped_timer{"loader.gtfs.trips.expand"};

Expand All @@ -218,7 +220,7 @@ void load_timetable(loader_config const& config,

{
progress_tracker->status("Stay Seated")
.out_bounds(85.F, 87.F)
.out_bounds(83.F, 85.F)
.in_high(route_services.size());
auto const timer = scoped_timer{"loader.gtfs.trips.block_id"};

Expand All @@ -231,7 +233,7 @@ void load_timetable(loader_config const& config,

{
progress_tracker->status("Write Trips")
.out_bounds(87.F, 100.F)
.out_bounds(85.F, 98.F)
.in_high(route_services.size());

auto const is_train_number = [](auto const& s) {
Expand All @@ -258,6 +260,9 @@ void load_timetable(loader_config const& config,
{source_file_idx, trp.from_line_, trp.to_line_},
train_nr, stop_seq_numbers);
}
if (shapes_data != nullptr) {
calculate_shape_offsets(tt, *shapes_data, trip_data.data_, shape_indices);
}

auto const timer = scoped_timer{"loader.gtfs.routes.build"};
auto const attributes = std::basic_string<attribute_combination_idx_t>{};
Expand Down Expand Up @@ -370,7 +375,6 @@ void load_timetable(loader_config const& config,
// Build transport ranges.
for (auto const& t : trip_data.data_) {
tt.trip_transport_ranges_.emplace_back(t.transport_ranges_);
tt.trip_shape_indices_.push_back(t.shape_idx_);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/loader/gtfs/loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ void gtfs_loader::load(
timetable& tt,
hash_map<bitfield, bitfield_idx_t>& global_bitfield_indices,
assistance_times* assistance,
shapes_storage_t* shapes) const {
shapes_storage* shapes_data) const {
return nigiri::loader::gtfs::load_timetable(
c, src, d, tt, global_bitfield_indices, assistance, shapes);
c, src, d, tt, global_bitfield_indices, assistance, shapes_data);
}

cista::hash_t gtfs_loader::hash(dir const& d) const {
Expand Down
Loading
Loading