KItinerary

locationutil.h
1 /*
2  SPDX-FileCopyrightText: 2018 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "kitinerary_export.h"
10 
11 class QString;
12 class QVariant;
13 
14 namespace KItinerary {
15 
16 class GeoCoordinates;
17 class PostalAddress;
18 
19 /** Utility functions related to location information. */
20 namespace LocationUtil
21 {
22 
23 /** Returns @c true if the given reservation is a location change.
24  * That is, some form of transport reservation with different departure
25  * and arrival locations.
26  */
27 bool KITINERARY_EXPORT isLocationChange(const QVariant &res);
28 
29 /** Returns the departure location of the given reservation.
30  * This assumes isLocationChange(res) == true.
31  */
32 QVariant KITINERARY_EXPORT departureLocation(const QVariant &res);
33 
34 /** Returns the arrival location of the given reservation.
35  * This assumes isLocationChange(res) == true.
36  */
37 QVariant KITINERARY_EXPORT arrivalLocation(const QVariant &res);
38 
39 /** Returns the location of a non-transport reservation.
40  * This assumes isLocationChange(res) == false.
41  */
42 QVariant KITINERARY_EXPORT location(const QVariant &res);
43 
44 /** Returns the geo coordinates of a given location. */
45 GeoCoordinates KITINERARY_EXPORT geo(const QVariant &location);
46 
47 /** Returns the address of the given location. */
48 PostalAddress KITINERARY_EXPORT address(const QVariant &location);
49 
50 /** Returns a description of the location. */
51 QString KITINERARY_EXPORT name(const QVariant &location);
52 
53 /** Computes the distance between to geo coordinates in meters. */
54 int KITINERARY_EXPORT distance(const GeoCoordinates &coord1, const GeoCoordinates &coord2);
55 /** Computes the distance between to geo coordinates in meters. */
56 int KITINERARY_EXPORT distance(float lat1, float lon1, float lat2, float lon2);
57 
58 /** Location comparison accuracy. */
59 enum Accuracy {
60  Exact, ///< Locations match exactly
61  CityLevel, ///< Locations are in the same city
62  WalkingDistance, ///< Locations are close enough together to not need transportation
63 };
64 
65 /** Returns @c true if the given locations are the same.
66  * @param lhs The left hand side in the location condition.
67  * @param rhs The right hand side in the location condition.
68  * @param accuracy Defines how closely the locations have to match.
69  */
70 bool KITINERARY_EXPORT isSameLocation(const QVariant &lhs, const QVariant &rhs, Accuracy accuracy = Exact);
71 
72 }
73 
74 }
75 
QString name(const QVariant &location)
Returns a description of the location.
bool isSameLocation(const QVariant &lhs, const QVariant &rhs, Accuracy accuracy=Exact)
Returns true if the given locations are the same.
Classes for reservation/travel data models, data extraction and data augmentation.
Locations match exactly.
Definition: locationutil.h:60
QVariant location(const QVariant &res)
Returns the location of a non-transport reservation.
QVariant departureLocation(const QVariant &res)
Returns the departure location of the given reservation.
QVariant arrivalLocation(const QVariant &res)
Returns the arrival location of the given reservation.
PostalAddress address(const QVariant &location)
Returns the address of the given location.
GeoCoordinates geo(const QVariant &location)
Returns the geo coordinates of a given location.
Locations are close enough together to not need transportation.
Definition: locationutil.h:62
Geographic coordinates.
Definition: place.h:21
Accuracy
Location comparison accuracy.
Definition: locationutil.h:59
int distance(const GeoCoordinates &coord1, const GeoCoordinates &coord2)
Computes the distance between to geo coordinates in meters.
Postal address.
Definition: place.h:44
Locations are in the same city.
Definition: locationutil.h:61
bool isLocationChange(const QVariant &res)
Returns true if the given reservation is a location change.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Sep 27 2021 23:17:37 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.