Skip to content

Commit

Permalink
Post process to update free and constrained flow speeds. (valhalla#1375)
Browse files Browse the repository at this point in the history
* added valhalla_add_predicted_traffic

* added updated function for DEs

* added update function declaration for DEs

* added logic to parse freeflow and constrained files and update the freeflow and constained speeds in the DEs.

* added freeflow and constrained speeds for testing.

* added predictive_traffic test and valhalla_add_predicted_traffic to the building of the utrecht tiles.

* added predictive_traffic test.

* added support for inline_config for testing.  added comments.

* added no logging.

* ran formatting

* updated.

* updated to not serialize the tile_builder.  Hopefully this should speed things up.

* ran formatter.
  • Loading branch information
gknisely authored Jun 21, 2018
1 parent 68f8665 commit 663a2e4
Show file tree
Hide file tree
Showing 9 changed files with 40,211 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* CHANGED: Fix destination only penalty for A* and time dependent cases.
* **Map Matching**
* FIXED: Fixed trace_route edge_walk server abort [#1365](https://github.com/valhalla/valhalla/pull/1365)
* **Enhancement**
* ADDED: Added post process for updating free and constrained speeds in the directed edges.

## Release Date: 2018-05-28 Valhalla 2.6.0
* **Infrastructure**:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ set(valhalla_programs valhalla_run_map_match valhalla_benchmark_loki valhalla_be
set(valhalla_data_tools valhalla_build_statistics valhalla_ways_to_edges valhalla_validate_transit
valhalla_benchmark_admins valhalla_build_connectivity valhalla_build_tiles
valhalla_build_admins valhalla_build_transit valhalla_fetch_transit valhalla_query_transit
valhalla_build_speeds valhalla_associate_segments)
valhalla_build_speeds valhalla_associate_segments valhalla_add_predicted_traffic)

## Valhalla services
set(valhalla_services valhalla_service valhalla_loki_worker valhalla_odin_worker valhalla_thor_worker)
Expand Down
40 changes: 40 additions & 0 deletions src/mjolnir/graphtilebuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,46 @@ void GraphTileBuilder::Update(const std::vector<NodeInfo>& nodes,
}
}

/**
* Updates a tile with updated directed edges.
*/
void GraphTileBuilder::Update(const std::vector<DirectedEdge>& directededges) {

// Get the name of the file
boost::filesystem::path filename =
tile_dir_ + filesystem::path_separator + GraphTile::FileSuffix(header_builder_.graphid());

// Make sure the directory exists on the system
if (!boost::filesystem::exists(filename.parent_path()))
boost::filesystem::create_directories(filename.parent_path());

// Open file and truncate
std::stringstream in_mem;
std::ofstream file(filename.c_str(), std::ios::out | std::ios::binary | std::ios::trunc);
if (file.is_open()) {
// Write the header
file.write(reinterpret_cast<const char*>(header_), sizeof(GraphTileHeader));

// Write the nodes.
file.write(reinterpret_cast<const char*>(nodes_), header_->nodecount() * sizeof(NodeInfo));

// Write the updated directed edges. Make sure edge count matches.
if (directededges.size() != header_->directededgecount()) {
throw std::runtime_error("GraphTileBuilder::Update - directed edge count has changed");
}
file.write(reinterpret_cast<const char*>(directededges.data()),
directededges.size() * sizeof(DirectedEdge));

// Write the rest of the tiles
auto begin = reinterpret_cast<const char*>(&access_restrictions_[0]);
auto end = reinterpret_cast<const char*>(header()) + header()->end_offset();
file.write(begin, end - begin);
file.close();
} else {
throw std::runtime_error("GraphTileBuilder::Update - Failed to open file " + filename.string());
}
}

// Gets a reference to the header builder.
GraphTileHeader& GraphTileBuilder::header_builder() {
return header_builder_;
Expand Down
Loading

0 comments on commit 663a2e4

Please sign in to comment.