@@ -156,7 +156,36 @@ void PathAlgorithm::Init(const PointLL& origll, const PointLL& destll,
156
156
hierarchy_limits_ = costing->GetHierarchyLimits ();
157
157
}
158
158
159
- // Calculate best path. This method is single mode, no time dependency.
159
+ // Modulate the hierarchy expansion within distance based on density at
160
+ // the destination (increase distance for lower densities and decrease
161
+ // for higher densities) and the distance between origin and destination
162
+ // (increase for shorter distances).
163
+ void PathAlgorithm::ModifyHierarchyLimits (const float dist,
164
+ const uint32_t density) {
165
+ // TODO - default distance below which we increase expansion within
166
+ // distance. This is somewhat temporary to address route quality on shorter
167
+ // routes - hopefully we will mark the data somehow to indicate how to
168
+ // use the hierarchy when approaching the destination (or use a
169
+ // bi-directional search without hierarchies for shorter routes).
170
+ float factor = 1 .0f ;
171
+ if (25000 .0f < dist && dist < 100000 .0f ) {
172
+ factor = std::min (3 .0f , 100000 .0f / dist);
173
+ }
174
+ /* TODO - need a reliable density factor near the destination (e.g. tile level?)
175
+ // Low density - increase expansion within distance.
176
+ // High density - decrease expansion within distance.
177
+ if (density < 8) {
178
+ float f = 1.0f + (8.0f - density) * 0.125f;
179
+ factor *= f;
180
+ } else if (density > 8) {
181
+ float f = 0.5f + (15.0f - density) * 0.0625;
182
+ factor *= f;
183
+ }*/
184
+ // TODO - just arterial for now...investigate whether to alter local as well
185
+ hierarchy_limits_[1 ].expansion_within_dist *= factor;
186
+ }
187
+
188
+ // Calculate best path. This method is single mode, not time-dependent.
160
189
std::vector<PathInfo> PathAlgorithm::GetBestPath (const PathLocation& origin,
161
190
const PathLocation& destination, GraphReader& graphreader,
162
191
const std::shared_ptr<DynamicCost>& costing) {
@@ -183,7 +212,12 @@ std::vector<PathInfo> PathAlgorithm::GetBestPath(const PathLocation& origin,
183
212
184
213
// Initialize the origin and destination locations
185
214
SetOrigin (graphreader, origin, costing, loop_edge_info);
186
- SetDestination (graphreader, dest, costing);
215
+ uint32_t density = SetDestination (graphreader, dest, costing);
216
+
217
+ // Update hierarchy limits
218
+ if (allow_transitions_) {
219
+ ModifyHierarchyLimits (mindist, density);
220
+ }
187
221
188
222
// Find shortest path
189
223
uint32_t nc = 0 ; // Count of iterations with no convergence
@@ -706,16 +740,21 @@ void PathAlgorithm::SetOrigin(GraphReader& graphreader,
706
740
}
707
741
708
742
// Add a destination edge
709
- void PathAlgorithm::SetDestination (GraphReader& graphreader,
743
+ uint32_t PathAlgorithm::SetDestination (GraphReader& graphreader,
710
744
const PathLocation& dest,
711
745
const std::shared_ptr<DynamicCost>& costing) {
712
746
// For each edge
747
+ uint32_t density = 0 ;
713
748
float seconds = 0 .0f ;
714
749
for (const auto & edge : dest.edges ()) {
715
750
// Keep the id and the cost to traverse the partial distance
716
751
const GraphTile* tile = graphreader.GetGraphTile (edge.id );
717
752
destinations_[edge.id ] = (costing->EdgeCost (tile->directededge (edge.id ), 0 .0f ) * edge.dist );
753
+
754
+ // Get the tile relative density
755
+ density = tile->header ()->density ();
718
756
}
757
+ return density;
719
758
}
720
759
721
760
// Test is the shortest path has been found.
0 commit comments