Commit 08d81572 authored by Volker Krause's avatar Volker Krause
Browse files

Add walking distance accuracy level for the location comparison

Needed by the Itinerary app.
parent 84bfdc53
......@@ -235,6 +235,12 @@ bool LocationUtil::isSameLocation(const QVariant &lhs, const QVariant &rhs, Loca
switch (accuracy) {
case Exact:
return d < 100;
case WalkingDistance:
{
// airports are large but we have no local transport there, so the distance threshold needs to be higher there
const auto isAirport = JsonLd::isA<Airport>(lhs) || JsonLd::isA<Airport>(rhs);
return d < (isAirport ? 2000 : 1000);
}
case CityLevel:
return d < 50000;
break;
......@@ -246,6 +252,7 @@ bool LocationUtil::isSameLocation(const QVariant &lhs, const QVariant &rhs, Loca
const auto rhsAddr = address(rhs);
switch (accuracy) {
case Exact:
case WalkingDistance:
if (!lhsAddr.streetAddress().isEmpty() && !lhsAddr.addressLocality().isEmpty()) {
return lhsAddr.streetAddress() == rhsAddr.streetAddress() && lhsAddr.addressLocality() == rhsAddr.addressLocality();
}
......
......@@ -68,7 +68,8 @@ int KITINERARY_EXPORT distance(const GeoCoordinates &coord1, const GeoCoordinate
/** Location comparison accuracy. */
enum Accuracy {
Exact, ///< Locations match exactly
CityLevel ///< Locations are in the same city
CityLevel, ///< Locations are in the same city
WalkingDistance, ///< Locations are close enough together to not need transportation
};
/** Returns @c true if the given locations are the same.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment