core: move get_distance() from divesite.cpp to units.cpp

This gives the distance between to location_t objects. It is
unclear why this was in divesite.cpp.

Moreover pass by value, not raw pointer.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-11 15:18:37 +02:00 committed by bstoeger
parent 2de6f69c19
commit 7d7766be9a
9 changed files with 30 additions and 30 deletions

View file

@ -298,7 +298,7 @@ bool GPSLocationInformationModel::filterAcceptsRow(int sourceRow, const QModelIn
return false;
return distance <= 0 ? ds->location == location
: (int64_t)get_distance(&ds->location, &location) * 1000 <= distance; // We need 64 bit to represent distances in mm
: (int64_t)get_distance(ds->location, location) * 1000 <= distance; // We need 64 bit to represent distances in mm
}
GPSLocationInformationModel::GPSLocationInformationModel(QObject *parent) : QSortFilterProxyModel(parent),

View file

@ -67,7 +67,7 @@ QVariant DivesiteImportedModel::data(const QModelIndex &index, int role) const
case NEAREST: {
// 40075000 is circumference of the earth in meters
struct dive_site *nearest_ds =
divelog.sites->get_by_gps_proximity(&ds->location, 40075000);
divelog.sites->get_by_gps_proximity(ds->location, 40075000);
if (nearest_ds)
return QString::fromStdString(nearest_ds->name);
else
@ -76,10 +76,9 @@ QVariant DivesiteImportedModel::data(const QModelIndex &index, int role) const
case DISTANCE: {
unsigned int distance = 0;
struct dive_site *nearest_ds =
divelog.sites->get_by_gps_proximity(&ds->location, 40075000);
divelog.sites->get_by_gps_proximity(ds->location, 40075000);
if (nearest_ds)
distance = get_distance(&ds->location,
&nearest_ds->location);
distance = get_distance(ds->location, nearest_ds->location);
return distance_string(distance);
}
case SELECTED: