mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
applying gps fixes: group repetitive code under a macro
See 2182167b53
. Keep the dupicated code in sync.
Originally-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This commit is contained in:
parent
ee9531f76e
commit
3479c9e197
1 changed files with 12 additions and 15 deletions
|
@ -252,6 +252,13 @@ static void copy_gps_location(struct gpsTracker &gps, struct dive *d)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SAME_GROUP 6 * 3600 /* six hours */
|
#define SAME_GROUP 6 * 3600 /* six hours */
|
||||||
|
#define SET_LOCATION(_dive, _gpsfix, _mark) \
|
||||||
|
{ \
|
||||||
|
copy_gps_location(_gpsfix, _dive); \
|
||||||
|
changed = true; \
|
||||||
|
last = _mark; \
|
||||||
|
}
|
||||||
|
|
||||||
bool GpsLocation::applyLocations()
|
bool GpsLocation::applyLocations()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -283,9 +290,7 @@ bool GpsLocation::applyLocations()
|
||||||
if (time_during_dive_with_offset(d, gpsTable[j].when, 0)) {
|
if (time_during_dive_with_offset(d, gpsTable[j].when, 0)) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
qDebug() << "gpsFix is during the dive, pick that one";
|
qDebug() << "gpsFix is during the dive, pick that one";
|
||||||
copy_gps_location(gpsTable[j], d);
|
SET_LOCATION(d, gpsTable[j], j);
|
||||||
changed = true;
|
|
||||||
last = j;
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
|
@ -304,25 +309,19 @@ bool GpsLocation::applyLocations()
|
||||||
} else if (gpsTable[j].when > dive_endtime(d)) {
|
} else if (gpsTable[j].when > dive_endtime(d)) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
qDebug() << "which is even later after the end of the dive, so pick the previous one";
|
qDebug() << "which is even later after the end of the dive, so pick the previous one";
|
||||||
copy_gps_location(gpsTable[j], d);
|
SET_LOCATION(d, gpsTable[j], j);
|
||||||
changed = true;
|
|
||||||
last = j;
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
/* ok, gpsFix is before, nextgpsFix is after */
|
/* ok, gpsFix is before, nextgpsFix is after */
|
||||||
if (d->when - gpsTable[j].when <= gpsTable[j+1].when - dive_endtime(d)) {
|
if (d->when - gpsTable[j].when <= gpsTable[j+1].when - dive_endtime(d)) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
qDebug() << "pick the one before as it's closer to the start";
|
qDebug() << "pick the one before as it's closer to the start";
|
||||||
copy_gps_location(gpsTable[j], d);
|
SET_LOCATION(d, gpsTable[j], j);
|
||||||
changed = true;
|
|
||||||
last = j;
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
qDebug() << "pick the one after as it's closer to the start";
|
qDebug() << "pick the one after as it's closer to the start";
|
||||||
copy_gps_location(gpsTable[j+1], d);
|
SET_LOCATION(d, gpsTable[j + 1], j + 1);
|
||||||
changed = true;
|
|
||||||
last = j + 1;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,9 +331,7 @@ bool GpsLocation::applyLocations()
|
||||||
} else {
|
} else {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
qDebug() << "which seems to be the best one for this dive, so pick it";
|
qDebug() << "which seems to be the best one for this dive, so pick it";
|
||||||
copy_gps_location(gpsTable[j], d);
|
SET_LOCATION(d, gpsTable[j], j);
|
||||||
changed = true;
|
|
||||||
last = j;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue