SUMARIA SYSTEMS
DANVERS, MA , U.S.A (07/1999 - 06/2008)
Link to SUMARIA SYSTEMS Tracktool : I have assumed many roles at Sumaria Systems from junior programmer to senior positions and also ISO Rep for the company.
I designed and developed an Automatic Surveyor software for the AdCam package using Visual C#.NEt on Win2000. GPS data is received asynchronously via GPS controller board. This multi-threaded application manages asynchronous read operations on a separate thread and user input on the main thread. The software seamlessly integrated with the main component thus avoiding use of third party software. Time for survey could be preset saving ample time for concentrating on other duties.
Designed and developed tools to compute the Altitude, Zone and Track of a racetrack. The main component of the tool was to create a digital track of an existing racetrack in virtual space. My role was to capture data from a GPS data file in GPGGA format and export it to Microsoft Visio. XSL transformation were done using MSXML parser The tool created an XML document from the VISIO file which is used by the Graphics package that was developed to show real time display of race cars. A sorting algorithm was written to remove all zombie data points which interfered with the smooth display of track in Real Time Graphics Display. A separate algorithm was developed to calculate the cross-sectional altitude of the track. This algorithm helped to display the track in a 3D mode on a 2D layer. The algorithm implements an algorithm similar to Bresenham's line algorithm for extrapolating the next point in a line.
Controller: My role was to design a Controller to simulate the graphical representation of GPS data. The software was written in VC++ 6.0. A CDC member function was used to represent the moving car as a circular shape. The objecs of CRect, CRgn, CBrush which were instantiated and passed to the CDC object. The simulated car was written to analyze the PAN, Tilt, and Zoom functions. This module helped in analyzing the different angles and functions of the camera thus saving the burden of lugging heavy camera equipment.
After developing the modules of the AdCam software. A demo was created to showcase the project to different businesses. My role was to create the demo. This was done using Demoshiled 7.5
ISO 9001: 2000 certification. My role as a management representative and data analyst was to understand the ISO 9001:2000 standards and create a database concurrently to manage the Quality Management System processes. To represent the company during Audits and help the Auditors with QMS processes. Resolve issues and take actions regarding customer complaints.
I also helped in the ISO 9001:2000 certification of S4 Inc for one of its IT Governemtn proposals. I strategically planned all processes and got them certified in less than 2 months.
Development of a GUI system:
Clients using the legacy COBOL system wanted a Graphical User Interface (GUI) for their application. SP11 a graphical conversion tool was used to create a windows look and feel maintaining all the underlying functionality of COBOL.
Sample Code for Track tool :
Sample C++ code for TrackTool
// TrackToolDlg.cpp : implementation file // #include "stdafx.h" #include "TrackTool.h" #include "TrackToolDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialog Data enum { IDD = IDD_ABOUTBOX }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Implementation protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) END_MESSAGE_MAP() // CTrackToolDlg dialog CTrackToolDlg::CTrackToolDlg(CWnd* pParent /*=NULL*/) : CDialog(CTrackToolDlg::IDD, pParent), theMap(0),theVisio(0), totalWidth(796),totalHeight(468), //468 myCarId(-999), index(0), m_saveVisioFile(FALSE), m_visXOrigin(0),m_visYOrigin(0), dwBufLen(255), progCtrl(0), lenOfMsg(0),ch(0), m_altitude(0) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_hcurArrow = AfxGetApp()->LoadStandardCursor(IDC_ARROW); m_hcurWait = AfxGetApp()->LoadStandardCursor(IDC_WAIT); } void CTrackToolDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_CANCEL_SOURCE_FILE, m_cancelDataInput); DDX_Control(pDX, IDC_VEHICLE_ID, m_vehicleId); DDX_Control(pDX, IDC_CREATE_XML, m_createXML); DDX_Control(pDX, IDC_STATUS, m_status); DDX_Control(pDX, IDC_EDIT1, m_inputFile); DDX_Control(pDX, IDC_EDIT2, m_outputFile); DDX_Control(pDX, IDC_APPEND, m_appendFile); DDX_Control(pDX, IDC_TRACK_PROGRESS, m_trackProgress); } BEGIN_MESSAGE_MAP(CTrackToolDlg, CDialog) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP ON_BN_CLICKED(IDC_DATA_SOURCE_FILE, OnBnClickedDataSourceFile) ON_BN_CLICKED(IDC_CANCEL_SOURCE_FILE, OnBnClickedCancelSourceFile) ON_CBN_SELCHANGE(IDC_VEHICLE_ID, OnCbnSelchangeVehicleId) ON_WM_TIMER() ON_BN_CLICKED(IDC_CREATE_XML, OnBnClickedCreateXml) ON_BN_CLICKED(IDC_START, OnBnClickedStart) ON_BN_CLICKED(IDC_APPEND, OnBnClickedAppend) END_MESSAGE_MAP() // CTrackToolDlg message handlers BOOL CTrackToolDlg::OnInitDialog() { CDialog::OnInitDialog(); //ShowWindow(SW_SHOWMAXIMIZED); //$$ This function helps maximize the window to full screen if(theMap != NULL) delete theMap; // delete MapDisplay object and create new theMap = new CMapDisplay(theGlobalObserver); CRect windowClientRect; GetClientRect(windowClientRect); totalHeight = windowClientRect.Height() - 111; totalWidth = windowClientRect.Width() - 4; /* if (theMap->Create(NULL,WS_CHILD | WS_VISIBLE , CRect(0,0,totalWidth + 4,totalHeight + 2), this) == FALSE) { MessageBox("Creation failed "); } theMap->SetWindowPos(NULL, 2, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER); */ m_trackProgress.SetPos(0); m_cancelDataInput.EnableWindow(FALSE); m_appendFile.EnableWindow(FALSE); GetDlgItem(IDC_START)->EnableWindow(FALSE); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control } void CTrackToolDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID, lParam); } } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CTrackToolDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } // The system calls this function to obtain the cursor to display while the user drags // the minimized window. HCURSOR CTrackToolDlg::OnQueryDragIcon() { return static_cast<HCURSOR>(m_hIcon); } void CTrackToolDlg::OnBnClickedDataSourceFile() { // TODO: Add your control notification handler code here m_DataFile = FALSE; // initialized to false will later be set depending on the file chosen m_inputFile.SetWindowText(NULL); m_outputFile.SetWindowText(NULL); m_createXML.EnableWindow(FALSE); CString fileExtension,datFile; CFileDialog openDialog(TRUE, ".*"); openDialog.m_ofn.lpstrInitialDir = ""; openDialog.m_ofn.lpstrFilter = "All Files\0*.*\0\0"; // Return value when the File dialog box opens INT_PTR nRet = -1; nRet = openDialog.DoModal(); // Handle the return value from DoModal switch ( nRet ) { case -1: em.MessageBox("Dialog Box could not be created !","",MB_OK); break; case IDABORT: // Do something em.MessageBox("problem opening file, cause:", "file may not exist\n Close and Retry", MB_OK); exit(0); break; case IDOK: // Do something GetDlgItem(IDC_DATA_SOURCE_FILE)->EnableWindow(FALSE); m_cancelDataInput.EnableWindow(TRUE); datFile = "dat"; if((input = fopen(openDialog.GetPathName(), "rb")) != NULL) { fileExtension = openDialog.GetFileExt(); // returns the file extension fileExtension.MakeLower(); if(datFile.Find(fileExtension) == -1) //if(fileExtension == "txt") { // it is either a txt file or someother file m_DataFile = FALSE; OnReadCarData(m_DataFile); rewind(input); break; } else //if(fileExtension == "dat") { m_DataFile = TRUE; OnReadCarData(m_DataFile); rewind(input); break; } } else em.MessageBox("problem opening file, cause:", "file may not exist", MB_OK); break; case IDCANCEL: // Do something m_inputFile.SetWindowText(NULL); //m_cancelDataInput.EnableWindow(TRUE); m_createXML.EnableWindow(TRUE); break; default: // do something break; }; } void CTrackToolDlg::OnBnClickedCancelSourceFile() { // TODO: Add your control notification handler code here // save the output file m_outputFile.GetWindowText(status); // get the file name vName.SetString(status); if(m_saveVisioFile != FALSE) theVisio->DOMDocumentPtr->save(vName); m_saveVisioFile = FALSE; /* // clear the visio lists if(!theVisio->xmlInValuesList.empty()) theVisio->xmlInValuesList.clear(); if(!theVisio->xmlOutValuesList.empty()) theVisio->xmlOutValuesList.clear(); if(!theVisio->xmlPitInValuesList.empty()) theVisio->xmlPitInValuesList.clear(); if(!theVisio->xmlShapeList.empty()) theVisio->xmlShapeList.clear(); if(!theVisio->xmlStartStopList.empty()) theVisio->xmlStartStopList.clear(); if(!theVisio->xmlTrackList.empty()) theVisio->xmlTrackList.clear(); if(!theVisio->xmlTurnValuesList.empty()) theVisio->xmlTurnValuesList.clear(); // clear dlg list if(!trackDataList.empty()) trackDataList.clear(); */ // Enable User to create XML m_createXML.EnableWindow(TRUE); // incase file is opened close it if(input != NULL) fclose(input); // close the file incase it is opened. //em.MessageBox("problem closing file, cause:", "file may not exist\n Close and Retry", MB_OK); // incase timer is on Kill it KillTimer(1234); index = 0; // set the frameNumber to 0 & RedrawWindow theMap->frameNumber = 0; theMap->easting = 0; theMap->northing = 0; //RedrawWindow(NULL,NULL,RDW_INVALIDATE); // reset the Combo box m_vehicleId.ResetContent(); // uninitialize the COM Interface // the COM Interface is ReferenceCounted and hence there is no need to release it // set the Progress Indicator to zero progCtrl = 0; m_trackProgress.SetPos(progCtrl); // Enable Select file button and disable Cancel File button GetDlgItem(IDC_DATA_SOURCE_FILE)->EnableWindow(TRUE); GetDlgItem(IDC_START)->EnableWindow(FALSE); GetDlgItem(IDC_APPEND)->EnableWindow(FALSE); m_cancelDataInput.EnableWindow(FALSE); //m_createXML.EnableWindow(FALSE); } // the logic to read the car number into the combo box is // included in this part void CTrackToolDlg::OnReadCarData(BOOL m_DataFile) { Position p; BOOL fileType = m_DataFile; if(!trackDataList.empty()) trackDataList.clear(); if(fileType == TRUE) // if dat file { while(!feof(input)) { p.readData(input); temp.CarId = p.getCarID(); temp.Easting = p.getEasting(); temp.Northing = p.getNorthing(); temp.Altitude = p.getAltitude(); trackDataList.push_back(temp); } } else // if txt file or any selected file { char bufferCMC[50]; // buffer to hold CMC string char bufferAshTech[52]; // buffer to hold ASHTECH string lenOfMsg = 0; while(!feof(input)) { ch = getc(input); if((char)ch == '\n') { if(lenOfMsg == 50) { // CMC board char inputChar = '\0'; //bufferCMC[0] = inputChar; bufferCMC[49] = '\0'; if (isValidMessage(bufferCMC)) { Position p(bufferCMC); theGlobalObserver.Notify(p); temp.CarId = p.getCarID(); temp.Easting = p.getEasting(); temp.Northing = p.getNorthing(); temp.Altitude = p.getAltitude(); trackDataList.push_back(temp); } // end if (isValidMessage(messageBuffer)) } // enf if(lenOfMsg == 50) if(lenOfMsg == 52) { // Ashtech board char inputChar = '\0'; //bufferAshTech[0] = inputChar; bufferAshTech[51] = '\0'; if (isValidNewMessage(bufferAshTech)) { NewPosition newp(bufferAshTech); theGlobalObserver.Notify(newp); temp.CarId = newp.getCarID(); temp.Easting = newp.getEasting(); temp.Northing = newp.getNorthing(); temp.Altitude = newp.getAltitude(); trackDataList.push_back(temp); } // end if (isValidMessage(messageBuffer)) } // end if(lenOfMsg == 52) lenOfMsg = 0; } // end if(((char)ch) == '$') else { if(lenOfMsg <= 49) bufferCMC[lenOfMsg] = char(ch); if(lenOfMsg <= 51) bufferAshTech[lenOfMsg] = char(ch); ++lenOfMsg; } } // end while(!feof(input)) lenOfMsg = 0; // set the length again to 0 /* bool linesProcessed = false; char messageBuffer[50]; while ((!feof(input)) && (!linesProcessed) ) { char inputChar = '\0'; while ((inputChar != '$') && (!feof(input))) fread(&inputChar, 1, 1, input); messageBuffer[0] = inputChar; fread(&messageBuffer[1], 48, 1, input); messageBuffer[49] = '\0'; if (isValidMessage(messageBuffer)) { Position p(messageBuffer); theGlobalObserver.Notify(p); temp.CarId = p.getCarID(); temp.Easting = p.getEasting(); temp.Northing = p.getNorthing(); temp.Altitude = p.getAltitude(); trackDataList.push_back(temp); } // end if (isValidMessage(messageBuffer)) } // end while ((!feof(input)) && (!linesProcessed) ) */ } // end else // fill the combo box with carNumber from the trackDataList // check to see if list not empty first; char buffer[256]; if(trackDataList.size() > 0) // some data is available { m_vehicleId.ResetContent(); for(trackDataListIterator = trackDataList.begin(); trackDataListIterator != trackDataList.end(); trackDataListIterator++) { temp = *trackDataListIterator; sprintf(buffer,"%1d",temp.CarId); int nIndex = m_vehicleId.FindString(-1,buffer); if(nIndex == CB_ERR) m_vehicleId.AddString(buffer); } // end for loop MessageBox("Please Select a Car Number from the Combo box"); } // end if(trackDataList.size() > 0) } // logic to select a car number void CTrackToolDlg::OnCbnSelchangeVehicleId() { // TODO: Add your control notification handler code here CString theSelection; theSelection.Empty(); int idx; if(( idx = m_vehicleId.GetCurSel()) > -1) { m_vehicleId.GetLBText(idx,theSelection); sscanf(theSelection,"%d",&myCarId); } else MessageBox("Please Select a Car Number or click cancel to Start again"); //} double lmaxEasting = 0.0; double lminEasting = 12000000.0; double lmaxNorthing = 0.0; double lminNorthing = 12000000.0; int i = 0; for(trackDataListIterator = trackDataList.begin(); trackDataListIterator != trackDataList.end(); trackDataListIterator++) { temp = *trackDataListIterator; if(temp.CarId == myCarId) { i++; double newEast = temp.Easting; double newNorth = temp.Northing; if (newEast < lminEasting) { lminEasting = newEast; } if (newEast > lmaxEasting) { lmaxEasting = newEast; } if (newNorth > lmaxNorthing) { lmaxNorthing = newNorth; } if (newNorth < lminNorthing) { lminNorthing = newNorth; } } // end if(temp.CarId == myCarId) }// end for loop m_trackProgress.SetRange(0,i); theMap->minEasting = lminEasting; theMap->maxEasting = lmaxEasting; theMap->minNorthing = lminNorthing; theMap->maxNorthing = lmaxNorthing; xFactor = 0.65*(theMap->maxEasting - theMap->minEasting); yFactor = 0.65*(theMap->maxNorthing - theMap->minNorthing); // Load the input.vdx file and set the origins if(theVisio != NULL) { theVisio = NULL; delete theVisio; } set_new_handler (newhandler); try{ theVisio = new CVisio(); } catch(bad_alloc &ba) { em.MessageBox(ba.what(),"Bad Allocation",MB_OK); } catch(exception e) { DWORD dwError = ::GetLastError(); char* errBuffer; errBuffer = NULL; sprintf(errBuffer,"%S",dwError); em.MessageBox(errBuffer,"",MB_OK); } catch(...) { DWORD dwError = ::GetLastError(); em.MessageBox("Unknown Error",(char *)dwError,MB_OK); } SUCCESS = VARIANT_TRUE; SUCCESS = theVisio->setOrigins(theMap->minEasting,theMap->minNorthing, xFactor, yFactor); if(SUCCESS == VARIANT_FALSE) { em.MessageBox("Problem loading file input.vdx \n ", "File may not exist\n Close and Check", MB_OK); OnBnClickedCancelSourceFile(); } else { try { dwBufLen = 255; if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Sumaria\\TrackTool",0,KEY_QUERY_VALUE,&hKey) != ERROR_SUCCESS) throw " Failed to Open Registry "; if(RegQueryValueEx(hKey,_T("InstallPath"),NULL,NULL,(LPBYTE) szProductType,&dwBufLen) != ERROR_SUCCESS) throw " Failed to Query Registry "; if(RegCloseKey(hKey) != ERROR_SUCCESS) throw " Failed to Close Registry "; status = szProductType; status.Append("output.vdx"); //status = "c:\\tracktool\\output.vdx"; m_outputFile.SetWindowText(status); MessageBox("Change output file Name and Click on ...Start Button / Append Button to Append to an existing file"); GetDlgItem(IDC_START)->EnableWindow(TRUE); m_appendFile.EnableWindow(TRUE); } // end try block catch(const char *str) { em.MessageBox(str,"Check again",MB_OK); } catch(...) { em.MessageBox("Unknown Error","",MB_OK); } } // end else } void CTrackToolDlg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default //CDialog::OnTimer(nIDEvent); m_createXML.EnableWindow(FALSE); if(m_DataFile == FALSE) { if(feof(input)) { KillTimer(1234); OnBnClickedCancelSourceFile(); AfxMessageBox("Complete Click Ok ",MB_OK | MB_ICONINFORMATION); } else { /////////////////////////////////////////////// ////////// modifications to accomodate the new GPGGA string ASHTEC data format ///////////////////////////////////// /////////////// the new code will determine either the CMC GPGGA string or ASHTEC Board char bufferCMC[50]; // buffer to hold CMC string char bufferAshTech[52]; // buffer to hold ASHTECH string while(!feof(input)) { ch = getc(input); if(((char)ch) == '\n') { if(lenOfMsg == 50) { // CMC board char inputChar = '\0'; //bufferCMC[0] = inputChar; bufferCMC[49] = '\0'; if (isValidMessage(bufferCMC)) { Position p(bufferCMC); theGlobalObserver.Notify(p); if(p.getCarID() == myCarId) { theVisio->dVPinX = theMap->easting = p.getEasting(); theVisio->dVPinY = theMap->northing = p.getNorthing(); theVisio->dVPinZ = p.getAltitude(); theVisio->dVPinX = (theVisio->dVPinX - theMap->minEasting + xFactor) * VISIOFACTOR; theVisio->dVPinY = (theVisio->dVPinY - theMap->minNorthing + yFactor) * VISIOFACTOR; index++; progCtrl++; theVisio->dShapeIDVal = index; theVisio->BuildShape(theVisio->DOMDocumentPtr,theVisio->DOMNodePtr,theVisio->xmlShapeList); status = ".......Building Visio File ......."; m_status.SetWindowText(status); //RedrawWindow(NULL,NULL,RDW_INVALIDATE); m_trackProgress.SetPos(progCtrl); }//if(p.getCarID() == myCarId) } // end if (isValidMessage(messageBuffer)) } // enf if(lenOfMsg == 50) if(lenOfMsg == 52) { // Ashtech board char inputChar = '\0'; //bufferAshTech[0] = inputChar; bufferAshTech[51] = '\0'; if (isValidNewMessage(bufferAshTech)) { NewPosition newp(bufferAshTech); theGlobalObserver.Notify(newp); if(newp.getCarID() == myCarId) { theVisio->dVPinX = theMap->easting = newp.getEasting(); theVisio->dVPinY = theMap->northing = newp.getNorthing(); theVisio->dVPinZ = newp.getAltitude(); theVisio->dVPinX = (theVisio->dVPinX - theMap->minEasting + xFactor) * VISIOFACTOR; theVisio->dVPinY = (theVisio->dVPinY - theMap->minNorthing + yFactor) * VISIOFACTOR; index++; progCtrl++; theVisio->dShapeIDVal = index; theVisio->BuildShape(theVisio->DOMDocumentPtr,theVisio->DOMNodePtr,theVisio->xmlShapeList); status = ".......Building Visio File ......."; m_status.SetWindowText(status); //RedrawWindow(NULL,NULL,RDW_INVALIDATE); m_trackProgress.SetPos(progCtrl); }//if(newp.getCarID() == myCarId) } // end if (isValidMessage(messageBuffer)) } // end if(lenOfMsg == 52) lenOfMsg = 0; } // end if(((char)ch) == '\n') else { if(lenOfMsg <= 49) bufferCMC[lenOfMsg] = char(ch); if(lenOfMsg <= 51) bufferAshTech[lenOfMsg] = char(ch); ++lenOfMsg; } //end else if(((char)ch) == '\n') } // end while(!feof(input)) /* char messageBuffer[50]; char inputChar = '\0'; while ((inputChar != '$') && (!feof(input))) fread(&inputChar, 1, 1, input); messageBuffer[0] = inputChar; fread(&messageBuffer[1], 48, 1, input); messageBuffer[49] = '\0'; if (isValidMessage(messageBuffer)) { Position p(messageBuffer); theGlobalObserver.Notify(p); if(p.getCarID() == myCarId) { theVisio->dVPinX = theMap->easting = p.getEasting(); theVisio->dVPinY = theMap->northing = p.getNorthing(); theVisio->dVPinZ = p.getAltitude(); theVisio->dVPinX = (theVisio->dVPinX - theMap->minEasting + xFactor) * VISIOFACTOR; theVisio->dVPinY = (theVisio->dVPinY - theMap->minNorthing + yFactor) * VISIOFACTOR; index++; progCtrl++; theVisio->dShapeIDVal = index; theVisio->BuildShape(theVisio->DOMDocumentPtr,theVisio->DOMNodePtr,theVisio->xmlShapeList); status = ".......Building Visio File ......."; m_status.SetWindowText(status); //RedrawWindow(NULL,NULL,RDW_INVALIDATE); m_trackProgress.SetPos(progCtrl); }//if(p.getCarID() == myCarId) } // end if (isValidMessage(messageBuffer)) */ } // end else if(feof(input)) } else // dat file { // the input file is a dat file if(feof(input)) { KillTimer(1234); OnBnClickedCancelSourceFile(); AfxMessageBox("Complete Click Ok ",MB_OK | MB_ICONINFORMATION); } else { Position p; p.readData(input); if(p.getCarID() == myCarId) { //UTMPosition pos(p.getLatitude(),p.getLongitude()); //p.easting = pos.easting; //p.northing = pos.northing; theVisio->dVPinX = theMap->easting = p.getEasting(); theVisio->dVPinY = theMap->northing = p.getNorthing(); theVisio->dVPinZ = p.getAltitude(); theVisio->dVPinX = (theVisio->dVPinX - theMap->minEasting + xFactor) * VISIOFACTOR; theVisio->dVPinY = (theVisio->dVPinY - theMap->minNorthing + yFactor) * VISIOFACTOR; index++; progCtrl++; theVisio->dShapeIDVal = index; theVisio->BuildShape(theVisio->DOMDocumentPtr,theVisio->DOMNodePtr,theVisio->xmlShapeList); status = ".......Building Visio File ......."; m_status.SetWindowText(status); //RedrawWindow(NULL,NULL,RDW_INVALIDATE); m_trackProgress.SetPos(progCtrl); } // end if(p.getCarId() } // end else } // end else } // end OnTimer(...) function void CTrackToolDlg::OnBnClickedCreateXml() { // TODO: Add your control notification handler code here status = " Select Visio File to create output XML file"; m_status.SetWindowText(status); m_inputFile.SetWindowText(NULL); m_outputFile.SetWindowText(NULL); m_createXML.EnableWindow(FALSE); GetDlgItem(IDC_DATA_SOURCE_FILE)->EnableWindow(FALSE); progCtrl = 0; m_trackProgress.SetPos(progCtrl); if(theVisio != NULL) { theVisio = NULL; delete theVisio; } try{ theVisio = new CVisio(); } catch(bad_alloc &ba) { em.MessageBox(ba.what(),"",MB_OK); } catch(exception e) { DWORD dwError = ::GetLastError(); e.what(); return; } catch(...) { DWORD dwError = ::GetLastError(); em.MessageBox("Unknown Error","",MB_OK); return; } // Open Dialog Box to choose file CFileDialog openDialog(TRUE, ".*"); openDialog.m_ofn.lpstrInitialDir = ""; openDialog.m_ofn.lpstrFilter = "All Files\0*.*\0\0"; // Return value when the File dialog box opens INT_PTR nRet = -1; nRet = openDialog.DoModal(); // Handle the return value from DoModal switch ( nRet ) { case -1: em.MessageBox("Dialog Box could not be created !","",MB_OK); break; case IDABORT: // Do something em.MessageBox("problem opening file, cause:", "file may not exist\n Close and Retry", MB_OK); exit(0); break; case IDOK: try { SUCCESS = VARIANT_TRUE; hr = S_OK; status = openDialog.GetPathName(); m_inputFile.SetWindowText(status); vName.Clear(); m_inputFile.GetWindowText(status); vName.SetString(status); int errThrow = 0; theVisio->DOMDocumentPtr->validateOnParse = TRUE; hr = theVisio->DOMDocumentPtr->load(vName); if( hr == S_FALSE) throw 2; if(theVisio->DOMDocumentPtr->readyState != 4) { while(theVisio->DOMDocumentPtr->readyState != 4) { ::Sleep(1000); } // end while } // end if hr = S_OK; // reset status = " Querying Visio File.... Please Wait "; m_status.SetWindowText(status); // get Origins of the Visio File //theVisio->DOMNodeListPtr = theVisio->DOMDocumentPtr->getElementsByTagName("XRulerOrigin"); //ASSERT(theVisio->DOMNodeListPtr != NULL); //if(theVisio->DOMNodeListPtr == NULL) throw " Please check the file you selected"; theVisio->DOMNodePtr = theVisio->DOMDocumentPtr->selectSingleNode(_bstr_t("//Pages/Page/PageSheet/RulerGrid/XRulerOrigin")); //theVisio->DOMNodePtr = theVisio->DOMNodeListPtr->item[1]; //ASSERT(theVisio->DOMNodePtr != NULL); if(theVisio->DOMNodePtr == NULL) throw " Have you Selected the correct file? "; theVisio->vt.Clear(); theVisio->vt = theVisio->DOMNodePtr->GetnodeTypedValue(); m_visXOrigin = myabs(double(theVisio->vt)/VISIOFACTOR); //theVisio->DOMNodeListPtr = theVisio->DOMDocumentPtr->getElementsByTagName("YRulerOrigin"); //ASSERT(theVisio->DOMNodeListPtr != NULL); theVisio->DOMNodePtr = theVisio->DOMDocumentPtr->selectSingleNode(_bstr_t("//Pages/Page/PageSheet/RulerGrid/YRulerOrigin")); ASSERT(theVisio->DOMNodePtr != NULL); theVisio->vt.Clear(); theVisio->vt = theVisio->DOMNodePtr->GetnodeTypedValue(); m_visYOrigin = myabs(double(theVisio->vt)/VISIOFACTOR); ////////////////////////////////////////////////////////////////// ////////////// stuff to create OpenGL init file//////////////////////// theVisio->OGLDOMDocumentPtr = NULL; theVisio->OGLDOMDocumentPtr = createDocument(); theVisio->OGLDOMDocumentPtr->async = FALSE; theVisio->OGLDOMDocumentPtr->validateOnParse = TRUE; ASSERT(theVisio->OGLDOMDocumentPtr != NULL); theVisio->OGLDOMNodePtr = NULL; theVisio->OGLDOMNodePtr = theVisio->OGLDOMDocumentPtr; // theVisio->fillxmlTrack();creates a list that is the skeleton file for our xml // output file SUCCESS = theVisio->fillxmlTrack(); if(SUCCESS == VARIANT_FALSE) throw "Unable to build the output.xml List"; SUCCESS = VARIANT_TRUE; SUCCESS = theVisio->BuildShape(theVisio->OGLDOMDocumentPtr,theVisio->OGLDOMNodePtr,theVisio->xmlTrackList); if(SUCCESS == VARIANT_FALSE) throw " Unable to build the output.xml file "; SUCCESS = VARIANT_TRUE; dwBufLen = 255; if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Sumaria\\TrackTool",0,KEY_QUERY_VALUE,&hKey) != ERROR_SUCCESS) throw " Failed to Open Registry "; if(RegQueryValueEx(hKey,_T("InstallPath"),NULL,NULL,(LPBYTE) szProductType,&dwBufLen) != ERROR_SUCCESS) throw " Failed to Query Registry "; if(RegCloseKey(hKey) != ERROR_SUCCESS) throw " Failed to Close Registry "; status = szProductType; status.Append("output.xml"); m_outputFile.SetWindowText(status); MessageBox(" File will be saved as output.xml , Please change name later "); ::SetCursor(m_hcurWait); m_outputFile.GetWindowText(status); // get the file name vName.SetString(status); hr = theVisio->OGLDOMDocumentPtr->save(vName); if(hr == S_FALSE) throw "Could not save the ####.xml file"; hr = S_OK; theVisio->OGLDOMDocumentPtr->async = FALSE; theVisio->OGLDOMDocumentPtr->validateOnParse = TRUE; hr = theVisio->OGLDOMDocumentPtr->load(vName); if(hr == S_FALSE) throw "Could not load the ####.xml file"; /////////////////////////////////////////// // if SUCCESSFULL till this point then do select and other stuff // ///////////////////// query the list based on conditions//////////// theVisio->outListPtr = theVisio->DOMDocumentPtr->selectNodes(_bstr_t("//Shape[Geom/Ellipse][XForm/PinX][XForm/PinY]/LayerMem[LayerMember = //Layer[Name = \"outside\"]/@IX]")); theVisio->inListPtr = theVisio->DOMDocumentPtr->selectNodes(_bstr_t("//Shape[Geom/Ellipse][XForm/PinX][XForm/PinY]/LayerMem[LayerMember = //Layer[Name = \"inside\"]/@IX]")); theVisio->fullinListPtr = theVisio->DOMDocumentPtr->selectNodes(_bstr_t("//Shape[Geom/Ellipse][XForm/PinX][XForm/PinY]/LayerMem[LayerMember = //Layer[Name = \"fullinside\"]/@IX]")); theVisio->pitListPtr = theVisio->DOMDocumentPtr->selectNodes(_bstr_t("//Shape[Geom/Ellipse][XForm/PinX][XForm/PinY]/LayerMem[LayerMember = //Layer[Name = \"pitwall\"]/@IX]")); theVisio->island1ListPtr = theVisio->DOMDocumentPtr->selectNodes(_bstr_t("//Shape[Geom/Ellipse][XForm/PinX][XForm/PinY]/LayerMem[LayerMember = //Layer[Name = \"island1\"]/@IX]")); theVisio->island2ListPtr = theVisio->DOMDocumentPtr->selectNodes(_bstr_t("//Shape[Geom/Ellipse][XForm/PinX][XForm/PinY]/LayerMem[LayerMember = //Layer[Name = \"island2\"]/@IX]")); theVisio->island3ListPtr = theVisio->DOMDocumentPtr->selectNodes(_bstr_t("//Shape[Geom/Ellipse][XForm/PinX][XForm/PinY]/LayerMem[LayerMember = //Layer[Name = \"island3\"]/@IX]")); theVisio->startstopListPtr = theVisio->DOMDocumentPtr->selectNodes(_bstr_t("//Shape[Geom][XForm/PinX][XForm/PinY][XForm1D/BeginX][XForm1D/BeginY][XForm1D/EndX][XForm1D/EndY]/LayerMem[LayerMember = //Layer[Name = \"startstop\"]/@IX]")); theVisio->turnListPtr = theVisio->DOMDocumentPtr->selectNodes(_bstr_t("//Shape[Text][XForm/PinX][XForm/PinY]/LayerMem[LayerMember = //Layer[Name = \"turnno\"]/@IX]")); theVisio->speedtrapListPtr = theVisio->DOMDocumentPtr->selectNodes(_bstr_t("//Shape[Geom][XForm/PinX][XForm/PinY][XForm1D/BeginX][XForm1D/BeginY][XForm1D/EndX][XForm1D/EndY]/LayerMem[LayerMember = //Layer[Name = \"speedtrap\"]/@IX]")); theVisio->zoneInListPtr = theVisio->DOMDocumentPtr->selectNodes(_bstr_t("//Shape[Geom][XForm/PinX][XForm/PinY][XForm1D/BeginX][XForm1D/BeginY][XForm1D/EndX][XForm1D/EndY]/LayerMem[LayerMember = //Layer[Name = \"zonein\"]/@IX]")); theVisio->zoneOutListPtr = theVisio->DOMDocumentPtr->selectNodes(_bstr_t("//Shape[Geom][XForm/PinX][XForm/PinY][XForm1D/BeginX][XForm1D/BeginY][XForm1D/EndX][XForm1D/EndY]/LayerMem[LayerMember = //Layer[Name = \"zoneout\"]/@IX]")); //theVisio->shapesListPtr = theVisio->DOMDocumentPtr->selectNodes(_bstr_t("//Shape/LayerMem[LayerMember = //Layer[Name = \"shapes\"]/@IX]")); // I have queried and am now filing in the list _variant_t vtOutX,vtOutY,vt; _variant_t vtInX,vtInY; _variant_t vtFullInX,vtFullInY; _variant_t vtPitInX,vtPitInY; _variant_t vtIslandX,vtIslandY; _variant_t vtStartStopX,vtStartStopY; _variant_t vtTurnX,vtTurnY,vtTurnAngle; if(OutList.empty() == FALSE) OutList.clear(); if(OutCheckedList.empty() == FALSE) OutCheckedList.clear(); if(InList.empty() == FALSE) InList.clear(); if(InCheckedList.empty() == FALSE) InCheckedList.clear(); if(FullInList.empty() == FALSE) FullInList.clear(); if(FullInCheckedList.empty() == FALSE) FullInCheckedList.clear(); if(PitInList.empty() == FALSE) PitInList.clear(); if(PitInCheckedList.empty() == FALSE) PitInCheckedList.clear(); if(Island1List.empty() == FALSE) Island1List.clear(); if(Island1CheckedList.empty() == FALSE) Island1CheckedList.clear(); if(Island2List.empty() == FALSE) Island2List.clear(); if(Island2CheckedList.empty() == FALSE) Island2CheckedList.clear(); if(Island3List.empty() == FALSE) Island3List.clear(); if(Island3CheckedList.empty() == FALSE) Island3CheckedList.clear(); if(StartStopList.empty() == FALSE) StartStopList.clear(); if(TurnNoList.empty() == FALSE) TurnNoList.clear(); if(speedtrapList.empty() == FALSE) speedtrapList.clear(); if(ZoneInList.empty() == FALSE) ZoneInList.clear(); if(ZoneOutList.empty() == FALSE) ZoneOutList.clear(); /* if(RectList.empty() == FALSE) RectList.clear(); if(LineList.empty() == FALSE) LineList.clear(); */ long outCount = 0; long inCount = 0; long fullinCount = 0; long pitCount = 0; long island1Count = 0; long island2Count = 0; long island3Count = 0; long startstopCount = 0; long turnnoCount = 0; //long shapesCount = 0; long speedtrapCount = 0; long zoneinCount = 0; long zoneoutCount = 0; // the following queries help determin existence of layer names //////////////////////// get the number/count of outsidesegment items theVisio->DOMNodePtr = NULL; theVisio->DOMNodePtr = theVisio->DOMDocumentPtr->selectSingleNode(_bstr_t("//Layer[Name = \"outside\"]")); if(theVisio->DOMNodePtr != NULL) outCount = theVisio->outListPtr->Getlength(); else throw " Please Check to make sure if OUTSIDE layer of track exists "; //////////////////////// get the number/count of insidesegment items theVisio->DOMNodePtr = NULL; theVisio->DOMNodePtr = theVisio->DOMDocumentPtr->selectSingleNode(_bstr_t("//Layer[Name = \"inside\"]")); if(theVisio->DOMNodePtr != NULL) inCount = theVisio->inListPtr->Getlength(); else throw " Please Check to make sure if INSIDE layer of track exists "; //////////////////////// get the number/count of fullinsidesegment items theVisio->DOMNodePtr = NULL; theVisio->DOMNodePtr = theVisio->DOMDocumentPtr->selectSingleNode(_bstr_t("//Layer[Name = \"fullinside\"]")); if(theVisio->DOMNodePtr != NULL) fullinCount = theVisio->fullinListPtr->Getlength(); //////////////////////// get the number/count of pitwall items theVisio->DOMNodePtr = NULL; theVisio->DOMNodePtr = theVisio->DOMDocumentPtr->selectSingleNode(_bstr_t("//Layer[Name = \"pitwall\"]")); if(theVisio->DOMNodePtr != NULL) pitCount = theVisio->pitListPtr->Getlength(); //////////////////////// get the number/count of island1 items theVisio->DOMNodePtr = NULL; theVisio->DOMNodePtr = theVisio->DOMDocumentPtr->selectSingleNode(_bstr_t("//Layer[Name = \"island1\"]")); if(theVisio->DOMNodePtr != NULL) island1Count = theVisio->island1ListPtr->Getlength(); //////////////////////// get the number/count of island2 items theVisio->DOMNodePtr = NULL; theVisio->DOMNodePtr = theVisio->DOMDocumentPtr->selectSingleNode(_bstr_t("//Layer[Name = \"island2\"]")); if(theVisio->DOMNodePtr != NULL) island2Count = theVisio->island2ListPtr->Getlength(); //////////////////////// get the number/count of island3 items theVisio->DOMNodePtr = NULL; theVisio->DOMNodePtr = theVisio->DOMDocumentPtr->selectSingleNode(_bstr_t("//Layer[Name = \"island3\"]")); if(theVisio->DOMNodePtr != NULL) island3Count = theVisio->island3ListPtr->Getlength(); //////////////////////// get the number/count of startstop items theVisio->DOMNodePtr = NULL; theVisio->DOMNodePtr = theVisio->DOMDocumentPtr->selectSingleNode(_bstr_t("//Layer[Name = \"startstop\"]")); if(theVisio->DOMNodePtr != NULL) startstopCount = theVisio->startstopListPtr->Getlength(); ////////////// get the number/count of turnnos theVisio->DOMNodePtr = NULL; theVisio->DOMNodePtr = theVisio->DOMDocumentPtr->selectSingleNode(_bstr_t("//Layer[Name = \"turnno\"]")); if(theVisio->DOMNodePtr != NULL) turnnoCount = theVisio->turnListPtr->Getlength(); theVisio->DOMNodePtr = NULL; theVisio->DOMNodePtr = theVisio->DOMDocumentPtr->selectSingleNode(_bstr_t("//Layer[Name = \"speedtrap\"]")); if(theVisio->DOMNodePtr != NULL) speedtrapCount = theVisio->speedtrapListPtr->Getlength(); theVisio->DOMNodePtr = NULL; theVisio->DOMNodePtr = theVisio->DOMDocumentPtr->selectSingleNode(_bstr_t("//Layer[Name = \"zonein\"]")); if(theVisio->DOMNodePtr != NULL) zoneinCount = theVisio->zoneInListPtr->Getlength(); theVisio->DOMNodePtr = NULL; theVisio->DOMNodePtr = theVisio->DOMDocumentPtr->selectSingleNode(_bstr_t("//Layer[Name = \"zoneout\"]")); if(theVisio->DOMNodePtr != NULL) zoneoutCount = theVisio->zoneOutListPtr->Getlength(); /* ////////////// get the number/count of shapes //theVisio->DOMNodePtr = NULL; //theVisio->DOMNodePtr = theVisio->DOMDocumentPtr->selectSingleNode(_bstr_t("//Layer[Name = \"shapes\"]")); //if(theVisio->DOMNodePtr != NULL) shapesCount = theVisio->shapesListPtr->Getlength(); */ // set the range for the progress control m_trackProgress.SetRange(0,(int)(outCount+inCount+pitCount+startstopCount+turnnoCount+speedtrapCount+zoneinCount+zoneoutCount)); // make the DOMNodePtr NULL; theVisio->DOMNodePtr = NULL; for(int i = 0; i < outCount; i++) { theVisio->DOMNodePtr = theVisio->outListPtr->item[i]; theVisio->DOMNodePtr = theVisio->DOMNodePtr->GetparentNode(); //theVisio->DOMNodePtr = theVisio->DOMNodePtr->firstChild; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(0); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/PinX")); vtOutX = theVisio->pChild->GetnodeTypedValue(); theVisio->gdXOut = (double(vtOutX)/VISIOFACTOR) + m_visXOrigin; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(1); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/PinY")); vtOutY = theVisio->pChild->GetnodeTypedValue(); theVisio->gdYOut = (double(vtOutY)/VISIOFACTOR) + m_visYOrigin; theVisio->pChild = NULL; theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label =\"Altitude\" or @NameU = \"Altitude\"]/Value")); if(theVisio->pChild == NULL) theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label = \"Altitude\"]/Value")); if(theVisio->pChild != NULL) { vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdZOut = double(vt); } else theVisio->gdZOut = 0.0; tempMap.Easting = theVisio->gdXOut; tempMap.Northing = theVisio->gdYOut; tempMap.Altitude = theVisio->gdZOut; OutList.push_back(tempMap); } // end for theVisio->DOMNodePtr = NULL; for(int j = 0; j < inCount; j++) { theVisio->DOMNodePtr = theVisio->inListPtr->item[j]; theVisio->DOMNodePtr = theVisio->DOMNodePtr->GetparentNode(); //theVisio->DOMNodePtr = theVisio->DOMNodePtr->firstChild; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(0); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/PinX")); vtInX = theVisio->pChild->GetnodeTypedValue(); theVisio->gdXIn = (double(vtInX)/VISIOFACTOR) + m_visXOrigin; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(1); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/PinY")); vtInY = theVisio->pChild->GetnodeTypedValue(); theVisio->gdYIn = (double(vtInY)/VISIOFACTOR) + m_visYOrigin; theVisio->pChild = NULL; theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label =\"Altitude\" or @NameU = \"Altitude\"]/Value")); if(theVisio->pChild == NULL) theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label = \"Altitude\"]/Value")); //if(theVisio->pChild == NULL) // theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label = \"Altitude\" or @ID = 1 or @ID = 2]/Value")); if(theVisio->pChild != NULL) { vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdZIn = double(vt); } else theVisio->gdZIn = 0.0; tempMap.Easting = theVisio->gdXIn; tempMap.Northing = theVisio->gdYIn; tempMap.Altitude = theVisio->gdZIn; InList.push_back(tempMap); } // end for // fullincount theVisio->DOMNodePtr = NULL; for(int fj = 0; fj < fullinCount; fj++) { theVisio->DOMNodePtr = theVisio->fullinListPtr->item[fj]; theVisio->DOMNodePtr = theVisio->DOMNodePtr->GetparentNode(); //theVisio->DOMNodePtr = theVisio->DOMNodePtr->firstChild; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(0); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/PinX")); vtFullInX = theVisio->pChild->GetnodeTypedValue(); theVisio->gdXFullIn = (double(vtFullInX)/VISIOFACTOR) + m_visXOrigin; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(1); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/PinY")); vtFullInY = theVisio->pChild->GetnodeTypedValue(); theVisio->gdYFullIn = (double(vtFullInY)/VISIOFACTOR) + m_visYOrigin; theVisio->pChild = NULL; theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label =\"Altitude\" or @NameU = \"Altitude\"]/Value")); if(theVisio->pChild == NULL) theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label = \"Altitude\"]/Value")); if(theVisio->pChild != NULL) { vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdZFullIn = double(vt); } else theVisio->gdZFullIn = 0.0; tempMap.Easting = theVisio->gdXFullIn; tempMap.Northing = theVisio->gdYFullIn; tempMap.Altitude = theVisio->gdZFullIn; FullInList.push_back(tempMap); } // end for theVisio->DOMNodePtr = NULL; for(int k = 0; k < pitCount; k++) { theVisio->DOMNodePtr = theVisio->pitListPtr->item[k]; theVisio->DOMNodePtr = theVisio->DOMNodePtr->GetparentNode(); //theVisio->DOMNodePtr = theVisio->DOMNodePtr->firstChild; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(0); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/PinX")); vtPitInX = theVisio->pChild->GetnodeTypedValue(); theVisio->gdXPitIn = (double(vtPitInX)/VISIOFACTOR) + m_visXOrigin; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(1); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/PinY")); vtPitInY = theVisio->pChild->GetnodeTypedValue(); theVisio->gdYPitIn = (double(vtPitInY)/VISIOFACTOR) + m_visYOrigin; theVisio->pChild = NULL; theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label =\"Altitude\" or @NameU = \"Altitude\"]/Value")); if(theVisio->pChild == NULL) theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label = \"Altitude\"]/Value")); if(theVisio->pChild != NULL) { vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdZPitIn = double(vt); } else theVisio->gdZPitIn = 0.0; tempMap.Easting = theVisio->gdXPitIn; tempMap.Northing = theVisio->gdYPitIn; tempMap.Altitude = theVisio->gdZPitIn; PitInList.push_back(tempMap); } // end for theVisio->DOMNodePtr = NULL; for(int i1 = 0; i1 < island1Count; i1++) { theVisio->DOMNodePtr = theVisio->island1ListPtr->item[i1]; theVisio->DOMNodePtr = theVisio->DOMNodePtr->GetparentNode(); //theVisio->DOMNodePtr = theVisio->DOMNodePtr->firstChild; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(0); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/PinX")); vtPitInX = theVisio->pChild->GetnodeTypedValue(); theVisio->gdXPitIn = (double(vtPitInX)/VISIOFACTOR) + m_visXOrigin; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(1); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/PinY")); vtPitInY = theVisio->pChild->GetnodeTypedValue(); theVisio->gdYPitIn = (double(vtPitInY)/VISIOFACTOR) + m_visYOrigin; theVisio->pChild = NULL; theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label =\"Altitude\" or @NameU = \"Altitude\"]/Value")); if(theVisio->pChild == NULL) theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label = \"Altitude\"]/Value")); if(theVisio->pChild != NULL) { vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdZPitIn = double(vt); } else theVisio->gdZPitIn = 0.0; tempMap.Easting = theVisio->gdXPitIn; tempMap.Northing = theVisio->gdYPitIn; tempMap.Altitude = theVisio->gdZPitIn; Island1List.push_back(tempMap); } // end for /* theVisio->DOMNodePtr = NULL; for(int l = 0; l < startstopCount; l++) { theVisio->DOMNodePtr = theVisio->startstopListPtr->item[l]; theVisio->DOMNodePtr = theVisio->DOMNodePtr->GetparentNode(); //theVisio->DOMNodePtr = theVisio->DOMNodePtr->firstChild; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(0); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/PinX")); vtStartStopX = theVisio->pChild->GetnodeTypedValue(); theVisio->gdXStartStop = (double(vtStartStopX)/VISIOFACTOR) + m_visXOrigin; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(1); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/PinY")); vtStartStopY = theVisio->pChild->GetnodeTypedValue(); theVisio->gdYStartStop = (double(vtStartStopY)/VISIOFACTOR) + m_visYOrigin; theVisio->pChild = NULL; theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label =\"Altitude\" or @NameU = \"Altitude\"]/Value")); if(theVisio->pChild != NULL) { vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdZStartStop = double(vt); } else theVisio->gdZStartStop = 0.0; tempMap.Easting = theVisio->gdXStartStop; tempMap.Northing = theVisio->gdYStartStop; tempMap.Altitude = theVisio->gdZStartStop; StartStopList.push_back(tempMap); } // end for */ theVisio->DOMNodePtr = NULL; for(int l = 0; l < startstopCount; l++) { theVisio->DOMNodePtr = theVisio->startstopListPtr->item[l]; theVisio->DOMNodePtr = theVisio->DOMNodePtr->GetparentNode(); //theVisio->DOMNodePtr = theVisio->DOMNodePtr->firstChild; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(0); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm1D/BeginX")); vtStartStopX = theVisio->pChild->GetnodeTypedValue(); theVisio->gdX = (double(vtStartStopX)/VISIOFACTOR) + m_visXOrigin; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(1); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm1D/BeginY")); vtStartStopY = theVisio->pChild->GetnodeTypedValue(); theVisio->gdY = (double(vtStartStopY)/VISIOFACTOR) + m_visYOrigin; theVisio->pChild = NULL; theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[@NameU = \"Altitude\"]/Value")); if(theVisio->pChild == NULL) theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label = \"Altitude\"]/Value")); if(theVisio->pChild != NULL) { vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdZ = double(vt); } else theVisio->gdZ = 0.0; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(0); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm1D/EndX")); vtStartStopX = theVisio->pChild->GetnodeTypedValue(); theVisio->gdEndX = (double(vtStartStopX)/VISIOFACTOR) + m_visXOrigin; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(1); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm1D/EndY")); vtStartStopY = theVisio->pChild->GetnodeTypedValue(); theVisio->gdEndY = (double(vtStartStopY)/VISIOFACTOR) + m_visYOrigin; theVisio->pChild = NULL; theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[@NameU = \"Altitude\"]/Value")); if(theVisio->pChild == NULL) theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label = \"Altitude\"]/Value")); if(theVisio->pChild != NULL) { vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdEndZ = double(vt); } else theVisio->gdEndZ = 0.0; startstop.BeginX = theVisio->gdX; startstop.BeginY = theVisio->gdY; startstop.BeginZ = theVisio->gdZ; startstop.EndX = theVisio->gdEndX; startstop.EndY = theVisio->gdEndY; startstop.EndZ = theVisio->gdEndZ; StartStopList.push_back(startstop); } // end for(int l = 0; l < startstopCount; l++) theVisio->DOMNodePtr = NULL; for(int m = 0; m < turnnoCount; m++) { theVisio->DOMNodePtr = theVisio->turnListPtr->item[m]; theVisio->DOMNodePtr = theVisio->DOMNodePtr->GetparentNode(); //theVisio->DOMNodePtr = theVisio->DOMNodePtr->firstChild; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(0); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/PinX")); vtTurnX = theVisio->pChild->GetnodeTypedValue(); theVisio->gdXTurn = (double(vtTurnX)/VISIOFACTOR) + m_visXOrigin; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(1); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/PinY")); vtTurnY = theVisio->pChild->GetnodeTypedValue(); theVisio->gdYTurn = (double(vtTurnY)/VISIOFACTOR) + m_visYOrigin; theVisio->pChild = NULL; theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label =\"Altitude\" or @NameU = \"Altitude\"]/Value")); if(theVisio->pChild == NULL) theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label = \"Altitude\"]/Value")); if(theVisio->pChild != NULL) { vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdZTurn = double(vt); } else theVisio->gdZTurn = 0.0; //// logic to access turnNo/Value theVisio->pChild = NULL; if((theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Text"))) != NULL) theVisio->gdTurnNo = theVisio->pChild->Gettext(); ////////// logic to access the font name : default Arial if((theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Char/Font"))) == NULL) { theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("//Fonts/FontEntry[@ID = 0]/@Name")); //theVisio->pChild = theVisio->DOMElementPtr->get_attributes(&theVisio->pTurnAttrib); //theVisio->pChild = theVisio->pTurnAttrib->Getitem(4); theVisio->gdFontType = theVisio->pChild->Gettext(); } else { theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("//Fonts/FontEntry[@ID = //Shape/Char/Font]/@Name")); //theVisio->pChild = theVisio->DOMElementPtr->get_attributes(&theVisio->pTurnAttrib); //theVisio->pChild = theVisio->pTurnAttrib->Getitem(4); theVisio->gdFontType = theVisio->pChild->Gettext(); } // code to access the turn Angle theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/Angle")); vtTurnAngle = theVisio->pChild->GetnodeTypedValue(); theVisio->gdTurnAngle = INT64(double(vtTurnAngle)/0.017453292519943); turn.Easting = theVisio->gdXTurn; turn.Northing = theVisio->gdYTurn; turn.Altitude = theVisio->gdZTurn; turn.Turnvalue = theVisio->gdTurnNo; turn.TurnfontType = theVisio->gdFontType; turn.TurnAngle = theVisio->gdTurnAngle; TurnNoList.push_back(turn); } // end for for(int m = 0; m < turnnoCount; m++) // speedtrapList theVisio->DOMNodePtr = NULL; for(int n = 0; n < speedtrapCount; n++) { theVisio->DOMNodePtr = theVisio->speedtrapListPtr->item[n]; theVisio->DOMNodePtr = theVisio->DOMNodePtr->GetparentNode(); //theVisio->DOMNodePtr = theVisio->DOMNodePtr->firstChild; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(0); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm1D/BeginX")); vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdX = (double(vt)/VISIOFACTOR) + m_visXOrigin; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(1); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm1D/BeginY")); vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdY = (double(vt)/VISIOFACTOR) + m_visYOrigin; theVisio->pChild = NULL; theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label =\"Altitude\" or @NameU = \"Altitude\"]/Value")); if(theVisio->pChild == NULL) theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label = \"Altitude\"]/Value")); if(theVisio->pChild != NULL) { vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdZ = double(vt); } else theVisio->gdZ = 0.0; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(0); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm1D/EndX")); vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdEndX = (double(vt)/VISIOFACTOR) + m_visXOrigin; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(1); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm1D/EndY")); vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdEndY = (double(vt)/VISIOFACTOR) + m_visYOrigin; theVisio->pChild = NULL; theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label =\"Altitude\" or @NameU = \"Altitude\"]/Value")); if(theVisio->pChild == NULL) theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label = \"Altitude\"]/Value")); if(theVisio->pChild != NULL) { vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdEndZ = double(vt); } else theVisio->gdEndZ = 0.0; //// logic to access speedtrapName theVisio->pChild = NULL; if((theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Text"))) != NULL) theVisio->gdName = theVisio->pChild->Gettext(); speedtrap.BeginX = theVisio->gdX; speedtrap.BeginY = theVisio->gdY; speedtrap.BeginZ = theVisio->gdZ; speedtrap.EndX = theVisio->gdEndX; speedtrap.EndY = theVisio->gdEndY; speedtrap.EndZ = theVisio->gdEndZ; speedtrap.speedtrapName = theVisio->gdName; speedtrapList.push_back(speedtrap); } // end for for(int n = 0; n < speedtrapCount; n++) // zoneinList theVisio->DOMNodePtr = NULL; for(int o = 0; o < zoneinCount; o++) { theVisio->DOMNodePtr = theVisio->zoneInListPtr->item[o]; theVisio->DOMNodePtr = theVisio->DOMNodePtr->GetparentNode(); //theVisio->DOMNodePtr = theVisio->DOMNodePtr->firstChild; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(0); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm1D/BeginX")); vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdXZoneIn1 = (double(vt)/VISIOFACTOR) + m_visXOrigin; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(1); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm1D/BeginY")); vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdYZoneIn1 = (double(vt)/VISIOFACTOR) + m_visYOrigin; theVisio->pChild = NULL; theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label =\"Altitude\" or @NameU = \"Altitude\"]/Value")); if(theVisio->pChild == NULL) theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label = \"Altitude\"]/Value")); if(theVisio->pChild != NULL) { vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdZZoneIn1 = double(vt); } else theVisio->gdZZoneIn1 = 0.0; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(0); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm1D/EndX")); vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdXZoneIn2 = (double(vt)/VISIOFACTOR) + m_visXOrigin; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(1); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm1D/EndY")); vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdYZoneIn2 = (double(vt)/VISIOFACTOR) + m_visYOrigin; theVisio->pChild = NULL; theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label =\"Altitude\" or @NameU = \"Altitude\"]/Value")); if(theVisio->pChild == NULL) theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label = \"Altitude\"]/Value")); if(theVisio->pChild != NULL) { vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdZZoneIn2 = double(vt); } else theVisio->gdZZoneIn2 = 0.0; //// logic to access speedtrapName theVisio->pChild = NULL; if((theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Text"))) != NULL) theVisio->gdZoneName = theVisio->pChild->Gettext(); zonein.BeginX = theVisio->gdXZoneIn1; zonein.BeginY = theVisio->gdYZoneIn1; zonein.BeginZ = theVisio->gdZZoneIn1; zonein.EndX = theVisio->gdXZoneIn2; zonein.EndY = theVisio->gdYZoneIn2; zonein.EndZ = theVisio->gdZZoneIn2; zonein.speedtrapName = theVisio->gdZoneName; ZoneInList.push_back(zonein); } // end for for(int o = 0; o < zoneinCount; o++) // zoneoutList theVisio->DOMNodePtr = NULL; for(int p = 0; p < zoneoutCount; p++) { theVisio->DOMNodePtr = theVisio->zoneOutListPtr->item[p]; theVisio->DOMNodePtr = theVisio->DOMNodePtr->GetparentNode(); //theVisio->DOMNodePtr = theVisio->DOMNodePtr->firstChild; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(0); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm1D/BeginX")); vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdXZoneOut1 = (double(vt)/VISIOFACTOR) + m_visXOrigin; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(1); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm1D/BeginY")); vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdYZoneOut1 = (double(vt)/VISIOFACTOR) + m_visYOrigin; theVisio->pChild = NULL; theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label =\"Altitude\" or @NameU = \"Altitude\"]/Value")); if(theVisio->pChild == NULL) theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label = \"Altitude\"]/Value")); if(theVisio->pChild != NULL) { vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdZZoneOut1 = double(vt); } else theVisio->gdZZoneOut1 = 0.0; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(0); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm1D/EndX")); vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdXZoneOut2 = (double(vt)/VISIOFACTOR) + m_visXOrigin; //theVisio->pChild = theVisio->DOMNodePtr->childNodes->Getitem(1); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm1D/EndY")); vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdYZoneOut2 = (double(vt)/VISIOFACTOR) + m_visYOrigin; theVisio->pChild = NULL; theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label =\"Altitude\" or @NameU = \"Altitude\"]/Value")); if(theVisio->pChild == NULL) theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label = \"Altitude\"]/Value")); if(theVisio->pChild != NULL) { vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdZZoneOut2 = double(vt); } else theVisio->gdZZoneOut2 = 0.0; //// logic to access speedtrapName theVisio->pChild = NULL; if((theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Text"))) != NULL) theVisio->gdZoneName = theVisio->pChild->Gettext(); zonein.BeginX = theVisio->gdXZoneOut1; zonein.BeginY = theVisio->gdYZoneOut1; zonein.BeginZ = theVisio->gdZZoneOut1; zonein.EndX = theVisio->gdXZoneOut2; zonein.EndY = theVisio->gdYZoneOut2; zonein.EndZ = theVisio->gdZZoneOut2; zonein.speedtrapName = theVisio->gdZoneName; ZoneOutList.push_back(zonein); } // end for for(int p = 0; p < zoneoutCount; p++) /* theVisio->DOMNodePtr = NULL; for(int n = 0; n < shapesCount; n++) { _variant_t v_Height,v_Width; theVisio->DOMNodePtr = theVisio->shapesListPtr->item[n]; if((theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("//Shape[Geom][XForm/PinX][XForm/PinY][XForm/Width][XForm/Height]"))) != NULL) { theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/Width")); v_Width = theVisio->pChild->GetnodeTypedValue(); theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/Height")); v_Height = theVisio->pChild->GetnodeTypedValue(); /// top left X Co-Ordinate and bottom right X Co-Ordinate of Rectangle theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/PinX")); vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdXRect0 = (double(vt) - (0.5 * double(v_Width)))/VISIOFACTOR + m_visXOrigin; theVisio->gdXRect1 = (double(vt) - (0.5 * double(v_Width)))/VISIOFACTOR + m_visXOrigin; theVisio->gdXRect2 = (double(vt) + (0.5 * double(v_Width)))/VISIOFACTOR + m_visXOrigin; theVisio->gdXRect3 = (double(vt) + (0.5 * double(v_Width)))/VISIOFACTOR + m_visXOrigin; /// top left Y Co-Ordinate and bottom right Y Co-Ordinate of Rectangle theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("XForm/PinY")); vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdYRect0 = (double(vt) + (0.5 * double(v_Height)))/VISIOFACTOR + m_visYOrigin; theVisio->gdYRect1 = (double(vt) - (0.5 * double(v_Height)))/VISIOFACTOR + m_visYOrigin; theVisio->gdYRect2 = (double(vt) - (0.5 * double(v_Height)))/VISIOFACTOR + m_visYOrigin; theVisio->gdYRect3 = (double(vt) + (0.5 * double(v_Height)))/VISIOFACTOR + m_visYOrigin; theVisio->pChild = NULL; theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("Prop[Label =\"Altitude\" or @NameU = \"Altitude\"]/Value")); if(theVisio->pChild != NULL) { vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdZRect0 = double(vt); theVisio->gdZRect1 = double(vt); theVisio->gdZRect2 = double(vt); theVisio->gdZRect3 = double(vt); } else { theVisio->gdZRect0 = 0.0; theVisio->gdZRect1 = 0.0; theVisio->gdZRect2 = 0.0; theVisio->gdZRect3 = 0.0; } //////////////////////////////// //// lineWeight and lineColor theVisio->pChild = NULL; if((theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("//Shape/Line/LineWeight"))) != NULL) { vt = theVisio->pChild->GetnodeTypedValue(); theVisio->gdLineWeight = double(vt) * 72.0; } else { theVisio->gdLineWeight = 0.72; } theVisio->pChild = NULL; if((theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("//Shape/Line/LineColor"))) != NULL) { char *RGBVal,val1,val2,val3,val4,val5,val6; int valNum; RGBVal = NULL; vt = theVisio->pChild->Gettext(); RGBVal = _com_util::ConvertBSTRToString(vt.bstrVal); /////////////////////////////////// ///// check to see if the value returned is a hexadecimal number ///// or a color code number theVisio->gdVisible = 1; if(RGBVal[0] == '#') { const char hexChars[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; val1 = RGBVal[1]; val2 = RGBVal[2]; val3 = RGBVal[3]; val4 = RGBVal[4]; val5 = RGBVal[5]; val6 = RGBVal[6]; int red,green,blue; red = 0; green = 0; blue = 0; for(valNum = 0;valNum < 16;valNum++) { if(val1 == RGBVal[valNum]) red = red + (valNum * 16); if(val3 == RGBVal[valNum]) green = valNum * 16; if(val5 == RGBVal[valNum]) blue = valNum * 16; } // end for for(valNum = 0;valNum < 16;valNum++) { if(val2 == RGBVal[valNum]) theVisio->gdRed = red + valNum; if(val4 == RGBVal[valNum]) theVisio->gdGreen = green + valNum; if(val6 == RGBVal[valNum]) theVisio->gdBlue = blue + valNum; } // end for } // end if(RGBVal[0] == '#') if(RGBVal[0] != '#') { int value; value = int(RGBVal[0]); switch(value) { case 0 : theVisio->gdRed = 0; theVisio->gdGreen = 0; theVisio->gdBlue = 0; theVisio->gdVisible = 0; break; case 1 : theVisio->gdRed = 255; theVisio->gdGreen = 255; theVisio->gdBlue = 255; break; case 2 : theVisio->gdRed = 255; theVisio->gdGreen = 0; theVisio->gdBlue = 0; break; case 3 : theVisio->gdRed = 0; theVisio->gdGreen = 255; theVisio->gdBlue = 0; break; case 4 : theVisio->gdRed = 0; theVisio->gdGreen = 0; theVisio->gdBlue = 255; break; case 5 : theVisio->gdRed = 255; theVisio->gdGreen = 255; theVisio->gdBlue = 0; break; case 6 : theVisio->gdRed = 255; theVisio->gdGreen = 0; theVisio->gdBlue = 255; break; case 7 : theVisio->gdRed = 0; theVisio->gdGreen = 255; theVisio->gdBlue = 255; break; case 8 : theVisio->gdRed = 128; theVisio->gdGreen = 0; theVisio->gdBlue = 0; break; case 9 : theVisio->gdRed = 0; theVisio->gdGreen = 128; theVisio->gdBlue = 0; break; case 10 : theVisio->gdRed = 0; theVisio->gdGreen = 0; theVisio->gdBlue = 128; break; case 11 : theVisio->gdRed = 128; theVisio->gdGreen = 128; theVisio->gdBlue = 0; break; case 12 : theVisio->gdRed = 128; theVisio->gdGreen = 0; theVisio->gdBlue = 128; break; case 13 : theVisio->gdRed = 0; theVisio->gdGreen = 128; theVisio->gdBlue = 128; break; case 14 : theVisio->gdRed = 192; theVisio->gdGreen = 192; theVisio->gdBlue = 192; break; case 15 : theVisio->gdRed = 230; theVisio->gdGreen = 230; theVisio->gdBlue = 230; break; case 16 : theVisio->gdRed = 205; theVisio->gdGreen = 205; theVisio->gdBlue = 205; break; case 17 : theVisio->gdRed = 179; theVisio->gdGreen = 179; theVisio->gdBlue = 179; break; case 18 : theVisio->gdRed = 154; theVisio->gdGreen = 154; theVisio->gdBlue = 154; break; case 19 : theVisio->gdRed = 128; theVisio->gdGreen = 128; theVisio->gdBlue = 128; break; case 20 : theVisio->gdRed = 102; theVisio->gdGreen = 102; theVisio->gdBlue = 102; break; case 21 : theVisio->gdRed = 77; theVisio->gdGreen = 77; theVisio->gdBlue = 77; break; case 22 : theVisio->gdRed = 51; theVisio->gdGreen = 51; theVisio->gdBlue = 51; break; case 23 : theVisio->gdRed = 26; theVisio->gdGreen = 26; theVisio->gdBlue = 26; break; default: break; } // end switch }// end if(RGBVal[0] != '#') } // end if((theVisio->pChild = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("//Shape/Line/LineColor"))) != NULL) else theVisio->gdVisible = 0; // add logic to include the rect values in list shapes.Easting0 = theVisio->gdXRect0; shapes.Northing0 = theVisio->gdYRect0; shapes.Altitude0 = theVisio->gdZRect0; shapes.Easting1 = theVisio->gdXRect1; shapes.Northing1 = theVisio->gdYRect1; shapes.Altitude1 = theVisio->gdZRect1; shapes.Easting2 = theVisio->gdXRect2; shapes.Northing2 = theVisio->gdYRect2; shapes.Altitude2 = theVisio->gdZRect2; shapes.Easting3 = theVisio->gdXRect3; shapes.Northing3 = theVisio->gdYRect3; shapes.Altitude3 = theVisio->gdZRect3; shapes.lineWeight = theVisio->gdLineWeight; shapes.visibility = theVisio->gdVisible; shapes.red = theVisio->gdRed; shapes.blue = theVisio->gdBlue; shapes.green = theVisio->gdGreen; shapes.alpha = 255; RectList.push_back(shapes); }// end if((theVisio->DOMNodePtr = theVisio->DOMNodePtr->selectSingleNode(_bstr_t("//Shape[Geom][XForm/PinX][XForm/PinY][XForm/Width][XForm/Height]")) != NULL) } // end for(int n = 0; n < shapesCount; n++) */ // sort the list // Algorithm : the nearest neighbour search //////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// /////////////////////// double range,angle,prevrange,prevangle; bool greater = FALSE; bool equal = FALSE; while(!OutList.empty()) { fstListIter = OutList.begin(); nxtListIter = OutList.begin(); curListIter = OutList.begin(); if(OutList.size() == 1) { OutCheckedList.push_back(*fstListIter); if(fstListIter != OutList.end()) OutList.erase(fstListIter); } if(OutList.size() == 2) { ++nxtListIter; OutCheckedList.push_back(*fstListIter); OutCheckedList.push_back(*nxtListIter); if(fstListIter != OutList.end()) OutList.erase(fstListIter); if(nxtListIter != OutList.end()) OutList.erase(nxtListIter); } if(OutList.size() == 3) { ++nxtListIter; curListIter = nxtListIter; ++curListIter; first = *fstListIter; next = *nxtListIter; cur = *curListIter; UTMPosition UTMPositionFirst(0,first.Northing,first.Easting); UTMPosition UTMPositionNext(0,next.Northing,next.Easting); UTMPositionFirst.angleTo(UTMPositionNext,angle,prevrange); UTMPosition UTMPositionCur(0,cur.Northing,cur.Easting); UTMPositionFirst.angleTo(UTMPositionCur,angle,range); if(prevrange > range) { //cout << "prevrange > range out" << endl; OutCheckedList.push_back(*fstListIter); OutCheckedList.push_back(*curListIter); OutCheckedList.push_back(*nxtListIter); OutList.erase(fstListIter); OutList.erase(nxtListIter); OutList.erase(curListIter); //OutCheckedList.push_back(*curListIter); //OutCheckedList.push_back(*nxtListIter); } else { //cout << "prevrange < range out" << endl; OutCheckedList.push_back(*fstListIter); OutCheckedList.push_back(*nxtListIter); OutCheckedList.push_back(*curListIter); OutList.erase(fstListIter); OutList.erase(nxtListIter); OutList.erase(curListIter); } } if(OutList.size() > 3) { ++nxtListIter; curListIter = nxtListIter; ++curListIter; first = *fstListIter; next = *nxtListIter; cur = *curListIter; UTMPosition UTMPositionFirst(0,first.Northing,first.Easting); UTMPosition UTMPositionNext(0,next.Northing,next.Easting); UTMPositionFirst.angleTo(UTMPositionNext,angle,prevrange); for(;curListIter != OutList.end();curListIter++) { cur = *curListIter; UTMPosition UTMPositionCur(0,cur.Northing,cur.Easting); UTMPositionFirst.angleTo(UTMPositionCur,angle,range); // range to determine if it is greater or lesser than prevrange if(prevrange > range) { prevrange = range; tmpListIter = curListIter; greater = TRUE; } // end if(prevrange > range) } // end for(;curListIter != OutList.end();curListIter++) if(greater) { swap(*nxtListIter,*tmpListIter); greater = FALSE; } if(!greater) { OutCheckedList.push_back(*fstListIter); if(fstListIter != OutList.end()) OutList.erase(fstListIter); } } // end if(OutList.size() > 3) } // end while(!OutList.empty()) //////////////////////////////////////////////////////////////// // sort the InList(inside of the track) greater = FALSE; while(!InList.empty()) { fstListIter = InList.begin(); nxtListIter = InList.begin(); curListIter = InList.begin(); if(InList.size() == 1) { InCheckedList.push_back(*fstListIter); if(fstListIter != InList.end()) InList.erase(fstListIter); } if(InList.size() == 2) { ++nxtListIter; InCheckedList.push_back(*fstListIter); InCheckedList.push_back(*nxtListIter); if(fstListIter != InList.end()) InList.erase(fstListIter); if(nxtListIter != InList.end()) InList.erase(nxtListIter); } if(InList.size() == 3) { ++nxtListIter; curListIter = nxtListIter; ++curListIter; first = *fstListIter; // first point next = *nxtListIter; // second point cur = *curListIter; // third point UTMPosition UTMPositionFirst(0,first.Northing,first.Easting); UTMPosition UTMPositionNext(0,next.Northing,next.Easting); UTMPositionFirst.angleTo(UTMPositionNext,angle,prevrange); UTMPosition UTMPositionCur(0,cur.Northing,cur.Easting); UTMPositionFirst.angleTo(UTMPositionCur,angle,range); if(prevrange > range) { //cout << "prevrange > range in " << endl; InCheckedList.push_back(*fstListIter); InCheckedList.push_back(*curListIter); InCheckedList.push_back(*nxtListIter); InList.erase(fstListIter); InList.erase(nxtListIter); InList.erase(curListIter); } else { //cout << "prevrange < range in" << endl; InCheckedList.push_back(*fstListIter); InCheckedList.push_back(*nxtListIter); InCheckedList.push_back(*curListIter); InList.erase(fstListIter); InList.erase(nxtListIter); InList.erase(curListIter); } } if(InList.size() > 3) { ++nxtListIter; curListIter = nxtListIter; ++curListIter; first = *fstListIter; next = *nxtListIter; cur = *curListIter; UTMPosition UTMPositionFirst(0,first.Northing,first.Easting); UTMPosition UTMPositionNext(0,next.Northing,next.Easting); UTMPositionFirst.angleTo(UTMPositionNext,angle,prevrange); for(;curListIter != InList.end();curListIter++) { cur = *curListIter; UTMPosition UTMPositionCur(0,cur.Northing,cur.Easting); UTMPositionFirst.angleTo(UTMPositionCur,angle,range); // range to determine if it is greater or lesser than prevrange if(prevrange > range) { prevrange = range; tmpListIter = curListIter; greater = TRUE; } // end if(prevrange > range) } // end for(;curListIter != InList.end();curListIter++) if(greater) { swap(*nxtListIter,*tmpListIter); greater = FALSE; } if(!greater) { InCheckedList.push_back(*fstListIter); if(fstListIter != InList.end()) InList.erase(fstListIter); } } // end if(InList.size() >= 3) } // end while(!InList.empty()) ///////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// // sort the FullInList(the new fullinside of the track)' // the new fullinside layer of the track is good only if // there is a fullinside layer // else the inside layer will be the default greater = FALSE; while(!FullInList.empty()) { fstListIter = FullInList.begin(); nxtListIter = FullInList.begin(); curListIter = FullInList.begin(); if(FullInList.size() == 1) { FullInCheckedList.push_back(*fstListIter); if(fstListIter != FullInList.end()) FullInList.erase(fstListIter); } if(FullInList.size() == 2) { ++nxtListIter; FullInCheckedList.push_back(*fstListIter); FullInCheckedList.push_back(*nxtListIter); if(fstListIter != FullInList.end()) FullInList.erase(fstListIter); if(nxtListIter != FullInList.end()) FullInList.erase(nxtListIter); } if(FullInList.size() == 3) { ++nxtListIter; curListIter = nxtListIter; ++curListIter; first = *fstListIter; // first point next = *nxtListIter; // second point cur = *curListIter; // third point UTMPosition UTMPositionFirst(0,first.Northing,first.Easting); UTMPosition UTMPositionNext(0,next.Northing,next.Easting); UTMPositionFirst.angleTo(UTMPositionNext,angle,prevrange); UTMPosition UTMPositionCur(0,cur.Northing,cur.Easting); UTMPositionFirst.angleTo(UTMPositionCur,angle,range); if(prevrange > range) { //cout << "prevrange > range in " << endl; FullInCheckedList.push_back(*fstListIter); FullInCheckedList.push_back(*curListIter); FullInCheckedList.push_back(*nxtListIter); FullInList.erase(fstListIter); FullInList.erase(nxtListIter); FullInList.erase(curListIter); } else { //cout << "prevrange < range in" << endl; FullInCheckedList.push_back(*fstListIter); FullInCheckedList.push_back(*nxtListIter); FullInCheckedList.push_back(*curListIter); FullInList.erase(fstListIter); FullInList.erase(nxtListIter); FullInList.erase(curListIter); } } if(FullInList.size() > 3) { ++nxtListIter; curListIter = nxtListIter; ++curListIter; first = *fstListIter; next = *nxtListIter; cur = *curListIter; UTMPosition UTMPositionFirst(0,first.Northing,first.Easting); UTMPosition UTMPositionNext(0,next.Northing,next.Easting); UTMPositionFirst.angleTo(UTMPositionNext,angle,prevrange); for(;curListIter != FullInList.end();curListIter++) { cur = *curListIter; UTMPosition UTMPositionCur(0,cur.Northing,cur.Easting); UTMPositionFirst.angleTo(UTMPositionCur,angle,range); // range to determine if it is greater or lesser than prevrange if(prevrange > range) { prevrange = range; tmpListIter = curListIter; greater = TRUE; } // end if(prevrange > range) } // end for(;curListIter != FullInList.end();curListIter++) if(greater) { swap(*nxtListIter,*tmpListIter); greater = FALSE; } if(!greater) { FullInCheckedList.push_back(*fstListIter); if(fstListIter != FullInList.end()) FullInList.erase(fstListIter); } } // end if(FullInList.size() >= 3) } // end while(!FullInList.empty()) ////////////////////////////////////////////////////////////////////// /////////////////////////////////// // sort the PitInList greater = FALSE; while(!PitInList.empty()) { fstListIter = PitInList.begin(); nxtListIter = PitInList.begin(); curListIter = PitInList.begin(); if(PitInList.size() == 1) { PitInCheckedList.push_back(*fstListIter); if(fstListIter != PitInList.end()) PitInList.erase(fstListIter); } if(PitInList.size() == 2) { ++nxtListIter; PitInCheckedList.push_back(*fstListIter); PitInCheckedList.push_back(*nxtListIter); if(fstListIter != PitInList.end()) PitInList.erase(fstListIter); if(nxtListIter != PitInList.end()) PitInList.erase(nxtListIter); } if(PitInList.size() == 3) { ++nxtListIter; curListIter = nxtListIter; ++curListIter; first = *fstListIter; // first point next = *nxtListIter; // second point cur = *curListIter; // third point UTMPosition UTMPositionFirst(0,first.Northing,first.Easting); UTMPosition UTMPositionNext(0,next.Northing,next.Easting); UTMPositionFirst.angleTo(UTMPositionNext,angle,prevrange); UTMPosition UTMPositionCur(0,cur.Northing,cur.Easting); UTMPositionFirst.angleTo(UTMPositionCur,angle,range); if(prevrange > range) { //cout << "prevrange > range pitin " << endl; PitInCheckedList.push_back(*fstListIter); PitInCheckedList.push_back(*curListIter); PitInCheckedList.push_back(*nxtListIter); } else { //cout << "prevrange < range pitin" << endl; PitInCheckedList.push_back(*fstListIter); PitInCheckedList.push_back(*nxtListIter); PitInCheckedList.push_back(*curListIter); } PitInList.erase(fstListIter); PitInList.erase(nxtListIter); PitInList.erase(curListIter); } if(PitInList.size() > 3) { ++nxtListIter; curListIter = nxtListIter; ++curListIter; first = *fstListIter; next = *nxtListIter; cur = *curListIter; UTMPosition UTMPositionFirst(0,first.Northing,first.Easting); UTMPosition UTMPositionNext(0,next.Northing,next.Easting); UTMPositionFirst.angleTo(UTMPositionNext,angle,prevrange); for(;curListIter != PitInList.end();curListIter++) { cur = *curListIter; UTMPosition UTMPositionCur(0,cur.Northing,cur.Easting); UTMPositionFirst.angleTo(UTMPositionCur,angle,range); // range to determine if it is greater or lesser than prevrange if(prevrange > range) { prevrange = range; tmpListIter = curListIter; greater = TRUE; } } // end for(;curListIter != PitInList.end();curListIter++) if(greater) { swap(*nxtListIter,*tmpListIter); greater = FALSE; } if(!greater) { PitInCheckedList.push_back(*fstListIter); if(fstListIter != PitInList.end()) PitInList.erase(fstListIter); } } // end if(PitInList.size() >= 3) } // end while(!PitInList.empty()) ////////////////////////////////////////////////////////////////////// /////////////////////////////////// // sort the Island1List greater = FALSE; while(!Island1List.empty()) { fstListIter = Island1List.begin(); nxtListIter = Island1List.begin(); curListIter = Island1List.begin(); if(Island1List.size() == 1) { Island1CheckedList.push_back(*fstListIter); if(fstListIter != Island1List.end()) Island1List.erase(fstListIter); } if(Island1List.size() == 2) { ++nxtListIter; Island1CheckedList.push_back(*fstListIter); Island1CheckedList.push_back(*nxtListIter); if(fstListIter != Island1List.end()) Island1List.erase(fstListIter); if(nxtListIter != Island1List.end()) Island1List.erase(nxtListIter); } if(Island1List.size() == 3) { ++nxtListIter; curListIter = nxtListIter; ++curListIter; first = *fstListIter; // first point next = *nxtListIter; // second point cur = *curListIter; // third point UTMPosition UTMPositionFirst(0,first.Northing,first.Easting); UTMPosition UTMPositionNext(0,next.Northing,next.Easting); UTMPositionFirst.angleTo(UTMPositionNext,angle,prevrange); UTMPosition UTMPositionCur(0,cur.Northing,cur.Easting); UTMPositionFirst.angleTo(UTMPositionCur,angle,range); if(prevrange > range) { //cout << "prevrange > range pitin " << endl; Island1CheckedList.push_back(*fstListIter); Island1CheckedList.push_back(*curListIter); Island1CheckedList.push_back(*nxtListIter); } else { //cout << "prevrange < range pitin" << endl; Island1CheckedList.push_back(*fstListIter); Island1CheckedList.push_back(*nxtListIter); Island1CheckedList.push_back(*curListIter); } Island1List.erase(fstListIter); Island1List.erase(nxtListIter); Island1List.erase(curListIter); } if(Island1List.size() > 3) { ++nxtListIter; curListIter = nxtListIter; ++curListIter; first = *fstListIter; next = *nxtListIter; cur = *curListIter; UTMPosition UTMPositionFirst(0,first.Northing,first.Easting); UTMPosition UTMPositionNext(0,next.Northing,next.Easting); UTMPositionFirst.angleTo(UTMPositionNext,angle,prevrange); for(;curListIter != Island1List.end();curListIter++) { cur = *curListIter; UTMPosition UTMPositionCur(0,cur.Northing,cur.Easting); UTMPositionFirst.angleTo(UTMPositionCur,angle,range); // range to determine if it is greater or lesser than prevrange if(prevrange > range) { prevrange = range; tmpListIter = curListIter; greater = TRUE; } } // end for(;curListIter != Island1List.end();curListIter++) if(greater) { swap(*nxtListIter,*tmpListIter); greater = FALSE; } if(!greater) { Island1CheckedList.push_back(*fstListIter); if(fstListIter != Island1List.end()) Island1List.erase(fstListIter); } } // end if(Island1List.size() >= 3) } // end while(!Island1List.empty()) /// // function to interpolate the track // this function rearranges the list interpolates the track // this function is used to show the appropriate altitude values // for the track if(FullInCheckedList.size() > 3) funcToInterpolateTrack(FullInCheckedList); funcToInterpolateTrack(OutCheckedList); funcToInterpolateTrack(InCheckedList); // the funcToInterpolateTrack(list<trackMapVals> &listName) joins the first element // of the list to the last // the Graphics Display program also does the same // in order to maintain a clear track..... // the last item from the list shall be removed // the item will be joined later while creating // the altitude.txt file // erase last element of OutCheckedList tempIter = OutCheckedList.end(); tempIter--; if(tempIter != OutCheckedList.end()) OutCheckedList.erase(tempIter); // erase last element of InCheckedList tempIter = InCheckedList.end(); tempIter--; if(tempIter != InCheckedList.end()) InCheckedList.erase(tempIter); // erase last element of FullInCheckedList tempIter = FullInCheckedList.end(); tempIter--; if(tempIter != FullInCheckedList.end()) FullInCheckedList.erase(tempIter); ///////////////// after sorting join the first point to the last ///////////// ////// the joining of first point to last is not used ////// /* if(OutCheckedList.size() > 0) { fstListIter = OutCheckedList.begin(); OutCheckedList.push_back(*fstListIter); } if(InCheckedList.size() > 0) { fstListIter = InCheckedList.begin(); InCheckedList.push_back(*fstListIter); } if(PitInCheckedList.size() > 0) { fstListIter = PitInCheckedList.begin(); PitInCheckedList.push_back(*fstListIter); } */ //////////////////////////////////////// /////////////////////////////// // Check the sorted file for similar points ///////////////////////////////////// /* for(OutCheckedListIter = OutCheckedList.begin();OutCheckedListIter != OutCheckedList.end();OutCheckedListIter++) { nxtListIter = OutCheckedListIter; ++nxtListIter; for(;nxtListIter != OutCheckedList.end();nxtListIter++) { first = *OutCheckedListIter; next = *nxtListIter; if(first.Easting == next.Easting) { if(first.Northing == next.Northing) { if(nxtListIter != OutCheckedList.end()) OutCheckedList.erase(nxtListIter); } } } } */ /* ///////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////// //////////////////////////////// /////////////// Logic to incorporate the altitude//////////// //////////// separate project for altitude has been created "AltitudeTool"////////////// //////////////////////////////// /////////////////////////////// /////////// //////// the idea is to take the floor value of each point and assign it to the grid double leastEasting,leastNorthing,highestEasting,highestNorthing; leastNorthing = 12000000.0; highestNorthing = 0.0; leastEasting = 12000000.0; highestEasting = 0.0; for(OutCheckedListIter = OutCheckedList.begin();OutCheckedListIter != OutCheckedList.end();OutCheckedListIter++) { out = *OutCheckedListIter; if (out.Easting < leastEasting) { leastEasting = out.Easting; } if (out.Easting > highestEasting) { highestEasting = out.Easting; } if (out.Northing > highestNorthing) { highestNorthing = out.Northing; } if (out.Northing < leastNorthing) { leastNorthing = out.Northing; } } //myAlt *altStruct; //altStruct = (myAlt *)malloc(sizeof(myAlt[abs(ceil(highestEasting)-floor(leastEasting))][abs(ceil(highestNorthing)- floor(leastNorthing))])); //myAlt altStruct[abs(ceil(highestEasting)-floor(leastEasting))][abs(ceil(highestNorthing)- floor(leastNorthing))]; CPaintDC dc(this); CDC *pDC = GetDC(); RenderableCircle rcCurrent(pDC,RGB(255, 0, 0), (int) __max(2.0 , 4.0), RGB(0, 0, 0)); BOOL FOUND; FOUND = FALSE; while(!InList.empty()) InList.clear(); for(InCheckedListIter = InCheckedList.begin();InCheckedListIter != InCheckedList.end();InCheckedListIter++) { InList.push_back(*InCheckedListIter); } while(!InList.empty()) { InCheckedListIter = InList.begin(); first = *InCheckedListIter; nxtListIter = InCheckedListIter; ++nxtListIter; if(nxtListIter != InList.end()) next = *nxtListIter; rcCurrent.render(pDC,first.Easting-leastEasting,first.Northing-leastNorthing); rcCurrent.render(pDC,next.Easting-leastEasting,next.Northing-leastNorthing); cur.Easting = (first.Easting+next.Easting)/2; cur.Northing = (first.Northing+next.Northing)/2; UTMPosition UTMPositionCur(0,cur.Northing,cur.Easting); OutCheckedListIter = OutCheckedList.begin(); tempMap = *OutCheckedListIter; UTMPosition UTMPositiontemp(0,tempMap.Northing,tempMap.Easting); UTMPositionCur.angleTo(UTMPositiontemp,angle,prevrange); curListIter = OutCheckedListIter; ++curListIter; while(curListIter != OutCheckedList.end()) { out = *curListIter; UTMPosition UTMPositionPresent(0,out.Northing,out.Easting); UTMPositionCur.angleTo(UTMPositionPresent,angle,range); if(prevrange > range) { prevrange = range; tmpListIter = curListIter; FOUND = TRUE; } ++curListIter; } if(FOUND) { in = *tmpListIter; rcCurrent.render(pDC,in.Easting-leastEasting,in.Northing-leastNorthing); pDC->MoveTo(first.Easting-leastEasting,first.Northing-leastNorthing); pDC->LineTo(in.Easting-leastEasting,in.Northing-leastNorthing); pDC->MoveTo(next.Easting-leastEasting,next.Northing-leastNorthing); pDC->LineTo(in.Easting-leastEasting,in.Northing-leastNorthing); FOUND = FALSE; } else { rcCurrent.render(pDC,tempMap.Easting-leastEasting,tempMap.Northing-leastNorthing); pDC->MoveTo(first.Easting-leastEasting,first.Northing-leastNorthing); pDC->LineTo(tempMap.Easting-leastEasting,tempMap.Northing-leastNorthing); pDC->MoveTo(next.Easting-leastEasting,next.Northing-leastNorthing); pDC->LineTo(tempMap.Easting-leastEasting,tempMap.Northing-leastNorthing); } InList.erase(InCheckedListIter); } dc.BitBlt(0,0,50,50,pDC,0,0,SRCCOPY); */ /* for(OutCheckedListIter = OutCheckedList.begin();OutCheckedListIter != OutCheckedList.end();OutCheckedListIter++) { first = *OutCheckedListIter; nxtListIter = InCheckedList.begin(); next = *nxtListIter; rcCurrent.render(pDC,first.Easting-leastEasting,first.Northing-leastNorthing); rcCurrent.render(pDC,next.Easting-leastEasting,next.Northing-leastNorthing); UTMPosition UTMPositionFirst(0,first.Northing,first.Easting); UTMPosition UTMPositionNext(0,next.Northing,next.Easting); UTMPositionFirst.angleTo(UTMPositionNext,angle,prevrange); ++nxtListIter; for(;nxtListIter != InCheckedList.end();nxtListIter++) { cur = *nxtListIter; rcCurrent.render(pDC,cur.Easting-leastEasting,cur.Northing-leastNorthing); UTMPosition UTMPositionCur(0,cur.Northing,cur.Easting); UTMPositionFirst.angleTo(UTMPositionCur,angle,range); if(prevrange > range) { prevrange = range; tmpListIter = nxtListIter; FOUND = TRUE; } } if(FOUND) { next = *tmpListIter; } pDC->MoveTo(first.Easting-leastEasting,first.Northing-leastNorthing); pDC->LineTo(next.Easting-leastEasting,next.Northing-leastNorthing); FOUND = FALSE; //pDC->Draw3dRect(100,100,300,300,RGB(255,0,0),RGB(255,0,0)); dc.BitBlt(0,0,50,50,pDC,0,0,SRCCOPY); //for(int i = 0; i < 2;i++) // OutCheckedListIter++; } */ // Build the XML File ////////////////////////////////// //////////////////////////////////////////////////// // run diagnostics ////////////////// SUCCESS = VARIANT_TRUE; hr = S_OK; SUCCESS = theVisio->fillxmlOutValues(); // This function creates // the xmlformat to fill the necessary values. // (other methods could be used but this was one of the solutions if(SUCCESS == VARIANT_FALSE) throw "Could not run fillxmlOutValues "; for(OutCheckedListIter = OutCheckedList.begin();OutCheckedListIter != OutCheckedList.end();OutCheckedListIter++) { status = "... Building outsideTrackSegment..."; m_status.SetWindowText(status); out = *OutCheckedListIter; theVisio->gdXOut = out.Easting; theVisio->gdYOut = out.Northing; theVisio->gdZOut = out.Altitude; progCtrl++; m_trackProgress.SetPos(progCtrl); theVisio->OGLDOMNodeListPtr = theVisio->OGLDOMDocumentPtr->getElementsByTagName("trackOutsideSegment"); theVisio->OGLDOMNodePtr = theVisio->OGLDOMNodeListPtr->item[0]; SUCCESS = theVisio->BuildShape(theVisio->OGLDOMDocumentPtr,theVisio->OGLDOMNodePtr,theVisio->xmlOutValuesList); if(SUCCESS == VARIANT_FALSE) throw " Problem creating the outside segment"; } hr = theVisio->OGLDOMDocumentPtr->save(vName); // Save the file to be reloaded to add values if(hr == S_FALSE) throw " Saving Outside segment failed"; SUCCESS = VARIANT_TRUE; hr = S_OK; //// run fillList SUCCESS = theVisio->fillxmlInValues(); if(SUCCESS = VARIANT_FALSE) throw "Could not run fillxmlInValues "; for(InCheckedListIter = InCheckedList.begin();InCheckedListIter != InCheckedList.end();InCheckedListIter++) { status = "... Building insideTrackSegment..."; m_status.SetWindowText(status); in = *InCheckedListIter; theVisio->gdXIn = in.Easting; theVisio->gdYIn = in.Northing; theVisio->gdZIn = in.Altitude; progCtrl++; m_trackProgress.SetPos(progCtrl); theVisio->OGLDOMNodeListPtr = theVisio->OGLDOMDocumentPtr->getElementsByTagName("trackInsideSegment"); theVisio->OGLDOMNodePtr = theVisio->OGLDOMNodeListPtr->item[0]; SUCCESS = theVisio->BuildShape(theVisio->OGLDOMDocumentPtr,theVisio->OGLDOMNodePtr,theVisio->xmlInValuesList); if(SUCCESS == VARIANT_FALSE) throw " Problem creating the inside segment"; } hr = theVisio->OGLDOMDocumentPtr->save(vName); // Save the file to be reloaded to add values if(hr == S_FALSE) throw " Problem Saving Inside segment failed"; SUCCESS = VARIANT_TRUE; hr = S_OK; // run fillList SUCCESS = theVisio->fillxmlPitInValues(); if(SUCCESS == VARIANT_FALSE) throw " Could not create fillxmlPitInValues"; for(PitInCheckedListIter = PitInCheckedList.begin();PitInCheckedListIter != PitInCheckedList.end();PitInCheckedListIter++) { status = "... Building pitSegment..."; m_status.SetWindowText(status); pitin = *PitInCheckedListIter; theVisio->gdXPitIn = pitin.Easting; theVisio->gdYPitIn = pitin.Northing; theVisio->gdZPitIn = pitin.Altitude; progCtrl++; m_trackProgress.SetPos(progCtrl); theVisio->OGLDOMNodeListPtr = theVisio->OGLDOMDocumentPtr->getElementsByTagName("trackPitIn"); theVisio->OGLDOMNodePtr = theVisio->OGLDOMNodeListPtr->item[0]; SUCCESS = theVisio->BuildShape(theVisio->OGLDOMDocumentPtr,theVisio->OGLDOMNodePtr,theVisio->xmlPitInValuesList); if(SUCCESS == VARIANT_FALSE) throw " Problem building pit "; } // end for(PitInCheckedListIter..................) hr = theVisio->OGLDOMDocumentPtr->save(vName); // Save the file to be reloaded to add values if(hr == S_FALSE) throw " Error Saving xml file "; SUCCESS = VARIANT_TRUE; hr = S_OK; // run fillList SUCCESS = theVisio->fillxmlPitInValues(); if(SUCCESS == VARIANT_FALSE) throw " Could not create fillxmlPitInValues"; for(Island1CheckedListIter = Island1CheckedList.begin();Island1CheckedListIter != Island1CheckedList.end();Island1CheckedListIter++) { status = "... Building island1Segment..."; m_status.SetWindowText(status); pitin = *Island1CheckedListIter; theVisio->gdXPitIn = pitin.Easting; theVisio->gdYPitIn = pitin.Northing; theVisio->gdZPitIn = pitin.Altitude; progCtrl++; m_trackProgress.SetPos(progCtrl); theVisio->OGLDOMNodeListPtr = theVisio->OGLDOMDocumentPtr->getElementsByTagName("trackPitIn"); theVisio->OGLDOMNodePtr = theVisio->OGLDOMNodeListPtr->item[1]; SUCCESS = theVisio->BuildShape(theVisio->OGLDOMDocumentPtr,theVisio->OGLDOMNodePtr,theVisio->xmlPitInValuesList); if(SUCCESS == VARIANT_FALSE) throw " Problem building island1 "; } // end for(Island1CheckedListIter..................) hr = theVisio->OGLDOMDocumentPtr->save(vName); // Save the file to be reloaded to add values if(hr == S_FALSE) throw " Error Saving xml file "; SUCCESS = VARIANT_TRUE; hr = S_OK; ///// run fillList SUCCESS = theVisio->fillxmlStartStopValues(); if(SUCCESS == VARIANT_FALSE) throw " could not create xmlstartstopvalues"; for(StartStopListIter = StartStopList.begin();StartStopListIter != StartStopList.end();StartStopListIter++) { status = "... Building startstop Line..."; m_status.SetWindowText(status); startstop = *StartStopListIter; trackMapVals refPoint,inPoint,outPoint; refPoint.Easting = startstop.BeginX; refPoint.Northing = startstop.BeginY; //getClosestPoint(InCheckedList,refPoint,inPoint); getClosestPoint(OutCheckedList,refPoint,outPoint); getClosestPoint(InCheckedList,refPoint,inPoint); // startstop.BeginZ = outPoint.Altitude; startstop.EndZ = inPoint.Altitude; theVisio->gdX = startstop.BeginX; theVisio->gdY = startstop.BeginY; theVisio->gdZ = startstop.BeginZ; theVisio->gdEndX = startstop.EndX; theVisio->gdEndY = startstop.EndY; theVisio->gdEndZ = startstop.EndZ; progCtrl++; m_trackProgress.SetPos(progCtrl); theVisio->OGLDOMNodeListPtr = theVisio->OGLDOMDocumentPtr->getElementsByTagName("trackStartStopSegment"); theVisio->OGLDOMNodePtr = theVisio->OGLDOMNodeListPtr->item[0]; SUCCESS = theVisio->BuildShape(theVisio->OGLDOMDocumentPtr,theVisio->OGLDOMNodePtr,theVisio->xmlStartStopList); if(SUCCESS == VARIANT_FALSE) throw " Problem building startstop segment"; } hr = theVisio->OGLDOMDocumentPtr->save(vName); // Save the file to be reloaded to add values if(hr == S_FALSE) throw "Problem saving file "; ////////////// Build the turn values SUCCESS = VARIANT_TRUE; hr = S_OK; SUCCESS = theVisio->fillxmlTurnValues();// This function creates // the xmlformat to fill the necessary values. // (other methods could be used but this was one of the solutions if(SUCCESS == VARIANT_FALSE) throw "Could not run fillxmlTurnValues "; for(TurnNoListIter = TurnNoList.begin();TurnNoListIter != TurnNoList.end();TurnNoListIter++) { status = "... Building turnNos Segment..."; m_status.SetWindowText(status); turn = *TurnNoListIter; theVisio->gdXTurn = turn.Easting; theVisio->gdYTurn = turn.Northing; theVisio->gdZTurn = turn.Altitude; theVisio->gdTurnNo = turn.Turnvalue; theVisio->gdFontType = turn.TurnfontType; theVisio->gdTurnAngle = turn.TurnAngle; progCtrl++; m_trackProgress.SetPos(progCtrl); theVisio->OGLDOMNodeListPtr = theVisio->OGLDOMDocumentPtr->getElementsByTagName("turnNos"); theVisio->OGLDOMNodePtr = theVisio->OGLDOMNodeListPtr->item[0]; SUCCESS = theVisio->BuildShape(theVisio->OGLDOMDocumentPtr,theVisio->OGLDOMNodePtr,theVisio->xmlTurnValuesList); if(SUCCESS == VARIANT_FALSE) throw " Problem creating the turn segment"; } hr = theVisio->OGLDOMDocumentPtr->save(vName); // Save the file to be reloaded to add values if(hr == S_FALSE) throw " Saving turn Numbers failed"; // code to build speed traps // should be fairly simple // Initially we init COMPtrs to point to the SpeedTraps element theVisio->initializePtrsToBuildSpeedTrap(vName); // After intializing let us fill the zonestructure list ///// run theVisio->fillxmlZoneStructureValues(); SUCCESS = theVisio->fillxmlSpeedTrapStructureValues(); if(SUCCESS == VARIANT_FALSE) throw " could not create xmlSpeedTrapStructureValues"; for(speedtrapListIter = speedtrapList.begin();speedtrapListIter != speedtrapList.end();speedtrapListIter++) { status = "... Building speedtraps ..."; m_status.SetWindowText(status); speedtrap = *speedtrapListIter; theVisio->gdX = speedtrap.BeginX; theVisio->gdY = speedtrap.BeginY; theVisio->gdZ = speedtrap.BeginZ; theVisio->gdEndX = speedtrap.EndX; theVisio->gdEndY = speedtrap.EndY; theVisio->gdEndZ = speedtrap.EndZ; theVisio->gdName = speedtrap.speedtrapName; progCtrl++; m_trackProgress.SetPos(progCtrl); SUCCESS = theVisio->BuildShape(theVisio->DOMDocumentPtr,theVisio->DOMNodePtr,theVisio->xmlSpeedTrapStructureList); if(SUCCESS == VARIANT_FALSE) throw " Problem building Zone1 segment"; } // end for(speedtrapListIter = speedtrapList.begin();speedtrapListIter != speedtrapList.end();speedtrapListIter++) hr = theVisio->DOMDocumentPtr->save(vName); // Save the file to be reloaded to add values if(hr == S_FALSE) throw "Problem saving file "; // the new Zone structure will be used to fill both the In and Out // Zone Structure based on the condition that we do have an in and an out // for each zone if we do not possess an in and an out, we terminate // Initially we init COMPtrs to point to the Zones element theVisio->initializePtrsToBuildZone(vName); // After intializing let us fill the zonestructure list ///// run theVisio->fillxmlZoneStructureValues(); SUCCESS = theVisio->fillxmlZoneStructureValues(); if(SUCCESS == VARIANT_FALSE) throw " could not create xmlZoneStructureValues"; for(ZoneInListIter = ZoneInList.begin();ZoneInListIter != ZoneInList.end();ZoneInListIter++) { // zonein = *ZoneInListIter; for(ZoneOutListIter = ZoneOutList.begin();ZoneOutListIter != ZoneOutList.end();ZoneOutListIter++) { zoneout = *ZoneOutListIter; if(zonein.speedtrapName == zoneout.speedtrapName) { // Check to see if the name matches and then build the file status = "... Building Zones..."; m_status.SetWindowText(status); status = " Matching Zones Found ..."; m_status.SetWindowText(status); theVisio->gdZoneName = zonein.speedtrapName; theVisio->gdXZoneIn1 = zonein.BeginX; theVisio->gdYZoneIn1 = zonein.BeginY; theVisio->gdZZoneIn1 = zonein.BeginZ; progCtrl++; m_trackProgress.SetPos(progCtrl); theVisio->gdXZoneIn2 = zonein.EndX; theVisio->gdYZoneIn2 = zonein.EndY; theVisio->gdZZoneIn2 = zonein.EndZ; progCtrl++; m_trackProgress.SetPos(progCtrl); theVisio->gdXZoneOut1 = zoneout.BeginX; theVisio->gdYZoneOut1 = zoneout.BeginY; theVisio->gdZZoneOut1 = zoneout.BeginZ; progCtrl++; m_trackProgress.SetPos(progCtrl); theVisio->gdXZoneOut2 = zoneout.EndX; theVisio->gdYZoneOut2 = zoneout.EndY; theVisio->gdZZoneOut2 = zoneout.EndZ; progCtrl++; m_trackProgress.SetPos(progCtrl); SUCCESS = theVisio->BuildShape(theVisio->DOMDocumentPtr,theVisio->DOMNodePtr,theVisio->xmlZoneStructureList); if(SUCCESS == VARIANT_FALSE) throw " Problem building Zone1 segment"; } // end if(zonein.speedtrapName == zoneout.speedtrapName) }// end for(ZoneOutListIter = ZoneOutList.begin();ZoneOutListIter != ZoneOutList.end();ZoneOutListIter++) }// end for(ZoneInListIter = ZoneInList.begin();ZoneInListIter != ZoneInList.end();ZoneInListIter++) hr = theVisio->DOMDocumentPtr->save(vName); // Save the file to be reloaded to add values if(hr == S_FALSE) throw "Problem saving file "; status = ".........Track File Complete..........."; m_status.SetWindowText(status); if(AfxMessageBox("Do you want to create the Altitude file ?",MB_YESNO | MB_ICONINFORMATION |MB_DEFBUTTON2) == IDYES) { status = ".........Building Altitude File Please Wait..........."; m_status.SetWindowText(status); /////////////// start altitude tool///////////////////// // The sorted list is used to build the altitude file // to create the region the list has to be // closed in other words.... the beginning of the list // should be joined to the end of the list // this forms a closed loop and helps in creating regions // if(OutCheckedList.size() > 3) { fstListIter = OutCheckedList.begin(); OutCheckedList.push_back(*fstListIter); } else { AfxMessageBox(" Outside Segment of track has less than 3 elements, Please Check the selected file",MB_ICONSTOP,NULL); exit(0); } if(InCheckedList.size() > 3) { fstListIter = InCheckedList.begin(); InCheckedList.push_back(*fstListIter); } else { AfxMessageBox(" Inside Segment of track has less than 3 elements, Please Check the selected file",MB_ICONSTOP,NULL); exit(0); } if(FullInCheckedList.size() > 3) { fstListIter = FullInCheckedList.begin(); FullInCheckedList.push_back(*fstListIter); // if fullinside layer exists and has // 3 or more points......... // we assume the fullinside to be the true inside // else we use the inside as the trueinside InCheckedList.clear(); for(FullInCheckedListIter = FullInCheckedList.begin();FullInCheckedListIter != FullInCheckedList.end();FullInCheckedListIter++) InCheckedList.push_back(*FullInCheckedListIter); } if(PitInCheckedList.size() > 0) // >0 is to make sure there is a pit with some shapes { fstListIter = PitInCheckedList.begin(); PitInCheckedList.push_back(*fstListIter); } // determine the min,max,Eastin and Northin leastNorthing = 12000000.0; highestNorthing = 0.0; leastEasting = 12000000.0; highestEasting = 0.0; // check minEasting , minNorthing, maxEasting and maxNorthing for(OutCheckedListIter = OutCheckedList.begin();OutCheckedListIter != OutCheckedList.end();OutCheckedListIter++) { out = *OutCheckedListIter; double newEast = out.Easting; double newNorth = out.Northing; if (newEast < leastEasting) { leastEasting = newEast; } if (newEast > highestEasting) { highestEasting = newEast; } if (newNorth > highestNorthing) { highestNorthing = newNorth; } if (newNorth < leastNorthing) { leastNorthing = newNorth; } } // end for(OutCheckedListIter = OutCheckedList.begin();OutCheckedListIter != OutCheckedList.end();OutCheckedListIter++) /////////////////////////////////////// /// create the grid 1m X 1m based on the Easting and northing values // trackMapVals data structure for holding Easting,Northing,Altitude,etc //trackMapVals **z; // **z is an array of pointers /// colMax represents number of columns /// rowMax represents number of rows colMax = abs(ceil(highestEasting) - floor(leastEasting)) + 4; rowMax = abs(ceil(highestNorthing) - floor(leastNorthing)) + 4; ///////////// Allocate pointers to array of pointers based on number of rows ////////////// or based on the difference of maxNorthing and minNorthing /////////// if((trackGrid = (trackMapVals **) malloc(rowMax * sizeof(trackMapVals *))) == NULL) throw " Could not allocate memory " ; ///////// if successful //////////////// ////////// Allocate memory in rowwise order, i.e the first ///////// pointer is an array to the first row ........ the second is pointer to second.... ///////// and so on till the maxRow is reached....... ////////// throw exceptions after each rowwise allocation for(int y = 0;y < rowMax;y++) { // malloc memory of 1 row each time if((trackGrid[y] = (trackMapVals *) malloc(colMax * sizeof(trackMapVals))) == NULL) { free(trackGrid); throw " Could not allocate memory,Close some programs and try again"; } // fill the row x and y co-ordinates with respective Easting(x) and Northing(y) values for(int x = 0;x < colMax;x++) { /// poplulate the array in increment of 1m tempMap.Easting = abs(floor(leastEasting)) + x - 2; tempMap.Northing = abs(floor(leastNorthing)) + y - 2; tempMap.Altitude = m_altitude; tempMap.Filled = FALSE; tempMap.InterPolated = FALSE; trackGrid[y][x]= tempMap; // tempMap is a struct object which has Easting,Northing,Altitude //rcCurrent.render(pDC,x,y); }// end for(int x = 0;x < colMax;x++) }// end for(int y = 0;y < rowMax;y++) // ////////////////////////////////////////////// ///////// modifications to the code based on //////// thompson track irregularity in altitude reporting //////////////////////////////////////////////// /////////////////////////////////// ////////////// //// funcToInterpolateTrack(list); ///// this function will take a list of points as a parameter and interpolate within the given list ////// //funcToInterpolateTrack(FullInCheckedList); //funcToInterpolateTrack(OutCheckedList); ///////// Determine the region : ///////// the region is determined by taking two consecutive points on the inside of the track ///////// the midpoint of the two point is then joined with ///////// the shortest distance on the outside. ///////// the two points on inside and one point on outside determine a triangular region BOOL FOUND; FOUND = FALSE; /////// clear myCurRgnIn List if(myCurRgnIn.empty() == FALSE) myCurRgnIn.clear(); ////// clear myCurRgnOut List if(myCurRgnOut.empty() == FALSE) myCurRgnOut.clear(); ////// clear the inlist if(InList.empty() == FALSE) InList.clear(); //////// fill the list with sorted points for(InCheckedListIter = InCheckedList.begin();InCheckedListIter != InCheckedList.end();InCheckedListIter++) { cur = *InCheckedListIter; InList.push_back(cur); } ////////// iterate thru the list till empty while(!InList.empty()) { fstListIter = InList.begin(); InListIter = InList.begin(); // increment the Iterator to point to the second member of the list for(int t = 0; t < 1;t++) ++InListIter; if(InList.size() == 1) { InList.erase(fstListIter); } if(InList.size() > 1) // if size > 1 { first = *fstListIter; // first point in sorted list next = *InListIter; // next point in sorted list // mid point of the first and next double midEasting = (first.Easting + next.Easting)/2; double midNorthing = (first.Northing + next.Northing)/2; UTMPosition UTMPositionIn(0,midNorthing,midEasting); curListIter = OutCheckedList.begin(); cur = *curListIter; UTMPosition UTMPositionOut(0,cur.Northing,cur.Easting); // find distance between the mid inside point and first outside point UTMPositionIn.angleTo(UTMPositionOut,prevangle,prevrange); while(curListIter != OutCheckedList.end()) { ++curListIter; cur = *curListIter; UTMPosition UTMPositionNextOut(0,cur.Northing,cur.Easting); UTMPositionIn.angleTo(UTMPositionNextOut,angle,range); if(prevrange > range) { prevrange = range; tmpListIter = curListIter; FOUND = TRUE; } // end if(prevrange > range) } // end while(curListIter != OutCheckedList.end()) if(!FOUND) { tmpListIter = OutCheckedList.begin(); tempMap = *tmpListIter; } if(FOUND) { tempMap = *tmpListIter; FOUND = FALSE; } //////////// fill the list (set of 3 points) //////////// in the order firstIn has the first inside point ////////////// secondIn has the next inside point ////////////// thirdOut has the outside track point curRgn.firstIn = first; curRgn.secondIn = next; curRgn.thirdOut = tempMap; myCurRgnIn.push_back(curRgn); //rcCurrent.render(pDC,tempMap.Easting-leastEasting,tempMap.Northing-leastNorthing); //rcCurrent.render(pDC,first.Easting-leastEasting,first.Northing-leastNorthing); //rcCurrent.render(pDC,next.Easting-leastEasting,next.Northing-leastNorthing); //pDC->MoveTo(tempMap.Easting-leastEasting,tempMap.Northing-leastNorthing); //pDC->LineTo(first.Easting-leastEasting,first.Northing-leastNorthing); //pDC->MoveTo(tempMap.Easting-leastEasting,tempMap.Northing-leastNorthing); //pDC->LineTo(next.Easting-leastEasting,next.Northing-leastNorthing); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); if(fstListIter != InList.end()) InList.erase(fstListIter); } // end else } // end while(!InList.empty()) //////////////////////////////////// ////////// join the first region to end of list //////// this is to determine the regions from outside to inside /////// if(myCurRgnIn.size() > 0) { myCurRgnIter = myCurRgnIn.begin(); myCurRgnIn.push_back(*myCurRgnIter); } ////////////// using the triangular vertices created ////////////// from inside to outside , create triangular vertices ///////////// from outside to inside for(myCurRgnIter = myCurRgnIn.begin();myCurRgnIter != myCurRgnIn.end();myCurRgnIter++) { Rgn thisRgn,nextRgn; myCurRgnIterNext = myCurRgnIter; // increment the iterator to point to the next item in list //////// ++myCurRgnIterNext should work , but i found some problems //////// for(int a = 0; a < 1;a++) ++myCurRgnIterNext; if(myCurRgnIterNext != myCurRgnIn.end()) { thisRgn = *myCurRgnIter; nextRgn = *myCurRgnIterNext; curRgn.firstIn = thisRgn.secondIn; curRgn.secondIn = thisRgn.thirdOut; curRgn.thirdOut = nextRgn.thirdOut; myCurRgnOut.push_back(curRgn); } // end if(myCurRgnIterNext != myCurRgnIn.end()) } // end for(myCurRgnIter = myCurRgnIn.begin();myCurRgnIter != myCurRgnIn.end();myCurRgnIter++) //////////////////////////////////////////// //////// pass the myCurRgnIn list thru the grid to triangulate the grid ///////////////////////////////////// for(myCurRgnIter = myCurRgnIn.begin();myCurRgnIter != myCurRgnIn.end();myCurRgnIter++) { Rgn newRgn; newRgn = *myCurRgnIter; CPoint ptVertex[3]; // holds the easting and northing points of a region double x1,x2,x3,y1,y2,y3,z1,z2,z3; int myMinEast,myMaxEast,myMinNorth,myMaxNorth; x1 = ptVertex[0].x = newRgn.firstIn.Easting; y1 = ptVertex[0].y = newRgn.firstIn.Northing; z1 = newRgn.firstIn.Altitude; x2 = ptVertex[1].x = newRgn.secondIn.Easting; y2 = ptVertex[1].y = newRgn.secondIn.Northing; z2 = newRgn.secondIn.Altitude; x3 = ptVertex[2].x = newRgn.thirdOut.Easting; y3 = ptVertex[2].y = newRgn.thirdOut.Northing; z3 = newRgn.thirdOut.Altitude; if(x1 <= x2) { myMinEast = abs(x1); myMaxEast = abs(x2); } else { myMinEast = abs(x2); myMaxEast = abs(x1); } if(myMinEast > x3) myMinEast = abs(x3); if(myMaxEast < x3) myMaxEast = abs(x3); if(y1 <= y2) { myMinNorth = abs(y1); myMaxNorth = abs(y2); } else { myMinNorth = abs(y2); myMaxNorth = abs(y1); } if(myMinNorth > y3) myMinNorth = abs(y3); if(myMaxNorth < y3) myMaxNorth = abs(y3); myMinEast = myMinEast - leastEasting ; myMaxEast = myMaxEast - leastEasting + 4; myMinNorth = myMinNorth - leastNorthing; myMaxNorth = myMaxNorth - leastNorthing + 4; if((rgnA.CreatePolygonRgn(ptVertex, 3, WINDING))== NULL) { /////////// Free the allocated memory rowwise for(int freeMe = 0;freeMe < rowMax;freeMe++) free(trackGrid[freeMe]); /// finally free the array of pointers. free(trackGrid); throw " Could Not Create Region "; } double A,B,C,D; A = y1*(z2 - z3) + y2*(z3 - z1) + y3*(z1 - z2); B = z1*(x2 - x3) + z2*(x3 - x1) + z3*(x1 - x2); C = x1*(y2 - y3) + x2*(y3 - y1) + x3*(y1 - y2); D = -(x1*(y2*z3 - y3*z2) + x2*(y3*z1 - y1*z3) + x3*(y1*z2 - y2*z1)); for(int ky = myMinNorth;ky < myMaxNorth;ky++) { for(int kx = myMinEast;kx < myMaxEast;kx++) { next = trackGrid[ky][kx]; ///////////////////////// //// determine if the point is in region if(rgnA.PtInRegion(abs(next.Easting),abs(next.Northing))) { next.Filled = TRUE; next.Altitude = (-D -(A*next.Easting) -(B*next.Northing))/C; if(next.Altitude > 0) next.InterPolated = TRUE; trackGrid[ky][kx] = next; //rcCurrent.render(pDC,next.Easting-leastEasting,next.Northing-leastNorthing); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } // end if(PtInRegion(rgnA,tempMap.Easting,tempMap.Northing)) /* if((floor(newRgn.firstIn.Easting) == tempMap.Easting) && (floor(newRgn.firstIn.Northing) == tempMap.Northing)) { tempMap.filled = TRUE; trackGrid[ky][kx] = tempMap; rcCurrent.render(pDC,tempMap.Easting-leastEasting,tempMap.Northing-leastNorthing); } if((floor(newRgn.secondIn.Easting) == tempMap.Easting) && (floor(newRgn.secondIn.Northing) == tempMap.Northing)) { tempMap.filled = TRUE; trackGrid[ky][kx] = tempMap; rcCurrent.render(pDC,tempMap.Easting-leastEasting,tempMap.Northing-leastNorthing); } if((floor(newRgn.thirdOut.Easting) == tempMap.Easting) && (floor(newRgn.thirdOut.Northing) == tempMap.Northing)) { tempMap.filled = TRUE; trackGrid[ky][kx] = tempMap; rcCurrent.render(pDC,tempMap.Easting-leastEasting,tempMap.Northing-leastNorthing); } */ }// end for(int kx = 0;kx < colMax;kx++) }// end for(int ky = 0;ky < rowMax;ky++) //// delete the previous region so a new one can be created rgnA.DeleteObject(); } // end for(myCurRgnIter = myCurRgnIn.begin();myCurRgnIter != myCurRgnIn.end();myCurRgnIter++) for(myCurRgnIter = myCurRgnIn.begin();myCurRgnIter != myCurRgnIn.end();myCurRgnIter++) { Rgn newRgn; newRgn = *myCurRgnIter; double x1,x2,x3,y1,y2,y3,z1,z2,z3; x1 = newRgn.firstIn.Easting; y1 = newRgn.firstIn.Northing; z1 = newRgn.firstIn.Altitude; x2 = newRgn.secondIn.Easting; y2 = newRgn.secondIn.Northing; z2 = newRgn.secondIn.Altitude; x3 = newRgn.thirdOut.Easting; y3 = newRgn.thirdOut.Northing; z3 = newRgn.thirdOut.Altitude; double A,B,C,D; A = y1*(z2 - z3) + y2*(z3 - z1) + y3*(z1 - z2); B = z1*(x2 - x3) + z2*(x3 - x1) + z3*(x1 - x2); C = x1*(y2 - y3) + x2*(y3 - y1) + x3*(y1 - y2); D = -(x1*(y2*z3 - y3*z2) + x2*(y3*z1 - y1*z3) + x3*(y1*z2 - y2*z1)); /////////////////////////////////////////////// ///////// fill the points adjacent to the line with ///////// the bresneham algorithm and stretch 2 grid spaces //////// in all directions................ //modifiedlineFillAlgorithm(x1,y1,x2,y2,A,B,C,D); //modifiedlineFillAlgorithm(x2,y2,x3,y3,A,B,C,D); //modifiedlineFillAlgorithm(x3,y3,x1,y1,A,B,C,D); lineFillAlgorithm(x1,y1,x2,y2,A,B,C,D); lineFillAlgorithm(x2,y2,x3,y3,A,B,C,D); lineFillAlgorithm(x3,y3,x1,y1,A,B,C,D); } // end for(myCurRgnIter = myCurRgnIn.begin();myCurRgnIter != myCurRgnIn.end();myCurRgnIter++) //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); /* for(int kyy = 0; kyy < rowMax; kyy++) { for(int kxx = 0; kxx < colMax;kxx++) { tempMap = trackGrid[kyy][kxx]; if((tempMap.InterPolated == FALSE)&& (tempMap.Filled == TRUE)) { char buff[256]; sprintf(buff,"%f",tempMap.Altitude); m_Easting.SetWindowText(buff); rcCurrent.render(pDC,tempMap.Easting-leastEasting,tempMap.Northing-leastNorthing); dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } } */ // open reg key if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Sumaria\\TrackTool",0,KEY_QUERY_VALUE,&hKey) != ERROR_SUCCESS) { /////////// Free the allocated memory rowwise for(int freeMe = 0;freeMe < rowMax;freeMe++) free(trackGrid[freeMe]); /// finally free the array of pointers. free(trackGrid); throw " Failed to Open Registry "; } dwBufLen = 255; if(RegQueryValueEx(hKey,_T("InstallPath"),NULL,NULL,(LPBYTE) szProductType,&dwBufLen) != ERROR_SUCCESS) { /////////// Free the allocated memory rowwise for(int freeMe = 0;freeMe < rowMax;freeMe++) free(trackGrid[freeMe]); /// finally free the array of pointers. free(trackGrid); throw " Failed to Query Registry "; } if(RegCloseKey(hKey) != ERROR_SUCCESS) { /////////// Free the allocated memory rowwise for(int freeMe = 0;freeMe < rowMax;freeMe++) free(trackGrid[freeMe]); /// finally free the array of pointers. free(trackGrid); throw " Failed to Close Registry "; } status = szProductType; status.Append("altData.txt"); FILE *altDat; // file stream to open a file if((altDat = fopen(status,"w+ | _O_CREAT")) == NULL) { /////////// Free the allocated memory rowwise for(int freeMe = 0;freeMe < rowMax;freeMe++) free(trackGrid[freeMe]); /// finally free the array of pointers. free(trackGrid); throw " Problem creating altData.txt file "; } // store the no of columns and no of rows if((fprintf(altDat,"No of Columns = %u,No of Rows = %u\n",colMax,rowMax)) < 0) { /////////// Free the allocated memory rowwise for(int freeMe = 0;freeMe < rowMax;freeMe++) free(trackGrid[freeMe]); /// finally free the array of pointers. free(trackGrid); throw "Error in writing data to the file"; } if((fprintf(altDat,"Northing,Easting,Altitude\n")) < 0) { /////////// Free the allocated memory rowwise for(int freeMe = 0;freeMe < rowMax;freeMe++) free(trackGrid[freeMe]); /// finally free the array of pointers. free(trackGrid); throw "Error in writing data to the file"; } ///////////////////////////////// /// write the first element of the grid tempMap = trackGrid[0][0]; if((fprintf(altDat,"MinEasting = %f,MinNorthing = %f\n",tempMap.Easting,tempMap.Northing)) < 0) { /////////// Free the allocated memory rowwise for(int freeMe = 0;freeMe < rowMax;freeMe++) free(trackGrid[freeMe]); /// finally free the array of pointers. free(trackGrid); throw "Error in writing data to the file"; } tempMap = trackGrid[rowMax - 1][colMax - 1]; if((fprintf(altDat,"MaxEasting = %f,MaxNorthing = %f\n",tempMap.Easting,tempMap.Northing)) < 0) { /////////// Free the allocated memory rowwise for(int freeMe = 0;freeMe < rowMax;freeMe++) free(trackGrid[freeMe]); /// finally free the array of pointers. free(trackGrid); throw "Error in writing data to the file"; } for(int kyy = 0; kyy < rowMax; kyy++) { for(int kxx = 0; kxx < colMax;kxx++) { tempMap = trackGrid[kyy][kxx]; //if((tempMap.Filled == TRUE) && (tempMap.InterPolated == TRUE)) if((fprintf(altDat,"%f,%f,%f\n",tempMap.Northing,tempMap.Easting,tempMap.Altitude)) < 0) { /////////// Free the allocated memory rowwise for(int freeMe = 0;freeMe < rowMax;freeMe++) free(trackGrid[freeMe]); /// finally free the array of pointers. free(trackGrid); throw " Error in writing Grid data to file"; } } } if((fclose(altDat)) == EOF) { /////////// Free the allocated memory rowwise for(int freeMe = 0;freeMe < rowMax;freeMe++) free(trackGrid[freeMe]); /// finally free the array of pointers. free(trackGrid); throw " Could not close the file altDat "; } /* for(int kyy = 0; kyy < rowMax; kyy++) { for(int kxx = 0; kxx < colMax;kxx++) { tempMap = trackGrid[kyy][kxx]; if(tempMap.InterPolated == TRUE) { OutCheckedList.push_back(tempMap); } } } */ /////////// Free the allocated memory rowwise for(int freeMe = 0;freeMe < rowMax;freeMe++) free(trackGrid[freeMe]); /// finally free the array of pointers. free(trackGrid); } // end if /////////////// end altitude tool///////////////////// status = " .............Complete........."; m_status.SetWindowText(status); ::SetCursor(m_hcurArrow); MessageBox(" The XML File is ready for use, THANK YOU "); m_createXML.EnableWindow(TRUE); GetDlgItem(IDC_DATA_SOURCE_FILE)->EnableWindow(TRUE); m_trackProgress.SetPos(0); } // end try block catch(int errThrow) { status = "Error............."; m_status.SetWindowText(status); if(errThrow == 1) { AfxMessageBox(" Unable to load the file, May be it is not the correct file",MB_OK); //OnBnClickedCreateXml(); break; } if(errThrow == 2) { MSXML2::IXMLDOMParseErrorPtr pError; pError = theVisio->DOMDocumentPtr->parseError; _bstr_t parseError =_bstr_t("At line ")+ _bstr_t(pError->Getline()) + _bstr_t("\n")+ _bstr_t(pError->Getreason()); em.MessageBox(parseError, "Check File again : Load failed ",MB_OK); if(pError == NULL) pError->Release(); m_inputFile.SetWindowText(NULL); //OnBnClickedCreateXml(); break; } } // end catch(int errThrow) catch(const char* str) { status = "Error............."; m_status.SetWindowText(status); em.MessageBox(str,"",MB_OK); m_inputFile.SetWindowText(NULL); GetDlgItem(IDC_DATA_SOURCE_FILE)->EnableWindow(TRUE); m_createXML.EnableWindow(TRUE); break; } // end catch(const char* str) catch(_com_error &e) { status = "Error............."; m_status.SetWindowText(status); const char * err; err = e.ErrorMessage(); em.MessageBox(err,"COM ERROR IN CREATE XML",MB_OK); break; } catch(...) { status = "Error............."; m_status.SetWindowText(status); em.MessageBox("Unknown Error in Create XML :","",MB_OK); break; } status = ""; m_status.SetWindowText(status); break; case IDCANCEL: // Do something status = ""; m_status.SetWindowText(status); GetDlgItem(IDC_DATA_SOURCE_FILE)->EnableWindow(TRUE); m_createXML.EnableWindow(TRUE); break; default: // do something break; }; // end switch } // end void CTrackToolDlg::OnBnClickedCreateXml() void CTrackToolDlg::OnBnClickedStart() { // TODO: Add your control notification handler code here GetDlgItem(IDC_START)->EnableWindow(FALSE); hr = S_OK; try { m_createXML.EnableWindow(FALSE); m_appendFile.EnableWindow(FALSE); m_outputFile.GetWindowText(status); vName.SetString(status); hr = theVisio->DOMDocumentPtr->save(vName); if(hr == S_FALSE) throw "Failed to save document for output"; ////////////////////////////////////////////// ///// the function initializePtrsToBuildShape(vName) ///// ///// assigns the DOMNodePtr of CVisio class ///// ///// to the first Shape Element ///// ///// A tag element called Shape has been deliberately ///// ///// introduced in a input.vdx file bundled with the setup ///// ///// any changes to the input.vdx file will lead to erroneous errors ///// ///// and program failure.......... ///// ///// in order to build the output.vdx file It has to ///// ///// have one Shape Element, according to the algorithm ///// ///// adopted......... other intuitive methods can be implemented ///// theVisio->initializePtrsToBuildShape(vName); ////////////////////////// ///////////////////////////// ///// the fillxmlShape() function creates a Shape structure ///// for visio..... it helps to pass the list. ///// the BuildShape function looks for elements ///// based on the list supplied................ ///// It was the solution on hand at that time ///// a more intuitive approach will be later adopted SUCCESS = theVisio->fillxmlShape(); if(SUCCESS == VARIANT_FALSE) throw " Failed to fill Shape list "; m_saveVisioFile = TRUE; fileInputTimer = SetTimer(1234,0,0); } // end try block catch(const char *str) { em.MessageBox(str,"",MB_OK); OnBnClickedCancelSourceFile(); } catch(_com_error &e) { const char * err; err = e.ErrorMessage(); em.MessageBox(err,"COM ERROR IN START",MB_OK); } catch(...) { em.MessageBox("Unknown Error","",MB_OK); OnBnClickedCancelSourceFile(); } } void CTrackToolDlg::OnBnClickedAppend() { // TODO: Add your control notification handler code here hr = S_OK; CFileDialog openDialog(TRUE, ".*"); openDialog.m_ofn.lpstrInitialDir = ""; openDialog.m_ofn.lpstrFilter = "All Files\0*.*\0\0"; // Return value when the File dialog box opens INT_PTR nRet = -1; nRet = openDialog.DoModal(); // Handle the return value from DoModal switch ( nRet ) { case -1: em.MessageBox("Dialog Box could not be created !","",MB_OK); break; case IDABORT: // Do something em.MessageBox("problem opening file, cause:", "file may not exist\n Close and Retry", MB_OK); exit(0); break; case IDOK: // Do something try { hr = S_OK; int errThrow = 0; status = openDialog.GetPathName(); m_inputFile.SetWindowText(status); vName.Clear(); m_inputFile.GetWindowText(status); vName.SetString(status); if(theVisio != NULL) { theVisio = NULL; delete theVisio; } theVisio = new CVisio(); theVisio->DOMDocumentPtr->async = FALSE; theVisio->DOMDocumentPtr->validateOnParse = TRUE; hr = theVisio->DOMDocumentPtr->load(vName); if( hr == S_FALSE) throw 2; if(theVisio->DOMDocumentPtr->readyState != 4) { while(theVisio->DOMDocumentPtr->readyState != 4) { ::Sleep(1000); } // end while } // end if //theVisio->DOMNodeListPtr = theVisio->DOMDocumentPtr->getElementsByTagName("Shape"); theVisio->DOMNodeListPtr = theVisio->DOMDocumentPtr->selectNodes(_bstr_t("//Shape")); // it is important to know the num of Shape Elements in the visio file // the new shapes will be added from here. index = theVisio->DOMNodeListPtr->Getlength(); ++index; // get the origins // get Origins of the Visio File //theVisio->DOMNodeListPtr = theVisio->DOMDocumentPtr->getElementsByTagName("XRulerOrigin"); theVisio->DOMNodePtr = theVisio->DOMDocumentPtr->selectSingleNode(_bstr_t("//Pages/Page/PageSheet/RulerGrid/XRulerOrigin")); //ASSERT(theVisio->DOMNodeListPtr != NULL); //if(theVisio->DOMNodeListPtr == NULL) throw " Please check the file you selected"; //theVisio->DOMNodePtr = theVisio->DOMNodeListPtr->item[1]; //ASSERT(theVisio->DOMNodePtr != NULL); if(theVisio->DOMNodePtr == NULL) throw " Have you Selected the correct file? "; theVisio->vt.Clear(); theVisio->vt = theVisio->DOMNodePtr->GetnodeTypedValue(); m_visXOrigin = myabs(double(theVisio->vt)/VISIOFACTOR); //theVisio->DOMNodeListPtr = theVisio->DOMDocumentPtr->getElementsByTagName("YRulerOrigin"); theVisio->DOMNodePtr = theVisio->DOMDocumentPtr->selectSingleNode(_bstr_t("//Pages/Page/PageSheet/RulerGrid/YRulerOrigin")); //ASSERT(theVisio->DOMNodeListPtr != NULL); //theVisio->DOMNodePtr = theVisio->DOMNodeListPtr->item[1]; ASSERT(theVisio->DOMNodePtr != NULL); theVisio->vt.Clear(); theVisio->vt = theVisio->DOMNodePtr->GetnodeTypedValue(); m_visYOrigin = myabs(double(theVisio->vt)/VISIOFACTOR); theMap->minEasting = m_visXOrigin; theMap->minNorthing = m_visYOrigin; xFactor = 0; yFactor = 0; ////////////////////////////////////////////////////////////////// } // end try block catch(int errThrow) { if(errThrow == 1){ AfxMessageBox(" Unable to load the file, May be it is not the correct file",MB_OK); //OnBnClickedCreateXml(); break; } if(errThrow == 2) { MSXML2::IXMLDOMParseErrorPtr pError; pError = theVisio->DOMDocumentPtr->parseError; _bstr_t parseError =_bstr_t("At line ")+ _bstr_t(pError->Getline()) + _bstr_t("\n")+ _bstr_t(pError->Getreason()); em.MessageBox(parseError, "Check File again : Load failed ",MB_OK); if(pError == NULL) pError->Release(); m_inputFile.SetWindowText(NULL); //OnBnClickedCreateXml(); break; } } catch(const char* str) { em.MessageBox(str,"",MB_OK); m_inputFile.SetWindowText(NULL); m_outputFile.SetWindowText(NULL); GetDlgItem(IDC_START)->EnableWindow(FALSE); break; } catch(_com_error &e) { const char * err; err = e.ErrorMessage(); em.MessageBox(err,"COM ERROR IN APPEND",MB_OK); break; } catch(...) { em.MessageBox("Unknown Error :","",MB_OK); break; } break; case IDCANCEL: // Do something // m_inputFile.SetWindowText(NULL); //m_cancelDataInput.EnableWindow(TRUE); //m_createXML.EnableWindow(TRUE); break; default: // do something break; }; // end switch } // end function void __cdecl newhandler(){ AfxMessageBox("New Handler called ",MB_OK); throw bad_alloc(); return; } //////////////////// //////// there is no need of this function void CTrackToolDlg::OnAshtechVsCMCBoard(){ // Logic to read the CMC data vs Ashtech data // the function returns void } // end of function ///////////////////////////////////////////////////////// ////////// Function lineFillAlgorithm //////// This function is used to walk the line and fill in the remaining //////// spaces adjacent to the line that are not filled and interpolated void CTrackToolDlg::lineFillAlgorithm(double Ax1,double Ay1,double Bx1,double By1,double A1,double B1,double C1,double D1) { //CPaintDC dc(this); //pDC = GetDC(); //RenderableCircle rcCurrent(pDC,RGB(255, 0, 0), (int) __max(2.0 , -4.0), RGB(0, 0, 0)); trackMapVals line; double Ax = abs(Ax1); double Ay = abs(Ay1); double Bx = abs(Bx1); double By = abs(By1); double A = A1; double B = B1; double C = C1; double D = D1; //////////////////// ///////////////////////////////////// //////////// Check and interpolate for Ax and Ay int mx = floor(Ax) - floor(leastEasting) + 2; int my = floor(Ay) - floor(leastNorthing) + 2; line = trackGrid[my][mx]; if(line.Filled == FALSE) { line.Altitude = (-D-(A*Ax)-(B*Ay))/C; if(line.Altitude > 0) { line.InterPolated = TRUE; line.Filled = TRUE; trackGrid[my][mx] = line; //rcCurrent.render(pDC,mx,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } line = trackGrid[my][mx +1]; if(line.Filled == FALSE) { line.Altitude = (-D-(A*(Ax + 1))-(B*Ay))/C; if(line.Altitude > 0) { line.InterPolated = TRUE; line.Filled = TRUE; trackGrid[my][mx + 1] = line; //rcCurrent.render(pDC,mx,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } line = trackGrid[my + 1][mx]; if(line.Filled == FALSE) { line.Altitude = (-D-(A*Ax)-(B*(Ay + 1)))/C; if(line.Altitude > 0) { line.InterPolated = TRUE; line.Filled = TRUE; trackGrid[my + 1][mx] = line; //rcCurrent.render(pDC,mx,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } line = trackGrid[my + 1][mx + 1]; if(line.Filled == FALSE) { line.Altitude = (-D-(A*(Ax + 1))-(B*(Ay + 1)))/C; if(line.Altitude > 0) { line.InterPolated = TRUE; line.Filled = TRUE; trackGrid[my + 1][mx + 1] = line; //rcCurrent.render(pDC,mx,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } //////////////////// ///////////////////////////////////// //////////// Check and interpolate for Bx and By mx = floor(Bx) - floor(leastEasting) + 2; my = floor(By) - floor(leastNorthing) + 2; line = trackGrid[my][mx]; if(line.Filled == FALSE) { line.Altitude = (-D-(A*Bx)-(B*By))/C; if(line.Altitude > 0) { line.InterPolated = TRUE; line.Filled = TRUE; trackGrid[my][mx] = line; //rcCurrent.render(pDC,mx,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } line = trackGrid[my][mx +1]; if(line.Filled == FALSE) { line.Altitude = (-D-(A*(Bx + 1))-(B*By))/C; if(line.Altitude > 0) { line.InterPolated = TRUE; line.Filled = TRUE; trackGrid[my][mx + 1] = line; //rcCurrent.render(pDC,mx,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } line = trackGrid[my + 1][mx]; if(line.Filled == FALSE) { line.Altitude = (-D-(A*Bx)-(B*(By + 1)))/C; if(line.Altitude > 0) { line.InterPolated = TRUE; line.Filled = TRUE; trackGrid[my + 1][mx] = line; //rcCurrent.render(pDC,mx,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } line = trackGrid[my + 1][mx + 1]; if(line.Filled == FALSE) { line.Altitude = (-D-(A*(Bx + 1))-(B*(By + 1)))/C; if(line.Altitude > 0) { line.InterPolated = TRUE; line.Filled = TRUE; trackGrid[my + 1][mx + 1] = line; //rcCurrent.render(pDC,mx,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } ////////////////////////////////////////////////////////////////// //////////// Bresenham's line drawing algorithm //////////// For every point that we intercept , we go two spaces in /////////// 4 directions and interpolate the altitude///////////// //////////// This is just to make sure we hit all the points in the track //////////////////////// //------------------------------------------------------------------------ // INITIALIZE THE COMPONENTS OF THE ALGORITHM THAT ARE NOT AFFECTED BY THE // SLOPE OR DIRECTION OF THE LINE //------------------------------------------------------------------------ int dX = abs(Bx-Ax); // store the change in X and Y of the line endpoints int dY = abs(By-Ay); //------------------------------------------------------------------------ // DETERMINE "DIRECTIONS" TO INCREMENT X AND Y (REGARDLESS OF DECISION) //------------------------------------------------------------------------ int Xincr, Yincr; if (Ax > Bx) { Xincr=-1; } else { Xincr=1; } // which direction in X? if (Ay > By) { Yincr=-1; } else { Yincr=1; } // which direction in Y? //------------------------------------------------------------------------ // BOOLEAN VARIABLE TO CHECK FOR EXTENTS //------------------------------------------------------------------------ BOOL EXTENTS = FALSE; //------------------------------------------------------------------------ // DETERMINE INDEPENDENT VARIABLE (ONE THAT ALWAYS INCREMENTS BY 1 (OR -1) ) // AND INITIATE APPROPRIATE LINE DRAWING ROUTINE (BASED ON FIRST OCTANT // ALWAYS). THE X AND Y'S MAY BE FLIPPED IF Y IS THE INDEPENDENT VARIABLE. //------------------------------------------------------------------------ if (dX >= dY) // if X is the independent variable { int dPr = dY<<1; // amount to increment decision if right is chosen (always) int dPru = dPr - (dX<<1); // amount to increment decision if up is chosen int P = dPr - dX; // decision variable start value for (; dX >= 0; dX--) // process each point in the line one at a time (just use dX) { //EXTENTS = checkExtents(Ax,Ay); //if(EXTENTS == TRUE) pointFillAlgorithm(Ax, Ay, A,B,C,D); // plot the pixel //EXTENTS = FALSE; if (P > 0) // is the pixel going right AND up? { Ax+=Xincr; // increment independent variable Ay+=Yincr; // increment dependent variable P+=dPru; // increment decision (for up) } else // is the pixel just going right? { Ax+=Xincr; // increment independent variable P+=dPr; // increment decision (for right) } } } else // if Y is the independent variable { int dPr = dX<<1; // amount to increment decision if right is chosen (always) int dPru = dPr - (dY<<1); // amount to increment decision if up is chosen int P = dPr - dY; // decision variable start value for (; dY >= 0; dY--) // process each point in the line one at a time (just use dY) { //EXTENTS = checkExtents(Ax,Ay); //if(EXTENTS == TRUE) pointFillAlgorithm(Ax, Ay, A,B,C,D); // plot the pixel //EXTENTS = FALSE; if (P > 0) // is the pixel going up AND right? { Ax+=Xincr; // increment dependent variable Ay+=Yincr; // increment independent variable P+=dPru; // increment decision (for up) } else // is the pixel just going up? { Ay+=Yincr; // increment independent variable P+=dPr; // increment decision (for right) } } } /////////////////////////////////////////// //////////////// ReleaseDC(pDC) helps clear the device context //if(pDC != NULL) //ReleaseDC(pDC); } // end function lineFillAlgorithm void CTrackToolDlg::pointFillAlgorithm(double Ax1,double Ay1,double A1,double B1,double C1,double D1) { ////////////////////////////////////////////////////////////////// ////// /// This function plots itself and two adjacent neighbours in all directions ///////////////////////// //CPaintDC dc(this); //pDC = GetDC(); //RenderableCircle rcCurrent(pDC,RGB(255, 0, 0), (int) __max(2.0 , -4.0), RGB(0, 0, 0)); trackMapVals point; double Ax = abs(Ax1); double Ay = abs(Ay1); double A = A1; double B = B1; double C = C1; double D = D1; //////////////////// ///////////////////////////////////// //////////// Check and interpolate for Ax and Ay int mx = floor(Ax) - floor(leastEasting) + 2; int my = floor(Ay) - floor(leastNorthing) + 2; //if( (mx > 0) && (my > 0) && (mx < colMax) && (my < rowMax)) //{ point = trackGrid[my][mx]; if(point.Filled == FALSE) { point.Altitude = (-D-(A*Ax)-(B*Ay))/C; if(point.Altitude > 0) { point.InterPolated = TRUE; point.Filled = TRUE; trackGrid[my][mx] = point; //rcCurrent.render(pDC,mx,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } for(int incr = 1;incr < 3;incr++) { point = trackGrid[my][mx + incr]; if(point.Filled == FALSE) { point.Altitude = (-D-(A*(Ax + incr))-(B*Ay))/C; if(point.Altitude > 0) { point.InterPolated = TRUE; point.Filled = TRUE; trackGrid[my][mx + incr] = point; //rcCurrent.render(pDC,mx + incr,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } point = trackGrid[my][mx - incr]; if(point.Filled == FALSE) { point.Altitude = (-D-(A*(Ax - incr))-(B*Ay))/C; if(point.Altitude > 0) { point.InterPolated = TRUE; point.Filled = TRUE; trackGrid[my][mx - incr] = point; //rcCurrent.render(pDC,mx -incr,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } point = trackGrid[my + incr][mx]; if(point.Filled == FALSE) { point.Altitude = (-D-(A*Ax)-(B*(Ay + incr)))/C; if(point.Altitude > 0) { point.InterPolated = TRUE; point.Filled = TRUE; trackGrid[my + incr][mx] = point; //rcCurrent.render(pDC,mx,my + incr); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } point = trackGrid[my - incr][mx]; if(point.Filled == FALSE) { point.Altitude = (-D-(A*Ax)-(B*(Ay - incr)))/C; if(point.Altitude > 0) { point.InterPolated = TRUE; point.Filled = TRUE; trackGrid[my - incr][mx] = point; //rcCurrent.render(pDC,mx,my - incr); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } } // end for(int incr = 1;incr < 3;incr++) //} //if(pDC != NULL) //ReleaseDC(pDC); }// end function BOOL CTrackToolDlg::checkExtents(double Ax1,double Ay1) { double Ax = floor(Ax1); double Ay = floor(Ay1); if(Ax < (leastEasting - 2) ) return FALSE; else return TRUE; if(Ax > (highestEasting + 2)) return FALSE; else return TRUE; if(Ay < (leastNorthing - 2)) return FALSE; else return TRUE; if(Ay > (highestNorthing + 2)) return FALSE; else return TRUE; } // end function void CTrackToolDlg::modifiedlineFillAlgorithm(double Ax1,double Ay1,double Bx1,double By1,double A1,double B1,double C1,double D1) { CPaintDC dc(this); //pDC = GetDC();; // RenderableCircle rcCurrent(pDC,RGB(255, 0, 0), (int) __max(2.0 , -4.0), RGB(0, 0, 0)); trackMapVals line; double Ax = abs(Ax1); double Ay = abs(Ay1); double Bx = abs(Bx1); double By = abs(By1); double A = A1; double B = B1; double C = C1; double D = D1; //////////////////// ///////////////////////////////////// //////////// Check and interpolate for Ax and Ay int mx = Ax - floor(leastEasting) + 2; int my = Ay - floor(leastNorthing) + 2; line = trackGrid[my][mx]; if(line.Filled == FALSE) { line.Altitude = (-D-(A*Ax)-(B*Ay))/C; if(line.Altitude > 0) { line.InterPolated = TRUE; line.Filled = TRUE; trackGrid[my][mx] = line; //rcCurrent.render(pDC,mx,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } line = trackGrid[my][mx +1]; if(line.Filled == FALSE) { line.Altitude = (-D-(A*(Ax + 1))-(B*Ay))/C; if(line.Altitude > 0) { line.InterPolated = TRUE; line.Filled = TRUE; trackGrid[my][mx + 1] = line; //rcCurrent.render(pDC,mx,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } line = trackGrid[my + 1][mx]; if(line.Filled == FALSE) { line.Altitude = (-D-(A*Ax)-(B*(Ay + 1)))/C; if(line.Altitude > 0) { line.InterPolated = TRUE; line.Filled = TRUE; trackGrid[my + 1][mx] = line; //rcCurrent.render(pDC,mx,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } line = trackGrid[my + 1][mx + 1]; if(line.Filled == FALSE) { line.Altitude = (-D-(A*(Ax + 1))-(B*(Ay + 1)))/C; if(line.Altitude > 0) { line.InterPolated = TRUE; line.Filled = TRUE; trackGrid[my + 1][mx + 1] = line; //rcCurrent.render(pDC,mx,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } //////////////////// ///////////////////////////////////// //////////// Check and interpolate for Bx and By mx = Bx - floor(leastEasting) + 2; my = By - floor(leastNorthing) + 2; line = trackGrid[my][mx]; if(line.Filled == FALSE) { line.Altitude = (-D-(A*Bx)-(B*By))/C; if(line.Altitude > 0) { line.InterPolated = TRUE; line.Filled = TRUE; trackGrid[my][mx] = line; //rcCurrent.render(pDC,mx,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } line = trackGrid[my][mx +1]; if(line.Filled == FALSE) { line.Altitude = (-D-(A*(Bx + 1))-(B*By))/C; if(line.Altitude > 0) { line.InterPolated = TRUE; line.Filled = TRUE; trackGrid[my][mx + 1] = line; //rcCurrent.render(pDC,mx,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } line = trackGrid[my + 1][mx]; if(line.Filled == FALSE) { line.Altitude = (-D-(A*Bx)-(B*(By + 1)))/C; if(line.Altitude > 0) { line.InterPolated = TRUE; line.Filled = TRUE; trackGrid[my + 1][mx] = line; //rcCurrent.render(pDC,mx,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } line = trackGrid[my + 1][mx + 1]; if(line.Filled == FALSE) { line.Altitude = (-D-(A*(Bx + 1))-(B*(By + 1)))/C; if(line.Altitude > 0) { line.InterPolated = TRUE; line.Filled = TRUE; trackGrid[my + 1][mx + 1] = line; //rcCurrent.render(pDC,mx,my); //dc.BitBlt(0,0,0,0,pDC,0,0,SRCCOPY); } } ////////////////////////////////////////////////////////////////// //////////// Bresenham's modified line drawing algorithm //////////// For every point that we intercept , we go two spaces in /////////// 4 directions and interpolate the altitude///////////// //////////// This is just to make sure we hit all the points in the track //////////////////////// int i; // loop counter int ystep, xstep; // the step on y and x axis int error; // the error accumulated during the increment int errorprev; // *vision the previous value of the error variable int y = Ay, x = Ax; // the line points int ddy, ddx; // compulsory variables: the double values of dy and dx int dx = Bx - Ax; int dy = By - By; BOOL EXTENTS = FALSE; EXTENTS = checkExtents(Ax,Ay); if(EXTENTS == TRUE) pointFillAlgorithm(x, y, A,B,C,D); // plot the pixel EXTENTS = FALSE; //POINT (y1, x1); // first point // NB the last point can't be here, because of its previous point (which has to be verified) if (dy < 0) { ystep = -1; dy = -dy; } else ystep = 1; if (dx < 0) { xstep = -1; dx = -dx; } else xstep = 1; ddy = 2 * dy; // work with double values for full precision ddx = 2 * dx; if (ddx >= ddy) { // first octant (0 <= slope <= 1) // compulsory initialization (even for errorprev, needed when dx==dy) errorprev = error = dx; // start in the middle of the square for (i=0 ; i < dx ; i++) { // do not use the first point (already done) x += xstep; error += ddy; if (error > ddx) { // increment y if AFTER the middle ( > ) y += ystep; error -= ddx; // three cases (octant == right->right-top for directions below): if (error + errorprev < ddx) // bottom square also //POINT (y-ystep, x); pointFillAlgorithm(x, y-ystep, A,B,C,D); // plot the pixel if (error + errorprev > ddx) // left square also //POINT (y, x-xstep); pointFillAlgorithm(x-xstep, y, A,B,C,D); // plot the pixel else //{ // corner: bottom and left squares also //POINT (y-ystep, x); //POINT (y, x-xstep); pointFillAlgorithm(x-xstep, y-ystep, A,B,C,D); // plot the pixel //pointFillAlgorithm(x-step, y, A,B,C,D); // plot the pixel } // end if EXTENTS = checkExtents(x,y); if(EXTENTS == TRUE) pointFillAlgorithm(x, y, A,B,C,D); // plot the pixel EXTENTS = FALSE; errorprev = error; }// end for } // end if begin else else { // the same as above errorprev = error = dy; for (i=0 ; i < dy ; i++) { y += ystep; error += ddx; if (error > ddy) { x += xstep; error -= ddy; if (error + errorprev < ddy) //POINT (y, x-xstep); pointFillAlgorithm(x-xstep, y, A,B,C,D); // plot the pixel if (error + errorprev > ddy) //POINT (y-ystep, x); pointFillAlgorithm(x, y-ystep, A,B,C,D); // plot the pixel else //{ //POINT (y, x-xstep); //POINT (y-ystep, x); pointFillAlgorithm(x-xstep, y-ystep, A,B,C,D); // plot the pixel //pointFillAlgorithm(x, y, A,B,C,D); // plot the pixel }// end if EXTENTS = checkExtents(x,y); if(EXTENTS == TRUE) pointFillAlgorithm(x, y, A,B,C,D); // plot the pixel EXTENTS = FALSE; errorprev = error; }// end for }// end else (ddx >= ddy){ //if(pDC != NULL) //ReleaseDC(pDC); } // end function void CTrackToolDlg::funcToInterpolateTrack(list<trackMapVals> &trackList) { //trackMapVals track; //list<trackMapVals>::iterator trackListIter; //int listSize = trackList.size(); double *trackArrayofAltitudes; //int counter = 0; try { //list<trackMapVals> tempTrack,temptempTrack; // two lists for manipulating the list //list<trackMapVals>::iterator listTrackIter,tempIter,temptempIter; // iterators to point to the list //trackMapVals listtrack; // struct object to hold values static int listcounter = 0; if(trackList.empty() == TRUE) throw " Track is empty please check "; if(tempTrack.empty() == FALSE) tempTrack.clear(); if(temptempTrack.empty() == FALSE) temptempTrack.clear(); BOOL FINDER; FINDER = TRUE; //initially check to see if list starts with a zero or nonzero value listTrackIter = trackList.begin(); listtrack = *listTrackIter; // check if listtrack.Altitude == 0 if(listtrack.Altitude == 0) { // enter the loop only if list starts with zero // the idea is to rearrange the list to start with a number // and to join the first number to the last of the list for(listTrackIter = trackList.begin();listTrackIter != trackList.end();listTrackIter++) { listtrack = *listTrackIter; if((listtrack.Altitude == 0) && (FINDER == TRUE)) tempTrack.push_back(*listTrackIter); if(listtrack.Altitude != 0.0) { if(FINDER == TRUE) { if(tempTrack.empty() == FALSE) tempTrack.clear(); // clear the track of previous zero altitude if any tempIter = listTrackIter; // assign the iterator for(;tempIter != trackList.end();tempIter++) { tempTrack.push_back(*tempIter); } // end for(;tempIter != trackList.end();tempIter+) // assign the iterator again to point to the original list tempIter = listTrackIter; while(tempIter != trackList.begin()) { listcounter++; tempIter--; } // end while(tempIter != trackList.begin()) // assign the iterator to beginning of list tempIter = trackList.begin(); for(int k = 0; k < listcounter; k++) { tempTrack.push_back(*tempIter); tempIter++; } // end for(int k = 0; k < listcounter; k++) FINDER = FALSE; } // end if(FINDER) } // end if(listtrack.Altitude != 0) } // end for(listTrackIter = trackList.begin();listTrackIter != trackList.end();listTrackIter++) // clear the original list and assign the nodes from // the templist //if(trackList.empty() == FALSE) trackList.clear(); for(listTrackIter = tempTrack.begin();listTrackIter != tempTrack.end();listTrackIter++) trackList.push_back(*listTrackIter); } // end if(listtrack.Altitude == 0) // join the first point to the last listTrackIter = trackList.begin(); trackList.push_back(*listTrackIter); // the list is now rearranged................... // i.e it starts with a non zero altitude and ends with a non zero altitude // or if all the elements are of altitude zero then it is as it is with an extra node // to interpolate the track based on the rearrangement double firstItem,secondItem; firstItem = 0.0; secondItem = 0.0; static int listcount; listcount = 0; tempIter = trackList.begin(); listtrack = *tempIter; firstItem = listtrack.Altitude; secondItem = listtrack.Altitude; //if(tempTrack.empty() == FALSE) tempTrack.clear(); // clear the list temptempTrack.clear(); // clear the list for(listTrackIter = trackList.begin();listTrackIter != trackList.end();listTrackIter++) { listtrack = *listTrackIter; if(listtrack.Altitude == 0) temptempTrack.push_back(*listTrackIter); if(listtrack.Altitude != 0) { if(temptempTrack.size() > 0) temptempIter = temptempTrack.begin(); firstItem = secondItem; listtrack = *listTrackIter; secondItem = listtrack.Altitude; double difference = (firstItem - secondItem); for(int z = 1; z < listcount; z++) { double deltadiff; //if(difference != 0) deltadiff = -(difference/listcount); //else //deltadiff = 0; firstItem = firstItem + deltadiff; if(temptempIter != temptempTrack.end()) listtrack = *temptempIter; listtrack.Altitude = firstItem; tempTrack.push_back(listtrack); ++temptempIter; } // end for(int z = 1; z < listcount; z++) tempTrack.push_back(*listTrackIter); //if(!temptempTrack.empty() == FALSE) temptempTrack.clear(); listcount = 0; } // end if(listtrack.Altitude != 0) // increment listcount listcount++; } // end for(listTrackIter = trackList.begin();listTrackIter != trackList.end();listTrackIter++) // if all the elements are of altitude zero // temptempTrack contains the entire list // transfer the entire list to the main list if(temptempTrack.size() == trackList.size()) { trackList.clear(); for(tempIter = temptempTrack.begin();tempIter != temptempTrack.end();tempIter++) trackList.push_back(*tempIter); } // end if(temptempTrack.size() == trackList.size()) // if there are non zero elements // transfer the elements back to the list if(temptempTrack.size() != trackList.size()) { trackList.clear(); for(tempIter = tempTrack.begin();tempIter != tempTrack.end();tempIter++) trackList.push_back(*tempIter); } // clear tempTrack and temptempTrack; tempTrack.clear(); temptempTrack.clear(); /* // clear contents of tempTrack if(!tempTrack.empty()) tempTrack.clear(); //// // malloc an array of doubles to store the altitude in the same order /// as it is in the list /// if((trackArrayofAltitudes = (double *)malloc(listSize* sizeof(double))) == NULL) throw " Insufficient Memory for allocation in funcToInterpolateTrack(..) "; for(listTrackIter = trackList.begin();listTrackIter != trackList.end();listTrackIter++) { track = *listTrackIter; trackArrayofAltitudes[counter] = track.Altitude; ++counter; }// end for(listTrackIter = trackList.begin();listTrackIter != trackList.end();listTrackIter++) /////////////////////////////////////// //////////////// /// logic to interpolate the array and then store the values back to the list assignedPoints altPoints; for(int i = 0; i < listSize; i++) { if(trackArrayofAltitudes[i] != 0.00) { altPoints.altitudeNumberInList = i; altPoints.altitudeValue = trackArrayofAltitudes[i]; assignedPointsList.push_back(altPoints); } // end if(trackArrayofAltitudes[i] != 0.00) } // end for (int i = 0; i < listSize; i++) if(assignedPointsList.size() > 1) // to make sure more than one point had an assigned // altitude { assignedPoints firstAssignedPoint,secondAssignedPoint; assignedPointsListIter = assignedPointsList.begin(); while(assignedPointsListIter != assignedPointsList.end()) { firstAssignedPoint = *assignedPointsListIter; ++assignedPointsListIter; if(assignedPointsListIter != assignedPointsList.end()) secondAssignedPoint = *assignedPointsListIter; double altDifference; altDifference = (firstAssignedPoint.altitudeValue - secondAssignedPoint.altitudeValue)/(firstAssignedPoint.altitudeNumberInList - secondAssignedPoint.altitudeNumberInList); for(int newVal = (firstAssignedPoint.altitudeNumberInList + 1); newVal < secondAssignedPoint.altitudeNumberInList; newVal++) trackArrayofAltitudes[newVal] = (trackArrayofAltitudes[newVal - 1] + altDifference); }//end while(assignedPointsListIter != assignedPointsList.end()) ////////////////////////////////////////////////////// ///////////////////////////////////////////////////// // Here the idea is to take the first point and the last point in // the list and interpolate between those point....... //// needs a little thinking assignedPointsListIter = assignedPointsList.begin(); firstAssignedPoint = *assignedPointsListIter; assignedPointsListIter = assignedPointsList.end(); --assignedPointsListIter; secondAssignedPoint = *assignedPointsListIter; double diff; diff = -((secondAssignedPoint.altitudeValue - firstAssignedPoint.altitudeValue)/(listSize - secondAssignedPoint.altitudeNumberInList + firstAssignedPoint.altitudeNumberInList)); /////// fill the points from last point in list to end of list first /////// and then lets fill from the first item in list till beginning for(int newValue = secondAssignedPoint.altitudeNumberInList + 1;newValue < (listSize -1);newValue++) trackArrayofAltitudes[newValue] = (trackArrayofAltitudes[newValue - 1] + diff); for(int newValueAgain = 0;newValueAgain < firstAssignedPoint.altitudeNumberInList; newValueAgain++) trackArrayofAltitudes[newValueAgain] = (trackArrayofAltitudes[newValueAgain] + diff); if(!OutCheckedList.empty()) OutCheckedList.clear(); counter = 0; for(trackListIter = trackList.begin();trackListIter != trackList.end();trackListIter++) { track = *trackListIter; track.Altitude = trackArrayofAltitudes[counter]; ++counter; OutCheckedList.push_back(track); }// end for(trackListIter = trackList.begin();trackListIter != trackList.end();trackListIter++) } // end if(assignedPointsList.size() > 1) free(trackArrayofAltitudes); */ } // end try block catch(const char* str) { em.MessageBox(str,"",MB_OK); /////////// Free the allocated memory rowwise for(int freeMe = 0;freeMe < rowMax;freeMe++) { if(trackGrid != NULL) free(trackGrid[freeMe]); } /// finally free the array of pointers. if(trackGrid != NULL) free(trackGrid); //if(pDC != NULL) //ReleaseDC(pDC); if(trackArrayofAltitudes != NULL) free(trackArrayofAltitudes); }// end catch(const char* str) catch(...) { em.MessageBox("Unknown Error in Create XML :","",MB_OK); /////////// Free the allocated memory rowwise for(int freeMe = 0;freeMe < rowMax;freeMe++) { if(trackGrid != NULL) free(trackGrid[freeMe]); } /// finally free the array of pointers. if(trackGrid != NULL) free(trackGrid); //if(pDC != NULL) //ReleaseDC(pDC); if(trackArrayofAltitudes != NULL) free(trackArrayofAltitudes); }// end catch(...) }// end func // function to get closest point void CTrackToolDlg::getClosestPoint(list<trackMapVals> &trackList,trackMapVals referencePoint,trackMapVals &closestPoint) { // try block try { double angle,range,prevangle,prevrange; BOOL FOUND; FOUND = FALSE; UTMPosition UTMPositionRef(0,referencePoint.Northing,referencePoint.Easting); curListIter = trackList.begin(); cur = *curListIter; UTMPosition UTMPositionClosest(0,cur.Northing,cur.Easting); UTMPositionRef.angleTo(UTMPositionClosest,prevangle,prevrange); while(curListIter != trackList.end()) { ++curListIter; cur = *curListIter; UTMPosition UTMPositionNextClosest(0,cur.Northing,cur.Easting); UTMPositionRef.angleTo(UTMPositionNextClosest,angle,range); if(prevrange > range) { prevrange = range; tmpListIter = curListIter; FOUND = TRUE; }// end if(prevrange > range) }// end while(curListIter != trackList.end()) if(!FOUND) { tmpListIter = trackList.begin(); closestPoint = *tmpListIter; }// end if(!FOUND) if(FOUND) { closestPoint = *tmpListIter; FOUND = FALSE; }// end if(FOUND) } // end try block catch(const char *str) { em.MessageBox(str,"",MB_OK); } // end catch(const char *str) catch(...) { em.MessageBox("UnKnown Error in function getClosestPoint(......)","",MB_OK); }// end catch(...) }// end function trackMapVals& CTrackToolDlg::getClosestPoint(list<trackMapVals> &trackList,trackMapVals referencePoint)