1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

HiTL-Il2 - fixed longitude coordinate calculation - overflow bound checking active

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1131 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
corvus 2010-07-18 07:48:45 +00:00 committed by corvus
parent 3335be3fd9
commit c98ba649db

View File

@ -350,7 +350,14 @@ void Il2Bridge::processUpdate(QString& data)
gpsData.Heading = current.azimuth;
gpsData.Groundspeed = current.groundspeed;
gpsData.Latitude = latitude + current.Y * DEG2M;
gpsData.Longitude = longitude + current.X * cos(gpsData.Latitude*DEG2RAD) * DEG2M;
if (gpsData.Latitude<-89.0 or gpsData.Latitude>89.0) {
// oops - this is rare enough to just prevent overflow here...
// IL2 has no north pole map anyway
gpsData.Latitude=0.0;
}
gpsData.Longitude = longitude + current.X * (1.0/cos(gpsData.Latitude*DEG2RAD)) * DEG2M;
while (gpsData.Longitude<-180.0) gpsData.Longitude+=360.0;
while (gpsData.Longitude>180.0) gpsData.Longitude-=360.0;
gpsData.Satellites = 7;
gpsData.Status = PositionActual::STATUS_FIX3D;
posActual->setData(gpsData);