Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

travel mode #1154

Merged
merged 49 commits into from
Aug 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
3e6f27d
rename contra_flow to travel_mode, use unsigned char
Aug 9, 2014
d09394e
add failing tests for travel mode
Aug 9, 2014
6fd615b
first cut at porting travel mode, some tests fail
Aug 9, 2014
6d6d299
most tests passing
emiltin Aug 11, 2014
dae9c9a
use 4 bits for travel mode
Aug 11, 2014
181dbe8
improve tests for travel mode
Aug 11, 2014
a5ee7e7
fixes
Aug 12, 2014
235a520
more tests passing
Aug 12, 2014
ff0dfac
fix initialization order to avoid compiler warning
Aug 12, 2014
6878928
remove spurious comment
Aug 12, 2014
8ea8846
remove unneeded methods
Aug 12, 2014
62495a6
remove comment
Aug 12, 2014
7a2d214
reactivate assert of sizeof(NodeBasedEdgeData)
Aug 12, 2014
6e1ab9f
profile fixes
emiltin Aug 12, 2014
4dd0377
fix compilation of tests
emiltin Aug 12, 2014
3460bd0
fix problems with mode, 1 failing test left
Aug 13, 2014
8e625a5
rename test
Aug 13, 2014
bfdc296
reduce failing test
Aug 13, 2014
0244060
add a few tests
Aug 14, 2014
bea6302
remove bitfield from SegmentInformation, works around compile err
Aug 15, 2014
35988d8
fix problem with mode of first instruction
Aug 15, 2014
207cddd
use enum for TravelMode
Aug 16, 2014
6f6aff7
remove direction field from ExtractionWay
Aug 16, 2014
6e364ff
rename travel mode None to Inaccessible
Aug 16, 2014
feaf871
announce mode changes
Aug 16, 2014
eb122a2
tidy feature file
Aug 16, 2014
6cdc590
typedef instead of enum for TravelMode to avoid gcc warnings
Aug 18, 2014
30362cf
update lua interface to speed and mode
Aug 18, 2014
1945aae
reorder members of SegmentInformation, remove bit fields where possible
DennisOSRM Aug 18, 2014
13ea12c
fix unit test
emiltin Aug 18, 2014
221113c
fix assert
emiltin Aug 18, 2014
418ff95
fix initialization order
Aug 19, 2014
3d94638
update car profile, add ferry mode
Aug 19, 2014
6ee7a81
update foot profile, add ferry mode
Aug 19, 2014
c37c8dc
add mode test
Aug 19, 2014
2780ff3
fix bug with mode of 1st instruction
Aug 19, 2014
fccb1aa
remove type attribute
Aug 19, 2014
9c23fd4
remove accidentially added file
Aug 19, 2014
60d80cf
code style fixes
Aug 19, 2014
6e2608b
fix cuke support file
Aug 19, 2014
1e40cd6
remove type assertion
Aug 19, 2014
2e3d33d
remove type from more structs, remove asserts
emiltin Aug 20, 2014
bcd5562
make accessors const, add comments
Aug 20, 2014
00dd246
use lambda to decide turn value
Aug 20, 2014
39d96a4
fix lambda syntax
DennisOSRM Aug 20, 2014
bb3cbf2
fix indentation, remove superflous else clause
DennisOSRM Aug 20, 2014
774e634
more robust check for parsed ways
Aug 20, 2014
6a09ce1
fix comparison in car speed profile
DennisOSRM Aug 21, 2014
d7fbd41
fix expected values of backward speed in test
DennisOSRM Aug 21, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions Contractor/EdgeBasedGraphFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeID nod
reverse_dist_prefix_sum[i],
m_geometry_compressor.GetPositionForID(e1),
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;

BOOST_ASSERT(m_edge_based_node_list.back().IsCompressed());
Expand Down Expand Up @@ -231,7 +233,9 @@ EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeID nod
0,
SPECIAL_EDGEID,
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());
}
}
Expand Down Expand Up @@ -500,7 +504,6 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedNodes()
}

BOOST_ASSERT(u < v);
BOOST_ASSERT(edge_data.type != SHRT_MAX);

