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

Method FindDirection

generator/cells_merger.cpp:156–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156std::optional<m2::PointI> CellsMerger::FindDirection(m2::PointI const & startXy) const
157{
158 std::array<std::pair<size_t, m2::PointI>, 4> directionsWithWeight;
159 std::array<m2::PointI, 4> const directions{{{1, 1}, {-1, 1}, {1, -1}, {-1, -1}}};
160 base::Transform(directions, std::begin(directionsWithWeight), [&](auto const & direction)
161 {
162 return std::make_pair(TryGet(startXy.x + direction.x, startXy.y).GetSum() +
163 TryGet(startXy.x, startXy.y + direction.y).GetSum() +
164 TryGet(startXy.x + direction.x, startXy.y + direction.y).GetSum(),
165 direction);
166 });
167 auto const direction = std::max_element(std::cbegin(directionsWithWeight), std::cend(directionsWithWeight))->second;
168 return Has(startXy + direction) ? direction : std::optional<m2::PointI>{};
169}
170
171void CellsMerger::Remove(m2::PointI const & minXy, m2::PointI const & maxXy)
172{

Callers

nothing calls this directly

Calls 6

TransformFunction · 0.85
TryGetFunction · 0.85
cbeginFunction · 0.85
cendFunction · 0.85
GetSumMethod · 0.80
beginFunction · 0.50

Tested by

no test coverage detected