mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 08:08:42 +00:00
Mapping and Latitude/Longitude logic changes
Patch changes the valid latitude/longitdue selection alogrithm. Ensures that the data points are valid (-90<=Lat<=90, -180<=Long<=180) Tightens up .WKO file import issues. Allows for missed GPS data points of 0/0 in Garmin FIT files. Changes mapping function to not plot invalid lat/long values. Fixes #75
This commit is contained in:
@@ -175,24 +175,27 @@ GoogleMapControl::rideSelected()
|
||||
}
|
||||
|
||||
rideData.clear();
|
||||
double prevLon = 0;
|
||||
double prevLat = 0;
|
||||
double prevLon = 1000;
|
||||
double prevLat = 1000;
|
||||
|
||||
foreach(RideFilePoint *rfp,ride->ride()->dataPoints())
|
||||
{
|
||||
RideFilePoint curRfp = *rfp;
|
||||
|
||||
if(ceil(rfp->lon) == 180 ||
|
||||
ceil(rfp->lat) == 180)
|
||||
{
|
||||
curRfp.lon = prevLon;
|
||||
curRfp.lat = prevLat;
|
||||
}
|
||||
// wko imports can have -320 type of values for roughly 40 degrees
|
||||
if((curRfp.lat) < -180)
|
||||
// This if range is a guess that we only have these -ve type numbers for actual 0 to 90 deg of Latitude
|
||||
if(curRfp.lat <= -270 && curRfp.lat >= -360)
|
||||
{
|
||||
curRfp.lat = 360 + curRfp.lat;
|
||||
}
|
||||
// Longitude = -180 to 180 degrees, Latitude = -90 to 90 degrees - anything else is invalid.
|
||||
if((curRfp.lon < -180 || curRfp.lon > 180 || curRfp.lat < -90 || curRfp.lat > 90)
|
||||
// Garmin FIT records a missed GPS signal as 0/0.
|
||||
|| ((curRfp.lon == 0) && (curRfp.lat == 0)))
|
||||
{
|
||||
curRfp.lon = 999;
|
||||
curRfp.lat = 999;
|
||||
}
|
||||
prevLon = curRfp.lon;
|
||||
prevLat = curRfp.lat;
|
||||
rideData.push_back(curRfp);
|
||||
@@ -263,12 +266,15 @@ void GoogleMapControl::createHtml()
|
||||
|
||||
BOOST_FOREACH(RideFilePoint rfp, rideData)
|
||||
{
|
||||
minLat = std::min(minLat,rfp.lat);
|
||||
maxLat = std::max(maxLat,rfp.lat);
|
||||
minLon = std::min(minLon,rfp.lon);
|
||||
maxLon = std::max(maxLon,rfp.lon);
|
||||
if (rfp.lat != 999 && rfp.lon != 999)
|
||||
{
|
||||
minLat = std::min(minLat,rfp.lat);
|
||||
maxLat = std::max(maxLat,rfp.lat);
|
||||
minLon = std::min(minLon,rfp.lon);
|
||||
maxLon = std::max(maxLon,rfp.lon);
|
||||
}
|
||||
}
|
||||
if(floor(minLat) == 0)
|
||||
if(minLon == 1000)
|
||||
{
|
||||
currentPage << tr("No GPS Data Present").toStdString();
|
||||
return;
|
||||
@@ -376,7 +382,7 @@ void GoogleMapControl::CreateSubPolyLine(const std::vector<RideFilePoint> &point
|
||||
|
||||
BOOST_FOREACH(RideFilePoint rfp, points)
|
||||
{
|
||||
if (ceil(rfp.lat) != 180 && ceil(rfp.lon) != 180)
|
||||
if (!(rfp.lat == 999 && rfp.lon == 999))
|
||||
{
|
||||
oss << "new GLatLng(" << rfp.lat << "," << rfp.lon << ")," << endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user