Check activation index of EntryClass and warn if activation failed
This commit is contained in:
parent
58b61c68a3
commit
b2ed46efb5
@ -85,12 +85,6 @@ class Extractor
|
|||||||
std::vector<util::Coordinate> &coordinates,
|
std::vector<util::Coordinate> &coordinates,
|
||||||
extractor::PackedOSMIDs &osm_node_ids);
|
extractor::PackedOSMIDs &osm_node_ids);
|
||||||
|
|
||||||
void WriteIntersectionClassificationData(
|
|
||||||
const std::string &output_file_name,
|
|
||||||
const std::vector<std::uint32_t> &node_based_intersection_classes,
|
|
||||||
const std::vector<util::guidance::BearingClass> &bearing_classes,
|
|
||||||
const std::vector<util::guidance::EntryClass> &entry_classes) const;
|
|
||||||
|
|
||||||
// Writes compressed node based graph and its embedding into a file for osrm-partition to use.
|
// Writes compressed node based graph and its embedding into a file for osrm-partition to use.
|
||||||
static void WriteCompressedNodeBasedGraph(const std::string &path,
|
static void WriteCompressedNodeBasedGraph(const std::string &path,
|
||||||
const util::NodeBasedDynamicGraph &graph,
|
const util::NodeBasedDynamicGraph &graph,
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "extractor/guidance/intersection.hpp"
|
#include "extractor/guidance/intersection.hpp"
|
||||||
|
|
||||||
|
#include "util/coordinate.hpp"
|
||||||
#include "util/guidance/bearing_class.hpp"
|
#include "util/guidance/bearing_class.hpp"
|
||||||
#include "util/guidance/entry_class.hpp"
|
#include "util/guidance/entry_class.hpp"
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ namespace guidance
|
|||||||
{
|
{
|
||||||
|
|
||||||
std::pair<util::guidance::EntryClass, util::guidance::BearingClass>
|
std::pair<util::guidance::EntryClass, util::guidance::BearingClass>
|
||||||
classifyIntersection(Intersection intersection);
|
classifyIntersection(Intersection intersection, const osrm::util::Coordinate &location);
|
||||||
|
|
||||||
} // namespace guidance
|
} // namespace guidance
|
||||||
} // namespace extractor
|
} // namespace extractor
|
||||||
|
@ -43,7 +43,8 @@ class EntryClass
|
|||||||
|
|
||||||
// we are hiding the access to the flags behind a protection wall, to make sure the bit logic
|
// we are hiding the access to the flags behind a protection wall, to make sure the bit logic
|
||||||
// isn't tempered with. zero based indexing
|
// isn't tempered with. zero based indexing
|
||||||
void activate(std::uint32_t index);
|
// return true if was activated and false if activation failed
|
||||||
|
bool activate(std::uint32_t index);
|
||||||
|
|
||||||
// check whether a certain turn allows entry
|
// check whether a certain turn allows entry
|
||||||
bool allowsEntry(std::uint32_t index) const;
|
bool allowsEntry(std::uint32_t index) const;
|
||||||
|
@ -499,7 +499,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
|||||||
// the entry class depends on the turn, so we have to classify the
|
// the entry class depends on the turn, so we have to classify the
|
||||||
// interesction for
|
// interesction for
|
||||||
// every edge
|
// every edge
|
||||||
const auto turn_classification = classifyIntersection(intersection);
|
const auto turn_classification = classifyIntersection(
|
||||||
|
intersection, m_coordinates[node_at_center_of_intersection]);
|
||||||
|
|
||||||
const auto entry_class_id =
|
const auto entry_class_id =
|
||||||
entry_class_hash.ConcurrentFindOrAdd(turn_classification.first);
|
entry_class_hash.ConcurrentFindOrAdd(turn_classification.first);
|
||||||
|
@ -12,7 +12,7 @@ namespace guidance
|
|||||||
{
|
{
|
||||||
|
|
||||||
std::pair<util::guidance::EntryClass, util::guidance::BearingClass>
|
std::pair<util::guidance::EntryClass, util::guidance::BearingClass>
|
||||||
classifyIntersection(Intersection intersection)
|
classifyIntersection(Intersection intersection, const osrm::util::Coordinate &location)
|
||||||
{
|
{
|
||||||
if (intersection.empty())
|
if (intersection.empty())
|
||||||
return {};
|
return {};
|
||||||
@ -56,7 +56,12 @@ classifyIntersection(Intersection intersection)
|
|||||||
for (const auto &road : intersection)
|
for (const auto &road : intersection)
|
||||||
{
|
{
|
||||||
if (road.entry_allowed)
|
if (road.entry_allowed)
|
||||||
entry_class.activate(number);
|
{
|
||||||
|
if (!entry_class.activate(number))
|
||||||
|
util::Log(logWARNING) << "Road " << number << " was not activated at "
|
||||||
|
<< location;
|
||||||
|
}
|
||||||
|
|
||||||
auto discrete_bearing_class =
|
auto discrete_bearing_class =
|
||||||
util::guidance::BearingClass::getDiscreteBearing(std::round(road.bearing));
|
util::guidance::BearingClass::getDiscreteBearing(std::round(road.bearing));
|
||||||
bearing_class.add(std::round(discrete_bearing_class *
|
bearing_class.add(std::round(discrete_bearing_class *
|
||||||
@ -69,7 +74,11 @@ classifyIntersection(Intersection intersection)
|
|||||||
for (const auto &road : intersection)
|
for (const auto &road : intersection)
|
||||||
{
|
{
|
||||||
if (road.entry_allowed)
|
if (road.entry_allowed)
|
||||||
entry_class.activate(number);
|
{
|
||||||
|
if (!entry_class.activate(number))
|
||||||
|
util::Log(logWARNING) << "Road " << number << " was not activated at "
|
||||||
|
<< location;
|
||||||
|
}
|
||||||
bearing_class.add(std::round(road.bearing));
|
bearing_class.add(std::round(road.bearing));
|
||||||
++number;
|
++number;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
|
|
||||||
|
#include <climits>
|
||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
namespace util
|
namespace util
|
||||||
@ -9,16 +11,19 @@ namespace util
|
|||||||
namespace guidance
|
namespace guidance
|
||||||
{
|
{
|
||||||
|
|
||||||
void EntryClass::activate(std::uint32_t index)
|
bool EntryClass::activate(std::uint32_t index)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(index < 8 * sizeof(FlagBaseType));
|
if (index >= CHAR_BIT * sizeof(FlagBaseType))
|
||||||
enabled_entries_flags |= (1 << index);
|
return false;
|
||||||
|
|
||||||
|
enabled_entries_flags |= (FlagBaseType{1} << index);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntryClass::allowsEntry(std::uint32_t index) const
|
bool EntryClass::allowsEntry(std::uint32_t index) const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(index < 8 * sizeof(FlagBaseType));
|
BOOST_ASSERT(index < CHAR_BIT * sizeof(FlagBaseType));
|
||||||
return 0 != (enabled_entries_flags & (1 << index));
|
return 0 != (enabled_entries_flags & (FlagBaseType{1} << index));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntryClass::operator==(const EntryClass &other) const
|
bool EntryClass::operator==(const EntryClass &other) const
|
||||||
|
Loading…
Reference in New Issue
Block a user