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-05-12 12:50:10 -04:00
|
|
|
#include "extractor/guidance/road_classification.hpp"
|
|
|
|
#include "extractor/guidance/turn_lane_types.hpp"
|
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
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace extractor
|
|
|
|
{
|
|
|
|
|
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
|
|
|
};
|
|
|
|
}
|
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)
|
2017-09-25 09:37:11 -04:00
|
|
|
: result(source, target, 0, 0, {}, -1, {}), weight_data(std::move(weight_data)),
|
|
|
|
duration_data(std::move(duration_data)), source_coordinate(std::move(source_coordinate))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit InternalExtractorEdge(NodeBasedEdgeWithOSM edge,
|
|
|
|
WeightData weight_data,
|
|
|
|
DurationData duration_data,
|
|
|
|
util::Coordinate source_coordinate)
|
|
|
|
: result(std::move(edge)), weight_data(weight_data), duration_data(duration_data),
|
|
|
|
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;
|
2015-05-09 11:21:36 -04:00
|
|
|
|
2014-01-09 10:13:35 -05:00
|
|
|
// necessary static util functions for stxxl's sorting
|
2015-11-24 19:33:19 -05:00
|
|
|
static InternalExtractorEdge min_osm_value()
|
2014-05-09 10:17:31 -04:00
|
|
|
{
|
2017-09-25 09:37:11 -04:00
|
|
|
return InternalExtractorEdge(
|
|
|
|
MIN_OSM_NODEID, MIN_OSM_NODEID, WeightData(), DurationData(), util::Coordinate());
|
2014-01-09 10:13:35 -05:00
|
|
|
}
|
2015-11-24 19:33:19 -05:00
|
|
|
static InternalExtractorEdge max_osm_value()
|
2014-05-09 10:17:31 -04:00
|
|
|
{
|
2017-09-25 09:37:11 -04:00
|
|
|
return InternalExtractorEdge(
|
|
|
|
MAX_OSM_NODEID, MAX_OSM_NODEID, WeightData(), DurationData(), util::Coordinate());
|
2014-01-09 10:13:35 -05:00
|
|
|
}
|
2015-11-24 19:33:19 -05:00
|
|
|
|
|
|
|
static InternalExtractorEdge min_internal_value()
|
|
|
|
{
|
|
|
|
auto v = min_osm_value();
|
|
|
|
v.result.source = 0;
|
|
|
|
v.result.target = 0;
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
static InternalExtractorEdge max_internal_value()
|
|
|
|
{
|
|
|
|
auto v = max_osm_value();
|
|
|
|
v.result.source = std::numeric_limits<NodeID>::max();
|
|
|
|
v.result.target = std::numeric_limits<NodeID>::max();
|
|
|
|
return v;
|
|
|
|
}
|
2014-01-09 10:13:35 -05:00
|
|
|
};
|
2016-01-05 10:51:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-28 09:00:48 -05:00
|
|
|
#endif // INTERNAL_EXTRACTOR_EDGE_HPP
|