2014-11-28 09:00:48 -05:00
|
|
|
#ifndef INTERNAL_EXTRACTOR_EDGE_HPP
|
|
|
|
#define INTERNAL_EXTRACTOR_EDGE_HPP
|
2014-01-09 10:13:35 -05:00
|
|
|
|
2016-01-11 10:55:22 -05:00
|
|
|
#include "extractor/node_based_edge.hpp"
|
2016-05-27 15:05:04 -04:00
|
|
|
#include "extractor/travel_mode.hpp"
|
2016-05-12 12:50:10 -04:00
|
|
|
#include "osrm/coordinate.hpp"
|
2016-05-27 15:05:04 -04:00
|
|
|
#include "util/typedefs.hpp"
|
2014-01-09 10:13:35 -05:00
|
|
|
|
|
|
|
#include <boost/assert.hpp>
|
2016-05-12 12:50:10 -04:00
|
|
|
#include <mapbox/variant.hpp>
|
2015-08-18 06:56:34 -04:00
|
|
|
#include <utility>
|
2014-11-24 11:57:01 -05:00
|
|
|
|
2022-12-11 04:10:26 -05:00
|
|
|
namespace osrm::extractor
|
2016-01-05 10:51:13 -05:00
|
|
|
{
|
|
|
|
|
2016-05-12 12:50:10 -04:00
|
|
|
namespace detail
|
2014-05-09 10:17:31 -04:00
|
|
|
{
|
2017-02-02 11:05:08 -05:00
|
|
|
// Use a single float to pack two positive values:
|
|
|
|
// * by_edge: + sign, value >= 0, value used as the edge weight
|
|
|
|
// * by_meter: - sign, value > 0, value used as a denominator in distance / value
|
|
|
|
struct ByEdgeOrByMeterValue
|
2016-05-12 12:50:10 -04:00
|
|
|
{
|
2017-02-02 11:05:08 -05:00
|
|
|
struct ValueByEdge
|
|
|
|
{
|
|
|
|
} static const by_edge;
|
|
|
|
struct ValueByMeter
|
|
|
|
{
|
|
|
|
} static const by_meter;
|
|
|
|
|
|
|
|
ByEdgeOrByMeterValue() : value(0.f) {}
|
|
|
|
|
|
|
|
ByEdgeOrByMeterValue(ValueByEdge, double input)
|
|
|
|
{
|
|
|
|
BOOST_ASSERT(input >= 0.f);
|
|
|
|
value = static_cast<value_type>(input);
|
|
|
|
}
|
2015-05-09 11:21:36 -04:00
|
|
|
|
2017-02-02 11:05:08 -05:00
|
|
|
ByEdgeOrByMeterValue(ValueByMeter, double input)
|
2015-05-09 11:21:36 -04:00
|
|
|
{
|
2017-02-02 11:05:08 -05:00
|
|
|
BOOST_ASSERT(input > 0.f);
|
|
|
|
value = -static_cast<value_type>(input);
|
2016-05-12 12:50:10 -04:00
|
|
|
}
|
|
|
|
|
2017-02-02 11:05:08 -05:00
|
|
|
double operator()(double distance) { return value >= 0 ? value : -distance / value; }
|
2016-05-12 12:50:10 -04:00
|
|
|
|
2017-02-02 11:05:08 -05:00
|
|
|
private:
|
|
|
|
using value_type = float;
|
|
|
|
value_type value;
|
2016-05-12 12:50:10 -04:00
|
|
|
};
|
2020-11-26 10:21:39 -05:00
|
|
|
} // namespace detail
|
2015-05-09 11:21:36 -04:00
|
|
|
|
2016-05-12 12:50:10 -04:00
|
|
|
struct InternalExtractorEdge
|
|
|
|
{
|
|
|
|
using WeightData = detail::ByEdgeOrByMeterValue;
|
|
|
|
using DurationData = detail::ByEdgeOrByMeterValue;
|
2015-05-09 11:21:36 -04:00
|
|
|
|
2017-09-25 09:37:11 -04:00
|
|
|
explicit InternalExtractorEdge() : weight_data(), duration_data() {}
|
2014-05-09 10:17:31 -04:00
|
|
|
|
2015-11-24 19:33:19 -05:00
|
|
|
explicit InternalExtractorEdge(OSMNodeID source,
|
|
|
|
OSMNodeID target,
|
2015-08-18 06:56:34 -04:00
|
|
|
WeightData weight_data,
|
2016-05-12 12:50:10 -04:00
|
|
|
DurationData duration_data,
|
|
|
|
util::Coordinate source_coordinate)
|
2022-10-28 10:16:12 -04:00
|
|
|
: result(source, target, {0}, {0}, {0}, {}, -1, {}), weight_data(weight_data),
|
2022-08-23 13:03:41 -04:00
|
|
|
duration_data(duration_data), source_coordinate(source_coordinate)
|
2017-09-25 09:37:11 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit InternalExtractorEdge(NodeBasedEdgeWithOSM edge,
|
|
|
|
WeightData weight_data,
|
|
|
|
DurationData duration_data,
|
|
|
|
util::Coordinate source_coordinate)
|
2022-08-23 13:03:41 -04:00
|
|
|
: result(edge), weight_data(weight_data), duration_data(duration_data),
|
2017-09-25 09:37:11 -04:00
|
|
|
source_coordinate(source_coordinate)
|
2014-01-09 10:13:35 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-05-09 11:21:36 -04:00
|
|
|
// data that will be written to disk
|
2015-11-24 19:33:19 -05:00
|
|
|
NodeBasedEdgeWithOSM result;
|
2015-05-09 11:21:36 -04:00
|
|
|
// intermediate edge weight
|
|
|
|
WeightData weight_data;
|
2016-05-12 12:50:10 -04:00
|
|
|
// intermediate edge duration
|
|
|
|
DurationData duration_data;
|
2015-05-09 11:21:36 -04:00
|
|
|
// coordinate of the source node
|
2016-02-23 15:23:13 -05:00
|
|
|
util::Coordinate source_coordinate;
|
2014-01-09 10:13:35 -05:00
|
|
|
};
|
2022-12-20 12:00:11 -05:00
|
|
|
} // namespace osrm::extractor
|
2016-01-05 10:51:13 -05:00
|
|
|
|
2014-11-28 09:00:48 -05:00
|
|
|
#endif // INTERNAL_EXTRACTOR_EDGE_HPP
|