[osrm] 01/05: Imported Upstream version 5.3.2+ds

Bas Couwenberg sebastic at debian.org
Tue Aug 9 14:48:09 UTC 2016


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository osrm.

commit 07ea59d4000c75ce7d7a65c7acddc69c52dbd649
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Tue Aug 9 16:16:55 2016 +0200

    Imported Upstream version 5.3.2+ds
---
 CHANGELOG.md                            |  5 ++++
 CMakeLists.txt                          |  2 +-
 features/guidance/trimming.feature      | 52 +++++++++++++++++++++++++++++++++
 src/engine/guidance/post_processing.cpp | 38 ++++++++++++++++--------
 4 files changed, 84 insertions(+), 13 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 760a74b..abf3326 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+# 5.3.2
+  Changes from 5.3.1
+    - Bugfixes
+      - fixed a bug that occurred when trimming very short segments at the begin/end of a route (less than 1 meter)
+
 # 5.3.1
   Changes from 5.3.1
     - Bugfixes:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 04d8759..c6518c9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,7 +10,7 @@ endif()
 project(OSRM C CXX)
 set(OSRM_VERSION_MAJOR 5)
 set(OSRM_VERSION_MINOR 3)
-set(OSRM_VERSION_PATCH 1)
+set(OSRM_VERSION_PATCH 2)
 
 # these two functions build up custom variables:
 #   OSRM_INCLUDE_PATHS and OSRM_DEFINES
diff --git a/features/guidance/trimming.feature b/features/guidance/trimming.feature
new file mode 100644
index 0000000..62808a7
--- /dev/null
+++ b/features/guidance/trimming.feature
@@ -0,0 +1,52 @@
+ at routing  @guidance @post-processing
+Feature: General Post-Processing related features
+
+    Background:
+        Given the profile "car"
+        Given a grid size of 0.1 meters
+
+    # this testcase used to crash geometry generation (at that time handled during intersection generation)
+    Scenario: Regression Test 2754 
+        Given the node map
+            | a | b | c | d | e |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   |   |   |   |   |   |
+            |   |   |   |   | f | g | h | i | j |
+
+        And the ways
+            | nodes |
+            | abcde |
+            | ef    |
+            | fghij |
+
+        When I route I should get
+            | waypoints | route |
+            | a,j       | ef,ef |
diff --git a/src/engine/guidance/post_processing.cpp b/src/engine/guidance/post_processing.cpp
index e859667..2bf41ea 100644
--- a/src/engine/guidance/post_processing.cpp
+++ b/src/engine/guidance/post_processing.cpp
@@ -878,25 +878,34 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
                                            geometry.locations[0], geometry.locations[1]) <= 1;
     if (zero_length_step || duplicated_coordinate)
     {
-        // fixup the coordinate
-        geometry.locations.erase(geometry.locations.begin());
-        geometry.annotations.erase(geometry.annotations.begin());
-        geometry.osm_node_ids.erase(geometry.osm_node_ids.begin());
 
         // remove the initial distance value
         geometry.segment_distances.erase(geometry.segment_distances.begin());
 
+        const auto offset = zero_length_step ? geometry.segment_offsets[1] : 1;
+        if (offset > 0)
+        {
+            // fixup the coordinates/annotations/ids
+            geometry.locations.erase(geometry.locations.begin(),
+                                     geometry.locations.begin() + offset);
+            geometry.annotations.erase(geometry.annotations.begin(),
+                                       geometry.annotations.begin() + offset);
+            geometry.osm_node_ids.erase(geometry.osm_node_ids.begin(),
+                                        geometry.osm_node_ids.begin() + offset);
+        }
+
         // We have to adjust the first step both for its name and the bearings
         if (zero_length_step)
         {
+            // since we are not only checking for epsilon but for a full meter, we can have multiple
+            // coordinates here.
             // move offsets to front
-            BOOST_ASSERT(geometry.segment_offsets[1] == 1);
             // geometry offsets have to be adjusted. Move all offsets to the front and reduce by
             // one. (This is an inplace forward one and reduce by one)
             std::transform(geometry.segment_offsets.begin() + 1,
                            geometry.segment_offsets.end(),
                            geometry.segment_offsets.begin(),
-                           [](const std::size_t val) { return val - 1; });
+                           [offset](const std::size_t val) { return val - offset; });
 
             geometry.segment_offsets.pop_back();
             const auto &current_depart = steps.front();
@@ -937,9 +946,9 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
         }
 
         // and update the leg geometry indices for the removed entry
-        std::for_each(steps.begin(), steps.end(), [](RouteStep &step) {
-            --step.geometry_begin;
-            --step.geometry_end;
+        std::for_each(steps.begin(), steps.end(), [offset](RouteStep &step) {
+            step.geometry_begin -= offset;
+            step.geometry_end -= offset;
         });
 
         auto &first_step = steps.front();
@@ -971,10 +980,12 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
     // all zero-length instructions
     if (next_to_last_step.distance <= 1 && steps.size() > 2)
     {
-        geometry.locations.pop_back();
-        geometry.annotations.pop_back();
-        geometry.osm_node_ids.pop_back();
         geometry.segment_offsets.pop_back();
+        // remove all the last coordinates from the geometry
+        geometry.locations.resize(geometry.segment_offsets.back() + 1);
+        geometry.annotations.resize(geometry.segment_offsets.back() + 1);
+        geometry.osm_node_ids.resize(geometry.segment_offsets.back() + 1);
+
         BOOST_ASSERT(geometry.segment_distances.back() <= 1);
         geometry.segment_distances.pop_back();
 
@@ -983,6 +994,7 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
         next_to_last_step.maneuver.bearing_after = 0;
         next_to_last_step.intersections.front().lanes = util::guidance::LaneTupel();
         next_to_last_step.intersections.front().lane_description.clear();
+        next_to_last_step.geometry_end = next_to_last_step.geometry_begin + 1;
         BOOST_ASSERT(next_to_last_step.intersections.size() == 1);
         auto &last_intersection = next_to_last_step.intersections.back();
         last_intersection.bearings = {last_intersection.bearings[last_intersection.in]};
@@ -1030,6 +1042,8 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
         last_step.intersections.front().bearings.front() = util::bearing::reverseBearing(bearing);
     }
 
+    BOOST_ASSERT(steps.back().geometry_end == geometry.locations.size());
+
     BOOST_ASSERT(steps.front().intersections.size() >= 1);
     BOOST_ASSERT(steps.front().intersections.front().bearings.size() == 1);
     BOOST_ASSERT(steps.front().intersections.front().entry.size() == 1);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/osrm.git



More information about the Pkg-grass-devel mailing list