MCPcopy Create free account
hub / github.com/comaps/comaps / Init

Method Init

tools/openlr/router.cpp:160–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160bool Router::Init(std::vector<WayPoint> const & points, double positiveOffsetM, double negativeOffsetM)
161{
162 CHECK_GREATER_OR_EQUAL(points.size(), 2, ());
163
164 m_points = points;
165 m_positiveOffsetM = positiveOffsetM;
166 m_negativeOffsetM = negativeOffsetM;
167
168 m_graph.ResetFakes();
169
170 m_pivots.clear();
171 for (size_t i = 1; i + 1 < m_points.size(); ++i)
172 {
173 m_pivots.emplace_back();
174 auto & ps = m_pivots.back();
175
176 std::vector<std::pair<routing::Edge, geometry::PointWithAltitude>> vicinity;
177 m_graph.FindClosestEdges(
178 mercator::RectByCenterXYAndSizeInMeters(m_points[i].m_point, routing::FeaturesRoadGraph::kClosestEdgesRadiusM),
179 kMaxRoadCandidates, vicinity);
180 for (auto const & v : vicinity)
181 {
182 auto const & e = v.first;
183 ps.push_back(e.GetStartJunction().GetPoint());
184 ps.push_back(e.GetEndJunction().GetPoint());
185 }
186
187 if (ps.empty())
188 return false;
189 }
190
191 m_pivots.push_back({m_points.back().m_point});
192 CHECK_EQUAL(m_pivots.size() + 1, m_points.size(), ());
193
194 {
195 m_sourceJunction = geometry::PointWithAltitude(m_points.front().m_point, 0 /* altitude */);
196 std::vector<std::pair<routing::Edge, geometry::PointWithAltitude>> sourceVicinity;
197 m_graph.FindClosestEdges(mercator::RectByCenterXYAndSizeInMeters(m_sourceJunction.GetPoint(),
198 routing::FeaturesRoadGraph::kClosestEdgesRadiusM),
199 kMaxRoadCandidates, sourceVicinity);
200 m_graph.AddFakeEdges(m_sourceJunction, sourceVicinity);
201 }
202
203 {
204 m_targetJunction = geometry::PointWithAltitude(m_points.back().m_point, 0 /* altitude */);
205 std::vector<std::pair<routing::Edge, geometry::PointWithAltitude>> targetVicinity;
206 m_graph.FindClosestEdges(mercator::RectByCenterXYAndSizeInMeters(m_targetJunction.GetPoint(),
207 routing::FeaturesRoadGraph::kClosestEdgesRadiusM),
208 kMaxRoadCandidates, targetVicinity);
209 m_graph.AddFakeEdges(m_targetJunction, targetVicinity);
210 }
211
212 return true;
213}
214
215bool Router::FindPath(Path & path)
216{

Callers 1

mainFunction · 0.45

Calls 13

backMethod · 0.80
frontMethod · 0.80
PointWithAltitudeClass · 0.50
sizeMethod · 0.45
ResetFakesMethod · 0.45
clearMethod · 0.45
emplace_backMethod · 0.45
FindClosestEdgesMethod · 0.45
push_backMethod · 0.45
GetPointMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected