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
|
|
|
|
|
|
|
explicit InternalExtractorEdge()
|
2016-01-05 06:04:04 -05:00
|
|
|
: result(MIN_OSM_NODEID,
|
|
|
|
MIN_OSM_NODEID,
|
2016-05-12 12:50:10 -04:00
|
|
|
SPECIAL_NODEID,
|
2016-01-05 06:04:04 -05:00
|
|
|
0,
|
|
|
|
0,
|
2016-11-24 07:29:17 -05:00
|
|
|
false, // forward
|
|
|
|
false, // backward
|
|
|
|
false, // roundabout
|
|
|
|
false, // circular
|
|
|
|
true, // can be startpoint
|
2017-02-14 06:59:16 -05:00
|
|
|
false, // local access only
|
|
|
|
false, // split edge
|
2016-01-05 06:04:04 -05:00
|
|
|
TRAVEL_MODE_INACCESSIBLE,
|
2017-06-27 18:01:05 -04:00
|
|
|
0,
|
2016-06-21 04:41:08 -04:00
|
|
|
guidance::TurnLaneType::empty,
|
2016-05-12 12:50:10 -04:00
|
|
|
guidance::RoadClassification()),
|
2017-02-02 11:05:08 -05:00
|
|
|
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
|
|
|
NodeID name_id,
|
|
|
|
WeightData weight_data,
|
2016-05-12 12:50:10 -04:00
|
|
|
DurationData duration_data,
|
2015-08-18 06:56:34 -04:00
|
|
|
bool forward,
|
|
|
|
bool backward,
|
|
|
|
bool roundabout,
|
2016-11-24 07:29:17 -05:00
|
|
|
bool circular,
|
2015-12-11 17:11:04 -05:00
|
|
|
bool startpoint,
|
2017-02-14 06:59:16 -05:00
|
|
|
bool restricted,
|
2016-02-24 04:29:23 -05:00
|
|
|
bool is_split,
|
2017-02-14 06:59:16 -05:00
|
|
|
TravelMode travel_mode,
|
2017-06-27 18:01:05 -04:00
|
|
|
ClassData classes,
|
2016-06-21 04:41:08 -04:00
|
|
|
LaneDescriptionID lane_description,
|
2016-05-12 12:50:10 -04:00
|
|
|
guidance::RoadClassification road_classification,
|
|
|
|
util::Coordinate source_coordinate)
|
2016-06-24 01:01:37 -04:00
|
|
|
: result(source,
|
|
|
|
target,
|
2015-08-18 06:56:34 -04:00
|
|
|
name_id,
|
|
|
|
0,
|
2016-05-12 12:50:10 -04:00
|
|
|
0,
|
2015-08-18 06:56:34 -04:00
|
|
|
forward,
|
|
|
|
backward,
|
|
|
|
roundabout,
|
2016-11-24 07:29:17 -05:00
|
|
|
circular,
|
2015-12-11 17:11:04 -05:00
|
|
|
startpoint,
|
2017-02-14 06:59:16 -05:00
|
|
|
restricted,
|
2016-02-24 04:29:23 -05:00
|
|
|
is_split,
|
2017-02-14 06:59:16 -05:00
|
|
|
travel_mode,
|
2017-06-27 18:01:05 -04:00
|
|
|
classes,
|
2016-06-21 04:41:08 -04:00
|
|
|
lane_description,
|
2016-02-24 04:29:23 -05:00
|
|
|
std::move(road_classification)),
|
2016-05-12 12:50:10 -04:00
|
|
|
weight_data(std::move(weight_data)), duration_data(std::move(duration_data)),
|
|
|
|
source_coordinate(std::move(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
|
|
|
{
|
2016-05-27 15:05:04 -04:00
|
|
|
return InternalExtractorEdge(MIN_OSM_NODEID,
|
|
|
|
MIN_OSM_NODEID,
|
2016-05-12 12:50:10 -04:00
|
|
|
SPECIAL_NODEID,
|
2017-02-02 11:05:08 -05:00
|
|
|
WeightData(),
|
|
|
|
DurationData(),
|
2016-11-24 07:29:17 -05:00
|
|
|
false, // forward
|
|
|
|
false, // backward
|
|
|
|
false, // roundabout
|
|
|
|
false, // circular
|
|
|
|
true, // can be startpoint
|
2017-02-14 06:59:16 -05:00
|
|
|
false, // local access only
|
|
|
|
false, // split edge
|
2016-05-27 15:05:04 -04:00
|
|
|
TRAVEL_MODE_INACCESSIBLE,
|
2017-06-27 18:01:05 -04:00
|
|
|
0,
|
2016-06-21 04:41:08 -04:00
|
|
|
INVALID_LANE_DESCRIPTIONID,
|
2016-05-12 12:50:10 -04:00
|
|
|
guidance::RoadClassification(),
|
|
|
|
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
|
|
|
{
|
2016-05-27 15:05:04 -04:00
|
|
|
return InternalExtractorEdge(MAX_OSM_NODEID,
|
|
|
|
MAX_OSM_NODEID,
|
2016-10-11 17:02:20 -04:00
|
|
|
SPECIAL_NODEID,
|
2017-02-02 11:05:08 -05:00
|
|
|
WeightData(),
|
|
|
|
DurationData(),
|
2016-11-24 07:29:17 -05:00
|
|
|
false, // forward
|
|
|
|
false, // backward
|
|
|
|
false, // roundabout
|
|
|
|
false, // circular
|
|
|
|
true, // can be startpoint
|
2017-02-14 06:59:16 -05:00
|
|
|
false, // local access only
|
|
|
|
false, // split edge
|
2016-05-27 15:05:04 -04:00
|
|
|
TRAVEL_MODE_INACCESSIBLE,
|
2017-06-27 18:01:05 -04:00
|
|
|
0,
|
2016-06-21 04:41:08 -04:00
|
|
|
INVALID_LANE_DESCRIPTIONID,
|
2016-05-12 12:50:10 -04:00
|
|
|
guidance::RoadClassification(),
|
|
|
|
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
|