- // SmallRoadStruct.cpp: implementation of the CSmallRoadStruct class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "GpsSC.h"
- #include "SmallRoadStruct.h"
- #include "RoadPoint.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CSmallRoadStruct::CSmallRoadStruct()
- {
- int i;
- SmallRoad_SN_Bytes = 2;
- for(i = 0; i < SmallRoad_SN_Bytes; i++) {
- SmallRoad_SerialNumber[i] = 0;
- }
- RoadName_Bytes = 10;
- for(i = 0; i < RoadName_Bytes + 1; i++) {
- RoadName[i] = 0;
- }
- Road_SD = 0; //S表示单向(single),D表示双向(double)
- Road_SD_Bytes = 1;
- RoadorName_DispLevel = 0; //低4位表示道路级别,高4位表示路名显示级别
- DispLevel_Bytes = 1;
- SmallRoad_PointTotal = 0;
- PointTotal_Bytes = 2;
- RoadPoint_Bytes = 12;
- ClearRoadPointList();
- }
- CSmallRoadStruct& CSmallRoadStruct::operator = (const CSmallRoadStruct& ds)
- {
- BYTE i;
- SmallRoad_SerialNumber[0] = ds.SmallRoad_SerialNumber[0];
- SmallRoad_SerialNumber[1] = ds.SmallRoad_SerialNumber[1];
- for(i = 0; i < ds.RoadName_Bytes; i++) {
- RoadName[i] = ds.RoadName[i];
- }
- Road_SD = ds.Road_SD;
- RoadorName_DispLevel = ds.RoadorName_DispLevel;
- SmallRoad_PointTotal = ds.SmallRoad_PointTotal;
- CopyList(&ds.RoadPointList,&RoadPointList);
- return *this;
- }
- CSmallRoadStruct::~CSmallRoadStruct()
- {
- ClearRoadPointList();
- }
- CSmallRoadStruct::ClearRoadPointList()
- {
- CRoadPoint *pRoadPoint;
- POSITION pos = RoadPointList.GetHeadPosition();
- while(pos != NULL) {
- pRoadPoint = (CRoadPoint*)RoadPointList.GetNext(pos);
- delete pRoadPoint;
- }
- RoadPointList.RemoveAll();
- }
- CSmallRoadStruct::CopyList(const CObList *SourceList,CObList *DestList)
- {
- CRoadPoint *pRoadPoint,*pTempPoint;
- POSITION pos;
- pos = SourceList->GetTailPosition();
- while(pos != NULL) {
- pRoadPoint = (CRoadPoint*)SourceList->GetPrev(pos);
- pTempPoint = new CRoadPoint;
- *pTempPoint = *pRoadPoint;
- DestList->AddHead(pTempPoint);
- }
- }
- CSmallRoadStruct::CopyReverseList(const CObList *SourceList,CObList *DestList)
- {
- CRoadPoint *pRoadPoint,*pTempPoint;
- POSITION pos;
- pos = SourceList->GetHeadPosition();
- while(pos != NULL) {
- pRoadPoint = (CRoadPoint*)SourceList->GetNext(pos);
- pTempPoint = new CRoadPoint;
- *pTempPoint = *pRoadPoint;
- DestList->AddHead(pTempPoint);
- }
- }
- CSmallRoadStruct::ChangeRoadDirection()
- {
- CObList TempList;
- CopyList(&RoadPointList,&TempList);
- ClearRoadPointList();
- CopyReverseList(&TempList,&RoadPointList);
- ClearRoadList(&TempList);
- }
- CSmallRoadStruct::ClearRoadList(CObList *TempList)
- {
- CRoadPoint *pRoadPoint;
- POSITION pos = TempList->GetHeadPosition();
- while(pos != NULL) {
- pRoadPoint = (CRoadPoint*)TempList->GetNext(pos);
- delete pRoadPoint;
- }
- TempList->RemoveAll();
- }