📄 gpsinterface_simulated.cpp
字号:
/*
* Roadnav
* GPSInterface_Simulated.cpp
*
* Copyright (c) 2004 - 2006 Richard L. Lynch <rllynch@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public License
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//////////////////////////////////////////////////////////////////////////////
/// \file
///
/// Simulated gps interface module.
///
//////////////////////////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef _MSC_VER
#pragma warning(disable: 4786)
#pragma warning(disable: 4800)
#endif
#include <wx/wx.h>
#include "libroadnav/MapSupport.h"
#include "GPSInterface_Simulated.h"
#ifdef HAVE_SIMULATED_GPS_SUPPORT
using namespace std;
GPSInterface_Simulated::GPSInterface_Simulated()
{
m_ptGPS.m_fLong = -70.99;
m_ptGPS.m_fLat = 43.004;
m_fHeading = 0;
m_fSpeed = 50;
}
GPSInterface_Simulated::~GPSInterface_Simulated()
{
}
wxString GPSInterface_Simulated::Name()
{
return wxT("Simulated");
}
IGPSInterface::EGPSStatus GPSInterface_Simulated::GetData(wxGPSEvent * pGPSEvent)
{
wxString strFixType;
vector<SSatelliteInfo> vSatelliteInfo;
long nSatellites = 0;
wxThread::Sleep(10);
m_fHeading += rand() % 10 - 5;
m_ptGPS.m_fLong += m_fSpeed / 1000000.0 * cos_deg(m_fHeading - 90);
m_ptGPS.m_fLat -= m_fSpeed / 1000000.0 * sin_deg(m_fHeading - 90);
while (m_fHeading < 0)
m_fHeading += 360;
while (m_fHeading >= 360)
m_fHeading -= 360;
strFixType = wxT("SPS");
nSatellites = 4;
SSatelliteInfo sInfo;
sInfo.m_iID = 2;
sInfo.m_fElevation = 42;
sInfo.m_fAzimuth = 294;
sInfo.m_fSNR = 45;
vSatelliteInfo.push_back(sInfo);
*pGPSEvent = wxGPSEvent(true, true, true, m_ptGPS, m_fSpeed, m_fHeading, strFixType, nSatellites, vSatelliteInfo, wxT(""));
return GPSStatusOK;
}
wxString GPSInterface_Simulated::GetLastError()
{
return m_strLastError;
}
IGPSInterface::EGPSStatus GPSInterface_Simulated::AutoDetect(wxThread * pThread)
{
m_strLastError = wxT("Autodetection not supported");
return GPSStatusAutoDetectionNotSupported;
}
#endif // #ifdef HAVE_SIMULATED_GPS_SUPPORT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -