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

memory mapped reverse geocoder #641

Merged
merged 3 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .pkg
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[adr]
[email protected]:triptix-tech/adr.git
branch=master
commit=b54517837bdf6d5ac4967858c2c4011f29e5789f
commit=d5ee67db28999b54e82a923fe32d7b461490f08f
[googletest]
[email protected]:motis-project/googletest.git
branch=master
Expand Down
8 changes: 4 additions & 4 deletions .pkg.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
521520066768043934
cista 5b6808fd7d7a7c1c7e4cb152b563dbf71e3efba4
16948827567758484956
cista 52577def055e4bdf90eaa461872fc1f7b5b1131d
zlib-ng 68ab3e2d80253ec5dc3c83691d9ff70477b32cd3
boost 73549ebca677fe6214202a1ab580362b4f80e653
googletest 7b64fca6ea0833628d6f86255a81424365f7cc0c
Expand All @@ -12,7 +12,7 @@ res b759b93316afeb529b6cb5b2548b24c41e382fb0
date ce88cc33b5551f66655614eeebb7c5b7189025fb
oh d21c30f40e52a83d6dc09bcffd0067598b5ec069
doctest 70e8f76437b76dd5e9c0a2eb9b907df190ab71a0
geo 5d99aeb10674a41a82d7c78f850abfd9605bf6e1
geo de5a3586871b8b76a487d42fcc673c9487a1e233
miniz 1edbdece9d71dc65c6ff405572ee37cbdcef7af4
curl 39c8a51e8ee0ab7ea712886df79c068405a2e008
json 410c74782230daaa15054d6ee0975c0607091cb3
Expand Down Expand Up @@ -45,5 +45,5 @@ reflect-cpp c54fe66de4650b60c23aadd4a06d9db4ffeda22f
FTXUI dd6a5d371fd7a3e2937bb579955003c54b727233
tg 20c0f298b8ce58de29a790290f44dca7c4ecc364
utf8proc 779b780da3b99d123133eb99707b65c7e4324cc8
adr b54517837bdf6d5ac4967858c2c4011f29e5789f
adr d5ee67db28999b54e82a923fe32d7b461490f08f
openapi-cpp 6b5fd40a2b552fc5656aeff56f203a34c1d9e9af
4 changes: 0 additions & 4 deletions include/motis/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,3 @@ struct config {
};

} // namespace motis

#include "cista/reflection/to_tuple.h"

static_assert(std::is_aggregate_v<motis::config::timetable>);
2 changes: 1 addition & 1 deletion include/motis/hashes.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ constexpr auto const osr_version = []() {
return meta_entry_t{"osr_bin_ver", 6U};
};
constexpr auto const adr_version = []() {
return meta_entry_t{"adr_bin_ver", 1U};
return meta_entry_t{"adr_bin_ver", 2U};
};
constexpr auto const n_version = []() {
return meta_entry_t{"nigiri_bin_ver", 6U};
Expand Down
3 changes: 2 additions & 1 deletion src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ config config::read_simple(std::vector<std::string> const& args) {
c.osm_ = p;
c.street_routing_ = true;
c.geocoding_ = true;
c.reverse_geocoding_ = true;
c.tiles_ = {config::tiles{.profile_ = "tiles-profiles/full.lua"}};
} else {
if (!c.timetable_.has_value()) {
Expand Down Expand Up @@ -399,7 +400,7 @@ config config::read_legacy(fs::path const& p) {
: std::nullopt;
c.street_routing_ = is_module_active("osr") || is_module_active("osrm") ||
is_module_active("ppr");
c.geocoding_ = is_module_active("adr");
c.geocoding_ = c.reverse_geocoding_ = is_module_active("adr");
c.tiles_ =
is_module_active("tiles")
? std::optional{tiles{.profile_ = cfg.profile_path_,
Expand Down
1 change: 0 additions & 1 deletion src/data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ void data::load_geocoder() {
void data::load_reverse_geocoder() {
r_ = std::make_unique<adr::reverse>(path_ / "adr",
cista::mmap::protection::READ);
r_->build_rtree(*t_);
}

void data::load_matches() {
Expand Down
27 changes: 24 additions & 3 deletions src/import.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "osr/ways.h"

#include "adr/adr.h"
#include "adr/reverse.h"
#include "adr/typeahead.h"

#include "motis/adr_extend_tt.h"
Expand Down Expand Up @@ -205,7 +206,10 @@ data import(config const& c, fs::path const& data_path, bool const write) {
d.load_reverse_geocoder();
}
},
{osm_hash, adr_version()}};
{osm_hash,
adr_version(),
{"geocoding", c.geocoding_},
{"reverse_geocoding", c.reverse_geocoding_}}};

auto tt = task{
"tt",
Expand Down Expand Up @@ -305,11 +309,28 @@ data import(config const& c, fs::path const& data_path, bool const write) {
if (write) {
cista::write(data_path / "adr" / "t_ext.bin", *d.t_);
}
d.r_.reset();
{
auto r = adr::reverse{data_path / "adr",
cista::mmap::protection::WRITE};
r.build_rtree(*d.t_);
r.write();
}
d.t_.get()->~typeahead();
d.load_geocoder();
if (c.geocoding_) {
d.load_geocoder();
}
if (c.reverse_geocoding_) {
d.load_reverse_geocoder();
}
},
[&]() { d.load_geocoder(); },
{tt_hash, osm_hash, adr_version(), n_version()}};
{tt_hash,
osm_hash,
adr_version(),
n_version(),
{"geocoding", c.geocoding_},
{"reverse_geocoding", c.reverse_geocoding_}}};

auto osr_footpath = task{
"osr_footpath",
Expand Down