MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / InsertEdgeBasedNode

Method InsertEdgeBasedNode

src/extractor/edge_based_graph_factory.cpp:98–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98NBGToEBG EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeID node_v)
99{
100 // merge edges together into one EdgeBasedNode
101 BOOST_ASSERT(node_u != SPECIAL_NODEID);
102 BOOST_ASSERT(node_v != SPECIAL_NODEID);
103
104 // find forward edge id and
105 const EdgeID edge_id_1 = m_node_based_graph.FindEdge(node_u, node_v);
106 BOOST_ASSERT(edge_id_1 != SPECIAL_EDGEID);
107
108 const EdgeData &forward_data = m_node_based_graph.GetEdgeData(edge_id_1);
109
110 // find reverse edge id and
111 const EdgeID edge_id_2 = m_node_based_graph.FindEdge(node_v, node_u);
112 BOOST_ASSERT(edge_id_2 != SPECIAL_EDGEID);
113
114 const EdgeData &reverse_data = m_node_based_graph.GetEdgeData(edge_id_2);
115
116 BOOST_ASSERT(nbe_to_ebn_mapping[edge_id_1] != SPECIAL_NODEID ||
117 nbe_to_ebn_mapping[edge_id_2] != SPECIAL_NODEID);
118
119 // ⚠ Use the sign bit of node weights to distinguish oneway streets:
120 // * MSB is set - a node corresponds to a one-way street
121 // * MSB is clear - a node corresponds to a bidirectional street
122 // Before using node weights data values must be adjusted:
123 // * in contraction if MSB is set the node weight is INVALID_EDGE_WEIGHT.
124 // This adjustment is needed to enforce loop creation for oneways.
125 // * in other cases node weights must be masked with 0x7fffffff to clear MSB
126 if (nbe_to_ebn_mapping[edge_id_1] != SPECIAL_NODEID &&
127 nbe_to_ebn_mapping[edge_id_2] == SPECIAL_NODEID)
128 m_edge_based_node_weights[nbe_to_ebn_mapping[edge_id_1]] |=
129 EdgeWeight{static_cast<EdgeWeight::value_type>(0x80000000)};
130
131 BOOST_ASSERT(m_compressed_edge_container.HasEntryForID(edge_id_1) ==
132 m_compressed_edge_container.HasEntryForID(edge_id_2));
133 BOOST_ASSERT(m_compressed_edge_container.HasEntryForID(edge_id_1));
134 BOOST_ASSERT(m_compressed_edge_container.HasEntryForID(edge_id_2));
135 const auto &forward_geometry = m_compressed_edge_container.GetBucketReference(edge_id_1);
136 BOOST_ASSERT(forward_geometry.size() ==
137 m_compressed_edge_container.GetBucketReference(edge_id_2).size());
138 const auto segment_count = forward_geometry.size();
139
140 // There should always be some geometry
141 BOOST_ASSERT(0 != segment_count);
142
143 // const unsigned packed_geometry_id = m_compressed_edge_container.ZipEdges(edge_id_1,
144 // edge_id_2);
145
146 NodeID current_edge_source_coordinate_id = node_u;
147
148 const auto edge_id_to_segment_id = [](const NodeID edge_based_node_id)
149 {
150 if (edge_based_node_id == SPECIAL_NODEID)
151 {
152 return SegmentID{SPECIAL_SEGMENTID, false};
153 }
154
155 return SegmentID{edge_based_node_id, true};

Callers

nothing calls this directly

Calls 6

irangeFunction · 0.85
HasEntryForIDMethod · 0.80
containsMethod · 0.80
FindEdgeMethod · 0.45
sizeMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected