Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8250cd0f10 | |||
| 631c9f2360 | |||
| d8741a39e3 | |||
| d33ff6a897 |
+1
-1
@@ -365,7 +365,7 @@ install:
|
||||
script:
|
||||
- if [[ $TARGET_ARCH == armhf ]] ; then echo "Skip tests for $TARGET_ARCH" && exit 0 ; fi
|
||||
- make -C test/data benchmark
|
||||
# - ./example/build/osrm-example test/data/mld/monaco.osrm
|
||||
- ./example/build/osrm-example test/data/mld/monaco.osrm
|
||||
# All tests assume to be run from the build directory
|
||||
- pushd ${OSRM_BUILD_DIR}
|
||||
- ./unit_tests/library-tests
|
||||
|
||||
+1
-1
@@ -3,9 +3,9 @@
|
||||
- Optimizations:
|
||||
- CHANGED: Map matching is now almost twice as fast. [#5060](https://github.com/Project-OSRM/osrm-backend/pull/5060)
|
||||
- CHANGED: Use Grisu2 for serializing floating point numbers. [#5188](https://github.com/Project-OSRM/osrm-backend/pull/5188)
|
||||
- ADDED: Node bindings can return pre-rendered JSON buffer. [#5189](https://github.com/Project-OSRM/osrm-backend/pull/5189)
|
||||
- Bugfixes:
|
||||
- FIXED: collapsing of ExitRoundabout instructions [#5114](https://github.com/Project-OSRM/osrm-backend/issues/5114)
|
||||
- FIXED: negative distances in table plugin annotation [#5106](https://github.com/Project-OSRM/osrm-backend/issues/5106)
|
||||
- Misc:
|
||||
- CHANGED: Support up to 512 named shared memory regions [#5185](https://github.com/Project-OSRM/osrm-backend/pull/5185)
|
||||
|
||||
|
||||
@@ -297,29 +297,6 @@ Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refer
|
||||
2) `waypoint_index`: index of the point in the trip.
|
||||
**`trips`**: an array of [`Route`](#route) objects that assemble the trace.
|
||||
|
||||
## Plugin behaviour
|
||||
|
||||
All plugins support a second additional object that is available to configure some NodeJS specific behaviours.
|
||||
|
||||
- `plugin_config` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object literal containing parameters for the trip query.
|
||||
- `plugin_config.format` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** The format of the result object to various API calls. Valid options are `object` (default), which returns a standard Javascript object, as described above, and `json_buffer`, which will return a NodeJS **[Buffer](https://nodejs.org/api/buffer.html)** object, containing a JSON string. The latter has the advantage that it can be immediately serialized to disk/sent over the network, and the generation of the string is performed outside the main NodeJS event loop. This option is ignored by the `tile` plugin.
|
||||
|
||||
**Examples**
|
||||
|
||||
```javascript
|
||||
var osrm = new OSRM('network.osrm');
|
||||
var options = {
|
||||
coordinates: [
|
||||
[13.36761474609375, 52.51663871100423],
|
||||
[13.374481201171875, 52.506191342034576]
|
||||
]
|
||||
};
|
||||
osrm.route(options, { format: "json_buffer" }, function(err, response) {
|
||||
if (err) throw err;
|
||||
console.log(response.toString("utf-8"));
|
||||
});
|
||||
```
|
||||
|
||||
## Responses
|
||||
|
||||
Responses
|
||||
|
||||
@@ -792,4 +792,4 @@ Feature: Basic Map Matching
|
||||
When I match I should get
|
||||
| trace | geometry | a:distance | a:duration | a:weight | duration |
|
||||
| 2345 | 1.00018,1,1.000315,1 | 15.013264 | 1.5 | 1.5 | 1.5 |
|
||||
| 4321 | 1.00027,1,1.000135,1 | 15.013264 | 1.5 | 1.5 | 1.5 |
|
||||
| 4321 | 1.00027,1,1.000135,1 | 15.013264 | 1.5 | 1.5 | 1.5 |
|
||||
|
||||
@@ -449,6 +449,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
const auto reverse_durations = datafacade.GetUncompressedReverseDurations(geometry_id);
|
||||
|
||||
const auto forward_geometry = datafacade.GetUncompressedForwardGeometry(geometry_id);
|
||||
const auto reverse_geometry = datafacade.GetUncompressedReverseGeometry(geometry_id);
|
||||
|
||||
const auto forward_weight_offset =
|
||||
std::accumulate(forward_weights.begin(),
|
||||
@@ -479,19 +480,19 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
datafacade.GetCoordinateOfNode(forward_geometry(data.fwd_segment_position)),
|
||||
point_on_segment);
|
||||
|
||||
const auto reverse_weight_offset =
|
||||
std::accumulate(reverse_weights.begin(),
|
||||
reverse_weights.end() - data.fwd_segment_position - 1,
|
||||
EdgeWeight{0});
|
||||
const auto rev_segment_position = reverse_weights.size() - data.fwd_segment_position - 1;
|
||||
|
||||
const auto reverse_weight_offset = std::accumulate(
|
||||
reverse_weights.begin(), reverse_weights.begin() + rev_segment_position, EdgeWeight{0});
|
||||
|
||||
const auto reverse_duration_offset =
|
||||
std::accumulate(reverse_durations.begin(),
|
||||
reverse_durations.end() - data.fwd_segment_position - 1,
|
||||
reverse_durations.begin() + rev_segment_position,
|
||||
EdgeDuration{0});
|
||||
|
||||
EdgeDistance reverse_distance_offset = 0;
|
||||
for (auto current = forward_geometry.begin();
|
||||
current < forward_geometry.end() - data.fwd_segment_position - 2;
|
||||
for (auto current = reverse_geometry.begin();
|
||||
current < reverse_geometry.begin() + rev_segment_position;
|
||||
++current)
|
||||
{
|
||||
reverse_distance_offset += util::coordinate_calculation::fccApproximateDistance(
|
||||
@@ -499,13 +500,11 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
datafacade.GetCoordinateOfNode(*std::next(current)));
|
||||
}
|
||||
|
||||
EdgeWeight reverse_weight =
|
||||
reverse_weights[reverse_weights.size() - data.fwd_segment_position - 1];
|
||||
EdgeDuration reverse_duration =
|
||||
reverse_durations[reverse_durations.size() - data.fwd_segment_position - 1];
|
||||
EdgeWeight reverse_weight = reverse_weights[rev_segment_position];
|
||||
EdgeDuration reverse_duration = reverse_durations[rev_segment_position];
|
||||
EdgeDistance reverse_distance = util::coordinate_calculation::fccApproximateDistance(
|
||||
point_on_segment,
|
||||
datafacade.GetCoordinateOfNode(forward_geometry(data.fwd_segment_position + 1)));
|
||||
datafacade.GetCoordinateOfNode(reverse_geometry(rev_segment_position)));
|
||||
|
||||
ratio = std::min(1.0, std::max(0.0, ratio));
|
||||
if (data.forward_segment_id.id != SPECIAL_SEGMENTID)
|
||||
@@ -693,7 +692,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
const CoordinateList &coordinates;
|
||||
DataFacadeT &datafacade;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace engine
|
||||
} // namespace osrm
|
||||
|
||||
#endif
|
||||
|
||||
@@ -46,14 +46,15 @@ namespace engine
|
||||
struct PhantomNode
|
||||
{
|
||||
PhantomNode()
|
||||
: forward_segment_id{SPECIAL_SEGMENTID, false},
|
||||
reverse_segment_id{SPECIAL_SEGMENTID, false}, forward_weight(INVALID_EDGE_WEIGHT),
|
||||
reverse_weight(INVALID_EDGE_WEIGHT), forward_weight_offset(0), reverse_weight_offset(0),
|
||||
: forward_segment_id{SPECIAL_SEGMENTID, false}, reverse_segment_id{SPECIAL_SEGMENTID,
|
||||
false},
|
||||
forward_weight(INVALID_EDGE_WEIGHT), reverse_weight(INVALID_EDGE_WEIGHT),
|
||||
forward_weight_offset(0), reverse_weight_offset(0),
|
||||
forward_distance(INVALID_EDGE_DISTANCE), reverse_distance(INVALID_EDGE_DISTANCE),
|
||||
forward_distance_offset(0), reverse_distance_offset(0),
|
||||
forward_duration(MAXIMAL_EDGE_DURATION), reverse_duration(MAXIMAL_EDGE_DURATION),
|
||||
forward_duration_offset(0), reverse_duration_offset(0), fwd_segment_position(0),
|
||||
is_valid_forward_source{false}, is_valid_forward_target{false},
|
||||
forward_duration_offset(0), reverse_duration_offset(0),
|
||||
fwd_segment_position(0), is_valid_forward_source{false}, is_valid_forward_target{false},
|
||||
is_valid_reverse_source{false}, is_valid_reverse_target{false}, bearing(0)
|
||||
|
||||
{
|
||||
@@ -111,8 +112,9 @@ struct PhantomNode
|
||||
|
||||
bool IsValid(const unsigned number_of_nodes) const
|
||||
{
|
||||
return location.IsValid() && ((forward_segment_id.id < number_of_nodes) ||
|
||||
(reverse_segment_id.id < number_of_nodes)) &&
|
||||
return location.IsValid() &&
|
||||
((forward_segment_id.id < number_of_nodes) ||
|
||||
(reverse_segment_id.id < number_of_nodes)) &&
|
||||
((forward_weight != INVALID_EDGE_WEIGHT) ||
|
||||
(reverse_weight != INVALID_EDGE_WEIGHT)) &&
|
||||
((forward_duration != MAXIMAL_EDGE_DURATION) ||
|
||||
|
||||
@@ -44,44 +44,13 @@ bool needsLoopBackwards(const PhantomNode &source_phantom, const PhantomNode &ta
|
||||
bool needsLoopForward(const PhantomNodes &phantoms);
|
||||
bool needsLoopBackwards(const PhantomNodes &phantoms);
|
||||
|
||||
template <typename Heap>
|
||||
void insertNodesInHeaps(Heap &forward_heap, Heap &reverse_heap, const PhantomNodes &nodes)
|
||||
namespace detail
|
||||
{
|
||||
const auto &source = nodes.source_phantom;
|
||||
if (source.IsValidForwardSource())
|
||||
{
|
||||
forward_heap.Insert(source.forward_segment_id.id,
|
||||
-source.GetForwardWeightPlusOffset(),
|
||||
source.forward_segment_id.id);
|
||||
}
|
||||
|
||||
if (source.IsValidReverseSource())
|
||||
{
|
||||
forward_heap.Insert(source.reverse_segment_id.id,
|
||||
-source.GetReverseWeightPlusOffset(),
|
||||
source.reverse_segment_id.id);
|
||||
}
|
||||
|
||||
const auto &target = nodes.target_phantom;
|
||||
if (target.IsValidForwardTarget())
|
||||
{
|
||||
reverse_heap.Insert(target.forward_segment_id.id,
|
||||
target.GetForwardWeightPlusOffset(),
|
||||
target.forward_segment_id.id);
|
||||
}
|
||||
|
||||
if (target.IsValidReverseTarget())
|
||||
{
|
||||
reverse_heap.Insert(target.reverse_segment_id.id,
|
||||
target.GetReverseWeightPlusOffset(),
|
||||
target.reverse_segment_id.id);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename ManyToManyQueryHeap>
|
||||
void insertSourceInHeap(ManyToManyQueryHeap &heap, const PhantomNode &phantom_node)
|
||||
template <typename Algorithm>
|
||||
void insertSourceInHeap(typename SearchEngineData<Algorithm>::ManyToManyQueryHeap &heap,
|
||||
const PhantomNode &phantom_node)
|
||||
{
|
||||
if (phantom_node.IsValidForwardSource())
|
||||
if (phantom_node.IsValidForwardTarget())
|
||||
{
|
||||
heap.Insert(phantom_node.forward_segment_id.id,
|
||||
-phantom_node.GetForwardWeightPlusOffset(),
|
||||
@@ -89,7 +58,7 @@ void insertSourceInHeap(ManyToManyQueryHeap &heap, const PhantomNode &phantom_no
|
||||
-phantom_node.GetForwardDuration(),
|
||||
-phantom_node.GetForwardDistance()});
|
||||
}
|
||||
if (phantom_node.IsValidReverseSource())
|
||||
if (phantom_node.IsValidReverseTarget())
|
||||
{
|
||||
heap.Insert(phantom_node.reverse_segment_id.id,
|
||||
-phantom_node.GetReverseWeightPlusOffset(),
|
||||
@@ -99,8 +68,9 @@ void insertSourceInHeap(ManyToManyQueryHeap &heap, const PhantomNode &phantom_no
|
||||
}
|
||||
}
|
||||
|
||||
template <typename ManyToManyQueryHeap>
|
||||
void insertTargetInHeap(ManyToManyQueryHeap &heap, const PhantomNode &phantom_node)
|
||||
template <typename Algorithm>
|
||||
void insertTargetInHeap(typename SearchEngineData<Algorithm>::ManyToManyQueryHeap &heap,
|
||||
const PhantomNode &phantom_node)
|
||||
{
|
||||
if (phantom_node.IsValidForwardTarget())
|
||||
{
|
||||
@@ -120,6 +90,109 @@ void insertTargetInHeap(ManyToManyQueryHeap &heap, const PhantomNode &phantom_no
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Algorithm>
|
||||
void insertSourceInHeap(typename SearchEngineData<Algorithm>::QueryHeap &heap,
|
||||
const PhantomNode &phantom_node)
|
||||
{
|
||||
if (phantom_node.IsValidForwardSource())
|
||||
{
|
||||
heap.Insert(phantom_node.forward_segment_id.id,
|
||||
-phantom_node.GetForwardWeightPlusOffset(),
|
||||
phantom_node.forward_segment_id.id);
|
||||
}
|
||||
if (phantom_node.IsValidReverseSource())
|
||||
{
|
||||
heap.Insert(phantom_node.reverse_segment_id.id,
|
||||
-phantom_node.GetReverseWeightPlusOffset(),
|
||||
phantom_node.reverse_segment_id.id);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Algorithm>
|
||||
void insertTargetInHeap(typename SearchEngineData<Algorithm>::QueryHeap &heap,
|
||||
const PhantomNode &phantom_node)
|
||||
{
|
||||
if (phantom_node.IsValidForwardTarget())
|
||||
{
|
||||
heap.Insert(phantom_node.forward_segment_id.id,
|
||||
phantom_node.GetForwardWeightPlusOffset(),
|
||||
phantom_node.forward_segment_id.id);
|
||||
}
|
||||
if (phantom_node.IsValidReverseTarget())
|
||||
{
|
||||
heap.Insert(phantom_node.reverse_segment_id.id,
|
||||
phantom_node.GetReverseWeightPlusOffset(),
|
||||
phantom_node.reverse_segment_id.id);
|
||||
}
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
inline void insertTargetInHeap(typename SearchEngineData<mld::Algorithm>::ManyToManyQueryHeap &heap,
|
||||
const PhantomNode &phantom_node)
|
||||
{
|
||||
detail::insertTargetInHeap<mld::Algorithm>(heap, phantom_node);
|
||||
}
|
||||
inline void insertTargetInHeap(typename SearchEngineData<ch::Algorithm>::ManyToManyQueryHeap &heap,
|
||||
const PhantomNode &phantom_node)
|
||||
{
|
||||
detail::insertTargetInHeap<ch::Algorithm>(heap, phantom_node);
|
||||
}
|
||||
inline void insertTargetInHeap(typename SearchEngineData<mld::Algorithm>::QueryHeap &heap,
|
||||
const PhantomNode &phantom_node)
|
||||
{
|
||||
detail::insertTargetInHeap<mld::Algorithm>(heap, phantom_node);
|
||||
}
|
||||
inline void insertTargetInHeap(typename SearchEngineData<ch::Algorithm>::QueryHeap &heap,
|
||||
const PhantomNode &phantom_node)
|
||||
{
|
||||
detail::insertTargetInHeap<ch::Algorithm>(heap, phantom_node);
|
||||
}
|
||||
inline void insertSourceInHeap(typename SearchEngineData<mld::Algorithm>::ManyToManyQueryHeap &heap,
|
||||
const PhantomNode &phantom_node)
|
||||
{
|
||||
detail::insertSourceInHeap<mld::Algorithm>(heap, phantom_node);
|
||||
}
|
||||
inline void insertSourceInHeap(typename SearchEngineData<ch::Algorithm>::ManyToManyQueryHeap &heap,
|
||||
const PhantomNode &phantom_node)
|
||||
{
|
||||
detail::insertSourceInHeap<ch::Algorithm>(heap, phantom_node);
|
||||
}
|
||||
inline void insertSourceInHeap(typename SearchEngineData<mld::Algorithm>::QueryHeap &heap,
|
||||
const PhantomNode &phantom_node)
|
||||
{
|
||||
detail::insertSourceInHeap<mld::Algorithm>(heap, phantom_node);
|
||||
}
|
||||
inline void insertSourceInHeap(typename SearchEngineData<ch::Algorithm>::QueryHeap &heap,
|
||||
const PhantomNode &phantom_node)
|
||||
{
|
||||
detail::insertSourceInHeap<ch::Algorithm>(heap, phantom_node);
|
||||
}
|
||||
|
||||
template <typename Heap>
|
||||
void insertNodesInHeaps(Heap &forward_heap, Heap &reverse_heap, const PhantomNodes &nodes)
|
||||
{
|
||||
insertSourceInHeap(forward_heap, nodes.source_phantom);
|
||||
insertTargetInHeap(reverse_heap, nodes.target_phantom);
|
||||
}
|
||||
|
||||
template <typename Algorithm>
|
||||
void insertSourceInHeap(typename SearchEngineData<Algorithm>::ManyToManyQueryHeap &heap,
|
||||
const PhantomNode &phantom_node)
|
||||
{
|
||||
if (phantom_node.IsValidForwardSource())
|
||||
{
|
||||
heap.Insert(phantom_node.forward_segment_id.id,
|
||||
-phantom_node.GetForwardWeightPlusOffset(),
|
||||
{phantom_node.forward_segment_id.id, -phantom_node.GetForwardDuration()});
|
||||
}
|
||||
if (phantom_node.IsValidReverseSource())
|
||||
{
|
||||
heap.Insert(phantom_node.reverse_segment_id.id,
|
||||
-phantom_node.GetReverseWeightPlusOffset(),
|
||||
{phantom_node.reverse_segment_id.id, -phantom_node.GetReverseDuration()});
|
||||
}
|
||||
}
|
||||
|
||||
template <typename FacadeT>
|
||||
void annotatePath(const FacadeT &facade,
|
||||
const PhantomNodes &phantom_node_pair,
|
||||
@@ -329,58 +402,10 @@ void annotatePath(const FacadeT &facade,
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Algorithm>
|
||||
double getPathDistance(const DataFacade<Algorithm> &facade,
|
||||
const std::vector<PathData> unpacked_path,
|
||||
const PhantomNode &source_phantom,
|
||||
const PhantomNode &target_phantom)
|
||||
{
|
||||
using util::coordinate_calculation::detail::DEGREE_TO_RAD;
|
||||
using util::coordinate_calculation::detail::EARTH_RADIUS;
|
||||
|
||||
double distance = 0;
|
||||
double prev_lat =
|
||||
static_cast<double>(util::toFloating(source_phantom.location.lat)) * DEGREE_TO_RAD;
|
||||
double prev_lon =
|
||||
static_cast<double>(util::toFloating(source_phantom.location.lon)) * DEGREE_TO_RAD;
|
||||
double prev_cos = std::cos(prev_lat);
|
||||
for (const auto &p : unpacked_path)
|
||||
{
|
||||
const auto current_coordinate = facade.GetCoordinateOfNode(p.turn_via_node);
|
||||
|
||||
const double current_lat =
|
||||
static_cast<double>(util::toFloating(current_coordinate.lat)) * DEGREE_TO_RAD;
|
||||
const double current_lon =
|
||||
static_cast<double>(util::toFloating(current_coordinate.lon)) * DEGREE_TO_RAD;
|
||||
const double current_cos = std::cos(current_lat);
|
||||
|
||||
const double sin_dlon = std::sin((prev_lon - current_lon) / 2.0);
|
||||
const double sin_dlat = std::sin((prev_lat - current_lat) / 2.0);
|
||||
|
||||
const double aharv = sin_dlat * sin_dlat + prev_cos * current_cos * sin_dlon * sin_dlon;
|
||||
const double charv = 2. * std::atan2(std::sqrt(aharv), std::sqrt(1.0 - aharv));
|
||||
distance += EARTH_RADIUS * charv;
|
||||
|
||||
prev_lat = current_lat;
|
||||
prev_lon = current_lon;
|
||||
prev_cos = current_cos;
|
||||
}
|
||||
|
||||
const double current_lat =
|
||||
static_cast<double>(util::toFloating(target_phantom.location.lat)) * DEGREE_TO_RAD;
|
||||
const double current_lon =
|
||||
static_cast<double>(util::toFloating(target_phantom.location.lon)) * DEGREE_TO_RAD;
|
||||
const double current_cos = std::cos(current_lat);
|
||||
|
||||
const double sin_dlon = std::sin((prev_lon - current_lon) / 2.0);
|
||||
const double sin_dlat = std::sin((prev_lat - current_lat) / 2.0);
|
||||
|
||||
const double aharv = sin_dlat * sin_dlat + prev_cos * current_cos * sin_dlon * sin_dlon;
|
||||
const double charv = 2. * std::atan2(std::sqrt(aharv), std::sqrt(1.0 - aharv));
|
||||
distance += EARTH_RADIUS * charv;
|
||||
|
||||
return distance;
|
||||
}
|
||||
EdgeDistance adjustPathDistanceToPhantomNodes(const std::vector<NodeID> &path,
|
||||
const PhantomNode &source_phantom,
|
||||
const PhantomNode &target_phantom,
|
||||
const EdgeDistance distance);
|
||||
|
||||
template <typename AlgorithmT>
|
||||
InternalRouteResult extractRoute(const DataFacade<AlgorithmT> &facade,
|
||||
|
||||
@@ -186,7 +186,7 @@ void routingStep(const DataFacade<Algorithm> &facade,
|
||||
}
|
||||
|
||||
template <bool UseDuration>
|
||||
std::tuple<EdgeWeight, EdgeDistance> getLoopWeight(const DataFacade<Algorithm> &facade, NodeID node)
|
||||
std::tuple<EdgeWeight,EdgeDistance> getLoopWeight(const DataFacade<Algorithm> &facade, NodeID node)
|
||||
{
|
||||
EdgeWeight loop_weight = UseDuration ? MAXIMAL_EDGE_DURATION : INVALID_EDGE_WEIGHT;
|
||||
EdgeDistance loop_distance = MAXIMAL_EDGE_DISTANCE;
|
||||
|
||||
@@ -97,7 +97,6 @@ inline LevelID getNodeQueryLevel(const MultiLevelPartition &partition,
|
||||
const std::vector<std::size_t> &phantom_indices)
|
||||
{
|
||||
auto min_level = [&partition, node](const PhantomNode &phantom_node) {
|
||||
|
||||
const auto &forward_segment = phantom_node.forward_segment_id;
|
||||
const auto forward_level =
|
||||
forward_segment.enabled ? partition.GetHighestDifferentLevel(node, forward_segment.id)
|
||||
@@ -120,7 +119,7 @@ inline LevelID getNodeQueryLevel(const MultiLevelPartition &partition,
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// Heaps only record for each node its predecessor ("parent") on the shortest path.
|
||||
// For re-constructing the actual path we need to trace back all parent "pointers".
|
||||
@@ -391,21 +390,27 @@ UnpackedPath search(SearchEngineData<Algorithm> &engine_working_data,
|
||||
EdgeWeight weight_upper_bound,
|
||||
Args... args)
|
||||
{
|
||||
if (forward_heap.Empty() || reverse_heap.Empty())
|
||||
if (forward_heap.Empty() && reverse_heap.Empty())
|
||||
{
|
||||
return std::make_tuple(INVALID_EDGE_WEIGHT, std::vector<NodeID>(), std::vector<EdgeID>());
|
||||
}
|
||||
|
||||
const auto &partition = facade.GetMultiLevelPartition();
|
||||
|
||||
BOOST_ASSERT(!forward_heap.Empty() && forward_heap.MinKey() < INVALID_EDGE_WEIGHT);
|
||||
BOOST_ASSERT(!reverse_heap.Empty() && reverse_heap.MinKey() < INVALID_EDGE_WEIGHT);
|
||||
BOOST_ASSERT(forward_heap.Empty() || forward_heap.MinKey() < INVALID_EDGE_WEIGHT);
|
||||
BOOST_ASSERT(reverse_heap.Empty() || reverse_heap.MinKey() < INVALID_EDGE_WEIGHT);
|
||||
|
||||
// run two-Target Dijkstra routing step.
|
||||
NodeID middle = SPECIAL_NODEID;
|
||||
EdgeWeight weight = weight_upper_bound;
|
||||
EdgeWeight forward_heap_min = forward_heap.MinKey();
|
||||
EdgeWeight reverse_heap_min = reverse_heap.MinKey();
|
||||
|
||||
EdgeWeight forward_heap_min = 0;
|
||||
if (!forward_heap.Empty())
|
||||
forward_heap_min = forward_heap.MinKey();
|
||||
EdgeWeight reverse_heap_min = 0;
|
||||
if (!reverse_heap.Empty())
|
||||
reverse_heap_min = reverse_heap.MinKey();
|
||||
|
||||
while (forward_heap.Size() + reverse_heap.Size() > 0 &&
|
||||
forward_heap_min + reverse_heap_min < weight)
|
||||
{
|
||||
@@ -657,11 +662,7 @@ double getNetworkDistance(SearchEngineData<Algorithm> &engine_working_data,
|
||||
const PhantomNode &target_phantom,
|
||||
EdgeWeight weight_upper_bound = INVALID_EDGE_WEIGHT)
|
||||
{
|
||||
forward_heap.Clear();
|
||||
reverse_heap.Clear();
|
||||
|
||||
const PhantomNodes phantom_nodes{source_phantom, target_phantom};
|
||||
insertNodesInHeaps(forward_heap, reverse_heap, phantom_nodes);
|
||||
|
||||
EdgeWeight weight = INVALID_EDGE_WEIGHT;
|
||||
std::vector<NodeID> unpacked_nodes;
|
||||
@@ -680,11 +681,22 @@ double getNetworkDistance(SearchEngineData<Algorithm> &engine_working_data,
|
||||
return std::numeric_limits<double>::max();
|
||||
}
|
||||
|
||||
std::vector<PathData> unpacked_path;
|
||||
EdgeDistance distance = 0;
|
||||
|
||||
annotatePath(facade, phantom_nodes, unpacked_nodes, unpacked_edges, unpacked_path);
|
||||
if (!unpacked_nodes.empty())
|
||||
{
|
||||
distance = std::accumulate(unpacked_nodes.begin(),
|
||||
std::prev(unpacked_nodes.end()),
|
||||
EdgeDistance{0},
|
||||
[&](const EdgeDistance distance, const auto node_id) {
|
||||
return distance + computeEdgeDistance(facade, node_id);
|
||||
});
|
||||
}
|
||||
|
||||
return getPathDistance(facade, unpacked_path, source_phantom, target_phantom);
|
||||
distance = adjustPathDistanceToPhantomNodes(
|
||||
unpacked_nodes, phantom_nodes.source_phantom, phantom_nodes.target_phantom, distance);
|
||||
|
||||
return distance;
|
||||
}
|
||||
|
||||
} // namespace mld
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define OSRM_BINDINGS_NODE_SUPPORT_HPP
|
||||
|
||||
#include "nodejs/json_v8_renderer.hpp"
|
||||
#include "util/json_renderer.hpp"
|
||||
|
||||
#include "osrm/approach.hpp"
|
||||
#include "osrm/bearing.hpp"
|
||||
@@ -25,7 +24,6 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -44,13 +42,6 @@ using match_parameters_ptr = std::unique_ptr<osrm::MatchParameters>;
|
||||
using nearest_parameters_ptr = std::unique_ptr<osrm::NearestParameters>;
|
||||
using table_parameters_ptr = std::unique_ptr<osrm::TableParameters>;
|
||||
|
||||
struct PluginParameters
|
||||
{
|
||||
bool renderJSONToBuffer = false;
|
||||
};
|
||||
|
||||
using ObjectOrString = typename mapbox::util::variant<osrm::json::Object, std::string>;
|
||||
|
||||
template <typename ResultT> inline v8::Local<v8::Value> render(const ResultT &result);
|
||||
|
||||
template <> v8::Local<v8::Value> inline render(const std::string &result)
|
||||
@@ -58,21 +49,11 @@ template <> v8::Local<v8::Value> inline render(const std::string &result)
|
||||
return Nan::CopyBuffer(result.data(), result.size()).ToLocalChecked();
|
||||
}
|
||||
|
||||
template <> v8::Local<v8::Value> inline render(const ObjectOrString &result)
|
||||
template <> v8::Local<v8::Value> inline render(const osrm::json::Object &result)
|
||||
{
|
||||
if (result.is<osrm::json::Object>())
|
||||
{
|
||||
// Convert osrm::json object tree into matching v8 object tree
|
||||
v8::Local<v8::Value> value;
|
||||
renderToV8(value, result.get<osrm::json::Object>());
|
||||
return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Return the string object as a node Buffer
|
||||
return Nan::CopyBuffer(result.get<std::string>().data(), result.get<std::string>().size())
|
||||
.ToLocalChecked();
|
||||
}
|
||||
v8::Local<v8::Value> value;
|
||||
renderToV8(value, result);
|
||||
return value;
|
||||
}
|
||||
|
||||
inline void ParseResult(const osrm::Status &result_status, osrm::json::Object &result)
|
||||
@@ -833,50 +814,6 @@ inline bool parseCommonParameters(const v8::Local<v8::Object> &obj, ParamType &p
|
||||
return true;
|
||||
}
|
||||
|
||||
inline PluginParameters
|
||||
argumentsToPluginParameters(const Nan::FunctionCallbackInfo<v8::Value> &args)
|
||||
{
|
||||
if (args.Length() < 3 || !args[1]->IsObject())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
v8::Local<v8::Object> obj = Nan::To<v8::Object>(args[1]).ToLocalChecked();
|
||||
if (obj->Has(Nan::New("format").ToLocalChecked()))
|
||||
{
|
||||
|
||||
v8::Local<v8::Value> format = obj->Get(Nan::New("format").ToLocalChecked());
|
||||
if (format.IsEmpty())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!format->IsString())
|
||||
{
|
||||
Nan::ThrowError("format must be a string: \"object\" or \"json_buffer\"");
|
||||
return {};
|
||||
}
|
||||
|
||||
const Nan::Utf8String format_utf8str(format);
|
||||
std::string format_str{*format_utf8str, *format_utf8str + format_utf8str.length()};
|
||||
|
||||
if (format_str == "object")
|
||||
{
|
||||
return {false};
|
||||
}
|
||||
else if (format_str == "json_buffer")
|
||||
{
|
||||
return {true};
|
||||
}
|
||||
else
|
||||
{
|
||||
Nan::ThrowError("format must be a string: \"object\" or \"json_buffer\"");
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
inline route_parameters_ptr
|
||||
argumentsToRouteParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
|
||||
bool requires_multiple_coordinates)
|
||||
@@ -1420,6 +1357,6 @@ argumentsToMatchParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
|
||||
return params;
|
||||
}
|
||||
|
||||
} // namespace node_osrm
|
||||
} // ns node_osrm
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,9 +23,6 @@ namespace detail
|
||||
{
|
||||
const constexpr double DEGREE_TO_RAD = 0.017453292519943295769236907684886;
|
||||
const constexpr double RAD_TO_DEGREE = 1. / DEGREE_TO_RAD;
|
||||
// earth radius varies between 6,356.750-6,378.135 km (3,949.901-3,963.189mi)
|
||||
// The IUGG value for the equatorial radius is 6378.137 km (3963.19 miles)
|
||||
const constexpr long double EARTH_RADIUS = 6372797.560856;
|
||||
|
||||
inline double degToRad(const double degree)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include <tbb/parallel_sort.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
@@ -88,13 +87,9 @@ NodeBasedDynamicGraphFromEdges(NodeID number_of_nodes,
|
||||
output_edge.data.flags = input_edge.flags;
|
||||
output_edge.data.annotation_data = input_edge.annotation_data;
|
||||
|
||||
BOOST_ASSERT(output_edge.data.weight >= 0);
|
||||
BOOST_ASSERT(output_edge.data.duration >= 0);
|
||||
if (output_edge.data.distance <= 0)
|
||||
{
|
||||
std::cout << "output_edge.data.distance " << output_edge.data.distance << std::endl;
|
||||
}
|
||||
BOOST_ASSERT(output_edge.data.distance >= 0);
|
||||
BOOST_ASSERT(output_edge.data.weight > 0);
|
||||
BOOST_ASSERT(output_edge.data.duration > 0);
|
||||
BOOST_ASSERT(output_edge.data.distance > 0);
|
||||
});
|
||||
|
||||
tbb::parallel_sort(edges_list.begin(), edges_list.end());
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "osrm",
|
||||
"version": "5.20.0-alpha.2",
|
||||
"version": "5.20.0-alpha.1",
|
||||
"private": false,
|
||||
"description": "The Open Source Routing Machine is a high performance routing engine written in C++14 designed to run on OpenStreetMap data.",
|
||||
"dependencies": {
|
||||
@@ -18,7 +18,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "node ./node_modules/eslint/bin/eslint.js -c ./.eslintrc features/step_definitions/ features/support/",
|
||||
"test": "npm run lint && node ./node_modules/cucumber/bin/cucumber.js features/ -p verify",
|
||||
"test": "npm run lint && node ./node_modules/cucumber/bin/cucumber.js features/ -p verify && node ./node_modules/cucumber/bin/cucumber.js features/ -p mld",
|
||||
"clean": "rm -rf test/cache",
|
||||
"docs": "./scripts/build_api_docs.sh",
|
||||
"install": "node-pre-gyp install --fallback-to-build=false || ./scripts/node_install.sh",
|
||||
|
||||
@@ -254,74 +254,12 @@ void calculateDistances(typename SearchEngineData<ch::Algorithm>::ManyToManyQuer
|
||||
}
|
||||
if (!packed_leg.empty())
|
||||
{
|
||||
auto annotation =
|
||||
EdgeDistance annotation =
|
||||
ch::calculateEBGNodeAnnotations(facade, packed_leg.begin(), packed_leg.end());
|
||||
annotation = adjustPathDistanceToPhantomNodes(
|
||||
packed_leg, source_phantom, target_phantom, annotation);
|
||||
|
||||
distances_table[row_index * number_of_targets + column_index] = annotation;
|
||||
|
||||
// check the direction of travel to figure out how to calculate the offset to/from
|
||||
// the source/target
|
||||
if (source_phantom.forward_segment_id.id == packed_leg.front())
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0 to 3
|
||||
// -->s <-- subtract offset to start at source
|
||||
// ......... <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
EdgeDistance offset = source_phantom.GetForwardDistance();
|
||||
distances_table[row_index * number_of_targets + column_index] -= offset;
|
||||
}
|
||||
else if (source_phantom.reverse_segment_id.id == packed_leg.front())
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0 to 3
|
||||
// s<------- <-- subtract offset to start at source
|
||||
// ... <-- want this distance
|
||||
// entry 0---1---2---3 <-- 3 is exit node
|
||||
EdgeDistance offset = source_phantom.GetReverseDistance();
|
||||
distances_table[row_index * number_of_targets + column_index] -= offset;
|
||||
}
|
||||
if (target_phantom.forward_segment_id.id == packed_leg.back())
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0 to 3
|
||||
// ++>t <-- add offset to get to target
|
||||
// ................ <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
EdgeDistance offset = target_phantom.GetForwardDistance();
|
||||
distances_table[row_index * number_of_targets + column_index] += offset;
|
||||
}
|
||||
else if (target_phantom.reverse_segment_id.id == packed_leg.back())
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0 to 3
|
||||
// <++t <-- add offset to get from target
|
||||
// ................ <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
EdgeDistance offset = target_phantom.GetReverseDistance();
|
||||
distances_table[row_index * number_of_targets + column_index] += offset;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// there is no shortcut to unpack. source and target are on the same EBG Node.
|
||||
// if the offset of the target is greater than the offset of the source, subtract it
|
||||
if (target_phantom.GetForwardDistance() > source_phantom.GetForwardDistance())
|
||||
{
|
||||
// --------->t <-- offsets
|
||||
// ->s <-- subtract source offset from target offset
|
||||
// ......... <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
EdgeDistance offset =
|
||||
target_phantom.GetForwardDistance() - source_phantom.GetForwardDistance();
|
||||
distances_table[row_index * number_of_targets + column_index] = offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
// s<--- <-- offsets
|
||||
// t<--------- <-- subtract source offset from target offset
|
||||
// ...... <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
EdgeDistance offset =
|
||||
target_phantom.GetReverseDistance() - source_phantom.GetReverseDistance();
|
||||
distances_table[row_index * number_of_targets + column_index] = offset;
|
||||
}
|
||||
}
|
||||
packed_leg.clear();
|
||||
}
|
||||
|
||||
@@ -227,6 +227,9 @@ SubMatchingList mapMatching(SearchEngineData<Algorithm> &engine_working_data,
|
||||
{
|
||||
continue;
|
||||
}
|
||||
forward_heap.Clear();
|
||||
const auto &source_phantom = prev_unbroken_timestamps_list[s].phantom_node;
|
||||
insertSourceInHeap(forward_heap, source_phantom);
|
||||
|
||||
for (const auto s_prime : util::irange<std::size_t>(0UL, current_viterbi.size()))
|
||||
{
|
||||
@@ -237,14 +240,19 @@ SubMatchingList mapMatching(SearchEngineData<Algorithm> &engine_working_data,
|
||||
continue;
|
||||
}
|
||||
|
||||
double network_distance =
|
||||
getNetworkDistance(engine_working_data,
|
||||
facade,
|
||||
forward_heap,
|
||||
reverse_heap,
|
||||
prev_unbroken_timestamps_list[s].phantom_node,
|
||||
current_timestamps_list[s_prime].phantom_node,
|
||||
weight_upper_bound);
|
||||
reverse_heap.Clear();
|
||||
const auto &target_phantom = current_timestamps_list[s_prime].phantom_node;
|
||||
insertTargetInHeap(reverse_heap, target_phantom);
|
||||
|
||||
double network_distance = getNetworkDistance(engine_working_data,
|
||||
facade,
|
||||
forward_heap,
|
||||
reverse_heap,
|
||||
source_phantom,
|
||||
target_phantom,
|
||||
weight_upper_bound);
|
||||
|
||||
network_distance = std::round(network_distance * 10) / 10;
|
||||
|
||||
// get distance diff between loc1/2 and locs/s_prime
|
||||
const auto d_t = std::abs(network_distance - haversine_distance);
|
||||
|
||||
@@ -33,6 +33,79 @@ bool needsLoopBackwards(const PhantomNodes &phantoms)
|
||||
return needsLoopBackwards(phantoms.source_phantom, phantoms.target_phantom);
|
||||
}
|
||||
|
||||
EdgeDistance adjustPathDistanceToPhantomNodes(const std::vector<NodeID> &path,
|
||||
const PhantomNode &source_phantom,
|
||||
const PhantomNode &target_phantom,
|
||||
const EdgeDistance uncorrected_distance)
|
||||
{
|
||||
EdgeDistance distance = uncorrected_distance;
|
||||
if (!path.empty())
|
||||
{
|
||||
|
||||
// check the direction of travel to figure out how to calculate the offset to/from
|
||||
// the source/target
|
||||
if (source_phantom.forward_segment_id.id == path.front())
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0 to 3
|
||||
// -->s <-- subtract offset to start at source
|
||||
// ......... <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
distance -= source_phantom.GetForwardDistance();
|
||||
}
|
||||
else if (source_phantom.reverse_segment_id.id == path.front())
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0 to 3
|
||||
// s<------- <-- subtract offset to start at source
|
||||
// ... <-- want this distance
|
||||
// entry 0---1---2---3 <-- 3 is exit node
|
||||
distance -= source_phantom.GetReverseDistance();
|
||||
}
|
||||
if (target_phantom.forward_segment_id.id == path.back())
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0 to 3
|
||||
// ++>t <-- add offset to get to target
|
||||
// ................ <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
distance += target_phantom.GetForwardDistance();
|
||||
}
|
||||
else if (target_phantom.reverse_segment_id.id == path.back())
|
||||
{
|
||||
// ............ <-- calculateEGBAnnotation returns distance from 0 to 3
|
||||
// <++t <-- add offset to get from target
|
||||
// ................ <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
distance += target_phantom.GetReverseDistance();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// there is no shortcut to unpack. source and target are on the same EBG Node.
|
||||
// if the offset of the target is greater than the offset of the source, subtract it
|
||||
if (target_phantom.GetForwardDistance() > source_phantom.GetForwardDistance())
|
||||
{
|
||||
// --------->t <-- offsets
|
||||
// ->s <-- subtract source offset from target offset
|
||||
// ......... <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
distance = target_phantom.GetForwardDistance() - source_phantom.GetForwardDistance();
|
||||
}
|
||||
else
|
||||
{
|
||||
// s<--- <-- offsets
|
||||
// t<--------- <-- subtract source offset from target offset
|
||||
// ...... <-- want this distance as result
|
||||
// entry 0---1---2---3--- <-- 3 is exit node
|
||||
distance = target_phantom.GetReverseDistance() - source_phantom.GetReverseDistance();
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_ASSERT_MSG(distance >= 0 || distance > -1.0f,
|
||||
"Distance correction generated negative number");
|
||||
// guard against underflow errors caused by rounding
|
||||
distance = std::max(EdgeDistance{0}, distance);
|
||||
return distance;
|
||||
}
|
||||
|
||||
} // namespace routing_algorithms
|
||||
} // namespace engine
|
||||
} // namespace osrm
|
||||
|
||||
@@ -100,7 +100,7 @@ void search(SearchEngineData<Algorithm> & /*engine_working_data*/,
|
||||
const PhantomNodes & /*phantom_nodes*/,
|
||||
const EdgeWeight weight_upper_bound)
|
||||
{
|
||||
if (forward_heap.Empty() || reverse_heap.Empty())
|
||||
if (forward_heap.Empty() && reverse_heap.Empty())
|
||||
{
|
||||
weight = INVALID_EDGE_WEIGHT;
|
||||
return;
|
||||
@@ -110,10 +110,14 @@ void search(SearchEngineData<Algorithm> & /*engine_working_data*/,
|
||||
weight = weight_upper_bound;
|
||||
|
||||
// get offset to account for offsets on phantom nodes on compressed edges
|
||||
const auto min_edge_offset = std::min(0, forward_heap.MinKey());
|
||||
BOOST_ASSERT(min_edge_offset <= 0);
|
||||
EdgeWeight min_edge_offset = 0;
|
||||
if (forward_heap.Size() > 0)
|
||||
{
|
||||
min_edge_offset = std::min(min_edge_offset, forward_heap.MinKey());
|
||||
BOOST_ASSERT(min_edge_offset <= 0);
|
||||
}
|
||||
// we only every insert negative offsets for nodes in the forward heap
|
||||
BOOST_ASSERT(reverse_heap.MinKey() >= 0);
|
||||
BOOST_ASSERT(reverse_heap.Empty() || reverse_heap.MinKey() >= 0);
|
||||
|
||||
// run two-Target Dijkstra routing step.
|
||||
while (0 < (forward_heap.Size() + reverse_heap.Size()))
|
||||
@@ -176,11 +180,6 @@ double getNetworkDistance(SearchEngineData<Algorithm> &engine_working_data,
|
||||
const PhantomNode &target_phantom,
|
||||
EdgeWeight weight_upper_bound)
|
||||
{
|
||||
forward_heap.Clear();
|
||||
reverse_heap.Clear();
|
||||
|
||||
insertNodesInHeaps(forward_heap, reverse_heap, {source_phantom, target_phantom});
|
||||
|
||||
EdgeWeight weight = INVALID_EDGE_WEIGHT;
|
||||
std::vector<NodeID> packed_path;
|
||||
search(engine_working_data,
|
||||
@@ -199,14 +198,31 @@ double getNetworkDistance(SearchEngineData<Algorithm> &engine_working_data,
|
||||
return std::numeric_limits<double>::max();
|
||||
}
|
||||
|
||||
std::vector<PathData> unpacked_path;
|
||||
unpackPath(facade,
|
||||
packed_path.begin(),
|
||||
packed_path.end(),
|
||||
{source_phantom, target_phantom},
|
||||
unpacked_path);
|
||||
EdgeDistance distance = 0;
|
||||
|
||||
return getPathDistance(facade, unpacked_path, source_phantom, target_phantom);
|
||||
std::vector<NodeID> unpacked_nodes;
|
||||
unpacked_nodes.reserve(packed_path.size());
|
||||
if (!packed_path.empty())
|
||||
{
|
||||
unpacked_nodes.push_back(packed_path.front());
|
||||
unpackPath(
|
||||
facade, packed_path.begin(), packed_path.end(), [&](const auto &edge, const auto &) {
|
||||
BOOST_ASSERT(edge.first == unpacked_nodes.back());
|
||||
unpacked_nodes.push_back(edge.second);
|
||||
});
|
||||
|
||||
distance = std::accumulate(unpacked_nodes.begin(),
|
||||
std::prev(unpacked_nodes.end()),
|
||||
EdgeDistance{0},
|
||||
[&](const EdgeDistance distance, const auto node_id) {
|
||||
return distance + computeEdgeDistance(facade, node_id);
|
||||
});
|
||||
}
|
||||
|
||||
distance =
|
||||
adjustPathDistanceToPhantomNodes(unpacked_nodes, source_phantom, target_phantom, distance);
|
||||
|
||||
return distance;
|
||||
}
|
||||
} // namespace ch
|
||||
|
||||
|
||||
@@ -555,21 +555,21 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
&scripting_environment,
|
||||
weight_multiplier,
|
||||
&conditional_restriction_map](
|
||||
// what nodes will be used? In most cases this will be the id
|
||||
// stored in the edge_data. In case of duplicated nodes (e.g.
|
||||
// due to via-way restrictions), one/both of these might
|
||||
// refer to a newly added edge based node
|
||||
const auto edge_based_node_from,
|
||||
const auto edge_based_node_to,
|
||||
// the situation of the turn
|
||||
const auto node_along_road_entering,
|
||||
const auto node_based_edge_from,
|
||||
const auto intersection_node,
|
||||
const auto node_based_edge_to,
|
||||
const auto &turn_angle,
|
||||
const auto &road_legs_on_the_right,
|
||||
const auto &road_legs_on_the_left,
|
||||
const auto &edge_geometries) {
|
||||
// what nodes will be used? In most cases this will be the id
|
||||
// stored in the edge_data. In case of duplicated nodes (e.g.
|
||||
// due to via-way restrictions), one/both of these might
|
||||
// refer to a newly added edge based node
|
||||
const auto edge_based_node_from,
|
||||
const auto edge_based_node_to,
|
||||
// the situation of the turn
|
||||
const auto node_along_road_entering,
|
||||
const auto node_based_edge_from,
|
||||
const auto intersection_node,
|
||||
const auto node_based_edge_to,
|
||||
const auto &turn_angle,
|
||||
const auto &road_legs_on_the_right,
|
||||
const auto &road_legs_on_the_left,
|
||||
const auto &edge_geometries) {
|
||||
const auto node_restricted =
|
||||
isRestricted(node_along_road_entering,
|
||||
intersection_node,
|
||||
@@ -890,7 +890,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
// TODO: this loop is not optimized - once we have a few
|
||||
// overrides available, we should index this for faster
|
||||
// lookups
|
||||
for (auto & override : unresolved_maneuver_overrides)
|
||||
for (auto &override : unresolved_maneuver_overrides)
|
||||
{
|
||||
for (auto &turn : override.turn_sequence)
|
||||
{
|
||||
|
||||
@@ -277,8 +277,8 @@ void ExtractionContainers::PrepareEdges(ScriptingEnvironment &scripting_environm
|
||||
{
|
||||
if (edge_iterator->result.osm_source_id < node_iterator->node_id)
|
||||
{
|
||||
util::Log(logDEBUG) << "Found invalid node reference "
|
||||
<< edge_iterator->result.source;
|
||||
util::Log(logDEBUG)
|
||||
<< "Found invalid node reference " << edge_iterator->result.source;
|
||||
edge_iterator->result.source = SPECIAL_NODEID;
|
||||
++edge_iterator;
|
||||
continue;
|
||||
@@ -1038,8 +1038,9 @@ void ExtractionContainers::PrepareRestrictions()
|
||||
// translate the turn from one segment onto another into a node restriction (the ways can
|
||||
// only
|
||||
// be connected at a single location)
|
||||
auto const get_node_restriction_from_OSM_ids = [&](
|
||||
auto const from_id, auto const to_id, const OSMNodeID via_node) {
|
||||
auto const get_node_restriction_from_OSM_ids = [&](auto const from_id,
|
||||
auto const to_id,
|
||||
const OSMNodeID via_node) {
|
||||
auto const from_segment_itr = referenced_ways.find(from_id);
|
||||
if (from_segment_itr->second.way_id != from_id)
|
||||
{
|
||||
|
||||
@@ -75,7 +75,7 @@ void ExtractorCallbacks::ProcessRestriction(const InputConditionalTurnRestrictio
|
||||
// util::Log() << restriction.toString();
|
||||
}
|
||||
|
||||
void ExtractorCallbacks::ProcessManeuverOverride(const InputManeuverOverride & override)
|
||||
void ExtractorCallbacks::ProcessManeuverOverride(const InputManeuverOverride &override)
|
||||
{
|
||||
external_memory.external_maneuver_overrides_list.push_back(override);
|
||||
}
|
||||
|
||||
@@ -185,17 +185,18 @@ void GraphCompressor::Compress(
|
||||
* just
|
||||
* like a barrier.
|
||||
*/
|
||||
const auto selectAnnotation = [&node_data_container](
|
||||
const AnnotationID front_annotation, const AnnotationID back_annotation) {
|
||||
// A lane has tags: u - (front) - v - (back) - w
|
||||
// During contraction, we keep only one of the tags. Usually the one closer
|
||||
// to the intersection is preferred. If its empty, however, we keep the
|
||||
// non-empty one
|
||||
if (node_data_container[back_annotation].lane_description_id ==
|
||||
INVALID_LANE_DESCRIPTIONID)
|
||||
return front_annotation;
|
||||
return back_annotation;
|
||||
};
|
||||
const auto selectAnnotation =
|
||||
[&node_data_container](const AnnotationID front_annotation,
|
||||
const AnnotationID back_annotation) {
|
||||
// A lane has tags: u - (front) - v - (back) - w
|
||||
// During contraction, we keep only one of the tags. Usually the one closer
|
||||
// to the intersection is preferred. If its empty, however, we keep the
|
||||
// non-empty one
|
||||
if (node_data_container[back_annotation].lane_description_id ==
|
||||
INVALID_LANE_DESCRIPTIONID)
|
||||
return front_annotation;
|
||||
return back_annotation;
|
||||
};
|
||||
|
||||
graph.GetEdgeData(forward_e1).annotation_data = selectAnnotation(
|
||||
fwd_edge_data1.annotation_data, fwd_edge_data2.annotation_data);
|
||||
|
||||
+11
-92
@@ -9,15 +9,12 @@
|
||||
#include "osrm/trip_parameters.hpp"
|
||||
|
||||
#include <exception>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "nodejs/node_osrm.hpp"
|
||||
#include "nodejs/node_osrm_support.hpp"
|
||||
|
||||
#include "util/json_renderer.hpp"
|
||||
|
||||
namespace node_osrm
|
||||
{
|
||||
|
||||
@@ -125,8 +122,6 @@ inline void async(const Nan::FunctionCallbackInfo<v8::Value> &info,
|
||||
if (!params)
|
||||
return;
|
||||
|
||||
auto pluginParams = argumentsToPluginParameters(info);
|
||||
|
||||
BOOST_ASSERT(params->IsValid());
|
||||
|
||||
if (!info[info.Length() - 1]->IsFunction())
|
||||
@@ -142,89 +137,9 @@ inline void async(const Nan::FunctionCallbackInfo<v8::Value> &info,
|
||||
Worker(std::shared_ptr<osrm::OSRM> osrm_,
|
||||
ParamPtr params_,
|
||||
ServiceMemFn service,
|
||||
Nan::Callback *callback,
|
||||
PluginParameters pluginParams_)
|
||||
Nan::Callback *callback)
|
||||
: Base(callback), osrm{std::move(osrm_)}, service{std::move(service)},
|
||||
params{std::move(params_)}, pluginParams{std::move(pluginParams_)}
|
||||
{
|
||||
}
|
||||
|
||||
void Execute() override try
|
||||
{
|
||||
osrm::json::Object r;
|
||||
const auto status = ((*osrm).*(service))(*params, r);
|
||||
ParseResult(status, r);
|
||||
if (pluginParams.renderJSONToBuffer)
|
||||
{
|
||||
std::ostringstream buf;
|
||||
osrm::util::json::render(buf, r);
|
||||
result = buf.str();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = r;
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
SetErrorMessage(e.what());
|
||||
}
|
||||
|
||||
void HandleOKCallback() override
|
||||
{
|
||||
Nan::HandleScope scope;
|
||||
|
||||
const constexpr auto argc = 2u;
|
||||
v8::Local<v8::Value> argv[argc] = {Nan::Null(), render(result)};
|
||||
|
||||
callback->Call(argc, argv);
|
||||
}
|
||||
|
||||
// Keeps the OSRM object alive even after shutdown until we're done with callback
|
||||
std::shared_ptr<osrm::OSRM> osrm;
|
||||
ServiceMemFn service;
|
||||
const ParamPtr params;
|
||||
const PluginParameters pluginParams;
|
||||
|
||||
ObjectOrString result;
|
||||
};
|
||||
|
||||
auto *callback = new Nan::Callback{info[info.Length() - 1].As<v8::Function>()};
|
||||
Nan::AsyncQueueWorker(
|
||||
new Worker{self->this_, std::move(params), service, callback, std::move(pluginParams)});
|
||||
}
|
||||
|
||||
template <typename ParameterParser, typename ServiceMemFn>
|
||||
inline void asyncForTiles(const Nan::FunctionCallbackInfo<v8::Value> &info,
|
||||
ParameterParser argsToParams,
|
||||
ServiceMemFn service,
|
||||
bool requires_multiple_coordinates)
|
||||
{
|
||||
auto params = argsToParams(info, requires_multiple_coordinates);
|
||||
if (!params)
|
||||
return;
|
||||
|
||||
auto pluginParams = argumentsToPluginParameters(info);
|
||||
|
||||
BOOST_ASSERT(params->IsValid());
|
||||
|
||||
if (!info[info.Length() - 1]->IsFunction())
|
||||
return Nan::ThrowTypeError("last argument must be a callback function");
|
||||
|
||||
auto *const self = Nan::ObjectWrap::Unwrap<Engine>(info.Holder());
|
||||
using ParamPtr = decltype(params);
|
||||
|
||||
struct Worker final : Nan::AsyncWorker
|
||||
{
|
||||
using Base = Nan::AsyncWorker;
|
||||
|
||||
Worker(std::shared_ptr<osrm::OSRM> osrm_,
|
||||
ParamPtr params_,
|
||||
ServiceMemFn service,
|
||||
Nan::Callback *callback,
|
||||
PluginParameters pluginParams_)
|
||||
: Base(callback), osrm{std::move(osrm_)}, service{std::move(service)},
|
||||
params{std::move(params_)}, pluginParams{std::move(pluginParams_)}
|
||||
params{std::move(params_)}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -252,14 +167,18 @@ inline void asyncForTiles(const Nan::FunctionCallbackInfo<v8::Value> &info,
|
||||
std::shared_ptr<osrm::OSRM> osrm;
|
||||
ServiceMemFn service;
|
||||
const ParamPtr params;
|
||||
const PluginParameters pluginParams;
|
||||
|
||||
std::string result;
|
||||
// All services return json::Object .. except for Tile!
|
||||
using ObjectOrString =
|
||||
typename std::conditional<std::is_same<ParamPtr, tile_parameters_ptr>::value,
|
||||
std::string,
|
||||
osrm::json::Object>::type;
|
||||
|
||||
ObjectOrString result;
|
||||
};
|
||||
|
||||
auto *callback = new Nan::Callback{info[info.Length() - 1].As<v8::Function>()};
|
||||
Nan::AsyncQueueWorker(
|
||||
new Worker{self->this_, std::move(params), service, callback, std::move(pluginParams)});
|
||||
Nan::AsyncQueueWorker(new Worker{self->this_, std::move(params), service, callback});
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
@@ -422,7 +341,7 @@ NAN_METHOD(Engine::table) //
|
||||
// clang-format on
|
||||
NAN_METHOD(Engine::tile)
|
||||
{
|
||||
asyncForTiles(info, &argumentsToTileParameters, &osrm::OSRM::Tile, {/*unused*/});
|
||||
async(info, &argumentsToTileParameters, &osrm::OSRM::Tile, {/*unused*/});
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
|
||||
@@ -81,10 +81,7 @@ return_code parseArguments(int argc,
|
||||
"time-zone-file",
|
||||
boost::program_options::value<std::string>(&contractor_config.updater_config.tz_file_path),
|
||||
"Required for conditional turn restriction parsing, provide a geojson file containing "
|
||||
"time zone boundaries")(
|
||||
"cache-distances",
|
||||
boost::program_options::bool_switch(&contractor_config.cache_distances)
|
||||
->default_value(false),
|
||||
"time zone boundaries")("cache-distances",boost::program_options::bool_switch(&contractor_config.cache_distances)->default_value(false),
|
||||
"Store distances for CH edges, avoiding the need for query-time re-calculation.");
|
||||
|
||||
// hidden options, will be allowed on command line, but will not be shown to the user
|
||||
|
||||
+13
-9
@@ -70,8 +70,8 @@ std::istream &operator>>(std::istream &in, EngineConfig::Algorithm &algorithm)
|
||||
throw util::RuntimeError(token, ErrorCode::UnknownAlgorithm, SOURCE_REF);
|
||||
return in;
|
||||
}
|
||||
} // namespace engine
|
||||
} // namespace osrm
|
||||
}
|
||||
}
|
||||
|
||||
// generate boost::program_options object for the routing part
|
||||
inline unsigned generateServerProgramOptions(const int argc,
|
||||
@@ -273,12 +273,10 @@ int main(int argc, const char *argv[]) try
|
||||
|
||||
#ifndef _WIN32
|
||||
int sig = 0;
|
||||
sigset_t wait_mask;
|
||||
sigemptyset(&wait_mask);
|
||||
sigaddset(&wait_mask, SIGINT);
|
||||
sigaddset(&wait_mask, SIGQUIT);
|
||||
sigaddset(&wait_mask, SIGTERM);
|
||||
pthread_sigmask(SIG_BLOCK, &wait_mask, nullptr); // only block necessary signals
|
||||
sigset_t new_mask;
|
||||
sigset_t old_mask;
|
||||
sigfillset(&new_mask);
|
||||
pthread_sigmask(SIG_BLOCK, &new_mask, &old_mask);
|
||||
#endif
|
||||
|
||||
auto service_handler = std::make_unique<server::ServiceHandler>(config);
|
||||
@@ -300,13 +298,19 @@ int main(int argc, const char *argv[]) try
|
||||
std::thread server_thread(std::move(server_task));
|
||||
|
||||
#ifndef _WIN32
|
||||
sigset_t wait_mask;
|
||||
pthread_sigmask(SIG_SETMASK, &old_mask, nullptr);
|
||||
sigemptyset(&wait_mask);
|
||||
sigaddset(&wait_mask, SIGINT);
|
||||
sigaddset(&wait_mask, SIGQUIT);
|
||||
sigaddset(&wait_mask, SIGTERM);
|
||||
pthread_sigmask(SIG_BLOCK, &wait_mask, nullptr);
|
||||
util::Log() << "running and waiting for requests";
|
||||
if (std::getenv("SIGNAL_PARENT_WHEN_READY"))
|
||||
{
|
||||
kill(getppid(), SIGUSR1);
|
||||
}
|
||||
sigwait(&wait_mask, &sig);
|
||||
util::Log() << "received signal " << sig;
|
||||
#else
|
||||
// Set console control handler to allow server to be stopped.
|
||||
console_ctrl_function = std::bind(&server::Server::Stop, routing_server);
|
||||
|
||||
@@ -22,6 +22,11 @@ namespace coordinate_calculation
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
// earth radius varies between 6,356.750-6,378.135 km (3,949.901-3,963.189mi)
|
||||
// The IUGG value for the equatorial radius is 6378.137 km (3963.19 miles)
|
||||
const constexpr double EARTH_RADIUS = 6372797.560856;
|
||||
|
||||
class CheapRulerContainer
|
||||
{
|
||||
public:
|
||||
@@ -112,7 +117,7 @@ double haversineDistance(const Coordinate coordinate_1, const Coordinate coordin
|
||||
const double aharv = std::pow(std::sin(dlat / 2.0), 2.0) +
|
||||
std::cos(dlat1) * std::cos(dlat2) * std::pow(std::sin(dlong / 2.), 2);
|
||||
const double charv = 2. * std::atan2(std::sqrt(aharv), std::sqrt(1.0 - aharv));
|
||||
return detail::EARTH_RADIUS * charv;
|
||||
return EARTH_RADIUS * charv;
|
||||
}
|
||||
|
||||
double greatCircleDistance(const Coordinate coordinate_1, const Coordinate coordinate_2)
|
||||
@@ -133,7 +138,7 @@ double greatCircleDistance(const Coordinate coordinate_1, const Coordinate coord
|
||||
|
||||
const double x_value = (float_lon2 - float_lon1) * std::cos((float_lat1 + float_lat2) / 2.0);
|
||||
const double y_value = float_lat2 - float_lat1;
|
||||
return std::hypot(x_value, y_value) * detail::EARTH_RADIUS;
|
||||
return std::hypot(x_value, y_value) * EARTH_RADIUS;
|
||||
}
|
||||
|
||||
double perpendicularDistance(const Coordinate segment_source,
|
||||
|
||||
+5
-5
@@ -74,11 +74,11 @@ benchmark: data $(DATA_NAME).requests
|
||||
$(TIMER) "queries\tCoreCH" "cat $(DATA_NAME).requests | xargs curl &> /dev/null"
|
||||
@cat osrm-routed.pid | xargs kill
|
||||
@rm osrm-routed.pid
|
||||
# @/bin/sh -c '$(OSRM_ROUTED) --algorithm=MLD mld/$(DATA_NAME).osrm > /dev/null & echo "$$!" > osrm-routed.pid'
|
||||
# @sleep 1
|
||||
# $(TIMER) "queries\tMLD" "cat $(DATA_NAME).requests | xargs curl &> /dev/null"
|
||||
# @cat osrm-routed.pid | xargs kill
|
||||
# @rm osrm-routed.pid
|
||||
@/bin/sh -c '$(OSRM_ROUTED) --algorithm=MLD mld/$(DATA_NAME).osrm > /dev/null & echo "$$!" > osrm-routed.pid'
|
||||
@sleep 1
|
||||
$(TIMER) "queries\tMLD" "cat $(DATA_NAME).requests | xargs curl &> /dev/null"
|
||||
@cat osrm-routed.pid | xargs kill
|
||||
@rm osrm-routed.pid
|
||||
@echo "**** timings ***"
|
||||
@cat /tmp/osrm.timings
|
||||
@echo "****************"
|
||||
|
||||
+8
-40
@@ -25,28 +25,6 @@ test('match: match in Monaco', function(assert) {
|
||||
});
|
||||
});
|
||||
|
||||
test('match: match in Monaco returning a buffer', function(assert) {
|
||||
assert.plan(6);
|
||||
var osrm = new OSRM(data_path);
|
||||
var options = {
|
||||
coordinates: three_test_coordinates,
|
||||
timestamps: [1424684612, 1424684616, 1424684620]
|
||||
};
|
||||
osrm.match(options, { format: 'json_buffer' }, function(err, response) {
|
||||
assert.ifError(err);
|
||||
assert.ok(response instanceof Buffer);
|
||||
response = JSON.parse(response);
|
||||
assert.equal(response.matchings.length, 1);
|
||||
assert.ok(response.matchings.every(function(m) {
|
||||
return !!m.distance && !!m.duration && Array.isArray(m.legs) && !!m.geometry && m.confidence > 0;
|
||||
}))
|
||||
assert.equal(response.tracepoints.length, 3);
|
||||
assert.ok(response.tracepoints.every(function(t) {
|
||||
return !!t.hint && !isNaN(t.matchings_index) && !isNaN(t.waypoint_index) && !!t.name;
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
test('match: match in Monaco without timestamps', function(assert) {
|
||||
assert.plan(3);
|
||||
var osrm = new OSRM(data_path);
|
||||
@@ -247,30 +225,20 @@ test('match: throws on invalid tidy param', function(assert) {
|
||||
/tidy must be of type Boolean/);
|
||||
});
|
||||
|
||||
test('match: throws on invalid config param', function(assert) {
|
||||
assert.plan(1);
|
||||
test('match: match in Monaco without motorways', function(assert) {
|
||||
assert.plan(3);
|
||||
var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'});
|
||||
var options = {
|
||||
coordinates: three_test_coordinates,
|
||||
exclude: ['motorway']
|
||||
};
|
||||
assert.throws(function() { osrm.match(options, { format: 'invalid' }, function(err, response) {}) },
|
||||
/format must be a string:/);
|
||||
osrm.match(options, function(err, response) {
|
||||
assert.ifError(err);
|
||||
assert.equal(response.tracepoints.length, 3);
|
||||
assert.equal(response.matchings.length, 1);
|
||||
});
|
||||
});
|
||||
|
||||
// test('match: match in Monaco without motorways', function(assert) {
|
||||
// assert.plan(3);
|
||||
// var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'});
|
||||
// var options = {
|
||||
// coordinates: three_test_coordinates,
|
||||
// exclude: ['motorway']
|
||||
// };
|
||||
// osrm.match(options, function(err, response) {
|
||||
// assert.ifError(err);
|
||||
// assert.equal(response.tracepoints.length, 3);
|
||||
// assert.equal(response.matchings.length, 1);
|
||||
// });
|
||||
// });
|
||||
|
||||
test('match: throws on invalid waypoints values needs at least two', function(assert) {
|
||||
assert.plan(1);
|
||||
var osrm = new OSRM(data_path);
|
||||
|
||||
+13
-32
@@ -19,21 +19,6 @@ test('nearest', function(assert) {
|
||||
});
|
||||
});
|
||||
|
||||
test('nearest', function(assert) {
|
||||
assert.plan(5);
|
||||
var osrm = new OSRM(data_path);
|
||||
osrm.nearest({
|
||||
coordinates: [three_test_coordinates[0]]
|
||||
}, { format: 'json_buffer' }, function(err, result) {
|
||||
assert.ifError(err);
|
||||
assert.ok(result instanceof Buffer);
|
||||
result = JSON.parse(result);
|
||||
assert.equal(result.waypoints.length, 1);
|
||||
assert.equal(result.waypoints[0].location.length, 2);
|
||||
assert.ok(result.waypoints[0].hasOwnProperty('name'));
|
||||
});
|
||||
});
|
||||
|
||||
test('nearest: can ask for multiple nearest pts', function(assert) {
|
||||
assert.plan(2);
|
||||
var osrm = new OSRM(data_path);
|
||||
@@ -47,7 +32,7 @@ test('nearest: can ask for multiple nearest pts', function(assert) {
|
||||
});
|
||||
|
||||
test('nearest: throws on invalid args', function(assert) {
|
||||
assert.plan(7);
|
||||
assert.plan(6);
|
||||
var osrm = new OSRM(data_path);
|
||||
var options = {};
|
||||
assert.throws(function() { osrm.nearest(options); },
|
||||
@@ -67,21 +52,17 @@ test('nearest: throws on invalid args', function(assert) {
|
||||
options.number = 0;
|
||||
assert.throws(function() { osrm.nearest(options, function(err, res) {}); },
|
||||
/Number must be an integer greater than or equal to 1/);
|
||||
|
||||
options.number = 1;
|
||||
assert.throws(function() { osrm.nearest(options, { format: 'invalid' }, function(err, res) {}); },
|
||||
/format must be a string:/);
|
||||
});
|
||||
|
||||
// test('nearest: nearest in Monaco without motorways', function(assert) {
|
||||
// assert.plan(2);
|
||||
// var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'});
|
||||
// var options = {
|
||||
// coordinates: [two_test_coordinates[0]],
|
||||
// exclude: ['motorway']
|
||||
// };
|
||||
// osrm.nearest(options, function(err, response) {
|
||||
// assert.ifError(err);
|
||||
// assert.equal(response.waypoints.length, 1);
|
||||
// });
|
||||
// });
|
||||
test('nearest: nearest in Monaco without motorways', function(assert) {
|
||||
assert.plan(2);
|
||||
var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'});
|
||||
var options = {
|
||||
coordinates: [two_test_coordinates[0]],
|
||||
exclude: ['motorway']
|
||||
};
|
||||
osrm.nearest(options, function(err, response) {
|
||||
assert.ifError(err);
|
||||
assert.equal(response.waypoints.length, 1);
|
||||
});
|
||||
});
|
||||
|
||||
+14
-30
@@ -43,22 +43,8 @@ test('route: routes Monaco on CoreCH', function(assert) {
|
||||
});
|
||||
});
|
||||
|
||||
test('route: routes Monaco and returns a JSON buffer', function(assert) {
|
||||
assert.plan(6);
|
||||
var osrm = new OSRM({path: monaco_corech_path, algorithm: 'CoreCH'});
|
||||
osrm.route({coordinates: [[13.43864,52.51993],[13.415852,52.513191]]}, { format: 'json_buffer'}, function(err, result) {
|
||||
assert.ifError(err);
|
||||
assert.ok(result instanceof Buffer);
|
||||
const route = JSON.parse(result);
|
||||
assert.ok(route.waypoints);
|
||||
assert.ok(route.routes);
|
||||
assert.ok(route.routes.length);
|
||||
assert.ok(route.routes[0].geometry);
|
||||
});
|
||||
});
|
||||
|
||||
test('route: throws with too few or invalid args', function(assert) {
|
||||
assert.plan(4);
|
||||
assert.plan(3);
|
||||
var osrm = new OSRM(monaco_path);
|
||||
assert.throws(function() { osrm.route({coordinates: two_test_coordinates}) },
|
||||
/Two arguments required/);
|
||||
@@ -66,8 +52,6 @@ test('route: throws with too few or invalid args', function(assert) {
|
||||
/First arg must be an object/);
|
||||
assert.throws(function() { osrm.route({coordinates: two_test_coordinates}, true)},
|
||||
/last argument must be a callback function/);
|
||||
assert.throws(function() { osrm.route({coordinates: two_test_coordinates}, { format: 'invalid' }, function(err, route) {})},
|
||||
/format must be a string:/);
|
||||
});
|
||||
|
||||
test('route: provides no alternatives by default, but when requested it may (not guaranteed)', function(assert) {
|
||||
@@ -592,17 +576,17 @@ test('route: in Monaco with custom limits on MLD', function(assert) {
|
||||
});
|
||||
});
|
||||
|
||||
// test('route: route in Monaco without motorways', function(assert) {
|
||||
// assert.plan(3);
|
||||
// var osrm = new OSRM({path: monaco_mld_path, algorithm: 'MLD'});
|
||||
// var options = {
|
||||
// coordinates: two_test_coordinates,
|
||||
// exclude: ['motorway']
|
||||
// };
|
||||
// osrm.route(options, function(err, response) {
|
||||
// assert.ifError(err);
|
||||
// assert.equal(response.waypoints.length, 2);
|
||||
// assert.equal(response.routes.length, 1);
|
||||
// });
|
||||
// });
|
||||
test('route: route in Monaco without motorways', function(assert) {
|
||||
assert.plan(3);
|
||||
var osrm = new OSRM({path: monaco_mld_path, algorithm: 'MLD'});
|
||||
var options = {
|
||||
coordinates: two_test_coordinates,
|
||||
exclude: ['motorway']
|
||||
};
|
||||
osrm.route(options, function(err, response) {
|
||||
assert.ifError(err);
|
||||
assert.equal(response.waypoints.length, 2);
|
||||
assert.equal(response.routes.length, 1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+13
-30
@@ -48,20 +48,6 @@ test('table: test annotations paramater combination', function(assert) {
|
||||
});
|
||||
});
|
||||
|
||||
test('table: returns buffer', function(assert) {
|
||||
assert.plan(3);
|
||||
var osrm = new OSRM(data_path);
|
||||
var options = {
|
||||
coordinates: [three_test_coordinates[0], three_test_coordinates[1]],
|
||||
};
|
||||
osrm.table(options, { format: 'json_buffer' }, function(err, table) {
|
||||
assert.ifError(err);
|
||||
assert.ok(table instanceof Buffer);
|
||||
table = JSON.parse(table);
|
||||
assert.ok(table['durations'], 'distances table result should exist');
|
||||
});
|
||||
});
|
||||
|
||||
var tables = ['distances', 'durations'];
|
||||
|
||||
tables.forEach(function(annotation) {
|
||||
@@ -130,7 +116,7 @@ tables.forEach(function(annotation) {
|
||||
});
|
||||
|
||||
test('table: ' + annotation + ' throws on invalid arguments', function(assert) {
|
||||
assert.plan(15);
|
||||
assert.plan(14);
|
||||
var osrm = new OSRM(data_path);
|
||||
var options = {annotations: [annotation.slice(0,-1)]};
|
||||
assert.throws(function() { osrm.table(options); },
|
||||
@@ -149,9 +135,6 @@ tables.forEach(function(annotation) {
|
||||
/Coordinates must be an array of \(lon\/lat\) pairs/);
|
||||
|
||||
options.coordinates = two_test_coordinates;
|
||||
assert.throws(function() { osrm.table(options, { format: 'invalid' }, function(err, response) {}) },
|
||||
/format must be a string:/);
|
||||
|
||||
options.sources = true;
|
||||
assert.throws(function() { osrm.table(options, function(err, response) {}) },
|
||||
/Sources must be an array of indices \(or undefined\)/);
|
||||
@@ -233,17 +216,17 @@ tables.forEach(function(annotation) {
|
||||
});
|
||||
});
|
||||
|
||||
// test('table: ' + annotation + ' table in Monaco without motorways', function(assert) {
|
||||
// assert.plan(1);
|
||||
// var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'});
|
||||
// var options = {
|
||||
// coordinates: two_test_coordinates,
|
||||
// exclude: ['motorway'],
|
||||
// annotations: [annotation.slice(0,-1)]
|
||||
// };
|
||||
// osrm.table(options, function(err, response) {
|
||||
// assert.equal(response[annotation].length, 2);
|
||||
// });
|
||||
// });
|
||||
test('table: ' + annotation + ' table in Monaco without motorways', function(assert) {
|
||||
assert.plan(1);
|
||||
var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'});
|
||||
var options = {
|
||||
coordinates: two_test_coordinates,
|
||||
exclude: ['motorway'],
|
||||
annotations: [annotation.slice(0,-1)]
|
||||
};
|
||||
osrm.table(options, function(err, response) {
|
||||
assert.equal(response[annotation].length, 2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+14
-29
@@ -17,19 +17,6 @@ test('trip: trip in Monaco', function(assert) {
|
||||
});
|
||||
});
|
||||
|
||||
test('trip: trip in Monaco as a buffer', function(assert) {
|
||||
assert.plan(3);
|
||||
var osrm = new OSRM(data_path);
|
||||
osrm.trip({coordinates: two_test_coordinates}, { format: 'json_buffer' }, function(err, trip) {
|
||||
assert.ifError(err);
|
||||
assert.ok(trip instanceof Buffer);
|
||||
trip = JSON.parse(trip);
|
||||
for (t = 0; t < trip.trips.length; t++) {
|
||||
assert.ok(trip.trips[t].geometry);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('trip: trip with many locations in Monaco', function(assert) {
|
||||
assert.plan(2);
|
||||
|
||||
@@ -46,14 +33,12 @@ test('trip: trip with many locations in Monaco', function(assert) {
|
||||
});
|
||||
|
||||
test('trip: throws with too few or invalid args', function(assert) {
|
||||
assert.plan(3);
|
||||
assert.plan(2);
|
||||
var osrm = new OSRM(data_path);
|
||||
assert.throws(function() { osrm.trip({coordinates: two_test_coordinates}) },
|
||||
/Two arguments required/);
|
||||
assert.throws(function() { osrm.trip(null, function(err, trip) {}) },
|
||||
/First arg must be an object/);
|
||||
assert.throws(function() { osrm.trip({coordinates: two_test_coordinates}, { format: 'invalid' }, function(err, trip) {}) },
|
||||
/format must be a string:/);
|
||||
});
|
||||
|
||||
test('trip: throws with bad params', function(assert) {
|
||||
@@ -342,17 +327,17 @@ test('trip: fixed start and end combinations', function(assert) {
|
||||
assert.end();
|
||||
});
|
||||
|
||||
// test('trip: trip in Monaco without motorways', function(assert) {
|
||||
// assert.plan(3);
|
||||
// var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'});
|
||||
// var options = {
|
||||
// coordinates: two_test_coordinates,
|
||||
// exclude: ['motorway']
|
||||
// };
|
||||
// osrm.trip(options, function(err, response) {
|
||||
// assert.ifError(err);
|
||||
// assert.equal(response.waypoints.length, 2);
|
||||
// assert.equal(response.trips.length, 1);
|
||||
// });
|
||||
// });
|
||||
test('trip: trip in Monaco without motorways', function(assert) {
|
||||
assert.plan(3);
|
||||
var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'});
|
||||
var options = {
|
||||
coordinates: two_test_coordinates,
|
||||
exclude: ['motorway']
|
||||
};
|
||||
osrm.trip(options, function(err, response) {
|
||||
assert.ifError(err);
|
||||
assert.equal(response.waypoints.length, 2);
|
||||
assert.equal(response.trips.length, 1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -31,79 +31,79 @@ std::ostream &operator<<(std::ostream &out, const QueryEdge &edge)
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(contracted_edge_container)
|
||||
|
||||
// BOOST_AUTO_TEST_CASE(merge_edge_of_multiple_graph)
|
||||
// {
|
||||
// ContractedEdgeContainer container;
|
||||
BOOST_AUTO_TEST_CASE(merge_edge_of_multiple_graph)
|
||||
{
|
||||
ContractedEdgeContainer container;
|
||||
|
||||
// std::vector<QueryEdge> edges;
|
||||
// edges.push_back(QueryEdge{0, 1, {1, false, 3, 6, true, false}});
|
||||
// edges.push_back(QueryEdge{1, 2, {2, false, 3, 6, true, false}});
|
||||
// edges.push_back(QueryEdge{2, 0, {3, false, 3, 6, false, true}});
|
||||
// edges.push_back(QueryEdge{2, 1, {4, false, 3, 6, false, true}});
|
||||
// container.Insert(edges);
|
||||
std::vector<QueryEdge> edges;
|
||||
edges.push_back(QueryEdge{0, 1, {1, false, 3, 6, true, false}});
|
||||
edges.push_back(QueryEdge{1, 2, {2, false, 3, 6, true, false}});
|
||||
edges.push_back(QueryEdge{2, 0, {3, false, 3, 6, false, true}});
|
||||
edges.push_back(QueryEdge{2, 1, {4, false, 3, 6, false, true}});
|
||||
container.Insert(edges);
|
||||
|
||||
// edges.clear();
|
||||
// edges.push_back(QueryEdge{0, 1, {1, false, 3, 6, true, false}});
|
||||
// edges.push_back(QueryEdge{1, 2, {2, false, 3, 6, true, false}});
|
||||
// edges.push_back(QueryEdge{2, 0, {3, false, 12, 24, false, true}});
|
||||
// edges.push_back(QueryEdge{2, 1, {4, false, 12, 24, false, true}});
|
||||
// container.Merge(edges);
|
||||
edges.clear();
|
||||
edges.push_back(QueryEdge{0, 1, {1, false, 3, 6, true, false}});
|
||||
edges.push_back(QueryEdge{1, 2, {2, false, 3, 6, true, false}});
|
||||
edges.push_back(QueryEdge{2, 0, {3, false, 12, 24, false, true}});
|
||||
edges.push_back(QueryEdge{2, 1, {4, false, 12, 24, false, true}});
|
||||
container.Merge(edges);
|
||||
|
||||
// edges.clear();
|
||||
// edges.push_back(QueryEdge{1, 4, {5, false, 3, 6, true, false}});
|
||||
// container.Merge(edges);
|
||||
edges.clear();
|
||||
edges.push_back(QueryEdge{1, 4, {5, false, 3, 6, true, false}});
|
||||
container.Merge(edges);
|
||||
|
||||
// std::vector<QueryEdge> reference_edges;
|
||||
// reference_edges.push_back(QueryEdge{0, 1, {1, false, 3, 6, true, false}});
|
||||
// reference_edges.push_back(QueryEdge{1, 2, {2, false, 3, 6, true, false}});
|
||||
// reference_edges.push_back(QueryEdge{1, 4, {5, false, 3, 6, true, false}});
|
||||
// reference_edges.push_back(QueryEdge{2, 0, {3, false, 3, 6, false, true}});
|
||||
// reference_edges.push_back(QueryEdge{2, 0, {3, false, 12, 24, false, true}});
|
||||
// reference_edges.push_back(QueryEdge{2, 1, {4, false, 3, 6, false, true}});
|
||||
// reference_edges.push_back(QueryEdge{2, 1, {4, false, 12, 24, false, true}});
|
||||
// CHECK_EQUAL_COLLECTIONS(container.edges, reference_edges);
|
||||
std::vector<QueryEdge> reference_edges;
|
||||
reference_edges.push_back(QueryEdge{0, 1, {1, false, 3, 6, true, false}});
|
||||
reference_edges.push_back(QueryEdge{1, 2, {2, false, 3, 6, true, false}});
|
||||
reference_edges.push_back(QueryEdge{1, 4, {5, false, 3, 6, true, false}});
|
||||
reference_edges.push_back(QueryEdge{2, 0, {3, false, 3, 6, false, true}});
|
||||
reference_edges.push_back(QueryEdge{2, 0, {3, false, 12, 24, false, true}});
|
||||
reference_edges.push_back(QueryEdge{2, 1, {4, false, 3, 6, false, true}});
|
||||
reference_edges.push_back(QueryEdge{2, 1, {4, false, 12, 24, false, true}});
|
||||
CHECK_EQUAL_COLLECTIONS(container.edges, reference_edges);
|
||||
|
||||
// auto filters = container.MakeEdgeFilters();
|
||||
// BOOST_CHECK_EQUAL(filters.size(), 2);
|
||||
auto filters = container.MakeEdgeFilters();
|
||||
BOOST_CHECK_EQUAL(filters.size(), 2);
|
||||
|
||||
// REQUIRE_SIZE_RANGE(filters[0], 7);
|
||||
// CHECK_EQUAL_RANGE(filters[0], true, true, false, true, true, true, true);
|
||||
REQUIRE_SIZE_RANGE(filters[0], 7);
|
||||
CHECK_EQUAL_RANGE(filters[0], true, true, false, true, true, true, true);
|
||||
|
||||
// REQUIRE_SIZE_RANGE(filters[1], 7);
|
||||
// CHECK_EQUAL_RANGE(filters[1], true, true, true, true, false, true, false);
|
||||
// }
|
||||
REQUIRE_SIZE_RANGE(filters[1], 7);
|
||||
CHECK_EQUAL_RANGE(filters[1], true, true, true, true, false, true, false);
|
||||
}
|
||||
|
||||
// BOOST_AUTO_TEST_CASE(merge_edge_of_multiple_disjoint_graph)
|
||||
// {
|
||||
// ContractedEdgeContainer container;
|
||||
BOOST_AUTO_TEST_CASE(merge_edge_of_multiple_disjoint_graph)
|
||||
{
|
||||
ContractedEdgeContainer container;
|
||||
|
||||
// std::vector<QueryEdge> edges;
|
||||
// edges.push_back(QueryEdge{0, 1, {1, false, 3, 6, true, false}});
|
||||
// edges.push_back(QueryEdge{1, 2, {2, false, 3, 6, true, false}});
|
||||
// edges.push_back(QueryEdge{2, 0, {3, false, 12, 24, false, true}});
|
||||
// edges.push_back(QueryEdge{2, 1, {4, false, 12, 24, false, true}});
|
||||
// container.Merge(edges);
|
||||
std::vector<QueryEdge> edges;
|
||||
edges.push_back(QueryEdge{0, 1, {1, false, 3, 6, true, false}});
|
||||
edges.push_back(QueryEdge{1, 2, {2, false, 3, 6, true, false}});
|
||||
edges.push_back(QueryEdge{2, 0, {3, false, 12, 24, false, true}});
|
||||
edges.push_back(QueryEdge{2, 1, {4, false, 12, 24, false, true}});
|
||||
container.Merge(edges);
|
||||
|
||||
// edges.clear();
|
||||
// edges.push_back(QueryEdge{1, 4, {5, false, 3, 6, true, false}});
|
||||
// container.Merge(edges);
|
||||
edges.clear();
|
||||
edges.push_back(QueryEdge{1, 4, {5, false, 3, 6, true, false}});
|
||||
container.Merge(edges);
|
||||
|
||||
// std::vector<QueryEdge> reference_edges;
|
||||
// reference_edges.push_back(QueryEdge{0, 1, {1, false, 3, 6, true, false}});
|
||||
// reference_edges.push_back(QueryEdge{1, 2, {2, false, 3, 6, true, false}});
|
||||
// reference_edges.push_back(QueryEdge{1, 4, {5, false, 3, 6, true, false}});
|
||||
// reference_edges.push_back(QueryEdge{2, 0, {3, false, 12, 24, false, true}});
|
||||
// reference_edges.push_back(QueryEdge{2, 1, {4, false, 12, 24, false, true}});
|
||||
// CHECK_EQUAL_COLLECTIONS(container.edges, reference_edges);
|
||||
std::vector<QueryEdge> reference_edges;
|
||||
reference_edges.push_back(QueryEdge{0, 1, {1, false, 3, 6, true, false}});
|
||||
reference_edges.push_back(QueryEdge{1, 2, {2, false, 3, 6, true, false}});
|
||||
reference_edges.push_back(QueryEdge{1, 4, {5, false, 3, 6, true, false}});
|
||||
reference_edges.push_back(QueryEdge{2, 0, {3, false, 12, 24, false, true}});
|
||||
reference_edges.push_back(QueryEdge{2, 1, {4, false, 12, 24, false, true}});
|
||||
CHECK_EQUAL_COLLECTIONS(container.edges, reference_edges);
|
||||
|
||||
// auto filters = container.MakeEdgeFilters();
|
||||
// BOOST_CHECK_EQUAL(filters.size(), 2);
|
||||
auto filters = container.MakeEdgeFilters();
|
||||
BOOST_CHECK_EQUAL(filters.size(), 2);
|
||||
|
||||
// REQUIRE_SIZE_RANGE(filters[0], 5);
|
||||
// CHECK_EQUAL_RANGE(filters[0], true, true, false, true, true);
|
||||
REQUIRE_SIZE_RANGE(filters[0], 5);
|
||||
CHECK_EQUAL_RANGE(filters[0], true, true, false, true, true);
|
||||
|
||||
// REQUIRE_SIZE_RANGE(filters[1], 5);
|
||||
// CHECK_EQUAL_RANGE(filters[1], false, false, true, false, false);
|
||||
// }
|
||||
REQUIRE_SIZE_RANGE(filters[1], 5);
|
||||
CHECK_EQUAL_RANGE(filters[1], false, false, true, false, false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
@@ -14,122 +14,122 @@ using namespace osrm::unit_test;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(graph_contractor)
|
||||
|
||||
// BOOST_AUTO_TEST_CASE(contract_graph)
|
||||
// {
|
||||
// tbb::task_scheduler_init scheduler(1);
|
||||
// /*
|
||||
// * <--1--<
|
||||
// * (0) >--3--> (1) >--3--> (3)
|
||||
// * v ^ v ^
|
||||
// * \ / \ |
|
||||
// * 1 1 1 1
|
||||
// * \ ^ \ /
|
||||
// * >(5) > (4) >
|
||||
// */
|
||||
// std::vector<TestEdge> edges = {TestEdge{0, 1, 3},
|
||||
// TestEdge{0, 5, 1},
|
||||
// TestEdge{1, 3, 3},
|
||||
// TestEdge{1, 4, 1},
|
||||
// TestEdge{3, 1, 1},
|
||||
// TestEdge{4, 3, 1},
|
||||
// TestEdge{5, 1, 1}};
|
||||
// auto reference_graph = makeGraph(edges);
|
||||
BOOST_AUTO_TEST_CASE(contract_graph)
|
||||
{
|
||||
tbb::task_scheduler_init scheduler(1);
|
||||
/*
|
||||
* <--1--<
|
||||
* (0) >--3--> (1) >--3--> (3)
|
||||
* v ^ v ^
|
||||
* \ / \ |
|
||||
* 1 1 1 1
|
||||
* \ ^ \ /
|
||||
* >(5) > (4) >
|
||||
*/
|
||||
std::vector<TestEdge> edges = {TestEdge{0, 1, 3},
|
||||
TestEdge{0, 5, 1},
|
||||
TestEdge{1, 3, 3},
|
||||
TestEdge{1, 4, 1},
|
||||
TestEdge{3, 1, 1},
|
||||
TestEdge{4, 3, 1},
|
||||
TestEdge{5, 1, 1}};
|
||||
auto reference_graph = makeGraph(edges);
|
||||
|
||||
// auto contracted_graph = reference_graph;
|
||||
// std::vector<bool> core = contractGraph(contracted_graph, {1, 1, 1, 1, 1, 1});
|
||||
auto contracted_graph = reference_graph;
|
||||
std::vector<bool> core = contractGraph(contracted_graph, {1, 1, 1, 1, 1, 1});
|
||||
|
||||
// // This contraction order is dependent on the priority caculation in the contractor
|
||||
// // but deterministic for the same graph.
|
||||
// CHECK_EQUAL_RANGE(core, false, false, false, false, false, false);
|
||||
// This contraction order is dependent on the priority caculation in the contractor
|
||||
// but deterministic for the same graph.
|
||||
CHECK_EQUAL_RANGE(core, false, false, false, false, false, false);
|
||||
|
||||
// /* After contracting 0 and 2:
|
||||
// *
|
||||
// * Deltes edges 5 -> 0, 1 -> 0
|
||||
// *
|
||||
// * <--1--<
|
||||
// * (0) ---3--> (1) >--3--> (3)
|
||||
// * \ ^ v ^
|
||||
// * \ / \ |
|
||||
// * 1 1 1 1
|
||||
// * \ ^ \ /
|
||||
// * >(5) > (4) >
|
||||
// */
|
||||
// reference_graph.DeleteEdgesTo(5, 0);
|
||||
// reference_graph.DeleteEdgesTo(1, 0);
|
||||
/* After contracting 0 and 2:
|
||||
*
|
||||
* Deltes edges 5 -> 0, 1 -> 0
|
||||
*
|
||||
* <--1--<
|
||||
* (0) ---3--> (1) >--3--> (3)
|
||||
* \ ^ v ^
|
||||
* \ / \ |
|
||||
* 1 1 1 1
|
||||
* \ ^ \ /
|
||||
* >(5) > (4) >
|
||||
*/
|
||||
reference_graph.DeleteEdgesTo(5, 0);
|
||||
reference_graph.DeleteEdgesTo(1, 0);
|
||||
|
||||
// /* After contracting 5:
|
||||
// *
|
||||
// * Deletes edges 1 -> 5
|
||||
// *
|
||||
// * <--1--<
|
||||
// * (0) ---3--> (1) >--3--> (3)
|
||||
// * \ ^ v ^
|
||||
// * \ / \ |
|
||||
// * 1 1 1 1
|
||||
// * \ / \ /
|
||||
// * >(5) > (4) >
|
||||
// */
|
||||
// reference_graph.DeleteEdgesTo(5, 0);
|
||||
// reference_graph.DeleteEdgesTo(1, 0);
|
||||
/* After contracting 5:
|
||||
*
|
||||
* Deletes edges 1 -> 5
|
||||
*
|
||||
* <--1--<
|
||||
* (0) ---3--> (1) >--3--> (3)
|
||||
* \ ^ v ^
|
||||
* \ / \ |
|
||||
* 1 1 1 1
|
||||
* \ / \ /
|
||||
* >(5) > (4) >
|
||||
*/
|
||||
reference_graph.DeleteEdgesTo(5, 0);
|
||||
reference_graph.DeleteEdgesTo(1, 0);
|
||||
|
||||
// After contracting 3:
|
||||
// *
|
||||
// * Deletes edges 1 -> 3
|
||||
// * Deletes edges 4 -> 3
|
||||
// * Insert edge 4 -> 1
|
||||
// *
|
||||
// * <--1---
|
||||
// * (0) ---3--> (1) >--3--- (3)
|
||||
// * \ ^ v ^ |
|
||||
// * \ / \ \ |
|
||||
// * 1 1 1 2 1
|
||||
// * \ / \ \ /
|
||||
// * >(5) > (4) >
|
||||
/* After contracting 3:
|
||||
*
|
||||
* Deletes edges 1 -> 3
|
||||
* Deletes edges 4 -> 3
|
||||
* Insert edge 4 -> 1
|
||||
*
|
||||
* <--1---
|
||||
* (0) ---3--> (1) >--3--- (3)
|
||||
* \ ^ v ^ |
|
||||
* \ / \ \ |
|
||||
* 1 1 1 2 1
|
||||
* \ / \ \ /
|
||||
* >(5) > (4) >
|
||||
*/
|
||||
reference_graph.DeleteEdgesTo(1, 3);
|
||||
reference_graph.DeleteEdgesTo(4, 3);
|
||||
// Insert shortcut
|
||||
reference_graph.InsertEdge(4, 1, {2, 4, 3, 0, true, true, false});
|
||||
|
||||
// reference_graph.DeleteEdgesTo(1, 3);
|
||||
// reference_graph.DeleteEdgesTo(4, 3);
|
||||
// // Insert shortcut
|
||||
// reference_graph.InsertEdge(4, 1, {2, 4, 3, 0, true, true, false});
|
||||
/* After contracting 4:
|
||||
*
|
||||
* Delete edges 1 -> 4
|
||||
*
|
||||
* <--1---
|
||||
* (0) ---3--> (1) >--3--- (3)
|
||||
* \ ^ v ^ |
|
||||
* \ / \ \ |
|
||||
* 1 1 1 2 1
|
||||
* \ / \ \ /
|
||||
* >(5) \ (4) >
|
||||
*/
|
||||
reference_graph.DeleteEdgesTo(1, 4);
|
||||
|
||||
// /* After contracting 4:
|
||||
// *
|
||||
// * Delete edges 1 -> 4
|
||||
// *
|
||||
// * <--1---
|
||||
// * (0) ---3--> (1) >--3--- (3)
|
||||
// * \ ^ v ^ |
|
||||
// * \ / \ \ |
|
||||
// * 1 1 1 2 1
|
||||
// * \ / \ \ /
|
||||
// * >(5) \ (4) >
|
||||
// */
|
||||
// reference_graph.DeleteEdgesTo(1, 4);
|
||||
/* After contracting 1:
|
||||
*
|
||||
* Delete no edges.
|
||||
*
|
||||
* <--1---
|
||||
* (0) ---3--> (1) >--3--- (3)
|
||||
* \ ^ v ^ |
|
||||
* \ / \ \ |
|
||||
* 1 1 1 2 1
|
||||
* \ / \ \ /
|
||||
* >(5) \ (4) >
|
||||
*/
|
||||
|
||||
// /* After contracting 1:
|
||||
// *
|
||||
// * Delete no edges.
|
||||
// *
|
||||
// * <--1---
|
||||
// * (0) ---3--> (1) >--3--- (3)
|
||||
// * \ ^ v ^ |
|
||||
// * \ / \ \ |
|
||||
// * 1 1 1 2 1
|
||||
// * \ / \ \ /
|
||||
// * >(5) \ (4) >
|
||||
// */
|
||||
|
||||
// REQUIRE_SIZE_RANGE(contracted_graph.GetAdjacentEdgeRange(0), 2);
|
||||
// BOOST_CHECK(contracted_graph.FindEdge(0, 1) != SPECIAL_EDGEID);
|
||||
// BOOST_CHECK(contracted_graph.FindEdge(0, 5) != SPECIAL_EDGEID);
|
||||
// REQUIRE_SIZE_RANGE(contracted_graph.GetAdjacentEdgeRange(1), 0);
|
||||
// REQUIRE_SIZE_RANGE(contracted_graph.GetAdjacentEdgeRange(2), 0);
|
||||
// REQUIRE_SIZE_RANGE(contracted_graph.GetAdjacentEdgeRange(3), 3);
|
||||
// BOOST_CHECK(contracted_graph.FindEdge(3, 1) != SPECIAL_EDGEID);
|
||||
// BOOST_CHECK(contracted_graph.FindEdge(3, 4) != SPECIAL_EDGEID);
|
||||
// REQUIRE_SIZE_RANGE(contracted_graph.GetAdjacentEdgeRange(4), 2);
|
||||
// BOOST_CHECK(contracted_graph.FindEdge(4, 1) != SPECIAL_EDGEID);
|
||||
// REQUIRE_SIZE_RANGE(contracted_graph.GetAdjacentEdgeRange(5), 1);
|
||||
// BOOST_CHECK(contracted_graph.FindEdge(5, 1) != SPECIAL_EDGEID);
|
||||
// }
|
||||
REQUIRE_SIZE_RANGE(contracted_graph.GetAdjacentEdgeRange(0), 2);
|
||||
BOOST_CHECK(contracted_graph.FindEdge(0, 1) != SPECIAL_EDGEID);
|
||||
BOOST_CHECK(contracted_graph.FindEdge(0, 5) != SPECIAL_EDGEID);
|
||||
REQUIRE_SIZE_RANGE(contracted_graph.GetAdjacentEdgeRange(1), 0);
|
||||
REQUIRE_SIZE_RANGE(contracted_graph.GetAdjacentEdgeRange(2), 0);
|
||||
REQUIRE_SIZE_RANGE(contracted_graph.GetAdjacentEdgeRange(3), 3);
|
||||
BOOST_CHECK(contracted_graph.FindEdge(3, 1) != SPECIAL_EDGEID);
|
||||
BOOST_CHECK(contracted_graph.FindEdge(3, 4) != SPECIAL_EDGEID);
|
||||
REQUIRE_SIZE_RANGE(contracted_graph.GetAdjacentEdgeRange(4), 2);
|
||||
BOOST_CHECK(contracted_graph.FindEdge(4, 1) != SPECIAL_EDGEID);
|
||||
REQUIRE_SIZE_RANGE(contracted_graph.GetAdjacentEdgeRange(5), 1);
|
||||
BOOST_CHECK(contracted_graph.FindEdge(5, 1) != SPECIAL_EDGEID);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
@@ -24,11 +24,11 @@ inline contractor::ContractorGraph makeGraph(const std::vector<TestEdge> &edges)
|
||||
input_edges.push_back(contractor::ContractorEdge{
|
||||
start,
|
||||
target,
|
||||
contractor::ContractorEdgeData{weight, weight * 2, 1.0, id++, 0, false, true, false}});
|
||||
contractor::ContractorEdgeData{weight, weight * 2, id++, 0, false, true, false}});
|
||||
input_edges.push_back(contractor::ContractorEdge{
|
||||
target,
|
||||
start,
|
||||
contractor::ContractorEdgeData{weight, weight * 2, 1.0, id++, 0, false, false, true}});
|
||||
contractor::ContractorEdgeData{weight, weight * 2, id++, 0, false, false, true}});
|
||||
}
|
||||
std::sort(input_edges.begin(), input_edges.end());
|
||||
|
||||
|
||||
@@ -1,296 +1,295 @@
|
||||
// #include "extractor/graph_compressor.hpp"
|
||||
// #include "extractor/compressed_edge_container.hpp"
|
||||
// #include "extractor/maneuver_override.hpp"
|
||||
// #include "extractor/restriction.hpp"
|
||||
// #include "util/node_based_graph.hpp"
|
||||
// #include "util/typedefs.hpp"
|
||||
#include "extractor/graph_compressor.hpp"
|
||||
#include "extractor/compressed_edge_container.hpp"
|
||||
#include "extractor/maneuver_override.hpp"
|
||||
#include "extractor/restriction.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
// #include "../unit_tests/mocks/mock_scripting_environment.hpp"
|
||||
#include "../unit_tests/mocks/mock_scripting_environment.hpp"
|
||||
|
||||
// #include <boost/test/test_case_template.hpp>
|
||||
// #include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/test_case_template.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
// #include <iostream>
|
||||
// #include <unordered_set>
|
||||
// #include <vector>
|
||||
#include <iostream>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
// BOOST_AUTO_TEST_SUITE(graph_compressor)
|
||||
BOOST_AUTO_TEST_SUITE(graph_compressor)
|
||||
|
||||
// using namespace osrm;
|
||||
// using namespace osrm::extractor;
|
||||
// using InputEdge = util::NodeBasedDynamicGraph::InputEdge;
|
||||
// using Graph = util::NodeBasedDynamicGraph;
|
||||
using namespace osrm;
|
||||
using namespace osrm::extractor;
|
||||
using InputEdge = util::NodeBasedDynamicGraph::InputEdge;
|
||||
using Graph = util::NodeBasedDynamicGraph;
|
||||
|
||||
// namespace
|
||||
// {
|
||||
namespace
|
||||
{
|
||||
|
||||
// // creates a default edge of unit weight
|
||||
// inline InputEdge MakeUnitEdge(const NodeID from, const NodeID to)
|
||||
// {
|
||||
// return {from, // source
|
||||
// to, // target
|
||||
// 1, // weight
|
||||
// 1, // duration
|
||||
// GeometryID{0, false}, // geometry_id
|
||||
// false, // reversed
|
||||
// NodeBasedEdgeClassification(), // default flags
|
||||
// 0}; // AnnotationID
|
||||
// }
|
||||
// creates a default edge of unit weight
|
||||
inline InputEdge MakeUnitEdge(const NodeID from, const NodeID to)
|
||||
{
|
||||
return {from, // source
|
||||
to, // target
|
||||
1, // weight
|
||||
1, // duration
|
||||
GeometryID{0, false}, // geometry_id
|
||||
false, // reversed
|
||||
NodeBasedEdgeClassification(), // default flags
|
||||
0}; // AnnotationID
|
||||
}
|
||||
|
||||
// bool compatible(Graph const &graph,
|
||||
// const std::vector<NodeBasedEdgeAnnotation> &node_data_container,
|
||||
// EdgeID const first,
|
||||
// EdgeID second)
|
||||
// {
|
||||
// auto const &first_flags = graph.GetEdgeData(first).flags;
|
||||
// auto const &second_flags = graph.GetEdgeData(second).flags;
|
||||
// if (!(first_flags == second_flags))
|
||||
// return false;
|
||||
bool compatible(Graph const &graph,
|
||||
const std::vector<NodeBasedEdgeAnnotation> &node_data_container,
|
||||
EdgeID const first,
|
||||
EdgeID second)
|
||||
{
|
||||
auto const &first_flags = graph.GetEdgeData(first).flags;
|
||||
auto const &second_flags = graph.GetEdgeData(second).flags;
|
||||
if (!(first_flags == second_flags))
|
||||
return false;
|
||||
|
||||
// if (graph.GetEdgeData(first).reversed != graph.GetEdgeData(second).reversed)
|
||||
// return false;
|
||||
if (graph.GetEdgeData(first).reversed != graph.GetEdgeData(second).reversed)
|
||||
return false;
|
||||
|
||||
// auto const &first_annotation = node_data_container[graph.GetEdgeData(first).annotation_data];
|
||||
// auto const &second_annotation =
|
||||
// node_data_container[graph.GetEdgeData(second).annotation_data];
|
||||
auto const &first_annotation = node_data_container[graph.GetEdgeData(first).annotation_data];
|
||||
auto const &second_annotation = node_data_container[graph.GetEdgeData(second).annotation_data];
|
||||
|
||||
// return first_annotation.CanCombineWith(second_annotation);
|
||||
// }
|
||||
return first_annotation.CanCombineWith(second_annotation);
|
||||
}
|
||||
|
||||
// } // namespace
|
||||
} // namespace
|
||||
|
||||
// BOOST_AUTO_TEST_CASE(long_road_test)
|
||||
// {
|
||||
// //
|
||||
// // 0---1---2---3---4
|
||||
// //
|
||||
// GraphCompressor compressor;
|
||||
BOOST_AUTO_TEST_CASE(long_road_test)
|
||||
{
|
||||
//
|
||||
// 0---1---2---3---4
|
||||
//
|
||||
GraphCompressor compressor;
|
||||
|
||||
// std::unordered_set<NodeID> barrier_nodes;
|
||||
// std::unordered_set<NodeID> traffic_lights;
|
||||
// std::vector<TurnRestriction> restrictions;
|
||||
// std::vector<ConditionalTurnRestriction> conditional_restrictions;
|
||||
// std::vector<NodeBasedEdgeAnnotation> annotations(1);
|
||||
// CompressedEdgeContainer container;
|
||||
// test::MockScriptingEnvironment scripting_environment;
|
||||
// std::vector<UnresolvedManeuverOverride> maneuver_overrides;
|
||||
std::unordered_set<NodeID> barrier_nodes;
|
||||
std::unordered_set<NodeID> traffic_lights;
|
||||
std::vector<TurnRestriction> restrictions;
|
||||
std::vector<ConditionalTurnRestriction> conditional_restrictions;
|
||||
std::vector<NodeBasedEdgeAnnotation> annotations(1);
|
||||
CompressedEdgeContainer container;
|
||||
test::MockScriptingEnvironment scripting_environment;
|
||||
std::vector<UnresolvedManeuverOverride> maneuver_overrides;
|
||||
|
||||
// std::vector<InputEdge> edges = {MakeUnitEdge(0, 1),
|
||||
// MakeUnitEdge(1, 0),
|
||||
// MakeUnitEdge(1, 2),
|
||||
// MakeUnitEdge(2, 1),
|
||||
// MakeUnitEdge(2, 3),
|
||||
// MakeUnitEdge(3, 2),
|
||||
// MakeUnitEdge(3, 4),
|
||||
// MakeUnitEdge(4, 3)};
|
||||
std::vector<InputEdge> edges = {MakeUnitEdge(0, 1),
|
||||
MakeUnitEdge(1, 0),
|
||||
MakeUnitEdge(1, 2),
|
||||
MakeUnitEdge(2, 1),
|
||||
MakeUnitEdge(2, 3),
|
||||
MakeUnitEdge(3, 2),
|
||||
MakeUnitEdge(3, 4),
|
||||
MakeUnitEdge(4, 3)};
|
||||
|
||||
// Graph graph(5, edges);
|
||||
// BOOST_CHECK(compatible(graph, annotations, 0, 2));
|
||||
// BOOST_CHECK(compatible(graph, annotations, 2, 4));
|
||||
// BOOST_CHECK(compatible(graph, annotations, 4, 6));
|
||||
Graph graph(5, edges);
|
||||
BOOST_CHECK(compatible(graph, annotations, 0, 2));
|
||||
BOOST_CHECK(compatible(graph, annotations, 2, 4));
|
||||
BOOST_CHECK(compatible(graph, annotations, 4, 6));
|
||||
|
||||
// compressor.Compress(barrier_nodes,
|
||||
// traffic_lights,
|
||||
// scripting_environment,
|
||||
// restrictions,
|
||||
// conditional_restrictions,
|
||||
// maneuver_overrides,
|
||||
// graph,
|
||||
// annotations,
|
||||
// container);
|
||||
// BOOST_CHECK_EQUAL(graph.FindEdge(0, 1), SPECIAL_EDGEID);
|
||||
// BOOST_CHECK_EQUAL(graph.FindEdge(1, 2), SPECIAL_EDGEID);
|
||||
// BOOST_CHECK_EQUAL(graph.FindEdge(2, 3), SPECIAL_EDGEID);
|
||||
// BOOST_CHECK_EQUAL(graph.FindEdge(3, 4), SPECIAL_EDGEID);
|
||||
// BOOST_CHECK(graph.FindEdge(0, 4) != SPECIAL_EDGEID);
|
||||
// }
|
||||
compressor.Compress(barrier_nodes,
|
||||
traffic_lights,
|
||||
scripting_environment,
|
||||
restrictions,
|
||||
conditional_restrictions,
|
||||
maneuver_overrides,
|
||||
graph,
|
||||
annotations,
|
||||
container);
|
||||
BOOST_CHECK_EQUAL(graph.FindEdge(0, 1), SPECIAL_EDGEID);
|
||||
BOOST_CHECK_EQUAL(graph.FindEdge(1, 2), SPECIAL_EDGEID);
|
||||
BOOST_CHECK_EQUAL(graph.FindEdge(2, 3), SPECIAL_EDGEID);
|
||||
BOOST_CHECK_EQUAL(graph.FindEdge(3, 4), SPECIAL_EDGEID);
|
||||
BOOST_CHECK(graph.FindEdge(0, 4) != SPECIAL_EDGEID);
|
||||
}
|
||||
|
||||
// BOOST_AUTO_TEST_CASE(loop_test)
|
||||
// {
|
||||
// //
|
||||
// // 0---1---2
|
||||
// // | |
|
||||
// // 5---4---3
|
||||
// //
|
||||
// GraphCompressor compressor;
|
||||
BOOST_AUTO_TEST_CASE(loop_test)
|
||||
{
|
||||
//
|
||||
// 0---1---2
|
||||
// | |
|
||||
// 5---4---3
|
||||
//
|
||||
GraphCompressor compressor;
|
||||
|
||||
// std::unordered_set<NodeID> barrier_nodes;
|
||||
// std::unordered_set<NodeID> traffic_lights;
|
||||
// std::vector<TurnRestriction> restrictions;
|
||||
// std::vector<ConditionalTurnRestriction> conditional_restrictions;
|
||||
// CompressedEdgeContainer container;
|
||||
// std::vector<NodeBasedEdgeAnnotation> annotations(1);
|
||||
// test::MockScriptingEnvironment scripting_environment;
|
||||
// std::vector<UnresolvedManeuverOverride> maneuver_overrides;
|
||||
std::unordered_set<NodeID> barrier_nodes;
|
||||
std::unordered_set<NodeID> traffic_lights;
|
||||
std::vector<TurnRestriction> restrictions;
|
||||
std::vector<ConditionalTurnRestriction> conditional_restrictions;
|
||||
CompressedEdgeContainer container;
|
||||
std::vector<NodeBasedEdgeAnnotation> annotations(1);
|
||||
test::MockScriptingEnvironment scripting_environment;
|
||||
std::vector<UnresolvedManeuverOverride> maneuver_overrides;
|
||||
|
||||
// std::vector<InputEdge> edges = {MakeUnitEdge(0, 1),
|
||||
// MakeUnitEdge(0, 5),
|
||||
// MakeUnitEdge(1, 0),
|
||||
// MakeUnitEdge(1, 2),
|
||||
// MakeUnitEdge(2, 1),
|
||||
// MakeUnitEdge(2, 3),
|
||||
// MakeUnitEdge(3, 2),
|
||||
// MakeUnitEdge(3, 4),
|
||||
// MakeUnitEdge(4, 3),
|
||||
// MakeUnitEdge(4, 5),
|
||||
// MakeUnitEdge(5, 0),
|
||||
// MakeUnitEdge(5, 4)};
|
||||
std::vector<InputEdge> edges = {MakeUnitEdge(0, 1),
|
||||
MakeUnitEdge(0, 5),
|
||||
MakeUnitEdge(1, 0),
|
||||
MakeUnitEdge(1, 2),
|
||||
MakeUnitEdge(2, 1),
|
||||
MakeUnitEdge(2, 3),
|
||||
MakeUnitEdge(3, 2),
|
||||
MakeUnitEdge(3, 4),
|
||||
MakeUnitEdge(4, 3),
|
||||
MakeUnitEdge(4, 5),
|
||||
MakeUnitEdge(5, 0),
|
||||
MakeUnitEdge(5, 4)};
|
||||
|
||||
// Graph graph(6, edges);
|
||||
// BOOST_CHECK(edges.size() == 12);
|
||||
// BOOST_CHECK(compatible(graph, annotations, 0, 1));
|
||||
// BOOST_CHECK(compatible(graph, annotations, 1, 2));
|
||||
// BOOST_CHECK(compatible(graph, annotations, 2, 3));
|
||||
// BOOST_CHECK(compatible(graph, annotations, 3, 4));
|
||||
// BOOST_CHECK(compatible(graph, annotations, 4, 5));
|
||||
// BOOST_CHECK(compatible(graph, annotations, 5, 6));
|
||||
// BOOST_CHECK(compatible(graph, annotations, 6, 7));
|
||||
// BOOST_CHECK(compatible(graph, annotations, 7, 8));
|
||||
// BOOST_CHECK(compatible(graph, annotations, 8, 9));
|
||||
// BOOST_CHECK(compatible(graph, annotations, 9, 10));
|
||||
// BOOST_CHECK(compatible(graph, annotations, 10, 11));
|
||||
// BOOST_CHECK(compatible(graph, annotations, 11, 0));
|
||||
Graph graph(6, edges);
|
||||
BOOST_CHECK(edges.size() == 12);
|
||||
BOOST_CHECK(compatible(graph, annotations, 0, 1));
|
||||
BOOST_CHECK(compatible(graph, annotations, 1, 2));
|
||||
BOOST_CHECK(compatible(graph, annotations, 2, 3));
|
||||
BOOST_CHECK(compatible(graph, annotations, 3, 4));
|
||||
BOOST_CHECK(compatible(graph, annotations, 4, 5));
|
||||
BOOST_CHECK(compatible(graph, annotations, 5, 6));
|
||||
BOOST_CHECK(compatible(graph, annotations, 6, 7));
|
||||
BOOST_CHECK(compatible(graph, annotations, 7, 8));
|
||||
BOOST_CHECK(compatible(graph, annotations, 8, 9));
|
||||
BOOST_CHECK(compatible(graph, annotations, 9, 10));
|
||||
BOOST_CHECK(compatible(graph, annotations, 10, 11));
|
||||
BOOST_CHECK(compatible(graph, annotations, 11, 0));
|
||||
|
||||
// compressor.Compress(barrier_nodes,
|
||||
// traffic_lights,
|
||||
// scripting_environment,
|
||||
// restrictions,
|
||||
// conditional_restrictions,
|
||||
// maneuver_overrides,
|
||||
// graph,
|
||||
// annotations,
|
||||
// container);
|
||||
compressor.Compress(barrier_nodes,
|
||||
traffic_lights,
|
||||
scripting_environment,
|
||||
restrictions,
|
||||
conditional_restrictions,
|
||||
maneuver_overrides,
|
||||
graph,
|
||||
annotations,
|
||||
container);
|
||||
|
||||
// BOOST_CHECK_EQUAL(graph.FindEdge(5, 0), SPECIAL_EDGEID);
|
||||
// BOOST_CHECK_EQUAL(graph.FindEdge(0, 1), SPECIAL_EDGEID);
|
||||
// BOOST_CHECK_EQUAL(graph.FindEdge(1, 2), SPECIAL_EDGEID);
|
||||
// BOOST_CHECK_EQUAL(graph.FindEdge(2, 3), SPECIAL_EDGEID);
|
||||
// BOOST_CHECK(graph.FindEdge(5, 3) != SPECIAL_EDGEID);
|
||||
// BOOST_CHECK(graph.FindEdge(3, 4) != SPECIAL_EDGEID);
|
||||
// BOOST_CHECK(graph.FindEdge(4, 5) != SPECIAL_EDGEID);
|
||||
// }
|
||||
BOOST_CHECK_EQUAL(graph.FindEdge(5, 0), SPECIAL_EDGEID);
|
||||
BOOST_CHECK_EQUAL(graph.FindEdge(0, 1), SPECIAL_EDGEID);
|
||||
BOOST_CHECK_EQUAL(graph.FindEdge(1, 2), SPECIAL_EDGEID);
|
||||
BOOST_CHECK_EQUAL(graph.FindEdge(2, 3), SPECIAL_EDGEID);
|
||||
BOOST_CHECK(graph.FindEdge(5, 3) != SPECIAL_EDGEID);
|
||||
BOOST_CHECK(graph.FindEdge(3, 4) != SPECIAL_EDGEID);
|
||||
BOOST_CHECK(graph.FindEdge(4, 5) != SPECIAL_EDGEID);
|
||||
}
|
||||
|
||||
// BOOST_AUTO_TEST_CASE(t_intersection)
|
||||
// {
|
||||
// //
|
||||
// // 0---1---2
|
||||
// // |
|
||||
// // 3
|
||||
// //
|
||||
// GraphCompressor compressor;
|
||||
BOOST_AUTO_TEST_CASE(t_intersection)
|
||||
{
|
||||
//
|
||||
// 0---1---2
|
||||
// |
|
||||
// 3
|
||||
//
|
||||
GraphCompressor compressor;
|
||||
|
||||
// std::unordered_set<NodeID> barrier_nodes;
|
||||
// std::unordered_set<NodeID> traffic_lights;
|
||||
// std::vector<NodeBasedEdgeAnnotation> annotations(1);
|
||||
// std::vector<TurnRestriction> restrictions;
|
||||
// std::vector<ConditionalTurnRestriction> conditional_restrictions;
|
||||
// CompressedEdgeContainer container;
|
||||
// test::MockScriptingEnvironment scripting_environment;
|
||||
// std::vector<UnresolvedManeuverOverride> maneuver_overrides;
|
||||
std::unordered_set<NodeID> barrier_nodes;
|
||||
std::unordered_set<NodeID> traffic_lights;
|
||||
std::vector<NodeBasedEdgeAnnotation> annotations(1);
|
||||
std::vector<TurnRestriction> restrictions;
|
||||
std::vector<ConditionalTurnRestriction> conditional_restrictions;
|
||||
CompressedEdgeContainer container;
|
||||
test::MockScriptingEnvironment scripting_environment;
|
||||
std::vector<UnresolvedManeuverOverride> maneuver_overrides;
|
||||
|
||||
// std::vector<InputEdge> edges = {MakeUnitEdge(0, 1),
|
||||
// MakeUnitEdge(1, 0),
|
||||
// MakeUnitEdge(1, 2),
|
||||
// MakeUnitEdge(1, 3),
|
||||
// MakeUnitEdge(2, 1),
|
||||
// MakeUnitEdge(3, 1)};
|
||||
std::vector<InputEdge> edges = {MakeUnitEdge(0, 1),
|
||||
MakeUnitEdge(1, 0),
|
||||
MakeUnitEdge(1, 2),
|
||||
MakeUnitEdge(1, 3),
|
||||
MakeUnitEdge(2, 1),
|
||||
MakeUnitEdge(3, 1)};
|
||||
|
||||
// Graph graph(4, edges);
|
||||
// BOOST_CHECK(compatible(graph, annotations, 0, 1));
|
||||
// BOOST_CHECK(compatible(graph, annotations, 1, 2));
|
||||
// BOOST_CHECK(compatible(graph, annotations, 2, 3));
|
||||
// BOOST_CHECK(compatible(graph, annotations, 3, 4));
|
||||
// BOOST_CHECK(compatible(graph, annotations, 4, 5));
|
||||
Graph graph(4, edges);
|
||||
BOOST_CHECK(compatible(graph, annotations, 0, 1));
|
||||
BOOST_CHECK(compatible(graph, annotations, 1, 2));
|
||||
BOOST_CHECK(compatible(graph, annotations, 2, 3));
|
||||
BOOST_CHECK(compatible(graph, annotations, 3, 4));
|
||||
BOOST_CHECK(compatible(graph, annotations, 4, 5));
|
||||
|
||||
// compressor.Compress(barrier_nodes,
|
||||
// traffic_lights,
|
||||
// scripting_environment,
|
||||
// restrictions,
|
||||
// conditional_restrictions,
|
||||
// maneuver_overrides,
|
||||
// graph,
|
||||
// annotations,
|
||||
// container);
|
||||
compressor.Compress(barrier_nodes,
|
||||
traffic_lights,
|
||||
scripting_environment,
|
||||
restrictions,
|
||||
conditional_restrictions,
|
||||
maneuver_overrides,
|
||||
graph,
|
||||
annotations,
|
||||
container);
|
||||
|
||||
// BOOST_CHECK(graph.FindEdge(0, 1) != SPECIAL_EDGEID);
|
||||
// BOOST_CHECK(graph.FindEdge(1, 2) != SPECIAL_EDGEID);
|
||||
// BOOST_CHECK(graph.FindEdge(1, 3) != SPECIAL_EDGEID);
|
||||
// }
|
||||
BOOST_CHECK(graph.FindEdge(0, 1) != SPECIAL_EDGEID);
|
||||
BOOST_CHECK(graph.FindEdge(1, 2) != SPECIAL_EDGEID);
|
||||
BOOST_CHECK(graph.FindEdge(1, 3) != SPECIAL_EDGEID);
|
||||
}
|
||||
|
||||
// BOOST_AUTO_TEST_CASE(street_name_changes)
|
||||
// {
|
||||
// //
|
||||
// // 0---1---2
|
||||
// //
|
||||
// GraphCompressor compressor;
|
||||
BOOST_AUTO_TEST_CASE(street_name_changes)
|
||||
{
|
||||
//
|
||||
// 0---1---2
|
||||
//
|
||||
GraphCompressor compressor;
|
||||
|
||||
// std::unordered_set<NodeID> barrier_nodes;
|
||||
// std::unordered_set<NodeID> traffic_lights;
|
||||
// std::vector<NodeBasedEdgeAnnotation> annotations(2);
|
||||
// std::vector<TurnRestriction> restrictions;
|
||||
// std::vector<ConditionalTurnRestriction> conditional_restrictions;
|
||||
// CompressedEdgeContainer container;
|
||||
// test::MockScriptingEnvironment scripting_environment;
|
||||
// std::vector<UnresolvedManeuverOverride> maneuver_overrides;
|
||||
std::unordered_set<NodeID> barrier_nodes;
|
||||
std::unordered_set<NodeID> traffic_lights;
|
||||
std::vector<NodeBasedEdgeAnnotation> annotations(2);
|
||||
std::vector<TurnRestriction> restrictions;
|
||||
std::vector<ConditionalTurnRestriction> conditional_restrictions;
|
||||
CompressedEdgeContainer container;
|
||||
test::MockScriptingEnvironment scripting_environment;
|
||||
std::vector<UnresolvedManeuverOverride> maneuver_overrides;
|
||||
|
||||
// std::vector<InputEdge> edges = {
|
||||
// MakeUnitEdge(0, 1), MakeUnitEdge(1, 0), MakeUnitEdge(1, 2), MakeUnitEdge(2, 1)};
|
||||
std::vector<InputEdge> edges = {
|
||||
MakeUnitEdge(0, 1), MakeUnitEdge(1, 0), MakeUnitEdge(1, 2), MakeUnitEdge(2, 1)};
|
||||
|
||||
// annotations[1].name_id = 1;
|
||||
// edges[2].data.annotation_data = edges[3].data.annotation_data = 1;
|
||||
annotations[1].name_id = 1;
|
||||
edges[2].data.annotation_data = edges[3].data.annotation_data = 1;
|
||||
|
||||
// Graph graph(5, edges);
|
||||
// BOOST_CHECK(compatible(graph, annotations, 0, 1));
|
||||
// BOOST_CHECK(compatible(graph, annotations, 2, 3));
|
||||
Graph graph(5, edges);
|
||||
BOOST_CHECK(compatible(graph, annotations, 0, 1));
|
||||
BOOST_CHECK(compatible(graph, annotations, 2, 3));
|
||||
|
||||
// compressor.Compress(barrier_nodes,
|
||||
// traffic_lights,
|
||||
// scripting_environment,
|
||||
// restrictions,
|
||||
// conditional_restrictions,
|
||||
// maneuver_overrides,
|
||||
// graph,
|
||||
// annotations,
|
||||
// container);
|
||||
compressor.Compress(barrier_nodes,
|
||||
traffic_lights,
|
||||
scripting_environment,
|
||||
restrictions,
|
||||
conditional_restrictions,
|
||||
maneuver_overrides,
|
||||
graph,
|
||||
annotations,
|
||||
container);
|
||||
|
||||
// BOOST_CHECK(graph.FindEdge(0, 1) != SPECIAL_EDGEID);
|
||||
// BOOST_CHECK(graph.FindEdge(1, 2) != SPECIAL_EDGEID);
|
||||
// }
|
||||
BOOST_CHECK(graph.FindEdge(0, 1) != SPECIAL_EDGEID);
|
||||
BOOST_CHECK(graph.FindEdge(1, 2) != SPECIAL_EDGEID);
|
||||
}
|
||||
|
||||
// BOOST_AUTO_TEST_CASE(direction_changes)
|
||||
// {
|
||||
// //
|
||||
// // 0-->1---2
|
||||
// //
|
||||
// GraphCompressor compressor;
|
||||
BOOST_AUTO_TEST_CASE(direction_changes)
|
||||
{
|
||||
//
|
||||
// 0-->1---2
|
||||
//
|
||||
GraphCompressor compressor;
|
||||
|
||||
// std::unordered_set<NodeID> barrier_nodes;
|
||||
// std::unordered_set<NodeID> traffic_lights;
|
||||
// std::vector<NodeBasedEdgeAnnotation> annotations(1);
|
||||
// std::vector<TurnRestriction> restrictions;
|
||||
// std::vector<ConditionalTurnRestriction> conditional_restrictions;
|
||||
// CompressedEdgeContainer container;
|
||||
// test::MockScriptingEnvironment scripting_environment;
|
||||
// std::vector<UnresolvedManeuverOverride> maneuver_overrides;
|
||||
std::unordered_set<NodeID> barrier_nodes;
|
||||
std::unordered_set<NodeID> traffic_lights;
|
||||
std::vector<NodeBasedEdgeAnnotation> annotations(1);
|
||||
std::vector<TurnRestriction> restrictions;
|
||||
std::vector<ConditionalTurnRestriction> conditional_restrictions;
|
||||
CompressedEdgeContainer container;
|
||||
test::MockScriptingEnvironment scripting_environment;
|
||||
std::vector<UnresolvedManeuverOverride> maneuver_overrides;
|
||||
|
||||
// std::vector<InputEdge> edges = {
|
||||
// MakeUnitEdge(0, 1), MakeUnitEdge(1, 0), MakeUnitEdge(1, 2), MakeUnitEdge(2, 1)};
|
||||
// // make first edge point forward
|
||||
// edges[1].data.reversed = true;
|
||||
std::vector<InputEdge> edges = {
|
||||
MakeUnitEdge(0, 1), MakeUnitEdge(1, 0), MakeUnitEdge(1, 2), MakeUnitEdge(2, 1)};
|
||||
// make first edge point forward
|
||||
edges[1].data.reversed = true;
|
||||
|
||||
// Graph graph(5, edges);
|
||||
// compressor.Compress(barrier_nodes,
|
||||
// traffic_lights,
|
||||
// scripting_environment,
|
||||
// restrictions,
|
||||
// conditional_restrictions,
|
||||
// maneuver_overrides,
|
||||
// graph,
|
||||
// annotations,
|
||||
// container);
|
||||
Graph graph(5, edges);
|
||||
compressor.Compress(barrier_nodes,
|
||||
traffic_lights,
|
||||
scripting_environment,
|
||||
restrictions,
|
||||
conditional_restrictions,
|
||||
maneuver_overrides,
|
||||
graph,
|
||||
annotations,
|
||||
container);
|
||||
|
||||
// BOOST_CHECK(graph.FindEdge(0, 1) != SPECIAL_EDGEID);
|
||||
// BOOST_CHECK(graph.FindEdge(1, 2) != SPECIAL_EDGEID);
|
||||
// }
|
||||
BOOST_CHECK(graph.FindEdge(0, 1) != SPECIAL_EDGEID);
|
||||
BOOST_CHECK(graph.FindEdge(1, 2) != SPECIAL_EDGEID);
|
||||
}
|
||||
|
||||
// BOOST_AUTO_TEST_SUITE_END()
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// #include "extractor/intersection/intersection_analysis.hpp"
|
||||
#include "extractor/intersection/intersection_analysis.hpp"
|
||||
|
||||
#include "extractor/graph_compressor.hpp"
|
||||
|
||||
@@ -17,306 +17,305 @@ using namespace osrm::extractor::intersection;
|
||||
using InputEdge = util::NodeBasedDynamicGraph::InputEdge;
|
||||
using Graph = util::NodeBasedDynamicGraph;
|
||||
|
||||
// BOOST_AUTO_TEST_CASE(simple_intersection_connectivity)
|
||||
// {
|
||||
// std::unordered_set<NodeID> barrier_nodes{6};
|
||||
// std::unordered_set<NodeID> traffic_lights;
|
||||
// std::vector<NodeBasedEdgeAnnotation> annotations{
|
||||
// {EMPTY_NAMEID, 0, INAVLID_CLASS_DATA, TRAVEL_MODE_DRIVING, false},
|
||||
// {EMPTY_NAMEID, 1, INAVLID_CLASS_DATA, TRAVEL_MODE_DRIVING, false}};
|
||||
// std::vector<TurnRestriction> restrictions{TurnRestriction{NodeRestriction{0, 2, 1}, false}};
|
||||
// std::vector<ConditionalTurnRestriction> conditional_restrictions;
|
||||
// CompressedEdgeContainer container;
|
||||
// test::MockScriptingEnvironment scripting_environment;
|
||||
// std::vector<UnresolvedManeuverOverride> maneuver_overrides;
|
||||
BOOST_AUTO_TEST_CASE(simple_intersection_connectivity)
|
||||
{
|
||||
std::unordered_set<NodeID> barrier_nodes{6};
|
||||
std::unordered_set<NodeID> traffic_lights;
|
||||
std::vector<NodeBasedEdgeAnnotation> annotations{
|
||||
{EMPTY_NAMEID, 0, INAVLID_CLASS_DATA, TRAVEL_MODE_DRIVING, false},
|
||||
{EMPTY_NAMEID, 1, INAVLID_CLASS_DATA, TRAVEL_MODE_DRIVING, false}};
|
||||
std::vector<TurnRestriction> restrictions{TurnRestriction{NodeRestriction{0, 2, 1}, false}};
|
||||
std::vector<ConditionalTurnRestriction> conditional_restrictions;
|
||||
CompressedEdgeContainer container;
|
||||
test::MockScriptingEnvironment scripting_environment;
|
||||
std::vector<UnresolvedManeuverOverride> maneuver_overrides;
|
||||
|
||||
// TurnLanesIndexedArray turn_lanes_data{{0, 0, 3},
|
||||
// {TurnLaneType::uturn | TurnLaneType::left,
|
||||
// TurnLaneType::straight,
|
||||
// TurnLaneType::straight | TurnLaneType::right}};
|
||||
TurnLanesIndexedArray turn_lanes_data{{0, 0, 3},
|
||||
{TurnLaneType::uturn | TurnLaneType::left,
|
||||
TurnLaneType::straight,
|
||||
TurnLaneType::straight | TurnLaneType::right}};
|
||||
|
||||
// // Graph with an additional turn restriction 0→2→1 and bollard at 6
|
||||
// // 0→5↔6↔7
|
||||
// // ↕
|
||||
// // 1↔2←3
|
||||
// // ↓
|
||||
// // 4
|
||||
// const auto unit_edge =
|
||||
// [](const NodeID from, const NodeID to, bool allowed, AnnotationID annotation) {
|
||||
// return InputEdge{from,
|
||||
// to,
|
||||
// 1,
|
||||
// 1,
|
||||
// GeometryID{0, false},
|
||||
// !allowed,
|
||||
// NodeBasedEdgeClassification(),
|
||||
// annotation};
|
||||
// };
|
||||
// Graph with an additional turn restriction 0→2→1 and bollard at 6
|
||||
// 0→5↔6↔7
|
||||
// ↕
|
||||
// 1↔2←3
|
||||
// ↓
|
||||
// 4
|
||||
const auto unit_edge =
|
||||
[](const NodeID from, const NodeID to, bool allowed, AnnotationID annotation) {
|
||||
return InputEdge{from,
|
||||
to,
|
||||
1,
|
||||
1,
|
||||
GeometryID{0, false},
|
||||
!allowed,
|
||||
NodeBasedEdgeClassification(),
|
||||
annotation};
|
||||
};
|
||||
|
||||
// std::vector<InputEdge> edges = {unit_edge(0, 2, true, 1),
|
||||
// unit_edge(0, 5, true, 0),
|
||||
// unit_edge(1, 2, true, 0),
|
||||
// unit_edge(2, 0, true, 0),
|
||||
// unit_edge(2, 1, true, 0),
|
||||
// unit_edge(2, 3, false, 0),
|
||||
// unit_edge(2, 4, true, 0),
|
||||
// unit_edge(3, 2, true, 0),
|
||||
// unit_edge(4, 2, false, 0),
|
||||
// unit_edge(5, 0, false, 0),
|
||||
// unit_edge(5, 6, true, 0),
|
||||
// unit_edge(6, 5, true, 0),
|
||||
// unit_edge(6, 7, true, 0),
|
||||
// unit_edge(7, 6, true, 0)};
|
||||
// IntersectionEdgeGeometries edge_geometries{
|
||||
// {0, 180, 180, 10.}, // 0→2
|
||||
// {1, 90, 90, 10.}, // 0→5
|
||||
// {2, 90, 90, 10.}, // 1→2
|
||||
// {3, 0, 0, 10.}, // 2→0
|
||||
// {4, 270, 270, 10.}, // 2→1
|
||||
// {5, 90, 90, 10.}, // 2→3
|
||||
// {6, 180, 180, 10.}, // 2→4
|
||||
// {7, 270, 270, 10.}, // 3→2
|
||||
// {8, 0, 0, 10.}, // 4→2
|
||||
// {9, 270, 270, 10.}, // 5→0
|
||||
// {10, 90, 90, 10.}, // 5→6
|
||||
// {11, 270, 270, 10.}, // 6→5
|
||||
// {12, 90, 90, 10.}, // 6→7
|
||||
// {13, 270, 270, 10.} // 7→6
|
||||
// };
|
||||
std::vector<InputEdge> edges = {unit_edge(0, 2, true, 1),
|
||||
unit_edge(0, 5, true, 0),
|
||||
unit_edge(1, 2, true, 0),
|
||||
unit_edge(2, 0, true, 0),
|
||||
unit_edge(2, 1, true, 0),
|
||||
unit_edge(2, 3, false, 0),
|
||||
unit_edge(2, 4, true, 0),
|
||||
unit_edge(3, 2, true, 0),
|
||||
unit_edge(4, 2, false, 0),
|
||||
unit_edge(5, 0, false, 0),
|
||||
unit_edge(5, 6, true, 0),
|
||||
unit_edge(6, 5, true, 0),
|
||||
unit_edge(6, 7, true, 0),
|
||||
unit_edge(7, 6, true, 0)};
|
||||
IntersectionEdgeGeometries edge_geometries{
|
||||
{0, 180, 180, 10.}, // 0→2
|
||||
{1, 90, 90, 10.}, // 0→5
|
||||
{2, 90, 90, 10.}, // 1→2
|
||||
{3, 0, 0, 10.}, // 2→0
|
||||
{4, 270, 270, 10.}, // 2→1
|
||||
{5, 90, 90, 10.}, // 2→3
|
||||
{6, 180, 180, 10.}, // 2→4
|
||||
{7, 270, 270, 10.}, // 3→2
|
||||
{8, 0, 0, 10.}, // 4→2
|
||||
{9, 270, 270, 10.}, // 5→0
|
||||
{10, 90, 90, 10.}, // 5→6
|
||||
{11, 270, 270, 10.}, // 6→5
|
||||
{12, 90, 90, 10.}, // 6→7
|
||||
{13, 270, 270, 10.} // 7→6
|
||||
};
|
||||
|
||||
// Graph graph(8, edges);
|
||||
Graph graph(8, edges);
|
||||
|
||||
// GraphCompressor().Compress(barrier_nodes,
|
||||
// traffic_lights,
|
||||
// scripting_environment,
|
||||
// restrictions,
|
||||
// conditional_restrictions,
|
||||
// maneuver_overrides,
|
||||
// graph,
|
||||
// annotations,
|
||||
// container);
|
||||
GraphCompressor().Compress(barrier_nodes,
|
||||
traffic_lights,
|
||||
scripting_environment,
|
||||
restrictions,
|
||||
conditional_restrictions,
|
||||
maneuver_overrides,
|
||||
graph,
|
||||
annotations,
|
||||
container);
|
||||
|
||||
// REQUIRE_SIZE_RANGE(getIncomingEdges(graph, 2), 3);
|
||||
// REQUIRE_SIZE_RANGE(getOutgoingEdges(graph, 2), 4);
|
||||
REQUIRE_SIZE_RANGE(getIncomingEdges(graph, 2), 3);
|
||||
REQUIRE_SIZE_RANGE(getOutgoingEdges(graph, 2), 4);
|
||||
|
||||
// EdgeBasedNodeDataContainer node_data_container(
|
||||
// std::vector<EdgeBasedNode>(graph.GetNumberOfEdges()), annotations);
|
||||
// RestrictionMap restriction_map(restrictions, IndexNodeByFromAndVia());
|
||||
EdgeBasedNodeDataContainer node_data_container(
|
||||
std::vector<EdgeBasedNode>(graph.GetNumberOfEdges()), annotations);
|
||||
RestrictionMap restriction_map(restrictions, IndexNodeByFromAndVia());
|
||||
|
||||
// const auto connectivity_matrix = [&](NodeID node) {
|
||||
// std::vector<bool> result;
|
||||
// const auto incoming_edges = getIncomingEdges(graph, node);
|
||||
// const auto outgoing_edges = getOutgoingEdges(graph, node);
|
||||
// for (const auto incoming_edge : incoming_edges)
|
||||
// {
|
||||
// for (const auto outgoing_edge : outgoing_edges)
|
||||
// {
|
||||
// result.push_back(isTurnAllowed(graph,
|
||||
// node_data_container,
|
||||
// restriction_map,
|
||||
// barrier_nodes,
|
||||
// edge_geometries,
|
||||
// turn_lanes_data,
|
||||
// incoming_edge,
|
||||
// outgoing_edge));
|
||||
// }
|
||||
// }
|
||||
// return result;
|
||||
// };
|
||||
const auto connectivity_matrix = [&](NodeID node) {
|
||||
std::vector<bool> result;
|
||||
const auto incoming_edges = getIncomingEdges(graph, node);
|
||||
const auto outgoing_edges = getOutgoingEdges(graph, node);
|
||||
for (const auto incoming_edge : incoming_edges)
|
||||
{
|
||||
for (const auto outgoing_edge : outgoing_edges)
|
||||
{
|
||||
result.push_back(isTurnAllowed(graph,
|
||||
node_data_container,
|
||||
restriction_map,
|
||||
barrier_nodes,
|
||||
edge_geometries,
|
||||
turn_lanes_data,
|
||||
incoming_edge,
|
||||
outgoing_edge));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
// CHECK_EQUAL_RANGE(connectivity_matrix(0), 1, 1); // from node 2 allowed U-turn and to node 5
|
||||
// CHECK_EQUAL_RANGE(connectivity_matrix(1), 1); // from node 2 allowed U-turn
|
||||
// CHECK_EQUAL_RANGE(connectivity_matrix(2),
|
||||
// // clang-format off
|
||||
// 1, 0, 0, 1, // from node 0 to node 4 and a U-turn at 2
|
||||
// 1, 0, 0, 1, // from node 1 to nodes 0 and 4
|
||||
// 1, 1, 0, 1 // from node 3 to nodes 0, 1 and 4
|
||||
// // clang-format on
|
||||
// );
|
||||
// REQUIRE_SIZE_RANGE(connectivity_matrix(3), 0); // no incoming edges, empty matrix
|
||||
// CHECK_EQUAL_RANGE(connectivity_matrix(4), 0); // from node 2 not allowed U-turn
|
||||
// CHECK_EQUAL_RANGE(connectivity_matrix(5),
|
||||
// // clang-format off
|
||||
// 0, 1, // from node 0 to node 6
|
||||
// 0, 1, // from node 6 a U-turn to node 6
|
||||
// // clang-format on
|
||||
// );
|
||||
CHECK_EQUAL_RANGE(connectivity_matrix(0), 1, 1); // from node 2 allowed U-turn and to node 5
|
||||
CHECK_EQUAL_RANGE(connectivity_matrix(1), 1); // from node 2 allowed U-turn
|
||||
CHECK_EQUAL_RANGE(connectivity_matrix(2),
|
||||
// clang-format off
|
||||
1, 0, 0, 1, // from node 0 to node 4 and a U-turn at 2
|
||||
1, 0, 0, 1, // from node 1 to nodes 0 and 4
|
||||
1, 1, 0, 1 // from node 3 to nodes 0, 1 and 4
|
||||
// clang-format on
|
||||
);
|
||||
REQUIRE_SIZE_RANGE(connectivity_matrix(3), 0); // no incoming edges, empty matrix
|
||||
CHECK_EQUAL_RANGE(connectivity_matrix(4), 0); // from node 2 not allowed U-turn
|
||||
CHECK_EQUAL_RANGE(connectivity_matrix(5),
|
||||
// clang-format off
|
||||
0, 1, // from node 0 to node 6
|
||||
0, 1, // from node 6 a U-turn to node 6
|
||||
// clang-format on
|
||||
);
|
||||
|
||||
// CHECK_EQUAL_RANGE(connectivity_matrix(6),
|
||||
// // clang-format off
|
||||
// 1, 0, // from node 5 a U-turn to node 5
|
||||
// 0, 1, // from node 7 a U-turn to node 7
|
||||
// // clang-format on
|
||||
// );
|
||||
// }
|
||||
CHECK_EQUAL_RANGE(connectivity_matrix(6),
|
||||
// clang-format off
|
||||
1, 0, // from node 5 a U-turn to node 5
|
||||
0, 1, // from node 7 a U-turn to node 7
|
||||
// clang-format on
|
||||
);
|
||||
}
|
||||
|
||||
// BOOST_AUTO_TEST_CASE(roundabout_intersection_connectivity)
|
||||
// {
|
||||
// std::unordered_set<NodeID> barrier_nodes;
|
||||
// std::unordered_set<NodeID> traffic_lights;
|
||||
// std::vector<NodeBasedEdgeAnnotation> annotations;
|
||||
// std::vector<TurnRestriction> restrictions;
|
||||
// std::vector<ConditionalTurnRestriction> conditional_restrictions;
|
||||
// CompressedEdgeContainer container;
|
||||
// test::MockScriptingEnvironment scripting_environment;
|
||||
// std::vector<UnresolvedManeuverOverride> maneuver_overrides;
|
||||
BOOST_AUTO_TEST_CASE(roundabout_intersection_connectivity)
|
||||
{
|
||||
std::unordered_set<NodeID> barrier_nodes;
|
||||
std::unordered_set<NodeID> traffic_lights;
|
||||
std::vector<NodeBasedEdgeAnnotation> annotations;
|
||||
std::vector<TurnRestriction> restrictions;
|
||||
std::vector<ConditionalTurnRestriction> conditional_restrictions;
|
||||
CompressedEdgeContainer container;
|
||||
test::MockScriptingEnvironment scripting_environment;
|
||||
std::vector<UnresolvedManeuverOverride> maneuver_overrides;
|
||||
|
||||
// TurnLanesIndexedArray turn_lanes_data;
|
||||
TurnLanesIndexedArray turn_lanes_data;
|
||||
|
||||
// // Graph with roundabout edges 5→0→2
|
||||
// // 1 2 3
|
||||
// // ↘ ↑ ↙
|
||||
// // 0
|
||||
// // ↙ ↑ ↘
|
||||
// // 4 5 6
|
||||
// const auto unit_edge = [](const NodeID from, const NodeID to, bool allowed, bool roundabout)
|
||||
// {
|
||||
// return InputEdge{from,
|
||||
// to,
|
||||
// 1,
|
||||
// 1,
|
||||
// GeometryID{0, false},
|
||||
// !allowed,
|
||||
// NodeBasedEdgeClassification{
|
||||
// true, false, false, roundabout, false, false, false, {}, 0, 0},
|
||||
// 0};
|
||||
// };
|
||||
// std::vector<InputEdge> edges = {unit_edge(0, 1, false, false),
|
||||
// unit_edge(0, 2, true, true),
|
||||
// unit_edge(0, 3, false, false),
|
||||
// unit_edge(0, 4, true, false),
|
||||
// unit_edge(0, 5, false, true),
|
||||
// unit_edge(0, 6, true, false),
|
||||
// unit_edge(1, 0, true, false),
|
||||
// unit_edge(2, 0, false, true),
|
||||
// unit_edge(3, 0, true, false),
|
||||
// unit_edge(4, 0, false, false),
|
||||
// unit_edge(5, 0, true, true),
|
||||
// unit_edge(6, 0, false, false)};
|
||||
// IntersectionEdgeGeometries edge_geometries{
|
||||
// {0, 315, 315, 10}, // 0→1
|
||||
// {1, 0, 0, 10}, // 0→2
|
||||
// {2, 45, 45, 10}, // 0→3
|
||||
// {3, 225, 225, 10}, // 0→4
|
||||
// {4, 180, 180, 10}, // 0→5
|
||||
// {5, 135, 135, 10}, // 0→6
|
||||
// {6, 135, 135, 10}, // 1→0
|
||||
// {7, 180, 180, 10}, // 2→0
|
||||
// {8, 225, 225, 10}, // 3→0
|
||||
// {9, 45, 45, 10}, // 4→0
|
||||
// {10, 0, 0, 10}, // 5→0
|
||||
// {11, 315, 315, 10} // 6→0
|
||||
// };
|
||||
// Graph with roundabout edges 5→0→2
|
||||
// 1 2 3
|
||||
// ↘ ↑ ↙
|
||||
// 0
|
||||
// ↙ ↑ ↘
|
||||
// 4 5 6
|
||||
const auto unit_edge = [](const NodeID from, const NodeID to, bool allowed, bool roundabout) {
|
||||
return InputEdge{from,
|
||||
to,
|
||||
1,
|
||||
1,
|
||||
GeometryID{0, false},
|
||||
!allowed,
|
||||
NodeBasedEdgeClassification{
|
||||
true, false, false, roundabout, false, false, false, {}, 0, 0},
|
||||
0};
|
||||
};
|
||||
std::vector<InputEdge> edges = {unit_edge(0, 1, false, false),
|
||||
unit_edge(0, 2, true, true),
|
||||
unit_edge(0, 3, false, false),
|
||||
unit_edge(0, 4, true, false),
|
||||
unit_edge(0, 5, false, true),
|
||||
unit_edge(0, 6, true, false),
|
||||
unit_edge(1, 0, true, false),
|
||||
unit_edge(2, 0, false, true),
|
||||
unit_edge(3, 0, true, false),
|
||||
unit_edge(4, 0, false, false),
|
||||
unit_edge(5, 0, true, true),
|
||||
unit_edge(6, 0, false, false)};
|
||||
IntersectionEdgeGeometries edge_geometries{
|
||||
{0, 315, 315, 10}, // 0→1
|
||||
{1, 0, 0, 10}, // 0→2
|
||||
{2, 45, 45, 10}, // 0→3
|
||||
{3, 225, 225, 10}, // 0→4
|
||||
{4, 180, 180, 10}, // 0→5
|
||||
{5, 135, 135, 10}, // 0→6
|
||||
{6, 135, 135, 10}, // 1→0
|
||||
{7, 180, 180, 10}, // 2→0
|
||||
{8, 225, 225, 10}, // 3→0
|
||||
{9, 45, 45, 10}, // 4→0
|
||||
{10, 0, 0, 10}, // 5→0
|
||||
{11, 315, 315, 10} // 6→0
|
||||
};
|
||||
|
||||
// Graph graph(7, edges);
|
||||
Graph graph(7, edges);
|
||||
|
||||
// GraphCompressor().Compress(barrier_nodes,
|
||||
// traffic_lights,
|
||||
// scripting_environment,
|
||||
// restrictions,
|
||||
// conditional_restrictions,
|
||||
// maneuver_overrides,
|
||||
// graph,
|
||||
// annotations,
|
||||
// container);
|
||||
GraphCompressor().Compress(barrier_nodes,
|
||||
traffic_lights,
|
||||
scripting_environment,
|
||||
restrictions,
|
||||
conditional_restrictions,
|
||||
maneuver_overrides,
|
||||
graph,
|
||||
annotations,
|
||||
container);
|
||||
|
||||
// REQUIRE_SIZE_RANGE(getIncomingEdges(graph, 0), 3);
|
||||
// REQUIRE_SIZE_RANGE(getOutgoingEdges(graph, 0), 6);
|
||||
REQUIRE_SIZE_RANGE(getIncomingEdges(graph, 0), 3);
|
||||
REQUIRE_SIZE_RANGE(getOutgoingEdges(graph, 0), 6);
|
||||
|
||||
// EdgeBasedNodeDataContainer node_data_container(
|
||||
// std::vector<EdgeBasedNode>(graph.GetNumberOfEdges()), annotations);
|
||||
// RestrictionMap restriction_map(restrictions, IndexNodeByFromAndVia());
|
||||
EdgeBasedNodeDataContainer node_data_container(
|
||||
std::vector<EdgeBasedNode>(graph.GetNumberOfEdges()), annotations);
|
||||
RestrictionMap restriction_map(restrictions, IndexNodeByFromAndVia());
|
||||
|
||||
// const auto connectivity_matrix = [&](NodeID node) {
|
||||
// std::vector<bool> result;
|
||||
// const auto incoming_edges = getIncomingEdges(graph, node);
|
||||
// const auto outgoing_edges = getOutgoingEdges(graph, node);
|
||||
// for (const auto incoming_edge : incoming_edges)
|
||||
// {
|
||||
// for (const auto outgoing_edge : outgoing_edges)
|
||||
// {
|
||||
// result.push_back(isTurnAllowed(graph,
|
||||
// node_data_container,
|
||||
// restriction_map,
|
||||
// barrier_nodes,
|
||||
// edge_geometries,
|
||||
// turn_lanes_data,
|
||||
// incoming_edge,
|
||||
// outgoing_edge));
|
||||
// }
|
||||
// }
|
||||
// return result;
|
||||
// };
|
||||
const auto connectivity_matrix = [&](NodeID node) {
|
||||
std::vector<bool> result;
|
||||
const auto incoming_edges = getIncomingEdges(graph, node);
|
||||
const auto outgoing_edges = getOutgoingEdges(graph, node);
|
||||
for (const auto incoming_edge : incoming_edges)
|
||||
{
|
||||
for (const auto outgoing_edge : outgoing_edges)
|
||||
{
|
||||
result.push_back(isTurnAllowed(graph,
|
||||
node_data_container,
|
||||
restriction_map,
|
||||
barrier_nodes,
|
||||
edge_geometries,
|
||||
turn_lanes_data,
|
||||
incoming_edge,
|
||||
outgoing_edge));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
// CHECK_EQUAL_RANGE(connectivity_matrix(0),
|
||||
// // clang-format off
|
||||
// 0, 1, 0, 0, 0, 1, // from node 1 to nodes 2 and 6
|
||||
// 0, 1, 0, 1, 0, 0, // from node 3 to nodes 2 and 4
|
||||
// 0, 1, 0, 1, 0, 1 // from node 5 to nodes 2, 4 and 6
|
||||
// // clang-format on
|
||||
// );
|
||||
// }
|
||||
CHECK_EQUAL_RANGE(connectivity_matrix(0),
|
||||
// clang-format off
|
||||
0, 1, 0, 0, 0, 1, // from node 1 to nodes 2 and 6
|
||||
0, 1, 0, 1, 0, 0, // from node 3 to nodes 2 and 4
|
||||
0, 1, 0, 1, 0, 1 // from node 5 to nodes 2, 4 and 6
|
||||
// clang-format on
|
||||
);
|
||||
}
|
||||
|
||||
// BOOST_AUTO_TEST_CASE(skip_degree_two_nodes)
|
||||
// {
|
||||
// std::unordered_set<NodeID> barrier_nodes{1};
|
||||
// std::unordered_set<NodeID> traffic_lights{2};
|
||||
// std::vector<NodeBasedEdgeAnnotation> annotations(1);
|
||||
// std::vector<TurnRestriction> restrictions;
|
||||
// std::vector<ConditionalTurnRestriction> conditional_restrictions;
|
||||
// CompressedEdgeContainer container;
|
||||
// test::MockScriptingEnvironment scripting_environment;
|
||||
// std::vector<UnresolvedManeuverOverride> maneuver_overrides;
|
||||
BOOST_AUTO_TEST_CASE(skip_degree_two_nodes)
|
||||
{
|
||||
std::unordered_set<NodeID> barrier_nodes{1};
|
||||
std::unordered_set<NodeID> traffic_lights{2};
|
||||
std::vector<NodeBasedEdgeAnnotation> annotations(1);
|
||||
std::vector<TurnRestriction> restrictions;
|
||||
std::vector<ConditionalTurnRestriction> conditional_restrictions;
|
||||
CompressedEdgeContainer container;
|
||||
test::MockScriptingEnvironment scripting_environment;
|
||||
std::vector<UnresolvedManeuverOverride> maneuver_overrides;
|
||||
|
||||
// TurnLanesIndexedArray turn_lanes_data;
|
||||
TurnLanesIndexedArray turn_lanes_data;
|
||||
|
||||
// // Graph
|
||||
// //
|
||||
// // 0↔1→2↔3↔4→5 7
|
||||
// // ↑ ↕ ↕
|
||||
// // 6 8 ↔ 9
|
||||
// //
|
||||
// const auto unit_edge = [](const NodeID from, const NodeID to, bool allowed) {
|
||||
// return InputEdge{
|
||||
// from, to, 1, 1, GeometryID{0, false}, !allowed, NodeBasedEdgeClassification{}, 0};
|
||||
// };
|
||||
// std::vector<InputEdge> edges = {unit_edge(0, 1, true), // 0
|
||||
// unit_edge(1, 0, true),
|
||||
// unit_edge(1, 2, true),
|
||||
// unit_edge(2, 1, false),
|
||||
// unit_edge(2, 3, true),
|
||||
// unit_edge(3, 2, true), // 5
|
||||
// unit_edge(3, 4, true),
|
||||
// unit_edge(4, 3, true),
|
||||
// unit_edge(4, 5, true),
|
||||
// unit_edge(4, 6, false),
|
||||
// unit_edge(5, 4, false), // 10
|
||||
// unit_edge(6, 4, true),
|
||||
// // Circle
|
||||
// unit_edge(7, 8, true), // 12
|
||||
// unit_edge(7, 9, true),
|
||||
// unit_edge(8, 7, true),
|
||||
// unit_edge(8, 9, true),
|
||||
// unit_edge(9, 7, true),
|
||||
// unit_edge(9, 8, true)};
|
||||
// Graph
|
||||
//
|
||||
// 0↔1→2↔3↔4→5 7
|
||||
// ↑ ↕ ↕
|
||||
// 6 8 ↔ 9
|
||||
//
|
||||
const auto unit_edge = [](const NodeID from, const NodeID to, bool allowed) {
|
||||
return InputEdge{
|
||||
from, to, 1, 1, GeometryID{0, false}, !allowed, NodeBasedEdgeClassification{}, 0};
|
||||
};
|
||||
std::vector<InputEdge> edges = {unit_edge(0, 1, true), // 0
|
||||
unit_edge(1, 0, true),
|
||||
unit_edge(1, 2, true),
|
||||
unit_edge(2, 1, false),
|
||||
unit_edge(2, 3, true),
|
||||
unit_edge(3, 2, true), // 5
|
||||
unit_edge(3, 4, true),
|
||||
unit_edge(4, 3, true),
|
||||
unit_edge(4, 5, true),
|
||||
unit_edge(4, 6, false),
|
||||
unit_edge(5, 4, false), // 10
|
||||
unit_edge(6, 4, true),
|
||||
// Circle
|
||||
unit_edge(7, 8, true), // 12
|
||||
unit_edge(7, 9, true),
|
||||
unit_edge(8, 7, true),
|
||||
unit_edge(8, 9, true),
|
||||
unit_edge(9, 7, true),
|
||||
unit_edge(9, 8, true)};
|
||||
|
||||
// Graph graph(10, edges);
|
||||
Graph graph(10, edges);
|
||||
|
||||
// GraphCompressor().Compress(barrier_nodes,
|
||||
// traffic_lights,
|
||||
// scripting_environment,
|
||||
// restrictions,
|
||||
// conditional_restrictions,
|
||||
// maneuver_overrides,
|
||||
// graph,
|
||||
// annotations,
|
||||
// container);
|
||||
GraphCompressor().Compress(barrier_nodes,
|
||||
traffic_lights,
|
||||
scripting_environment,
|
||||
restrictions,
|
||||
conditional_restrictions,
|
||||
maneuver_overrides,
|
||||
graph,
|
||||
annotations,
|
||||
container);
|
||||
|
||||
// BOOST_CHECK_EQUAL(graph.GetTarget(skipDegreeTwoNodes(graph, {0, 0}).edge), 4);
|
||||
// BOOST_CHECK_EQUAL(graph.GetTarget(skipDegreeTwoNodes(graph, {4, 7}).edge), 0);
|
||||
// BOOST_CHECK_EQUAL(graph.GetTarget(skipDegreeTwoNodes(graph, {5, 10}).edge), 4);
|
||||
// BOOST_CHECK_EQUAL(graph.GetTarget(skipDegreeTwoNodes(graph, {6, 11}).edge), 4);
|
||||
// BOOST_CHECK_EQUAL(graph.GetTarget(skipDegreeTwoNodes(graph, {7, 12}).edge), 7);
|
||||
// }
|
||||
BOOST_CHECK_EQUAL(graph.GetTarget(skipDegreeTwoNodes(graph, {0, 0}).edge), 4);
|
||||
BOOST_CHECK_EQUAL(graph.GetTarget(skipDegreeTwoNodes(graph, {4, 7}).edge), 0);
|
||||
BOOST_CHECK_EQUAL(graph.GetTarget(skipDegreeTwoNodes(graph, {5, 10}).edge), 4);
|
||||
BOOST_CHECK_EQUAL(graph.GetTarget(skipDegreeTwoNodes(graph, {6, 11}).edge), 4);
|
||||
BOOST_CHECK_EQUAL(graph.GetTarget(skipDegreeTwoNodes(graph, {7, 12}).edge), 7);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
@@ -16,13 +16,13 @@ BOOST_AUTO_TEST_CASE(test_extract_with_invalid_config)
|
||||
std::exception); // including osrm::util::exception, osmium::io_error, etc.
|
||||
}
|
||||
|
||||
// BOOST_AUTO_TEST_CASE(test_extract_with_valid_config)
|
||||
// {
|
||||
// osrm::ExtractorConfig config;
|
||||
// config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf";
|
||||
// config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco.osm.pbf");
|
||||
// config.requested_num_threads = tbb::task_scheduler_init::default_num_threads();
|
||||
// BOOST_CHECK_NO_THROW(osrm::extract(config));
|
||||
// }
|
||||
BOOST_AUTO_TEST_CASE(test_extract_with_valid_config)
|
||||
{
|
||||
osrm::ExtractorConfig config;
|
||||
config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf";
|
||||
config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco.osm.pbf");
|
||||
config.requested_num_threads = tbb::task_scheduler_init::default_num_threads();
|
||||
BOOST_CHECK_NO_THROW(osrm::extract(config));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
@@ -32,9 +32,9 @@ auto makeGraph(const std::vector<MockEdge> &mock_edges)
|
||||
max_id = std::max<std::size_t>(max_id, std::max(m.start, m.target));
|
||||
|
||||
edges.push_back(InputEdge{
|
||||
m.start, m.target, EdgeBasedGraphEdgeData{SPECIAL_NODEID, 1, 1, 1, true, false}});
|
||||
m.start, m.target, EdgeBasedGraphEdgeData{SPECIAL_NODEID, 1, 1, true, false}});
|
||||
edges.push_back(InputEdge{
|
||||
m.target, m.start, EdgeBasedGraphEdgeData{SPECIAL_NODEID, 1, 1, 1, false, true}});
|
||||
m.target, m.start, EdgeBasedGraphEdgeData{SPECIAL_NODEID, 1, 1, false, true}});
|
||||
}
|
||||
std::sort(edges.begin(), edges.end());
|
||||
return DynamicEdgeBasedGraph(max_id + 1, edges);
|
||||
|
||||
@@ -12,50 +12,46 @@ using namespace osrm::updater;
|
||||
|
||||
BOOST_AUTO_TEST_CASE(timezoner_test)
|
||||
{
|
||||
// const char json[] =
|
||||
// "{ \"type\" : \"FeatureCollection\", \"features\": ["
|
||||
// "{ \"type\" : \"Feature\","
|
||||
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\":
|
||||
// \"polygon\", "
|
||||
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
||||
// "48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
// "49.07206], [8.28369, 48.88277]]] }} ]}";
|
||||
// std::time_t now = time(0);
|
||||
// BOOST_CHECK_NO_THROW(Timezoner tz(json, now));
|
||||
const char json[] =
|
||||
"{ \"type\" : \"FeatureCollection\", \"features\": ["
|
||||
"{ \"type\" : \"Feature\","
|
||||
"\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\": \"polygon\", "
|
||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
"49.07206], [8.28369, 48.88277]]] }} ]}";
|
||||
std::time_t now = time(0);
|
||||
BOOST_CHECK_NO_THROW(Timezoner tz(json, now));
|
||||
|
||||
// boost::filesystem::path test_path(TEST_DATA_DIR "/test.geojson");
|
||||
// BOOST_CHECK_NO_THROW(Timezoner tz(test_path, now));
|
||||
boost::filesystem::path test_path(TEST_DATA_DIR "/test.geojson");
|
||||
BOOST_CHECK_NO_THROW(Timezoner tz(test_path, now));
|
||||
|
||||
// missing opening bracket
|
||||
// const char bad[] =
|
||||
// "\"type\" : \"FeatureCollection\", \"features\": ["
|
||||
// "{ \"type\" : \"Feature\","
|
||||
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\":
|
||||
// \"polygon\", "
|
||||
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
||||
// "48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
// "49.07206], [8.28369, 48.88277]]] }} ]}";
|
||||
// BOOST_CHECK_THROW(Timezoner tz(bad, now), util::exception);
|
||||
const char bad[] =
|
||||
"\"type\" : \"FeatureCollection\", \"features\": ["
|
||||
"{ \"type\" : \"Feature\","
|
||||
"\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\": \"polygon\", "
|
||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
"49.07206], [8.28369, 48.88277]]] }} ]}";
|
||||
BOOST_CHECK_THROW(Timezoner tz(bad, now), util::exception);
|
||||
|
||||
// missing/malformed FeatureCollection type field
|
||||
// const char missing_type[] =
|
||||
// "{ \"FeatureCollection\", \"features\": ["
|
||||
// "{ \"type\" : \"Feature\","
|
||||
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\":
|
||||
// \"polygon\", "
|
||||
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
||||
// "48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
// "49.07206], [8.28369, 48.88277]]] }} ]}";
|
||||
// BOOST_CHECK_THROW(Timezoner tz(missing_type, now), util::exception);
|
||||
const char missing_type[] =
|
||||
"{ \"FeatureCollection\", \"features\": ["
|
||||
"{ \"type\" : \"Feature\","
|
||||
"\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\": \"polygon\", "
|
||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
"49.07206], [8.28369, 48.88277]]] }} ]}";
|
||||
BOOST_CHECK_THROW(Timezoner tz(missing_type, now), util::exception);
|
||||
|
||||
// const char missing_featc[] =
|
||||
// "{ \"type\" : \"Collection\", \"features\": ["
|
||||
// "{ \"type\" : \"Feature\","
|
||||
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\":
|
||||
// \"polygon\", "
|
||||
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
||||
// "48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
// "49.07206], [8.28369, 48.88277]]] }} ]}";
|
||||
// BOOST_CHECK_THROW(Timezoner tz(missing_featc, now), util::exception);
|
||||
const char missing_featc[] =
|
||||
"{ \"type\" : \"Collection\", \"features\": ["
|
||||
"{ \"type\" : \"Feature\","
|
||||
"\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\": \"polygon\", "
|
||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
"49.07206], [8.28369, 48.88277]]] }} ]}";
|
||||
BOOST_CHECK_THROW(Timezoner tz(missing_featc, now), util::exception);
|
||||
}
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
@@ -71,74 +71,68 @@ BOOST_AUTO_TEST_CASE(timezone_validation_test)
|
||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
"49.07206], [8.28369, 48.88277]]] }}";
|
||||
doc.Parse(missing_tzid);
|
||||
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||
|
||||
// char tzid_err[] = "{ \"type\" : \"Feature\","
|
||||
// "\"properties\" : { \"TZID\" : []}, \"geometry\" : { \"type\": \"polygon\",
|
||||
// "
|
||||
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
||||
// "48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
// "49.07206], [8.28369, 48.88277]]] }}";
|
||||
// doc.Parse(tzid_err);
|
||||
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||
char tzid_err[] = "{ \"type\" : \"Feature\","
|
||||
"\"properties\" : { \"TZID\" : []}, \"geometry\" : { \"type\": \"polygon\", "
|
||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
"49.07206], [8.28369, 48.88277]]] }}";
|
||||
doc.Parse(tzid_err);
|
||||
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||
|
||||
// char missing_geom[] = "{ \"type\" : \"Feature\","
|
||||
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometries\" : { "
|
||||
// "\"type\": \"polygon\", "
|
||||
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
||||
// "48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
// "49.07206], [8.28369, 48.88277]]] }}";
|
||||
// doc.Parse(missing_geom);
|
||||
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||
char missing_geom[] = "{ \"type\" : \"Feature\","
|
||||
"\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometries\" : { "
|
||||
"\"type\": \"polygon\", "
|
||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
"49.07206], [8.28369, 48.88277]]] }}";
|
||||
doc.Parse(missing_geom);
|
||||
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||
|
||||
// char nonobj_geom[] =
|
||||
// "{ \"type\" : \"Feature\","
|
||||
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : [ \"type\",
|
||||
// \"polygon\", "
|
||||
// "\"coordinates\", [[[8.28369,48.88277], [8.57757, "
|
||||
// "48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
// "49.07206], [8.28369, 48.88277]]] ]}";
|
||||
// doc.Parse(nonobj_geom);
|
||||
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||
char nonobj_geom[] =
|
||||
"{ \"type\" : \"Feature\","
|
||||
"\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : [ \"type\", \"polygon\", "
|
||||
"\"coordinates\", [[[8.28369,48.88277], [8.57757, "
|
||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
"49.07206], [8.28369, 48.88277]]] ]}";
|
||||
doc.Parse(nonobj_geom);
|
||||
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||
|
||||
// char missing_geom_type[] = "{ \"type\" : \"Feature\","
|
||||
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" :
|
||||
// { "
|
||||
// "\"no_type\": \"polygon\", "
|
||||
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
||||
// "48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
// "49.07206], [8.28369, 48.88277]]] }}";
|
||||
// doc.Parse(missing_geom_type);
|
||||
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||
char missing_geom_type[] = "{ \"type\" : \"Feature\","
|
||||
"\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { "
|
||||
"\"no_type\": \"polygon\", "
|
||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
"49.07206], [8.28369, 48.88277]]] }}";
|
||||
doc.Parse(missing_geom_type);
|
||||
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||
|
||||
// char nonstring_geom_type[] = "{ \"type\" : \"Feature\","
|
||||
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\"
|
||||
// : "
|
||||
// "{ \"type\": [\"polygon\"], "
|
||||
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
||||
// "48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
// "49.07206], [8.28369, 48.88277]]] }}";
|
||||
// doc.Parse(nonstring_geom_type);
|
||||
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||
char nonstring_geom_type[] = "{ \"type\" : \"Feature\","
|
||||
"\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : "
|
||||
"{ \"type\": [\"polygon\"], "
|
||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
"49.07206], [8.28369, 48.88277]]] }}";
|
||||
doc.Parse(nonstring_geom_type);
|
||||
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||
|
||||
// char missing_coords[] =
|
||||
// "{ \"type\" : \"Feature\","
|
||||
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\":
|
||||
// \"polygon\", "
|
||||
// "\"coords\": [[[8.28369,48.88277], [8.57757, "
|
||||
// "48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
// "49.07206], [8.28369, 48.88277]]] }}";
|
||||
// doc.Parse(missing_coords);
|
||||
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||
char missing_coords[] =
|
||||
"{ \"type\" : \"Feature\","
|
||||
"\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\": \"polygon\", "
|
||||
"\"coords\": [[[8.28369,48.88277], [8.57757, "
|
||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
"49.07206], [8.28369, 48.88277]]] }}";
|
||||
doc.Parse(missing_coords);
|
||||
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||
|
||||
// char missing_outerring[] =
|
||||
// "{ \"type\" : \"Feature\","
|
||||
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\":
|
||||
// \"polygon\", "
|
||||
// "\"coordinates\": [[8.28369,48.88277], [8.57757, "
|
||||
// "48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
// "49.07206], [8.28369, 48.88277]] }}";
|
||||
// doc.Parse(missing_outerring);
|
||||
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||
char missing_outerring[] =
|
||||
"{ \"type\" : \"Feature\","
|
||||
"\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\": \"polygon\", "
|
||||
"\"coordinates\": [[8.28369,48.88277], [8.57757, "
|
||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
||||
"49.07206], [8.28369, 48.88277]] }}";
|
||||
doc.Parse(missing_outerring);
|
||||
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||
}
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user