// Note: edges that end on barrier nodes or on a turn restriction
// may actually be in two distinct components. We choose the smallest
Expand Down Expand Up @@ -648,7 +651,8 @@ EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(const std::string &original_edg
(edge_is_compressed ? m_geometry_compressor.GetPositionForID(e1) : v),
edge_data1.nameID,
turn_instruction,
edge_is_compressed);
edge_is_compressed,
edge_data2.travel_mode);

++original_edges_counter;

Expand Down Expand Up @@ -718,15 +722,6 @@ TurnInstruction EdgeBasedGraphFactory::AnalyzeTurn(const NodeID node_u,
const EdgeData &data1 = m_node_based_graph->GetEdgeData(edge1);
const EdgeData &data2 = m_node_based_graph->GetEdgeData(edge2);

if (!data1.contraFlow && data2.contraFlow)
{
return TurnInstruction::EnterAgainstAllowedDirection;
}
if (data1.contraFlow && !data2.contraFlow)
{
return TurnInstruction::LeaveAgainstAllowedDirection;
}

// roundabouts need to be handled explicitely
if (data1.roundabout && data2.roundabout)
{
Expand Down
15 changes: 12 additions & 3 deletions DataStructures/EdgeBasedNode.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef EDGE_BASED_NODE_H
#define EDGE_BASED_NODE_H

#include "../DataStructures/TravelMode.h"
#include "../Util/SimpleLogger.h"
#include "../typedefs.h"

Expand All @@ -25,7 +26,9 @@ struct EdgeBasedNode
reverse_offset(0),
packed_geometry_id(SPECIAL_EDGEID),
fwd_segment_position( std::numeric_limits<unsigned short>::max() ),
is_in_tiny_cc(false)
is_in_tiny_cc(false),
forward_travel_mode(TRAVEL_MODE_INACCESSIBLE),
backward_travel_mode(TRAVEL_MODE_INACCESSIBLE)
{ }

explicit EdgeBasedNode(
Expand All @@ -40,7 +43,9 @@ struct EdgeBasedNode
int reverse_offset,
unsigned packed_geometry_id,
unsigned short fwd_segment_position,
bool belongs_to_tiny_component
bool belongs_to_tiny_component,
TravelMode forward_travel_mode,
TravelMode backward_travel_mode
) :
forward_edge_based_node_id(forward_edge_based_node_id),
reverse_edge_based_node_id(reverse_edge_based_node_id),
Expand All @@ -53,7 +58,9 @@ struct EdgeBasedNode
reverse_offset(reverse_offset),
packed_geometry_id(packed_geometry_id),
fwd_segment_position(fwd_segment_position),
is_in_tiny_cc(belongs_to_tiny_component)
is_in_tiny_cc(belongs_to_tiny_component),
forward_travel_mode(forward_travel_mode),
backward_travel_mode(backward_travel_mode)
{
BOOST_ASSERT((forward_edge_based_node_id != SPECIAL_NODEID) ||
(reverse_edge_based_node_id != SPECIAL_NODEID));
Expand Down Expand Up @@ -85,6 +92,8 @@ struct EdgeBasedNode
unsigned packed_geometry_id; // if set, then the edge represents a packed geometry
unsigned short fwd_segment_position; // segment id in a compressed geometry
bool is_in_tiny_cc;
TravelMode forward_travel_mode : 4;
TravelMode backward_travel_mode : 4;
};

#endif //EDGE_BASED_NODE_H
8 changes: 3 additions & 5 deletions DataStructures/ImportEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,15 @@ NodeBasedEdge::NodeBasedEdge(NodeID source,
EdgeWeight weight,
bool forward,
bool backward,
short type,
bool roundabout,
bool in_tiny_cc,
bool access_restricted,
bool contra_flow,
TravelMode travel_mode,
bool is_split)
: source(source), target(target), name_id(name_id), weight(weight), type(type),
: source(source), target(target), name_id(name_id), weight(weight),
forward(forward), backward(backward), roundabout(roundabout), in_tiny_cc(in_tiny_cc),
access_restricted(access_restricted), contra_flow(contra_flow), is_split(is_split)
access_restricted(access_restricted), is_split(is_split), travel_mode(travel_mode)
{
BOOST_ASSERT_MSG(type > 0, "negative edge type");
}

bool EdgeBasedEdge::operator<(const EdgeBasedEdge &other) const
Expand Down
7 changes: 3 additions & 4 deletions DataStructures/ImportEdge.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef IMPORT_EDGE_H
#define IMPORT_EDGE_H

#include "../DataStructures/TravelMode.h"
#include "../typedefs.h"

struct NodeBasedEdge
Expand All @@ -40,25 +41,23 @@ struct NodeBasedEdge
EdgeWeight weight,
bool forward,
bool backward,
short type,
bool roundabout,
bool in_tiny_cc,
bool access_restricted,
bool contra_flow,
TravelMode travel_mode,
bool is_split);

NodeID source;
NodeID target;
NodeID name_id;
EdgeWeight weight;
short type;
bool forward : 1;
bool backward : 1;
bool roundabout : 1;
bool in_tiny_cc : 1;
bool access_restricted : 1;
bool contra_flow : 1;
bool is_split : 1;
TravelMode travel_mode : 4;

NodeBasedEdge() = delete;
};
Expand Down
13 changes: 6 additions & 7 deletions DataStructures/NodeBasedGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,22 @@ struct NodeBasedEdgeData
{
NodeBasedEdgeData()
: distance(INVALID_EDGE_WEIGHT), edgeBasedNodeID(SPECIAL_NODEID),
nameID(std::numeric_limits<unsigned>::max()), type(std::numeric_limits<short>::max()),
nameID(std::numeric_limits<unsigned>::max()),
isAccessRestricted(false), shortcut(false), forward(false), backward(false),
roundabout(false), ignore_in_grid(false), contraFlow(false)
roundabout(false), ignore_in_grid(false), travel_mode(TRAVEL_MODE_INACCESSIBLE)
{
}

int distance;
unsigned edgeBasedNodeID;
unsigned nameID;
short type;
bool isAccessRestricted : 1;
bool shortcut : 1;
bool forward : 1;
bool backward : 1;
bool roundabout : 1;
bool ignore_in_grid : 1;
bool contraFlow : 1;
TravelMode travel_mode : 4;

void SwapDirectionFlags()
{
Expand All @@ -42,7 +41,7 @@ struct NodeBasedEdgeData
{
return (forward == other.forward) && (backward == other.backward) &&
(nameID == other.nameID) && (ignore_in_grid == other.ignore_in_grid) &&
(contraFlow == other.contraFlow);
(travel_mode == other.travel_mode);
}
};

Expand Down Expand Up @@ -91,9 +90,9 @@ NodeBasedDynamicGraphFromImportEdges(int number_of_nodes, std::vector<ImportEdge
edge.data.roundabout = import_edge.roundabout;
edge.data.ignore_in_grid = import_edge.in_tiny_cc;
edge.data.nameID = import_edge.name_id;
edge.data.type = import_edge.type;
edge.data.isAccessRestricted = import_edge.access_restricted;
edge.data.contraFlow = import_edge.contra_flow;
edge.data.travel_mode = import_edge.travel_mode;

edges_list.push_back(edge);

if (!import_edge.is_split)
Expand Down
10 changes: 7 additions & 3 deletions DataStructures/OriginalEdgeData.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define ORIGINAL_EDGE_DATA_H

#include "TurnInstructions.h"
#include "../DataStructures/TravelMode.h"
#include "../typedefs.h"

#include <limits>
Expand All @@ -38,23 +39,26 @@ struct OriginalEdgeData
explicit OriginalEdgeData(NodeID via_node,
unsigned name_id,
TurnInstruction turn_instruction,
bool compressed_geometry)
bool compressed_geometry,
TravelMode travel_mode)
: 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()
: via_node(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(TRAVEL_MODE_INACCESSIBLE)
{
}

NodeID via_node;
unsigned name_id;
TurnInstruction turn_instruction;
bool compressed_geometry;
TravelMode travel_mode;
};

#endif // ORIGINAL_EDGE_DATA_H
16 changes: 12 additions & 4 deletions DataStructures/PhantomNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define PHANTOM_NODES_H

#include <osrm/Coordinate.h>
#include "../DataStructures/TravelMode.h"
#include "../Util/SimpleLogger.h"
#include "../typedefs.h"

Expand All @@ -39,7 +40,8 @@ struct PhantomNode
PhantomNode(NodeID forward_node_id, NodeID reverse_node_id, unsigned name_id,
int forward_weight, int reverse_weight, int forward_offset, int reverse_offset,
unsigned packed_geometry_id, FixedPointCoordinate &location,
unsigned short fwd_segment_position) :
unsigned short fwd_segment_position,
TravelMode forward_travel_mode, TravelMode backward_travel_mode) :
forward_node_id(forward_node_id),
reverse_node_id(reverse_node_id),
name_id(name_id),
Expand All @@ -49,7 +51,9 @@ struct PhantomNode
reverse_offset(reverse_offset),
packed_geometry_id(packed_geometry_id),
location(location),
fwd_segment_position(fwd_segment_position)
fwd_segment_position(fwd_segment_position),
forward_travel_mode(forward_travel_mode),
backward_travel_mode(backward_travel_mode)
{ }

