first cut at porting travel mode, some tests fail
This commit is contained in:
parent
d09394ed52
commit
6fd615b9cd
@ -181,7 +181,9 @@ EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeID nod
|
|||||||
reverse_dist_prefix_sum[i],
|
reverse_dist_prefix_sum[i],
|
||||||
m_geometry_compressor.GetPositionForID(e1),
|
m_geometry_compressor.GetPositionForID(e1),
|
||||||
i,
|
i,
|
||||||
belongs_to_tiny_cc);
|
belongs_to_tiny_cc,
|
||||||
|
forward_data.travel_mode,
|
||||||
|
reverse_data.travel_mode);
|
||||||
current_edge_source_coordinate_id = current_edge_target_coordinate_id;
|
current_edge_source_coordinate_id = current_edge_target_coordinate_id;
|
||||||
|
|
||||||
BOOST_ASSERT(m_edge_based_node_list.back().IsCompressed());
|
BOOST_ASSERT(m_edge_based_node_list.back().IsCompressed());
|
||||||
@ -231,7 +233,9 @@ EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeID nod
|
|||||||
0,
|
0,
|
||||||
SPECIAL_EDGEID,
|
SPECIAL_EDGEID,
|
||||||
0,
|
0,
|
||||||
belongs_to_tiny_cc);
|
belongs_to_tiny_cc,
|
||||||
|
forward_data.travel_mode,
|
||||||
|
reverse_data.travel_mode);
|
||||||
BOOST_ASSERT(!m_edge_based_node_list.back().IsCompressed());
|
BOOST_ASSERT(!m_edge_based_node_list.back().IsCompressed());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -648,7 +652,8 @@ EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(const std::string &original_edg
|
|||||||
(edge_is_compressed ? m_geometry_compressor.GetPositionForID(e1) : v),
|
(edge_is_compressed ? m_geometry_compressor.GetPositionForID(e1) : v),
|
||||||
edge_data1.nameID,
|
edge_data1.nameID,
|
||||||
turn_instruction,
|
turn_instruction,
|
||||||
edge_is_compressed);
|
edge_is_compressed,
|
||||||
|
edge_data2.travel_mode);
|
||||||
|
|
||||||
++original_edges_counter;
|
++original_edges_counter;
|
||||||
|
|
||||||
|
@ -134,8 +134,12 @@ int Prepare::Process(int argc, char *argv[])
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#pragma message("Memory consumption on Windows can be higher due to different bit packing")
|
#pragma message("Memory consumption on Windows can be higher due to different bit packing")
|
||||||
#else
|
#else
|
||||||
static_assert(sizeof(ImportEdge) == 20,
|
SimpleLogger().Write() << "sizeof(ImportEdge): " << sizeof(ImportEdge);
|
||||||
"changing ImportEdge type has influence on memory consumption!");
|
SimpleLogger().Write() << "sizeof(NodeBasedEdgeData): " << sizeof(NodeBasedEdgeData);
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
//static_assert(sizeof(ImportEdge) == 21,
|
||||||
|
// "changing ImportEdge type has influence on memory consumption!");
|
||||||
#endif
|
#endif
|
||||||
NodeID number_of_node_based_nodes =
|
NodeID number_of_node_based_nodes =
|
||||||
readBinaryOSRMGraphFromStream(input_stream,
|
readBinaryOSRMGraphFromStream(input_stream,
|
||||||
|
@ -25,7 +25,9 @@ struct EdgeBasedNode
|
|||||||
reverse_offset(0),
|
reverse_offset(0),
|
||||||
packed_geometry_id(SPECIAL_EDGEID),
|
packed_geometry_id(SPECIAL_EDGEID),
|
||||||
fwd_segment_position( std::numeric_limits<unsigned short>::max() ),
|
fwd_segment_position( std::numeric_limits<unsigned short>::max() ),
|
||||||
is_in_tiny_cc(false)
|
is_in_tiny_cc(false),
|
||||||
|
travel_mode(0),
|
||||||
|
backward_travel_mode(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
explicit EdgeBasedNode(
|
explicit EdgeBasedNode(
|
||||||
@ -40,7 +42,9 @@ struct EdgeBasedNode
|
|||||||
int reverse_offset,
|
int reverse_offset,
|
||||||
unsigned packed_geometry_id,
|
unsigned packed_geometry_id,
|
||||||
unsigned short fwd_segment_position,
|
unsigned short fwd_segment_position,
|
||||||
bool belongs_to_tiny_component
|
bool belongs_to_tiny_component,
|
||||||
|
TravelMode travel_mode,
|
||||||
|
TravelMode backward_travel_mode
|
||||||
) :
|
) :
|
||||||
forward_edge_based_node_id(forward_edge_based_node_id),
|
forward_edge_based_node_id(forward_edge_based_node_id),
|
||||||
reverse_edge_based_node_id(reverse_edge_based_node_id),
|
reverse_edge_based_node_id(reverse_edge_based_node_id),
|
||||||
@ -53,7 +57,9 @@ struct EdgeBasedNode
|
|||||||
reverse_offset(reverse_offset),
|
reverse_offset(reverse_offset),
|
||||||
packed_geometry_id(packed_geometry_id),
|
packed_geometry_id(packed_geometry_id),
|
||||||
fwd_segment_position(fwd_segment_position),
|
fwd_segment_position(fwd_segment_position),
|
||||||
is_in_tiny_cc(belongs_to_tiny_component)
|
is_in_tiny_cc(belongs_to_tiny_component),
|
||||||
|
travel_mode(travel_mode),
|
||||||
|
backward_travel_mode(backward_travel_mode)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT((forward_edge_based_node_id != SPECIAL_NODEID) ||
|
BOOST_ASSERT((forward_edge_based_node_id != SPECIAL_NODEID) ||
|
||||||
(reverse_edge_based_node_id != SPECIAL_NODEID));
|
(reverse_edge_based_node_id != SPECIAL_NODEID));
|
||||||
@ -85,6 +91,8 @@ struct EdgeBasedNode
|
|||||||
unsigned packed_geometry_id; // if set, then the edge represents a packed geometry
|
unsigned packed_geometry_id; // if set, then the edge represents a packed geometry
|
||||||
unsigned short fwd_segment_position; // segment id in a compressed geometry
|
unsigned short fwd_segment_position; // segment id in a compressed geometry
|
||||||
bool is_in_tiny_cc;
|
bool is_in_tiny_cc;
|
||||||
|
TravelMode travel_mode;
|
||||||
|
TravelMode backward_travel_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //EDGE_BASED_NODE_H
|
#endif //EDGE_BASED_NODE_H
|
||||||
|
@ -57,8 +57,8 @@ struct NodeBasedEdge
|
|||||||
bool roundabout : 1;
|
bool roundabout : 1;
|
||||||
bool in_tiny_cc : 1;
|
bool in_tiny_cc : 1;
|
||||||
bool access_restricted : 1;
|
bool access_restricted : 1;
|
||||||
TravelMode travel_mode : 1;
|
|
||||||
bool is_split : 1;
|
bool is_split : 1;
|
||||||
|
TravelMode travel_mode;
|
||||||
|
|
||||||
NodeBasedEdge() = delete;
|
NodeBasedEdge() = delete;
|
||||||
};
|
};
|
||||||
|
@ -29,7 +29,7 @@ struct NodeBasedEdgeData
|
|||||||
bool backward : 1;
|
bool backward : 1;
|
||||||
bool roundabout : 1;
|
bool roundabout : 1;
|
||||||
bool ignore_in_grid : 1;
|
bool ignore_in_grid : 1;
|
||||||
TravelMode travel_mode : 1;
|
TravelMode travel_mode;
|
||||||
|
|
||||||
void SwapDirectionFlags()
|
void SwapDirectionFlags()
|
||||||
{
|
{
|
||||||
@ -59,7 +59,8 @@ using SimpleNodeBasedDynamicGraph = DynamicGraph<SimpleEdgeData>;
|
|||||||
inline std::shared_ptr<NodeBasedDynamicGraph>
|
inline std::shared_ptr<NodeBasedDynamicGraph>
|
||||||
NodeBasedDynamicGraphFromImportEdges(int number_of_nodes, std::vector<ImportEdge> &input_edge_list)
|
NodeBasedDynamicGraphFromImportEdges(int number_of_nodes, std::vector<ImportEdge> &input_edge_list)
|
||||||
{
|
{
|
||||||
static_assert(sizeof(NodeBasedEdgeData) == 16, "changing node based edge data size changes memory consumption");
|
//TODO
|
||||||
|
//static_assert(sizeof(NodeBasedEdgeData) == 16, "changing node based edge data size changes memory consumption");
|
||||||
|
|
||||||
DeallocatingVector<NodeBasedDynamicGraph::InputEdge> edges_list;
|
DeallocatingVector<NodeBasedDynamicGraph::InputEdge> edges_list;
|
||||||
NodeBasedDynamicGraph::InputEdge edge;
|
NodeBasedDynamicGraph::InputEdge edge;
|
||||||
|
@ -38,16 +38,18 @@ struct OriginalEdgeData
|
|||||||
explicit OriginalEdgeData(NodeID via_node,
|
explicit OriginalEdgeData(NodeID via_node,
|
||||||
unsigned name_id,
|
unsigned name_id,
|
||||||
TurnInstruction turn_instruction,
|
TurnInstruction turn_instruction,
|
||||||
bool compressed_geometry)
|
bool compressed_geometry,
|
||||||
|
TravelMode travel_mode)
|
||||||
: via_node(via_node), name_id(name_id), turn_instruction(turn_instruction),
|
: via_node(via_node), name_id(name_id), turn_instruction(turn_instruction),
|
||||||
compressed_geometry(compressed_geometry)
|
compressed_geometry(compressed_geometry), travel_mode(travel_mode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
OriginalEdgeData()
|
OriginalEdgeData()
|
||||||
: via_node(std::numeric_limits<unsigned>::max()),
|
: via_node(std::numeric_limits<unsigned>::max()),
|
||||||
name_id(std::numeric_limits<unsigned>::max()),
|
name_id(std::numeric_limits<unsigned>::max()),
|
||||||
turn_instruction(TurnInstruction::NoTurn), compressed_geometry(false)
|
turn_instruction(TurnInstruction::NoTurn), compressed_geometry(false),
|
||||||
|
travel_mode(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +57,7 @@ struct OriginalEdgeData
|
|||||||
unsigned name_id;
|
unsigned name_id;
|
||||||
TurnInstruction turn_instruction;
|
TurnInstruction turn_instruction;
|
||||||
bool compressed_geometry;
|
bool compressed_geometry;
|
||||||
|
TravelMode travel_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ORIGINAL_EDGE_DATA_H
|
#endif // ORIGINAL_EDGE_DATA_H
|
||||||
|
@ -39,7 +39,8 @@ struct PhantomNode
|
|||||||
PhantomNode(NodeID forward_node_id, NodeID reverse_node_id, unsigned name_id,
|
PhantomNode(NodeID forward_node_id, NodeID reverse_node_id, unsigned name_id,
|
||||||
int forward_weight, int reverse_weight, int forward_offset, int reverse_offset,
|
int forward_weight, int reverse_weight, int forward_offset, int reverse_offset,
|
||||||
unsigned packed_geometry_id, FixedPointCoordinate &location,
|
unsigned packed_geometry_id, FixedPointCoordinate &location,
|
||||||
unsigned short fwd_segment_position) :
|
unsigned short fwd_segment_position,
|
||||||
|
TravelMode travel_mode, TravelMode backward_travel_mode) :
|
||||||
forward_node_id(forward_node_id),
|
forward_node_id(forward_node_id),
|
||||||
reverse_node_id(reverse_node_id),
|
reverse_node_id(reverse_node_id),
|
||||||
name_id(name_id),
|
name_id(name_id),
|
||||||
@ -49,7 +50,9 @@ struct PhantomNode
|
|||||||
reverse_offset(reverse_offset),
|
reverse_offset(reverse_offset),
|
||||||
packed_geometry_id(packed_geometry_id),
|
packed_geometry_id(packed_geometry_id),
|
||||||
location(location),
|
location(location),
|
||||||
fwd_segment_position(fwd_segment_position)
|
fwd_segment_position(fwd_segment_position),
|
||||||
|
travel_mode(travel_mode),
|
||||||
|
backward_travel_mode(backward_travel_mode)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
PhantomNode() :
|
PhantomNode() :
|
||||||
@ -61,7 +64,9 @@ struct PhantomNode
|
|||||||
forward_offset(0),
|
forward_offset(0),
|
||||||
reverse_offset(0),
|
reverse_offset(0),
|
||||||
packed_geometry_id(SPECIAL_EDGEID),
|
packed_geometry_id(SPECIAL_EDGEID),
|
||||||
fwd_segment_position(0)
|
fwd_segment_position(0),
|
||||||
|
travel_mode(0),
|
||||||
|
backward_travel_mode(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
NodeID forward_node_id;
|
NodeID forward_node_id;
|
||||||
@ -74,7 +79,9 @@ struct PhantomNode
|
|||||||
unsigned packed_geometry_id;
|
unsigned packed_geometry_id;
|
||||||
FixedPointCoordinate location;
|
FixedPointCoordinate location;
|
||||||
unsigned short fwd_segment_position;
|
unsigned short fwd_segment_position;
|
||||||
|
TravelMode travel_mode;
|
||||||
|
TravelMode backward_travel_mode;
|
||||||
|
|
||||||
int GetForwardWeightPlusOffset() const
|
int GetForwardWeightPlusOffset() const
|
||||||
{
|
{
|
||||||
if (SPECIAL_NODEID == forward_node_id)
|
if (SPECIAL_NODEID == forward_node_id)
|
||||||
|
@ -41,18 +41,25 @@ struct PathData
|
|||||||
PathData()
|
PathData()
|
||||||
: node(SPECIAL_NODEID), name_id(INVALID_EDGE_WEIGHT),
|
: node(SPECIAL_NODEID), name_id(INVALID_EDGE_WEIGHT),
|
||||||
segment_duration(INVALID_EDGE_WEIGHT),
|
segment_duration(INVALID_EDGE_WEIGHT),
|
||||||
turn_instruction(TurnInstruction::NoTurn)
|
turn_instruction(TurnInstruction::NoTurn),
|
||||||
|
travel_mode(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PathData(NodeID node, unsigned name_id, TurnInstruction turn_instruction, EdgeWeight segment_duration)
|
PathData(NodeID node,
|
||||||
: node(node), name_id(name_id), segment_duration(segment_duration), turn_instruction(turn_instruction)
|
unsigned name_id,
|
||||||
|
TurnInstruction turn_instruction,
|
||||||
|
EdgeWeight segment_duration,
|
||||||
|
TravelMode travel_mode)
|
||||||
|
: node(node), name_id(name_id), segment_duration(segment_duration), turn_instruction(turn_instruction),
|
||||||
|
travel_mode(travel_mode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
NodeID node;
|
NodeID node;
|
||||||
unsigned name_id;
|
unsigned name_id;
|
||||||
EdgeWeight segment_duration;
|
EdgeWeight segment_duration;
|
||||||
TurnInstruction turn_instruction;
|
TurnInstruction turn_instruction;
|
||||||
|
TravelMode travel_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RawRouteData
|
struct RawRouteData
|
||||||
|
@ -45,16 +45,19 @@ struct SegmentInformation
|
|||||||
TurnInstruction turn_instruction;
|
TurnInstruction turn_instruction;
|
||||||
bool necessary:1;
|
bool necessary:1;
|
||||||
bool is_via_location:1;
|
bool is_via_location:1;
|
||||||
|
TravelMode travel_mode;
|
||||||
|
|
||||||
explicit SegmentInformation(const FixedPointCoordinate &location,
|
explicit SegmentInformation(const FixedPointCoordinate &location,
|
||||||
const NodeID name_id,
|
const NodeID name_id,
|
||||||
const EdgeWeight duration,
|
const EdgeWeight duration,
|
||||||
const float length,
|
const float length,
|
||||||
const TurnInstruction turn_instruction,
|
const TurnInstruction turn_instruction,
|
||||||
const bool necessary,
|
const bool necessary,
|
||||||
const bool is_via_location)
|
const bool is_via_location,
|
||||||
|
const TravelMode travel_mode)
|
||||||
: location(location), name_id(name_id), duration(duration), length(length), bearing(0),
|
: location(location), name_id(name_id), duration(duration), length(length), bearing(0),
|
||||||
turn_instruction(turn_instruction), necessary(necessary), is_via_location(is_via_location)
|
turn_instruction(turn_instruction), necessary(necessary), is_via_location(is_via_location),
|
||||||
|
travel_mode(travel_mode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,9 +65,11 @@ struct SegmentInformation
|
|||||||
const NodeID name_id,
|
const NodeID name_id,
|
||||||
const EdgeWeight duration,
|
const EdgeWeight duration,
|
||||||
const float length,
|
const float length,
|
||||||
const TurnInstruction turn_instruction)
|
const TurnInstruction turn_instruction,
|
||||||
|
const TravelMode travel_mode)
|
||||||
: location(location), name_id(name_id), duration(duration), length(length), bearing(0),
|
: location(location), name_id(name_id), duration(duration), length(length), bearing(0),
|
||||||
turn_instruction(turn_instruction), necessary(turn_instruction != TurnInstruction::NoTurn), is_via_location(false)
|
turn_instruction(turn_instruction), necessary(turn_instruction != TurnInstruction::NoTurn), is_via_location(false),
|
||||||
|
travel_mode(travel_mode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -801,7 +801,9 @@ class StaticRTree
|
|||||||
current_segment.reverse_offset,
|
current_segment.reverse_offset,
|
||||||
current_segment.packed_geometry_id,
|
current_segment.packed_geometry_id,
|
||||||
foot_point_coordinate_on_segment,
|
foot_point_coordinate_on_segment,
|
||||||
current_segment.fwd_segment_position);
|
current_segment.fwd_segment_position,
|
||||||
|
current_segment.travel_mode,
|
||||||
|
current_segment.backward_travel_mode);
|
||||||
|
|
||||||
// Hack to fix rounding errors and wandering via nodes.
|
// Hack to fix rounding errors and wandering via nodes.
|
||||||
FixUpRoundingIssue(input_coordinate, result_phantom_node_vector.back());
|
FixUpRoundingIssue(input_coordinate, result_phantom_node_vector.back());
|
||||||
@ -1077,7 +1079,9 @@ class StaticRTree
|
|||||||
current_edge.reverse_offset,
|
current_edge.reverse_offset,
|
||||||
current_edge.packed_geometry_id,
|
current_edge.packed_geometry_id,
|
||||||
nearest,
|
nearest,
|
||||||
current_edge.fwd_segment_position};
|
current_edge.fwd_segment_position,
|
||||||
|
current_edge.travel_mode,
|
||||||
|
current_edge.backward_travel_mode};
|
||||||
nearest_edge = current_edge;
|
nearest_edge = current_edge;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,10 @@ void DescriptionFactory::SetStartSegment(const PhantomNode &source, const bool t
|
|||||||
start_phantom = source;
|
start_phantom = source;
|
||||||
const EdgeWeight segment_duration =
|
const EdgeWeight segment_duration =
|
||||||
(traversed_in_reverse ? source.reverse_weight : source.forward_weight);
|
(traversed_in_reverse ? source.reverse_weight : source.forward_weight);
|
||||||
|
const TravelMode travel_mode =
|
||||||
|
(traversed_in_reverse ? source.backward_travel_mode : source.travel_mode);
|
||||||
AppendSegment(source.location,
|
AppendSegment(source.location,
|
||||||
PathData(0, source.name_id, TurnInstruction::HeadOn, segment_duration));
|
PathData(0, source.name_id, TurnInstruction::HeadOn, segment_duration, travel_mode));
|
||||||
BOOST_ASSERT(path_description.back().duration == segment_duration);
|
BOOST_ASSERT(path_description.back().duration == segment_duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +59,7 @@ void DescriptionFactory::SetEndSegment(const PhantomNode &target,
|
|||||||
target_phantom = target;
|
target_phantom = target;
|
||||||
const EdgeWeight segment_duration =
|
const EdgeWeight segment_duration =
|
||||||
(traversed_in_reverse ? target.reverse_weight : target.forward_weight);
|
(traversed_in_reverse ? target.reverse_weight : target.forward_weight);
|
||||||
|
<<<<<<< HEAD
|
||||||
path_description.emplace_back(target.location,
|
path_description.emplace_back(target.location,
|
||||||
target.name_id,
|
target.name_id,
|
||||||
segment_duration,
|
segment_duration,
|
||||||
@ -64,7 +67,8 @@ void DescriptionFactory::SetEndSegment(const PhantomNode &target,
|
|||||||
is_via_location ? TurnInstruction::ReachViaLocation
|
is_via_location ? TurnInstruction::ReachViaLocation
|
||||||
: TurnInstruction::NoTurn,
|
: TurnInstruction::NoTurn,
|
||||||
true,
|
true,
|
||||||
true);
|
true,
|
||||||
|
travel_mode);
|
||||||
BOOST_ASSERT(path_description.back().duration == segment_duration);
|
BOOST_ASSERT(path_description.back().duration == segment_duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +85,8 @@ void DescriptionFactory::AppendSegment(const FixedPointCoordinate &coordinate,
|
|||||||
path_point.name_id,
|
path_point.name_id,
|
||||||
path_point.segment_duration,
|
path_point.segment_duration,
|
||||||
0.f,
|
0.f,
|
||||||
path_point.turn_instruction);
|
path_point.turn_instruction,
|
||||||
|
path_point.travel_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSON::Value DescriptionFactory::AppendEncodedPolylineString(const bool return_encoded)
|
JSON::Value DescriptionFactory::AppendEncodedPolylineString(const bool return_encoded)
|
||||||
|
@ -356,6 +356,7 @@ template <class DataFacadeT> class JSONDescriptor : public BaseDescriptor<DataFa
|
|||||||
json_instruction_row.values.push_back(Azimuth::Get(bearing_value));
|
json_instruction_row.values.push_back(Azimuth::Get(bearing_value));
|
||||||
json_instruction_row.values.push_back(
|
json_instruction_row.values.push_back(
|
||||||
static_cast<unsigned>(round(bearing_value)));
|
static_cast<unsigned>(round(bearing_value)));
|
||||||
|
json_instruction_row.values.push_back(segment.travel_mode);
|
||||||
|
|
||||||
route_segments_list.emplace_back(
|
route_segments_list.emplace_back(
|
||||||
segment.name_id,
|
segment.name_id,
|
||||||
|
@ -53,6 +53,8 @@ struct ExtractionWay
|
|||||||
roundabout = false;
|
roundabout = false;
|
||||||
isAccessRestricted = false;
|
isAccessRestricted = false;
|
||||||
ignoreInGrid = false;
|
ignoreInGrid = false;
|
||||||
|
travel_mode = 0;
|
||||||
|
backward_travel_mode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Directions
|
enum Directions
|
||||||
@ -60,6 +62,22 @@ struct ExtractionWay
|
|||||||
oneway,
|
oneway,
|
||||||
bidirectional,
|
bidirectional,
|
||||||
opposite };
|
opposite };
|
||||||
|
|
||||||
|
inline bool IsBidirectional() { return travel_mode!=0 && backward_travel_mode!=0; }
|
||||||
|
inline bool IsOneway() { return travel_mode!=0 && backward_travel_mode==0; }
|
||||||
|
inline bool IsOpposite() { return travel_mode==0 && backward_travel_mode!=0; }
|
||||||
|
inline bool HasDiffDirections() { return (travel_mode != backward_travel_mode) || (speed != backward_speed); }
|
||||||
|
inline Directions Direction()
|
||||||
|
{
|
||||||
|
if( IsOneway() ) {
|
||||||
|
return ExtractionWay::oneway;
|
||||||
|
}
|
||||||
|
if( IsOpposite() ) {
|
||||||
|
return ExtractionWay::opposite;
|
||||||
|
}
|
||||||
|
return ExtractionWay::bidirectional;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned id;
|
unsigned id;
|
||||||
unsigned nameID;
|
unsigned nameID;
|
||||||
double speed;
|
double speed;
|
||||||
@ -74,6 +92,8 @@ struct ExtractionWay
|
|||||||
bool ignoreInGrid;
|
bool ignoreInGrid;
|
||||||
std::vector<NodeID> path;
|
std::vector<NodeID> path;
|
||||||
HashTable<std::string, std::string> keyVals;
|
HashTable<std::string, std::string> keyVals;
|
||||||
|
TravelMode travel_mode;
|
||||||
|
TravelMode backward_travel_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EXTRACTION_WAY_H
|
#endif // EXTRACTION_WAY_H
|
||||||
|
@ -112,8 +112,10 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way)
|
|||||||
parsed_way.direction = ExtractionWay::oneway;
|
parsed_way.direction = ExtractionWay::oneway;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool split_edge =
|
bool split_edge = parsed_way.IsBidirectional() && parsed_way.HasDiffDirections();
|
||||||
(parsed_way.backward_speed > 0) && (parsed_way.speed != parsed_way.backward_speed);
|
|
||||||
|
//const bool split_edge =
|
||||||
|
// (parsed_way.backward_speed > 0) && (parsed_way.speed != parsed_way.backward_speed);
|
||||||
|
|
||||||
for (unsigned n = 0; n < (parsed_way.path.size() - 1); ++n)
|
for (unsigned n = 0; n < (parsed_way.path.size() - 1); ++n)
|
||||||
{
|
{
|
||||||
@ -128,7 +130,7 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way)
|
|||||||
parsed_way.ignoreInGrid,
|
parsed_way.ignoreInGrid,
|
||||||
(0 < parsed_way.duration),
|
(0 < parsed_way.duration),
|
||||||
parsed_way.isAccessRestricted,
|
parsed_way.isAccessRestricted,
|
||||||
false,
|
parsed_way.travel_mode,
|
||||||
split_edge));
|
split_edge));
|
||||||
external_memory.used_node_id_list.push_back(parsed_way.path[n]);
|
external_memory.used_node_id_list.push_back(parsed_way.path[n]);
|
||||||
}
|
}
|
||||||
@ -158,7 +160,7 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way)
|
|||||||
parsed_way.ignoreInGrid,
|
parsed_way.ignoreInGrid,
|
||||||
(0 < parsed_way.duration),
|
(0 < parsed_way.duration),
|
||||||
parsed_way.isAccessRestricted,
|
parsed_way.isAccessRestricted,
|
||||||
(ExtractionWay::oneway == parsed_way.direction),
|
parsed_way.backward_travel_mode,
|
||||||
split_edge));
|
split_edge));
|
||||||
}
|
}
|
||||||
external_memory.way_start_end_id_list.push_back(
|
external_memory.way_start_end_id_list.push_back(
|
||||||
|
@ -65,12 +65,12 @@ struct InternalExtractorEdge
|
|||||||
// necessary static util functions for stxxl's sorting
|
// necessary static util functions for stxxl's sorting
|
||||||
static InternalExtractorEdge min_value()
|
static InternalExtractorEdge min_value()
|
||||||
{
|
{
|
||||||
return InternalExtractorEdge(0, 0, 0, 0, 0, 0, false, false, false, false, false, false);
|
return InternalExtractorEdge(0, 0, 0, 0, 0, 0, false, false, false, false, 0, false);
|
||||||
}
|
}
|
||||||
static InternalExtractorEdge max_value()
|
static InternalExtractorEdge max_value()
|
||||||
{
|
{
|
||||||
return InternalExtractorEdge(
|
return InternalExtractorEdge(
|
||||||
SPECIAL_NODEID, SPECIAL_NODEID, 0, 0, 0, 0, false, false, false, false, false, false);
|
SPECIAL_NODEID, SPECIAL_NODEID, 0, 0, 0, 0, false, false, false, false, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID start;
|
NodeID start;
|
||||||
|
@ -86,6 +86,8 @@ void ScriptingEnvironment::initLuaState(lua_State* lua_state)
|
|||||||
.def_readwrite("ignore_in_grid", &ExtractionWay::ignoreInGrid)
|
.def_readwrite("ignore_in_grid", &ExtractionWay::ignoreInGrid)
|
||||||
.def_readwrite("tags", &ExtractionWay::keyVals)
|
.def_readwrite("tags", &ExtractionWay::keyVals)
|
||||||
.def_readwrite("direction", &ExtractionWay::direction)
|
.def_readwrite("direction", &ExtractionWay::direction)
|
||||||
|
.def_readwrite("mode", &ExtractionWay::travel_mode)
|
||||||
|
.def_readwrite("backward_mode", &ExtractionWay::backward_travel_mode)
|
||||||
.enum_("constants")[
|
.enum_("constants")[
|
||||||
luabind::value("notSure", 0),
|
luabind::value("notSure", 0),
|
||||||
luabind::value("oneway", 1),
|
luabind::value("oneway", 1),
|
||||||
|
2
Rakefile
2
Rakefile
@ -6,7 +6,7 @@ require 'sys/proctable'
|
|||||||
|
|
||||||
BUILD_FOLDER = 'build'
|
BUILD_FOLDER = 'build'
|
||||||
DATA_FOLDER = 'sandbox'
|
DATA_FOLDER = 'sandbox'
|
||||||
PROFILE = 'examples/postgis'
|
PROFILE = 'bicycle'
|
||||||
OSRM_PORT = 5000
|
OSRM_PORT = 5000
|
||||||
PROFILES_FOLDER = '../profiles'
|
PROFILES_FOLDER = '../profiles'
|
||||||
|
|
||||||
|
@ -227,14 +227,16 @@ template <class DataFacadeT> class BasicRoutingInterface
|
|||||||
BOOST_ASSERT_MSG(!ed.shortcut, "original edge flagged as shortcut");
|
BOOST_ASSERT_MSG(!ed.shortcut, "original edge flagged as shortcut");
|
||||||
unsigned name_index = facade->GetNameIndexFromEdgeID(ed.id);
|
unsigned name_index = facade->GetNameIndexFromEdgeID(ed.id);
|
||||||
const TurnInstruction turn_instruction = facade->GetTurnInstructionForEdgeID(ed.id);
|
const TurnInstruction turn_instruction = facade->GetTurnInstructionForEdgeID(ed.id);
|
||||||
|
const TravelMode travel_mode = facade->GetTravelModeForEdgeID(ed.id);
|
||||||
|
|
||||||
if (!facade->EdgeIsCompressed(ed.id))
|
if (!facade->EdgeIsCompressed(ed.id))
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(!facade->EdgeIsCompressed(ed.id));
|
BOOST_ASSERT(!facade->EdgeIsCompressed(ed.id));
|
||||||
unpacked_path.emplace_back(facade->GetGeometryIndexForEdgeID(ed.id),
|
unpacked_path.emplace_back(facade->GetGeometryIndexForEdgeID(ed.id),
|
||||||
name_index,
|
name_index,
|
||||||
turn_instruction,
|
turn_instruction,
|
||||||
ed.distance);
|
ed.distance,
|
||||||
|
travel_mode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -255,7 +257,7 @@ template <class DataFacadeT> class BasicRoutingInterface
|
|||||||
BOOST_ASSERT(start_index <= end_index);
|
BOOST_ASSERT(start_index <= end_index);
|
||||||
for (std::size_t i = start_index; i < end_index; ++i)
|
for (std::size_t i = start_index; i < end_index; ++i)
|
||||||
{
|
{
|
||||||
unpacked_path.emplace_back(id_vector[i], name_index, TurnInstruction::NoTurn, 0);
|
unpacked_path.emplace_back(id_vector[i], name_index, TurnInstruction::NoTurn, 0, 0);
|
||||||
}
|
}
|
||||||
unpacked_path.back().turn_instruction = turn_instruction;
|
unpacked_path.back().turn_instruction = turn_instruction;
|
||||||
unpacked_path.back().segment_duration = ed.distance;
|
unpacked_path.back().segment_duration = ed.distance;
|
||||||
@ -299,9 +301,10 @@ template <class DataFacadeT> class BasicRoutingInterface
|
|||||||
{
|
{
|
||||||
BOOST_ASSERT(i < id_vector.size());
|
BOOST_ASSERT(i < id_vector.size());
|
||||||
unpacked_path.emplace_back(PathData{id_vector[i],
|
unpacked_path.emplace_back(PathData{id_vector[i],
|
||||||
phantom_node_pair.target_phantom.name_id,
|
phantom_node_pair.target_phantom.name_id,
|
||||||
TurnInstruction::NoTurn,
|
TurnInstruction::NoTurn,
|
||||||
0});
|
0,
|
||||||
|
0});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +92,8 @@ template <class EdgeDataT> class BaseDataFacade
|
|||||||
|
|
||||||
virtual TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const = 0;
|
virtual TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const = 0;
|
||||||
|
|
||||||
|
virtual TravelMode GetTravelModeForEdgeID(const unsigned id) const = 0;
|
||||||
|
|
||||||
virtual bool LocateClosestEndPointForCoordinate(const FixedPointCoordinate &input_coordinate,
|
virtual bool LocateClosestEndPointForCoordinate(const FixedPointCoordinate &input_coordinate,
|
||||||
FixedPointCoordinate &result,
|
FixedPointCoordinate &result,
|
||||||
const unsigned zoom_level = 18) = 0;
|
const unsigned zoom_level = 18) = 0;
|
||||||
|
@ -66,6 +66,7 @@ template <class EdgeDataT> class InternalDataFacade : public BaseDataFacade<Edge
|
|||||||
ShM<NodeID, false>::vector m_via_node_list;
|
ShM<NodeID, false>::vector m_via_node_list;
|
||||||
ShM<unsigned, false>::vector m_name_ID_list;
|
ShM<unsigned, false>::vector m_name_ID_list;
|
||||||
ShM<TurnInstruction, false>::vector m_turn_instruction_list;
|
ShM<TurnInstruction, false>::vector m_turn_instruction_list;
|
||||||
|
ShM<TravelMode, false>::vector m_travel_mode_list;
|
||||||
ShM<char, false>::vector m_names_char_list;
|
ShM<char, false>::vector m_names_char_list;
|
||||||
ShM<bool, false>::vector m_egde_is_compressed;
|
ShM<bool, false>::vector m_egde_is_compressed;
|
||||||
ShM<unsigned, false>::vector m_geometry_indices;
|
ShM<unsigned, false>::vector m_geometry_indices;
|
||||||
@ -145,6 +146,7 @@ template <class EdgeDataT> class InternalDataFacade : public BaseDataFacade<Edge
|
|||||||
m_via_node_list.resize(number_of_edges);
|
m_via_node_list.resize(number_of_edges);
|
||||||
m_name_ID_list.resize(number_of_edges);
|
m_name_ID_list.resize(number_of_edges);
|
||||||
m_turn_instruction_list.resize(number_of_edges);
|
m_turn_instruction_list.resize(number_of_edges);
|
||||||
|
m_travel_mode_list.resize(number_of_edges);
|
||||||
m_egde_is_compressed.resize(number_of_edges);
|
m_egde_is_compressed.resize(number_of_edges);
|
||||||
|
|
||||||
unsigned compressed = 0;
|
unsigned compressed = 0;
|
||||||
@ -156,6 +158,7 @@ template <class EdgeDataT> class InternalDataFacade : public BaseDataFacade<Edge
|
|||||||
m_via_node_list[i] = current_edge_data.via_node;
|
m_via_node_list[i] = current_edge_data.via_node;
|
||||||
m_name_ID_list[i] = current_edge_data.name_id;
|
m_name_ID_list[i] = current_edge_data.name_id;
|
||||||
m_turn_instruction_list[i] = current_edge_data.turn_instruction;
|
m_turn_instruction_list[i] = current_edge_data.turn_instruction;
|
||||||
|
m_travel_mode_list[i] = current_edge_data.travel_mode;
|
||||||
m_egde_is_compressed[i] = current_edge_data.compressed_geometry;
|
m_egde_is_compressed[i] = current_edge_data.compressed_geometry;
|
||||||
if (m_egde_is_compressed[i])
|
if (m_egde_is_compressed[i])
|
||||||
{
|
{
|
||||||
@ -356,6 +359,11 @@ template <class EdgeDataT> class InternalDataFacade : public BaseDataFacade<Edge
|
|||||||
return m_turn_instruction_list.at(id);
|
return m_turn_instruction_list.at(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TravelMode GetTravelModeForEdgeID(const unsigned id) const
|
||||||
|
{
|
||||||
|
return 15;//m_travel_mode_list.at(id);
|
||||||
|
}
|
||||||
|
|
||||||
bool LocateClosestEndPointForCoordinate(const FixedPointCoordinate &input_coordinate,
|
bool LocateClosestEndPointForCoordinate(const FixedPointCoordinate &input_coordinate,
|
||||||
FixedPointCoordinate &result,
|
FixedPointCoordinate &result,
|
||||||
const unsigned zoom_level = 18) final
|
const unsigned zoom_level = 18) final
|
||||||
|
@ -77,6 +77,7 @@ template <class EdgeDataT> class SharedDataFacade : public BaseDataFacade<EdgeDa
|
|||||||
ShM<NodeID, true>::vector m_via_node_list;
|
ShM<NodeID, true>::vector m_via_node_list;
|
||||||
ShM<unsigned, true>::vector m_name_ID_list;
|
ShM<unsigned, true>::vector m_name_ID_list;
|
||||||
ShM<TurnInstruction, true>::vector m_turn_instruction_list;
|
ShM<TurnInstruction, true>::vector m_turn_instruction_list;
|
||||||
|
ShM<TravelMode, true>::vector m_travel_mode_list;
|
||||||
ShM<char, true>::vector m_names_char_list;
|
ShM<char, true>::vector m_names_char_list;
|
||||||
ShM<unsigned, true>::vector m_name_begin_indices;
|
ShM<unsigned, true>::vector m_name_begin_indices;
|
||||||
ShM<bool, true>::vector m_egde_is_compressed;
|
ShM<bool, true>::vector m_egde_is_compressed;
|
||||||
@ -150,7 +151,9 @@ template <class EdgeDataT> class SharedDataFacade : public BaseDataFacade<EdgeDa
|
|||||||
turn_instruction_list_ptr,
|
turn_instruction_list_ptr,
|
||||||
data_layout->num_entries[SharedDataLayout::TURN_INSTRUCTION]);
|
data_layout->num_entries[SharedDataLayout::TURN_INSTRUCTION]);
|
||||||
m_turn_instruction_list.swap(turn_instruction_list);
|
m_turn_instruction_list.swap(turn_instruction_list);
|
||||||
|
|
||||||
|
//TODO m_travel_mode_list
|
||||||
|
|
||||||
unsigned *name_id_list_ptr =
|
unsigned *name_id_list_ptr =
|
||||||
data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::NAME_ID_LIST);
|
data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::NAME_ID_LIST);
|
||||||
typename ShM<unsigned, true>::vector name_id_list(
|
typename ShM<unsigned, true>::vector name_id_list(
|
||||||
@ -346,6 +349,11 @@ template <class EdgeDataT> class SharedDataFacade : public BaseDataFacade<EdgeDa
|
|||||||
return m_turn_instruction_list.at(id);
|
return m_turn_instruction_list.at(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TravelMode GetTravelModeForEdgeID(const unsigned id) const
|
||||||
|
{
|
||||||
|
return m_travel_mode_list.at(id);
|
||||||
|
}
|
||||||
|
|
||||||
bool LocateClosestEndPointForCoordinate(const FixedPointCoordinate &input_coordinate,
|
bool LocateClosestEndPointForCoordinate(const FixedPointCoordinate &input_coordinate,
|
||||||
FixedPointCoordinate &result,
|
FixedPointCoordinate &result,
|
||||||
const unsigned zoom_level = 18) final
|
const unsigned zoom_level = 18) final
|
||||||
|
@ -146,6 +146,9 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream,
|
|||||||
input_stream.read((char *)&travel_mode, sizeof(TravelMode));
|
input_stream.read((char *)&travel_mode, sizeof(TravelMode));
|
||||||
input_stream.read((char *)&is_split, sizeof(bool));
|
input_stream.read((char *)&is_split, sizeof(bool));
|
||||||
|
|
||||||
|
|
||||||
|
SimpleLogger().Write() << "mode read: " << (int)travel_mode;
|
||||||
|
|
||||||
BOOST_ASSERT_MSG(length > 0, "loaded null length edge");
|
BOOST_ASSERT_MSG(length > 0, "loaded null length edge");
|
||||||
BOOST_ASSERT_MSG(weight > 0, "loaded null weight");
|
BOOST_ASSERT_MSG(weight > 0, "loaded null weight");
|
||||||
BOOST_ASSERT_MSG(0 <= dir && dir <= 2, "loaded bogus direction");
|
BOOST_ASSERT_MSG(0 <= dir && dir <= 2, "loaded bogus direction");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
routing @bicycle @mode
|
@routing @bicycle @mode
|
||||||
Feature: Bike - Mode flag
|
Feature: Bike - Mode flag
|
||||||
|
|
||||||
# bicycle modes:
|
# bicycle modes:
|
||||||
|
@ -94,7 +94,13 @@ u_turn_penalty = 20
|
|||||||
use_turn_restrictions = false
|
use_turn_restrictions = false
|
||||||
turn_penalty = 60
|
turn_penalty = 60
|
||||||
turn_bias = 1.4
|
turn_bias = 1.4
|
||||||
-- End of globals
|
|
||||||
|
|
||||||
|
--modes
|
||||||
|
mode_normal = 1
|
||||||
|
mode_pushing = 2
|
||||||
|
mode_ferry = 3
|
||||||
|
mode_train = 4
|
||||||
|
|
||||||
|
|
||||||
local function parse_maxspeed(source)
|
local function parse_maxspeed(source)
|
||||||
@ -229,6 +235,7 @@ function way_function (way)
|
|||||||
-- public_transport platforms (new tagging platform)
|
-- public_transport platforms (new tagging platform)
|
||||||
way.speed = platform_speeds[public_transport]
|
way.speed = platform_speeds[public_transport]
|
||||||
elseif railway and railway_speeds[railway] then
|
elseif railway and railway_speeds[railway] then
|
||||||
|
way.mode = mode_train
|
||||||
-- railways
|
-- railways
|
||||||
if access and access_tag_whitelist[access] then
|
if access and access_tag_whitelist[access] then
|
||||||
way.speed = railway_speeds[railway]
|
way.speed = railway_speeds[railway]
|
||||||
@ -251,11 +258,14 @@ function way_function (way)
|
|||||||
if pedestrian_speeds[highway] then
|
if pedestrian_speeds[highway] then
|
||||||
-- pedestrian-only ways and areas
|
-- pedestrian-only ways and areas
|
||||||
way.speed = pedestrian_speeds[highway]
|
way.speed = pedestrian_speeds[highway]
|
||||||
|
way.mode = mode_pushing
|
||||||
elseif man_made and man_made_speeds[man_made] then
|
elseif man_made and man_made_speeds[man_made] then
|
||||||
-- man made structures
|
-- man made structures
|
||||||
way.speed = man_made_speeds[man_made]
|
way.speed = man_made_speeds[man_made]
|
||||||
|
way.mode = mode_pushing
|
||||||
elseif foot == 'yes' then
|
elseif foot == 'yes' then
|
||||||
way.speed = walking_speed
|
way.speed = walking_speed
|
||||||
|
way.mode = mode_pushing
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -308,9 +318,11 @@ function way_function (way)
|
|||||||
if junction ~= "roundabout" then
|
if junction ~= "roundabout" then
|
||||||
if way.direction == Way.oneway then
|
if way.direction == Way.oneway then
|
||||||
way.backward_speed = walking_speed
|
way.backward_speed = walking_speed
|
||||||
|
way.mode = mode_pushing
|
||||||
elseif way.direction == Way.opposite then
|
elseif way.direction == Way.opposite then
|
||||||
way.backward_speed = walking_speed
|
way.backward_speed = walking_speed
|
||||||
way.speed = way.speed
|
way.speed = way.speed
|
||||||
|
way.mode = mode_pushing
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -6,6 +6,14 @@
|
|||||||
-- Secondary road: 18km/h = 18000m/3600s = 100m/20s
|
-- Secondary road: 18km/h = 18000m/3600s = 100m/20s
|
||||||
-- Tertiary road: 12km/h = 12000m/3600s = 100m/30s
|
-- Tertiary road: 12km/h = 12000m/3600s = 100m/30s
|
||||||
|
|
||||||
|
-- modes:
|
||||||
|
-- 1: normal
|
||||||
|
-- 2: route
|
||||||
|
-- 3: river downstream
|
||||||
|
-- 4: river upstream
|
||||||
|
-- 5: steps down
|
||||||
|
-- 6: steps up
|
||||||
|
|
||||||
speed_profile = {
|
speed_profile = {
|
||||||
["primary"] = 36,
|
["primary"] = 36,
|
||||||
["secondary"] = 18,
|
["secondary"] = 18,
|
||||||
@ -61,12 +69,16 @@ function way_function (way)
|
|||||||
|
|
||||||
if route ~= nil and durationIsValid(duration) then
|
if route ~= nil and durationIsValid(duration) then
|
||||||
way.duration = math.max( 1, parseDuration(duration) )
|
way.duration = math.max( 1, parseDuration(duration) )
|
||||||
|
way.mode = 2
|
||||||
|
way.backward_mode = 2
|
||||||
else
|
else
|
||||||
local speed_forw = speed_profile[highway] or speed_profile['default']
|
local speed_forw = speed_profile[highway] or speed_profile['default']
|
||||||
local speed_back = speed_forw
|
local speed_back = speed_forw
|
||||||
|
|
||||||
if highway == "river" then
|
if highway == "river" then
|
||||||
local temp_speed = speed_forw;
|
local temp_speed = speed_forw;
|
||||||
|
way.mode = 3
|
||||||
|
way.backward_mode = 4
|
||||||
speed_forw = temp_speed*1.5
|
speed_forw = temp_speed*1.5
|
||||||
speed_back = temp_speed/1.5
|
speed_back = temp_speed/1.5
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user