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

Function ProccessHouses

libs/search/house_detector.cpp:419–513  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

417};
418
419void ProccessHouses(vector<HouseProjection const *> const & st, ResultAccumulator & acc)
420{
421 vector<HouseChain> houseChains;
422 size_t const count = st.size();
423 size_t numberOfStreetHouses = count;
424 vector<bool> used(count, false);
425 string const & houseNumber = acc.GetFullNumber();
426 int const step = acc.UseOdd() ? 2 : 1;
427
428 for (size_t i = 0; i < count; ++i)
429 {
430 HouseProjection const * hp = st[i];
431 if (st[i]->m_house->GetNumber() == houseNumber)
432 {
433 houseChains.push_back(HouseChain(hp));
434 used[i] = true;
435 --numberOfStreetHouses;
436 }
437 }
438 if (houseChains.empty())
439 return;
440
441 queue<int> houseNumbersToCheck;
442 AddToQueue(houseChains[0].houses[0]->m_house->GetIntNumber(), step, houseNumbersToCheck);
443 while (numberOfStreetHouses > 0)
444 {
445 if (!houseNumbersToCheck.empty())
446 {
447 int candidateHouseNumber = houseNumbersToCheck.front();
448 houseNumbersToCheck.pop();
449 vector<uint32_t> candidates;
450 ASSERT_LESS(used.size(), numeric_limits<uint32_t>::max(), ());
451 uint32_t const count = static_cast<uint32_t>(used.size());
452 for (uint32_t i = 0; i < count; ++i)
453 if (!used[i] && st[i]->m_house->GetIntNumber() == candidateHouseNumber)
454 candidates.push_back(i);
455
456 bool shouldAddHouseToQueue = false;
457 vector<Competitiors> comp;
458
459 for (size_t i = 0; i < candidates.size(); ++i)
460 {
461 string num = st[candidates[i]]->m_house->GetNumber();
462 ASSERT_LESS(houseChains.size(), numeric_limits<uint32_t>::max(), ());
463 for (size_t j = 0; j < houseChains.size(); ++j)
464 {
465 if (!houseChains[j].Find(num))
466 {
467 double dist = numeric_limits<double>::max();
468 for (size_t k = 0; k < houseChains[j].houses.size(); ++k)
469 if (abs(houseChains[j].houses[k]->m_house->GetIntNumber() - st[candidates[i]]->m_house->GetIntNumber()) <=
470 HN_NEARBY_DISTANCE)
471 dist = min(dist, GetDistanceMeters(houseChains[j].houses[k]->m_house->GetPosition(),
472 st[candidates[i]]->m_house->GetPosition()));
473 if (dist < HN_MAX_CONNECTION_DIST_M)
474 comp.push_back(Competitiors(candidates[i], static_cast<uint32_t>(j), dist));
475 }
476 }

Callers 1

GetBestHouseWithNumberFunction · 0.85

Calls 15

HouseChainClass · 0.85
AddToQueueFunction · 0.85
CompetitiorsClass · 0.85
GetBestHouseFromChainsFunction · 0.85
UseOddMethod · 0.80
frontMethod · 0.80
popMethod · 0.80
GetDistanceMetersFunction · 0.70
sizeMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45
GetIntNumberMethod · 0.45

Tested by

no test coverage detected