PhantomNode() :
Expand All @@ -61,7 +65,9 @@ struct PhantomNode
forward_offset(0),
reverse_offset(0),
packed_geometry_id(SPECIAL_EDGEID),
fwd_segment_position(0)
fwd_segment_position(0),
forward_travel_mode(TRAVEL_MODE_INACCESSIBLE),
backward_travel_mode(TRAVEL_MODE_INACCESSIBLE)
{ }

NodeID forward_node_id;
Expand All @@ -74,7 +80,9 @@ struct PhantomNode
unsigned packed_geometry_id;
FixedPointCoordinate location;
unsigned short fwd_segment_position;

TravelMode forward_travel_mode : 4;
TravelMode backward_travel_mode : 4;

int GetForwardWeightPlusOffset() const
{
if (SPECIAL_NODEID == forward_node_id)
Expand Down
14 changes: 11 additions & 3 deletions DataStructures/RawRouteData.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define RAW_ROUTE_DATA_H

#include "../DataStructures/PhantomNodes.h"
#include "../DataStructures/TravelMode.h"
#include "../DataStructures/TurnInstructions.h"
#include "../typedefs.h"

Expand All @@ -41,18 +42,25 @@ struct PathData
PathData()
: node(SPECIAL_NODEID), name_id(INVALID_EDGE_WEIGHT),
segment_duration(INVALID_EDGE_WEIGHT),
turn_instruction(TurnInstruction::NoTurn)
turn_instruction(TurnInstruction::NoTurn),
travel_mode(TRAVEL_MODE_INACCESSIBLE)
{
}

PathData(NodeID node, unsigned name_id, TurnInstruction turn_instruction, EdgeWeight segment_duration)
: node(node), name_id(name_id), segment_duration(segment_duration), turn_instruction(turn_instruction)
PathData(NodeID node,
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;
unsigned name_id;
EdgeWeight segment_duration;
TurnInstruction turn_instruction;
TravelMode travel_mode : 4;
};

struct RawRouteData
Expand Down
18 changes: 12 additions & 6 deletions DataStructures/SegmentInformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "TurnInstructions.h"

#include "../DataStructures/TravelMode.h"
#include "../typedefs.h"

#include <osrm/Coordinate.h>
Expand All @@ -43,28 +44,33 @@ struct SegmentInformation
float length;
short bearing; // more than enough [0..3600] fits into 12 bits
TurnInstruction turn_instruction;
bool necessary:1;
bool is_via_location:1;
TravelMode travel_mode;
bool necessary;
bool is_via_location;

explicit SegmentInformation(const FixedPointCoordinate &location,
const NodeID name_id,
const EdgeWeight duration,
const float length,
const TurnInstruction turn_instruction,
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),
turn_instruction(turn_instruction), necessary(necessary), is_via_location(is_via_location)
turn_instruction(turn_instruction), travel_mode(travel_mode), necessary(necessary),
is_via_location(is_via_location)
{
}

explicit SegmentInformation(const FixedPointCoordinate &location,
const NodeID name_id,
const EdgeWeight duration,
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),
turn_instruction(turn_instruction), necessary(turn_instruction != TurnInstruction::NoTurn), is_via_location(false)
turn_instruction(turn_instruction), travel_mode(travel_mode),
necessary(turn_instruction != TurnInstruction::NoTurn), is_via_location(false)
{
}
};
Expand Down
Loading