SmallRoadStruct.cpp
上传用户:yffx2008
上传日期:2014-10-12
资源大小:12414k
文件大小:3k
源码类别:

交通/航空行业

开发平台:

Visual C++

  1. // SmallRoadStruct.cpp: implementation of the CSmallRoadStruct class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "GpsSC.h"
  6. #include "SmallRoadStruct.h"
  7. #include "RoadPoint.h"
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char THIS_FILE[]=__FILE__;
  11. #define new DEBUG_NEW
  12. #endif
  13. //////////////////////////////////////////////////////////////////////
  14. // Construction/Destruction
  15. //////////////////////////////////////////////////////////////////////
  16. CSmallRoadStruct::CSmallRoadStruct()
  17. {
  18. int i;
  19. SmallRoad_SN_Bytes = 2;
  20. for(i = 0; i < SmallRoad_SN_Bytes; i++) {
  21. SmallRoad_SerialNumber[i] = 0;
  22. }
  23. RoadName_Bytes = 10;
  24. for(i = 0; i < RoadName_Bytes + 1; i++) {
  25. RoadName[i] = 0; 
  26. }
  27. Road_SD = 0; //S表示单向(single),D表示双向(double)
  28. Road_SD_Bytes = 1;
  29. RoadorName_DispLevel = 0; //低4位表示道路级别,高4位表示路名显示级别
  30. DispLevel_Bytes = 1;
  31. SmallRoad_PointTotal = 0;
  32. PointTotal_Bytes = 2;
  33. RoadPoint_Bytes = 12;
  34. ClearRoadPointList();
  35. }
  36. CSmallRoadStruct& CSmallRoadStruct::operator = (const CSmallRoadStruct& ds)
  37. {
  38. BYTE i;
  39. SmallRoad_SerialNumber[0] = ds.SmallRoad_SerialNumber[0];
  40. SmallRoad_SerialNumber[1] = ds.SmallRoad_SerialNumber[1];
  41. for(i = 0; i < ds.RoadName_Bytes; i++) {
  42. RoadName[i] = ds.RoadName[i];
  43. }
  44. Road_SD = ds.Road_SD;
  45. RoadorName_DispLevel = ds.RoadorName_DispLevel;
  46. SmallRoad_PointTotal = ds.SmallRoad_PointTotal;
  47. CopyList(&ds.RoadPointList,&RoadPointList);
  48. return *this;
  49. }
  50. CSmallRoadStruct::~CSmallRoadStruct()
  51. {
  52. ClearRoadPointList();
  53. }
  54. CSmallRoadStruct::ClearRoadPointList()
  55. {
  56. CRoadPoint *pRoadPoint;
  57. POSITION pos = RoadPointList.GetHeadPosition();
  58. while(pos != NULL) {
  59. pRoadPoint = (CRoadPoint*)RoadPointList.GetNext(pos);
  60. delete pRoadPoint;
  61. }
  62. RoadPointList.RemoveAll();
  63. }
  64. CSmallRoadStruct::CopyList(const CObList *SourceList,CObList *DestList)
  65. {
  66. CRoadPoint *pRoadPoint,*pTempPoint;
  67. POSITION pos;
  68. pos = SourceList->GetTailPosition();
  69. while(pos != NULL) {
  70. pRoadPoint  = (CRoadPoint*)SourceList->GetPrev(pos);
  71. pTempPoint  = new CRoadPoint;
  72. *pTempPoint = *pRoadPoint;
  73. DestList->AddHead(pTempPoint);
  74. }
  75. }
  76. CSmallRoadStruct::CopyReverseList(const CObList *SourceList,CObList *DestList)
  77. {
  78. CRoadPoint *pRoadPoint,*pTempPoint;
  79. POSITION pos;
  80. pos = SourceList->GetHeadPosition();
  81. while(pos != NULL) {
  82. pRoadPoint  = (CRoadPoint*)SourceList->GetNext(pos);
  83. pTempPoint  = new CRoadPoint;
  84. *pTempPoint = *pRoadPoint;
  85. DestList->AddHead(pTempPoint);
  86. }
  87. }
  88. CSmallRoadStruct::ChangeRoadDirection()
  89. {
  90. CObList TempList;
  91. CopyList(&RoadPointList,&TempList);
  92. ClearRoadPointList();
  93. CopyReverseList(&TempList,&RoadPointList);
  94. ClearRoadList(&TempList);
  95. }
  96. CSmallRoadStruct::ClearRoadList(CObList *TempList)
  97. {
  98. CRoadPoint *pRoadPoint;
  99. POSITION pos = TempList->GetHeadPosition();
  100. while(pos != NULL) {
  101. pRoadPoint = (CRoadPoint*)TempList->GetNext(pos);
  102. delete pRoadPoint;
  103. }
  104. TempList->RemoveAll();
  105. }