YaAlgorithmForCell.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "stdafx.h"
  2. #include "YaAlgorithmForCell.h"
  3. #include "../../mylog/log_module.h"
  4. #include "../../locate_algorithm.h"
  5. const int check_direction_same = 1;
  6. const int check_direction_not_same = -1;
  7. const int check_direction_error = -2;
  8. const int station_info_error = -3;
  9. const int return_correct = 0;
  10. int YaAlgorithmForCell::do_algorithm(Card* card, int cnt)
  11. {
  12. card->is_fit_pos = false;
  13. std::shared_ptr<Cell> cell = std::make_shared<Cell>();
  14. std::shared_ptr<POS> pos = nullptr;
  15. cell->card_stamp_time = card->time_stamp_cal;
  16. cell->originId = -1;
  17. //1.数据有效性判断 DIST_COUNT_CARD_CUR_CT_LESS_LAST
  18. int ret_by_check_data = card->CheckDistData(cnt);
  19. // ct 回退, 不做补值
  20. if(ret_by_check_data == DIST_COUNT_CARD_CUR_CT_LESS_LAST)
  21. {
  22. return 1;
  23. }
  24. if(ret_by_check_data != 0){
  25. return 1;
  26. }
  27. //2.组装数据
  28. std::shared_ptr<ReceiveDataMap> pRdm = std::make_shared<ReceiveDataMap>();
  29. pRdm->clear();
  30. if(card->AssembleDistData(pRdm) != 0 || pRdm->size() <= 0){
  31. return 1;
  32. }
  33. pos = std::make_shared<POS>();
  34. //3.算法定位
  35. std::vector<std::shared_ptr<POS>> udm_pos;
  36. if(LocateAlgorithm::CalcTdoaPosition(pRdm,card->pTdoaReaderPathMap,udm_pos) != 0)
  37. {
  38. return 1;
  39. }
  40. //4.从多解中筛选出一个解,存在两种可能:
  41. //a.可能无解返回非0,
  42. //b.可能有解,但解不正确,比如解的位置在4727,-100,但选出的解是4727,-200
  43. if(card->ChooseOneSolution(pRdm, udm_pos, pos) != 0)
  44. {
  45. return 1;
  46. }
  47. card->SaveOriginDataBeforeFilter(pos);
  48. //判断是否在地图集
  49. if (!LocateAlgorithm::IsOnMap(pos,card->pTdoaReaderPathMap))
  50. {
  51. return 1;
  52. }
  53. return 1;
  54. }