diff --git a/include/contractor/processing_chain.hpp b/include/contractor/processing_chain.hpp index 08247cf44ec..42034eb571c 100644 --- a/include/contractor/processing_chain.hpp +++ b/include/contractor/processing_chain.hpp @@ -4,6 +4,7 @@ #include "contractor/contractor.hpp" #include "contractor/contractor_options.hpp" #include "contractor/query_edge.hpp" +#include "extractor/edge_based_edge.hpp" #include "util/static_graph.hpp" #include "util/deallocating_vector.hpp" #include "util/node_based_graph.hpp" diff --git a/include/extractor/edge_based_edge.hpp b/include/extractor/edge_based_edge.hpp new file mode 100644 index 00000000000..e4e5ef3f3ba --- /dev/null +++ b/include/extractor/edge_based_edge.hpp @@ -0,0 +1,80 @@ +#ifndef EDGE_BASED_EDGE_HPP +#define EDGE_BASED_EDGE_HPP + +#include "extractor/travel_mode.hpp" +#include "util/typedefs.hpp" + +namespace osrm +{ +namespace extractor +{ + +struct EdgeBasedEdge +{ + public: + EdgeBasedEdge(); + + template explicit EdgeBasedEdge(const EdgeT &other); + + EdgeBasedEdge(const NodeID source, + const NodeID target, + const NodeID edge_id, + const EdgeWeight weight, + const bool forward, + const bool backward); + + bool operator<(const EdgeBasedEdge &other) const; + + NodeID source; + NodeID target; + NodeID edge_id; + EdgeWeight weight : 30; + bool forward : 1; + bool backward : 1; +}; + +// Impl. + +inline EdgeBasedEdge::EdgeBasedEdge() + : source(0), target(0), edge_id(0), weight(0), forward(false), backward(false) +{ +} + +template +inline EdgeBasedEdge::EdgeBasedEdge(const EdgeT &other) + : source(other.source), target(other.target), edge_id(other.data.via), + weight(other.data.distance), forward(other.data.forward), backward(other.data.backward) +{ +} + +inline EdgeBasedEdge::EdgeBasedEdge(const NodeID source, + const NodeID target, + const NodeID edge_id, + const EdgeWeight weight, + const bool forward, + const bool backward) + : source(source), target(target), edge_id(edge_id), weight(weight), forward(forward), + backward(backward) +{ +} + +inline bool EdgeBasedEdge::operator<(const EdgeBasedEdge &other) const +{ + if (source == other.source) + { + if (target == other.target) + { + if (weight == other.weight) + { + return forward && backward && ((!other.forward) || (!other.backward)); + } + return weight < other.weight; + } + return target < other.target; + } + return source < other.source; +} +} // ns extractor +} // ns osrm + +#endif /* EDGE_BASED_EDGE_HPP */ diff --git a/include/extractor/edge_based_graph_factory.hpp b/include/extractor/edge_based_graph_factory.hpp index 19a3d1ba8b7..94772a3dda1 100644 --- a/include/extractor/edge_based_graph_factory.hpp +++ b/include/extractor/edge_based_graph_factory.hpp @@ -3,6 +3,7 @@ #ifndef EDGE_BASED_GRAPH_FACTORY_HPP_ #define EDGE_BASED_GRAPH_FACTORY_HPP_ +#include "extractor/edge_based_edge.hpp" #include "extractor/speed_profile.hpp" #include "util/typedefs.hpp" #include "extractor/compressed_edge_container.hpp" diff --git a/include/extractor/extractor.hpp b/include/extractor/extractor.hpp index c9faca9d5f1..68feaf624da 100644 --- a/include/extractor/extractor.hpp +++ b/include/extractor/extractor.hpp @@ -1,6 +1,7 @@ #ifndef EXTRACTOR_HPP #define EXTRACTOR_HPP +#include "extractor/edge_based_edge.hpp" #include "extractor/extractor_options.hpp" #include "extractor/edge_based_graph_factory.hpp" #include "extractor/graph_compressor.hpp" diff --git a/include/extractor/import_edge.hpp b/include/extractor/import_edge.hpp deleted file mode 100644 index 48729a37598..00000000000 --- a/include/extractor/import_edge.hpp +++ /dev/null @@ -1,152 +0,0 @@ -#ifndef IMPORT_EDGE_HPP -#define IMPORT_EDGE_HPP - -#include "extractor/travel_mode.hpp" -#include "util/typedefs.hpp" - -namespace osrm -{ -namespace extractor -{ - -struct NodeBasedEdge -{ - bool operator<(const NodeBasedEdge &other) const - { - if (source == other.source) - { - if (target == other.target) - { - if (weight == other.weight) - { - return forward && backward && ((!other.forward) || (!other.backward)); - } - return weight < other.weight; - } - return target < other.target; - } - return source < other.source; - } - - NodeBasedEdge() - : source(SPECIAL_NODEID), target(SPECIAL_NODEID), name_id(0), weight(0), forward(false), - backward(false), roundabout(false), access_restricted(false), startpoint(true), - is_split(false), travel_mode(false) - { - } - - NodeBasedEdge(NodeID source, - NodeID target, - NodeID name_id, - EdgeWeight weight, - bool forward, - bool backward, - bool roundabout, - bool access_restricted, - bool startpoint, - TravelMode travel_mode, - bool is_split) - : source(source), target(target), name_id(name_id), weight(weight), forward(forward), - backward(backward), roundabout(roundabout), access_restricted(access_restricted), - startpoint(startpoint), is_split(is_split), travel_mode(travel_mode) - { - } - - NodeID source; - NodeID target; - NodeID name_id; - EdgeWeight weight; - bool forward : 1; - bool backward : 1; - bool roundabout : 1; - bool access_restricted : 1; - bool startpoint : 1; - bool is_split : 1; - TravelMode travel_mode : 4; -}; - -struct NodeBasedEdgeWithOSM : NodeBasedEdge -{ - explicit NodeBasedEdgeWithOSM(OSMNodeID source, - OSMNodeID target, - NodeID name_id, - EdgeWeight weight, - bool forward, - bool backward, - bool roundabout, - bool access_restricted, - bool startpoint, - TravelMode travel_mode, - bool is_split) - : NodeBasedEdge(SPECIAL_NODEID, - SPECIAL_NODEID, - name_id, - weight, - forward, - backward, - roundabout, - access_restricted, - startpoint, - travel_mode, - is_split), - osm_source_id(source), osm_target_id(target) - { - } - - OSMNodeID osm_source_id; - OSMNodeID osm_target_id; -}; - -struct EdgeBasedEdge -{ - - public: - bool operator<(const EdgeBasedEdge &other) const - { - if (source == other.source) - { - if (target == other.target) - { - if (weight == other.weight) - { - return forward && backward && ((!other.forward) || (!other.backward)); - } - return weight < other.weight; - } - return target < other.target; - } - return source < other.source; - } - template - explicit EdgeBasedEdge(const EdgeT &other) - : source(other.source), target(other.target), edge_id(other.data.via), - weight(other.data.distance), forward(other.data.forward), backward(other.data.backward) - { - } - - EdgeBasedEdge() : source(0), target(0), edge_id(0), weight(0), forward(false), backward(false) - { - } - - EdgeBasedEdge(const NodeID source, - const NodeID target, - const NodeID edge_id, - const EdgeWeight weight, - const bool forward, - const bool backward) - : source(source), target(target), edge_id(edge_id), weight(weight), forward(forward), - backward(backward) - { - } - - NodeID source; - NodeID target; - NodeID edge_id; - EdgeWeight weight : 30; - bool forward : 1; - bool backward : 1; -}; -} -} - -#endif /* IMPORT_EDGE_HPP */ diff --git a/include/extractor/internal_extractor_edge.hpp b/include/extractor/internal_extractor_edge.hpp index 8e4a133bc25..a85a95d99a2 100644 --- a/include/extractor/internal_extractor_edge.hpp +++ b/include/extractor/internal_extractor_edge.hpp @@ -3,7 +3,7 @@ #include "util/typedefs.hpp" #include "extractor/travel_mode.hpp" -#include "extractor/import_edge.hpp" +#include "extractor/node_based_edge.hpp" #include diff --git a/include/extractor/node_based_edge.hpp b/include/extractor/node_based_edge.hpp new file mode 100644 index 00000000000..434af6c1ebc --- /dev/null +++ b/include/extractor/node_based_edge.hpp @@ -0,0 +1,133 @@ +#ifndef NODE_BASED_EDGE_HPP +#define NODE_BASED_EDGE_HPP + +#include "extractor/travel_mode.hpp" +#include "util/typedefs.hpp" + +namespace osrm +{ +namespace extractor +{ + +struct NodeBasedEdge +{ + NodeBasedEdge(); + + NodeBasedEdge(NodeID source, + NodeID target, + NodeID name_id, + EdgeWeight weight, + bool forward, + bool backward, + bool roundabout, + bool access_restricted, + bool startpoint, + TravelMode travel_mode, + bool is_split); + + bool operator<(const NodeBasedEdge &other) const; + + NodeID source; + NodeID target; + NodeID name_id; + EdgeWeight weight; + bool forward : 1; + bool backward : 1; + bool roundabout : 1; + bool access_restricted : 1; + bool startpoint : 1; + bool is_split : 1; + TravelMode travel_mode : 4; +}; + +struct NodeBasedEdgeWithOSM : NodeBasedEdge +{ + NodeBasedEdgeWithOSM(OSMNodeID source, + OSMNodeID target, + NodeID name_id, + EdgeWeight weight, + bool forward, + bool backward, + bool roundabout, + bool access_restricted, + bool startpoint, + TravelMode travel_mode, + bool is_split); + + OSMNodeID osm_source_id; + OSMNodeID osm_target_id; +}; + +// Impl. + +inline NodeBasedEdge::NodeBasedEdge() + : source(SPECIAL_NODEID), target(SPECIAL_NODEID), name_id(0), weight(0), forward(false), + backward(false), roundabout(false), access_restricted(false), startpoint(true), + is_split(false), travel_mode(false) +{ +} + +inline NodeBasedEdge::NodeBasedEdge(NodeID source, + NodeID target, + NodeID name_id, + EdgeWeight weight, + bool forward, + bool backward, + bool roundabout, + bool access_restricted, + bool startpoint, + TravelMode travel_mode, + bool is_split) + : source(source), target(target), name_id(name_id), weight(weight), forward(forward), + backward(backward), roundabout(roundabout), access_restricted(access_restricted), + startpoint(startpoint), is_split(is_split), travel_mode(travel_mode) +{ +} + +inline bool NodeBasedEdge::operator<(const NodeBasedEdge &other) const +{ + if (source == other.source) + { + if (target == other.target) + { + if (weight == other.weight) + { + return forward && backward && ((!other.forward) || (!other.backward)); + } + return weight < other.weight; + } + return target < other.target; + } + return source < other.source; +} + +inline NodeBasedEdgeWithOSM::NodeBasedEdgeWithOSM(OSMNodeID source, + OSMNodeID target, + NodeID name_id, + EdgeWeight weight, + bool forward, + bool backward, + bool roundabout, + bool access_restricted, + bool startpoint, + TravelMode travel_mode, + bool is_split) + : NodeBasedEdge(SPECIAL_NODEID, + SPECIAL_NODEID, + name_id, + weight, + forward, + backward, + roundabout, + access_restricted, + startpoint, + travel_mode, + is_split), + osm_source_id(source), osm_target_id(target) +{ +} + +} // ns extractor +} // ns osrm + +#endif /* NODE_BASED_EDGE_HPP */ diff --git a/include/extractor/restriction_map.hpp b/include/extractor/restriction_map.hpp index 5b9a35fb4dd..23b3ac88681 100644 --- a/include/extractor/restriction_map.hpp +++ b/include/extractor/restriction_map.hpp @@ -1,6 +1,7 @@ #ifndef RESTRICTION_MAP_HPP #define RESTRICTION_MAP_HPP +#include "extractor/edge_based_edge.hpp" #include "extractor/restriction.hpp" #include "util/std_hash.hpp" #include "util/typedefs.hpp" diff --git a/include/extractor/tarjan_scc.hpp b/include/extractor/tarjan_scc.hpp index c49f00fb75b..874d3f677fd 100644 --- a/include/extractor/tarjan_scc.hpp +++ b/include/extractor/tarjan_scc.hpp @@ -3,7 +3,7 @@ #include "util/typedefs.hpp" #include "util/deallocating_vector.hpp" -#include "extractor/import_edge.hpp" +#include "extractor/node_based_edge.hpp" #include "extractor/query_node.hpp" #include "util/percent.hpp" diff --git a/include/util/graph_loader.hpp b/include/util/graph_loader.hpp index b4d3f4f5e75..91a7f7e77dd 100644 --- a/include/util/graph_loader.hpp +++ b/include/util/graph_loader.hpp @@ -5,7 +5,7 @@ #include "util/osrm_exception.hpp" #include "util/simple_logger.hpp" #include "extractor/external_memory_node.hpp" -#include "extractor/import_edge.hpp" +#include "extractor/node_based_edge.hpp" #include "extractor/query_node.hpp" #include "extractor/restriction.hpp" #include "util/typedefs.hpp" diff --git a/include/util/node_based_graph.hpp b/include/util/node_based_graph.hpp index c1aa0323d2a..fcfad9e4daa 100644 --- a/include/util/node_based_graph.hpp +++ b/include/util/node_based_graph.hpp @@ -2,7 +2,7 @@ #define NODE_BASED_GRAPH_HPP #include "util/dynamic_graph.hpp" -#include "extractor/import_edge.hpp" +#include "extractor/node_based_edge.hpp" #include "util/graph_utils.hpp" #include diff --git a/src/contractor/processing_chain.cpp b/src/contractor/processing_chain.cpp index f563de45bfb..30402bfa2a6 100644 --- a/src/contractor/processing_chain.cpp +++ b/src/contractor/processing_chain.cpp @@ -1,7 +1,7 @@ #include "contractor/processing_chain.hpp" #include "contractor/contractor.hpp" -#include "contractor/contractor.hpp" +#include "extractor/edge_based_edge.hpp" #include "util/deallocating_vector.hpp" diff --git a/src/extractor/edge_based_graph_factory.cpp b/src/extractor/edge_based_graph_factory.cpp index 38fc76990b0..6b60a193ecf 100644 --- a/src/extractor/edge_based_graph_factory.cpp +++ b/src/extractor/edge_based_graph_factory.cpp @@ -1,3 +1,4 @@ +#include "extractor/edge_based_edge.hpp" #include "extractor/edge_based_graph_factory.hpp" #include "util/coordinate_calculation.hpp" #include "util/percent.hpp" diff --git a/src/extractor/extractor.cpp b/src/extractor/extractor.cpp index 693576877f7..ddf787c355a 100644 --- a/src/extractor/extractor.cpp +++ b/src/extractor/extractor.cpp @@ -1,5 +1,6 @@ #include "extractor/extractor.hpp" +#include "extractor/edge_based_edge.hpp" #include "extractor/extraction_containers.hpp" #include "extractor/extraction_node.hpp" #include "extractor/extraction_way.hpp"