From 4c6d6aeaa7008a5209721561a419243e83a9c12d Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Tue, 18 Oct 2016 07:34:02 -0600 Subject: [PATCH] Fix retrieval of forward/reverse data. --- include/util/vector_tile.hpp | 2 +- include/util/web_mercator.hpp | 11 ++--- src/engine/plugins/tile.cpp | 78 ++++++++++++++++++++++++++++------- 3 files changed, 69 insertions(+), 22 deletions(-) diff --git a/include/util/vector_tile.hpp b/include/util/vector_tile.hpp index f3c05791e..26a3e42ac 100644 --- a/include/util/vector_tile.hpp +++ b/include/util/vector_tile.hpp @@ -36,7 +36,7 @@ const constexpr std::uint32_t VARIANT_TYPE_BOOL = 7; // Vector tiles are 4096 virtual pixels on each side const constexpr double EXTENT = 4096.0; -const constexpr double BUFFER = 128.0; +const constexpr double BUFFER = 512.0; } } } diff --git a/include/util/web_mercator.hpp b/include/util/web_mercator.hpp index d3fd755b8..6fc8dea8e 100644 --- a/include/util/web_mercator.hpp +++ b/include/util/web_mercator.hpp @@ -141,12 +141,13 @@ inline FloatCoordinate toWGS84(const FloatCoordinate &mercator_coordinate) // Converts a WMS tile coordinate (z,x,y) into a wgs bounding box inline void xyzToWGS84( - const int x, const int y, const int z, double &minx, double &miny, double &maxx, double &maxy) + const int x, const int y, const int z, double &minx, double &miny, double &maxx, double &maxy, + int mercator_buffer = 0) { - minx = x * TILE_SIZE; - miny = (y + 1.0) * TILE_SIZE; - maxx = (x + 1.0) * TILE_SIZE; - maxy = y * TILE_SIZE; + minx = x * TILE_SIZE - mercator_buffer; + miny = (y + 1.0) * TILE_SIZE - mercator_buffer; + maxx = (x + 1.0) * TILE_SIZE + mercator_buffer; + maxy = y * TILE_SIZE + mercator_buffer; // 2^z * TILE_SIZE const double shift = (1u << static_cast(z)) * TILE_SIZE; pixelToDegree(shift, minx, miny); diff --git a/src/engine/plugins/tile.cpp b/src/engine/plugins/tile.cpp index e65f28d3b..e8198f031 100644 --- a/src/engine/plugins/tile.cpp +++ b/src/engine/plugins/tile.cpp @@ -278,8 +278,15 @@ Status TilePlugin::HandleRequest(const std::shared_ptr first_geometry, second_geometry; std::vector unpacked_shortcut; - std::vector forward_weight_vector; + std::vector first_weight_vector; for (const auto &source_ebn : edge_based_node_info) { + if (outgoing_edges.count(source_ebn.second.target_intersection) == 0) + { + continue; + } + // Grab a copy of the geometry leading up to the intersection. - first_geometry = - facade->GetUncompressedForwardGeometry(source_ebn.second.packed_geometry_id); + if (source_ebn.second.is_geometry_forward) + { + first_geometry = + facade->GetUncompressedForwardGeometry(source_ebn.second.packed_geometry_id); + } + else + { + first_geometry = + facade->GetUncompressedReverseGeometry(source_ebn.second.packed_geometry_id); + } // We earlier saved the source and target intersection nodes for every road section. // We can use the target node to find all road sections that lead away from @@ -479,7 +500,9 @@ Status TilePlugin::HandleRequest(const std::shared_ptrFindSmallestEdge( @@ -530,15 +553,32 @@ Status TilePlugin::HandleRequest(const std::shared_ptrGetUncompressedReverseGeometry( - edge_based_node_info.at(target_ebn).packed_geometry_id); + // (i.e. the forward geometry of the target edge-based-node) + + if (!edge_based_node_info.at(target_ebn).is_geometry_forward) + { + second_geometry = facade->GetUncompressedForwardGeometry( + edge_based_node_info.at(target_ebn).packed_geometry_id); + } + else + { + second_geometry = facade->GetUncompressedReverseGeometry( + edge_based_node_info.at(target_ebn).packed_geometry_id); + } // Now, calculate the sum of the weight of all the segments. - forward_weight_vector = - facade->GetUncompressedForwardWeights(source_ebn.second.packed_geometry_id); + if (source_ebn.second.is_geometry_forward) + { + first_weight_vector = facade->GetUncompressedForwardWeights( + source_ebn.second.packed_geometry_id); + } + else + { + first_weight_vector = facade->GetUncompressedReverseWeights( + source_ebn.second.packed_geometry_id); + } const auto sum_node_weight = std::accumulate( - forward_weight_vector.begin(), forward_weight_vector.end(), EdgeWeight{0}); + first_weight_vector.begin(), first_weight_vector.end(), EdgeWeight{0}); // The edge.weight is the whole edge weight, which includes the turn cost. // The turn cost is the edge.weight minus the sum of the individual road @@ -624,9 +664,15 @@ Status TilePlugin::HandleRequest(const std::shared_ptr