Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
3b9ae88
valhalla traffic buider
boonboonsiri Aug 27, 2025
1f63542
valhalla-historic-traffic-builder
boonboonsiri Aug 27, 2025
0d515a7
more cleanup
boonboonsiri Aug 27, 2025
7397554
readme
boonboonsiri Sep 2, 2025
75d2e46
valhalla mvt tiles
boonboonsiri Sep 5, 2025
ad0feac
only look inside bbox, very high performance gains
boonboonsiri Sep 8, 2025
e99970c
fix bbox bug
boonboonsiri Sep 8, 2025
bfb2d9f
speed bucket
boonboonsiri Sep 8, 2025
8cdebe6
reverse direction
boonboonsiri Sep 9, 2025
63f4b51
remove unnessesary code
boonboonsiri Sep 9, 2025
2e99b5a
cleaning up geometries
boonboonsiri Sep 9, 2025
a048a3a
adjusting north south
boonboonsiri Sep 11, 2025
7902771
adding vtzero submodule
boonboonsiri Sep 11, 2025
b3c07e8
fix compilation
boonboonsiri Sep 11, 2025
b148b11
fixes, tag shortcuts, bettre config, code cleanup
boonboonsiri Sep 17, 2025
b99eeb7
really temp add historic time query
boonboonsiri Sep 17, 2025
a90c5df
fix bug
boonboonsiri Sep 17, 2025
c67b151
docs
boonboonsiri Sep 18, 2025
9a640e0
change log in readme_radar as well
boonboonsiri Sep 18, 2025
bf05865
rebuild
boonboonsiri Sep 18, 2025
dd86151
rebuild
boonboonsiri Sep 19, 2025
7218028
rebuild
boonboonsiri Sep 19, 2025
a17b84d
rebuil
boonboonsiri Sep 19, 2025
53b1da0
rebuild
boonboonsiri Sep 19, 2025
652d4e1
rebuild
boonboonsiri Sep 19, 2025
f3ed5af
rebuild
boonboonsiri Sep 19, 2025
34b9fd5
rebuild
boonboonsiri Sep 19, 2025
4a192c9
rebuild
boonboonsiri Sep 19, 2025
d3db30f
fix build script
boonboonsiri Sep 19, 2025
6742b15
rebuild
boonboonsiri Sep 19, 2025
0b98b80
fix minggw script
boonboonsiri Sep 19, 2025
c052bd3
rebuidl
boonboonsiri Sep 19, 2025
c1a2678
rebuild
boonboonsiri Sep 19, 2025
9aef2a3
rebuild
boonboonsiri Sep 19, 2025
7ced393
rebuild
boonboonsiri Sep 19, 2025
87f613c
rebuild
boonboonsiri Sep 19, 2025
ccd484f
rebuild
boonboonsiri Sep 19, 2025
be17a39
rebuild
boonboonsiri Sep 19, 2025
8230624
rebuild
boonboonsiri Sep 19, 2025
e7bf08a
rebuild
boonboonsiri Sep 19, 2025
d654cdd
rebuild
boonboonsiri Sep 19, 2025
75bf573
rebuild
boonboonsiri Sep 22, 2025
891ba93
rebuild
boonboonsiri Sep 22, 2025
3081c25
build verify step
boonboonsiri Sep 22, 2025
21d510f
clang format
boonboonsiri Sep 22, 2025
d506a7e
add predicted speeds original back
boonboonsiri Sep 23, 2025
d540abc
closure options
boonboonsiri Oct 8, 2025
e0991ac
Merge remote-tracking branch 'origin/boon/valhalla-cleanup' into boon…
boonboonsiri Oct 8, 2025
772ab0a
clean up
boonboonsiri Oct 31, 2025
1ac9d97
merge
boonboonsiri Oct 31, 2025
11c63f4
fallback to historic traffic data if live traffic data missing, bug f…
boonboonsiri Oct 31, 2025
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ mason_packages/
valhalla-server/
data/


# scripts
scripts/gdal-2.0.0/
scripts/gdal-2.0.0.tar.gz
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@
[submodule "third_party/unordered_dense"]
path = third_party/unordered_dense
url = https://github.com/martinus/unordered_dense
[submodule "third_party/vtzero"]
path = third_party/vtzero
url = https://github.com/mapbox/vtzero.git
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ set(rapidjson_include_dir ${VALHALLA_SOURCE_DIR}/third_party/rapidjson/include)
set(unordered_dense_include_dir ${VALHALLA_SOURCE_DIR}/third_party/unordered_dense/include)
set(cxxopts_include_dir ${VALHALLA_SOURCE_DIR}/third_party/cxxopts/include)
set(dirent_include_dir ${VALHALLA_SOURCE_DIR}/third_party/dirent/include)
set(vtzero_include_dir ${VALHALLA_SOURCE_DIR}/third_party/vtzero/include)
set(protozero_include_dir ${VALHALLA_SOURCE_DIR}/third_party/protozero/include)

# Override protozero path for vtzero
set(PROTOZERO_INCLUDE_DIR ${VALHALLA_SOURCE_DIR}/third_party/protozero/include)
if (PREFER_EXTERNAL_DEPS)
# date
find_package(date QUIET)
Expand Down
4 changes: 3 additions & 1 deletion proto/options.proto
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ message AvoidEdge {
message HierarchyLimits {
uint32 up_transition_count = 1; // Keep track of # of upward transitions
// Internal use only, remember to clear on incoming requests
uint32 max_up_transitions = 2; // Maximum number of upward transitions before
uint32 max_up_transitions = 2; // Maximum number of upward transitions before
// expansion is stopped on a level.
float expand_within_dist = 3; // Distance (m) to destination within which
// expansion of a hierarchy level is
Expand Down Expand Up @@ -372,6 +372,7 @@ message Options {
osrm = 2;
pbf = 3;
geotiff = 4;
mvt = 5;
}

enum Action {
Expand All @@ -388,6 +389,7 @@ message Options {
expansion = 10;
centroid = 11;
status = 12;
tile = 13;
}

enum DateTimeType {
Expand Down
26 changes: 26 additions & 0 deletions scripts/valhalla_build_config
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ config = {
'logging': {'type': 'std_out', 'color': True, 'file_name': 'path_to_some_file.log'},
},
'additional_data': {'elevation': '/data/valhalla/elevation/', 'elevation_url': Optional(str)},
'map_tile': {
'valhalla_tile_0_min_zoom': 5,
'valhalla_tile_1_min_zoom': 12,
'valhalla_tile_2_min_zoom': 18,
'max_edges_added': 200000,
'valhalla_road_class_0_min_zoom': 5,
'valhalla_road_class_1_min_zoom': 7,
'valhalla_road_class_2_min_zoom': 12,
'valhalla_road_class_3_min_zoom': 13,
'valhalla_road_class_4_min_zoom': 14,
'valhalla_all_road_classes_min_zoom': 14,
'add_debug_info_to_tile': False,
},
'loki': {
'actions': [
'locate',
Expand Down Expand Up @@ -395,6 +408,19 @@ help_text = {
'elevation': 'Location of elevation tiles',
'elevation_url': 'Http location to read elevations from. this address is used if elevation tiles were not found in the elevation directory. Ex.: http://<your_valhalla_tile_server_host>:<your_valhalla_tile_server_port>/some/Optional/path/{tilePath}?some=Optional&query=params. Valhalla will look for the {tilePath} portion of the url and fill this out with an elevation path when it makes a request for that particular elevation',
},
'map_tile': {
'valhalla_tile_0_min_zoom': 'Maplibre zoom level in which Valhalla level 0 tiles are used',
'valhalla_tile_1_min_zoom': 'Maplibre zoom level in which Valhalla level 1 tiles are used',
'valhalla_tile_2_min_zoom': 'Maplibre zoom level in which Valhalla level 2 tiles are used',
'max_edges_added': 'Maximum number of edges added to a tile',
'valhalla_road_class_0_min_zoom': 'Maplibre zoom level in which Valhalla road class 0 tiles are used',
'valhalla_road_class_1_min_zoom': 'Maplibre zoom level in which Valhalla road class 1 tiles are used',
'valhalla_road_class_2_min_zoom': 'Maplibre zoom level in which Valhalla road class 2 tiles are used',
'valhalla_road_class_3_min_zoom': 'Maplibre zoom level in which Valhalla road class 3 tiles are used',
'valhalla_road_class_4_min_zoom': 'Maplibre zoom level in which Valhalla road class 4 tiles are used',
'valhalla_all_road_classes_min_zoom': 'Maplibre zoom level in which Valhalla all road classes tiles are used',
'add_debug_info_to_tile': 'Whether to add debug information to the tile such as road class, road name',
},
'loki': {
'actions': 'Comma separated list of allowable actions for the service, one or more of: locate, route, height, optimized_route, isochrone, trace_route, trace_attributes, transit_available, expansion, centroid, status',
'use_connectivity': 'a boolean value to know whether or not to construct the connectivity maps',
Expand Down
21 changes: 21 additions & 0 deletions src/loki/worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,25 @@ loki_worker_t::work(const std::list<zmq::message_t>& job,
prime_server::worker_t::result_t result{true, {}, ""};
try {
// request parsing
LOG_INFO("LOKI DEBUG: About to parse HTTP request");
LOG_INFO("LOKI DEBUG: Job data size: " + std::to_string(job.front().size()));
auto http_request =
prime_server::http_request_t::from_string(static_cast<const char*>(job.front().data()),
job.front().size());
LOG_INFO("LOKI DEBUG: HTTP request created, about to call ParseApi");
LOG_INFO("LOKI DEBUG: HTTP request path: '" + http_request.path + "'");
LOG_INFO("LOKI DEBUG: HTTP request method: " + std::to_string(static_cast<int>(http_request.method)));
LOG_INFO("LOKI DEBUG: HTTP request path length: " + std::to_string(http_request.path.length()));
LOG_INFO("LOKI DEBUG: HTTP request path starts with /tile/: " + std::to_string(http_request.path.find("/tile/") == 0));
LOG_INFO("LOKI DEBUG: HTTP request query parameters:");
for (const auto& kv : http_request.query) {
LOG_INFO("LOKI DEBUG: Query param: " + kv.first + " = " + (kv.second.empty() ? "empty" : kv.second.front()));
}
ParseApi(http_request, request);
LOG_INFO("LOKI DEBUG: ParseApi completed successfully");
LOG_INFO("LOKI DEBUG: API options id after ParseApi: '" + request.options().id() + "'");
const auto& options = request.options();
LOG_INFO("LOKI DEBUG: Got options, action: " + Options_Action_Enum_Name(options.action()));

// check there is a valid action
if (actions.find(options.action()) == actions.cend()) {
Expand Down Expand Up @@ -415,6 +429,13 @@ loki_worker_t::work(const std::list<zmq::message_t>& job,
status(request);
result.messages.emplace_back(request.SerializeAsString());
break;
case Options::tile:
LOG_INFO("LOKI DEBUG: Processing tile action");
// For tile requests, we need to pass through to thor/odin for processing
// The tile action will be handled by the tyr actor
result.messages.emplace_back(request.SerializeAsString());
LOG_INFO("LOKI DEBUG: Tile action processed successfully");
break;
case Options::expansion:
if (options.expansion_action() == Options::route) {
route(request);
Expand Down
41 changes: 39 additions & 2 deletions src/odin/worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
#include "odin/util.h"
#include "proto/trip.pb.h"
#include "tyr/serializers.h"
#include "tyr/actor.h"

#include <boost/property_tree/ptree.hpp>

#include <functional>
#include <string>
#include <sstream>

using namespace valhalla;
using namespace valhalla::tyr;
Expand All @@ -21,7 +23,7 @@ namespace valhalla {
namespace odin {

odin_worker_t::odin_worker_t(const boost::property_tree::ptree& config)
: service_worker_t(config), markup_formatter_(config) {
: service_worker_t(config), markup_formatter_(config), config_(config) {
// signal that the worker started successfully
started();
}
Expand Down Expand Up @@ -60,6 +62,7 @@ odin_worker_t::work(const std::list<zmq::message_t>& job,
const std::function<void()>& interrupt_function) {
auto& info = *static_cast<prime_server::http_request_info_t*>(request_info);
LOG_INFO("Got Odin Request " + std::to_string(info.id));
LOG_INFO("ODIN DEBUG: Odin worker is being called");
Api request;
prime_server::worker_t::result_t result{false, {}, {}};
try {
Expand All @@ -73,14 +76,48 @@ odin_worker_t::work(const std::list<zmq::message_t>& job,
throw valhalla_exception_t{200, "Failed parsing pbf in Odin::Worker"};
}

// its either a simple status request or its a route to narrate
// its either a simple status request, tile request, or its a route to narrate
switch (request.options().action()) {
case Options::status: {
status(request);
auto response = tyr::serializeStatus(request);
result = to_response(response, info, request);
break;
}
case Options::tile: {
LOG_INFO("ODIN DEBUG: Calling Tyr actor directly for tile request");
// For tile requests, we need to call the Tyr actor directly
// since the Tyr actor is not part of the worker pipeline

// Extract tile coordinates and time parameter from HTTP request if not already in API options
if (request.options().id().empty()) {
LOG_INFO("ODIN DEBUG: API options id is empty, using test tile coordinates");
// For now, use test coordinates to verify the MVT generation works
// TODO: Fix the HTTP routing to properly extract coordinates from URL
request.mutable_options()->set_id("12/2048/1365"); // Test coordinates for zoom 12
request.mutable_options()->set_format(Options_Format_mvt);
LOG_INFO("ODIN DEBUG: Set test tile coordinates: 12/2048/1365");
}

// Check if time parameter is set
if (request.options().has_date_time_case()) {
LOG_INFO("ODIN DEBUG: Time parameter set: " + request.options().date_time());
} else {
LOG_INFO("ODIN DEBUG: No time parameter set, using current traffic");
}

try {
// Create a Tyr actor to handle the tile request
valhalla::tyr::actor_t actor(config_);
auto response = actor.act(request);
result = to_response(response, info, request);
LOG_INFO("ODIN DEBUG: Tyr actor completed successfully, response size: " + std::to_string(response.size()));
} catch (const std::exception& e) {
LOG_ERROR("ODIN DEBUG: Tyr actor failed with error: " + std::string(e.what()));
throw valhalla_exception_t{400, std::string("Tyr actor failed: ") + e.what()};
}
break;
}
default: {
// narrate them and serialize them along
auto response = narrate(request);
Expand Down
4 changes: 3 additions & 1 deletion src/proto_conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ bool Options_Action_Enum_Parse(const std::string& action, Options::Action* a) {
{"expansion", Options::expansion},
{"centroid", Options::centroid},
{"status", Options::status},
{"tile", Options::tile}
};
auto i = actions.find(action);
if (i == actions.cend())
Expand All @@ -136,7 +137,7 @@ bool Options_ExpansionAction_Enum_Parse(const std::string& action, Options::Acti
static const std::unordered_map<std::string, Options::Action>
actions{{"route", Options::route},
{"isochrone", Options::isochrone},
{"sources_to_targets", Options::sources_to_targets}};
{"sources_to_targets", Options::sources_to_targets}, {"tile", Options::tile}};
auto i = actions.find(action);
if (i == actions.cend())
return false;
Expand All @@ -158,6 +159,7 @@ const std::string& Options_Action_Enum_Name(const Options::Action action) {
{Options::expansion, "expansion"},
{Options::centroid, "centroid"},
{Options::status, "status"},
{Options::tile, "tile"},
};
auto i = actions.find(action);
return i == actions.cend() ? empty_str : i->second;
Expand Down
8 changes: 8 additions & 0 deletions src/thor/worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ thor_worker_t::work(const std::list<zmq::message_t>& job,
result.messages.emplace_back(serialize_to_pbf(request));
break;
}
case Options::tile: {
LOG_INFO("THOR DEBUG: Processing tile action");
// For tile requests, we just pass through to the next worker (Odin)
// The actual MVT generation happens in the Tyr actor
result.messages.emplace_back(serialize_to_pbf(request));
LOG_INFO("THOR DEBUG: Tile action processed successfully, message size: " + std::to_string(result.messages.back().size()));
break;
}
default:
throw valhalla_exception_t{400}; // this should never happen
}
Expand Down
9 changes: 7 additions & 2 deletions src/tyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ set(sources
route_summary_cache.cc
serializers.cc
transit_available_serializer.cc
expansion_serializer.cc)
expansion_serializer.cc
mvt_serializer.cc)

set(sources_with_warnings
locate_serializer.cc
Expand All @@ -19,7 +20,9 @@ set(sources_with_warnings

set(system_includes
${date_include_dir}
$<$<BOOL:${WIN32}>:${dirent_include_dir}>)
$<$<BOOL:${WIN32}>:${dirent_include_dir}>
${VALHALLA_SOURCE_DIR}/third_party/vtzero/include
${VALHALLA_SOURCE_DIR}/third_party/protozero/include)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to encode the tile info


valhalla_module(NAME tyr
SOURCES
Expand All @@ -39,6 +42,8 @@ valhalla_module(NAME tyr
${system_includes}
PRIVATE
${rapidjson_include_dir}
${vtzero_include_dir}
${VALHALLA_SOURCE_DIR}/third_party/protozero/include
DEPENDS
valhalla::loki
valhalla::thor
Expand Down
Loading