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 QUrl;
13 class QVariant;
14 
15 namespace KItinerary {
16 
17 class GeoCoordinates;
18 class PostalAddress;
19 
20 /** Utility functions related to location information. */
21 namespace LocationUtil
22 {
23 
24 /** Returns @c true if the given reservation is a location change.
25  * That is, some form of transport reservation with different departure
26  * and arrival locations.
27  */
28 bool KITINERARY_EXPORT isLocationChange(const QVariant &res);
29 
30 /** Returns the departure location of the given reservation.
31  * This assumes isLocationChange(res) == true.
32  */
33 QVariant KITINERARY_EXPORT departureLocation(const QVariant &res);
34 
35 /** Returns the arrival location of the given reservation.
36  * This assumes isLocationChange(res) == true.
37  */
38 QVariant KITINERARY_EXPORT arrivalLocation(const QVariant &res);
39 
40 /** Returns the location of a non-transport reservation.
41  * This assumes isLocationChange(res) == false.
42  */
43 QVariant KITINERARY_EXPORT location(const QVariant &res);
44 
45 /** Returns the geo coordinates of a given location. */
46 GeoCoordinates KITINERARY_EXPORT geo(const QVariant &location);
47 
48 /** Returns the address of the given location. */
49 PostalAddress KITINERARY_EXPORT address(const QVariant &location);
50 
51 /** Returns a description of the location. */
52 QString KITINERARY_EXPORT name(const QVariant &location);
53 
54 /** Computes the distance between to geo coordinates in meters. */
55 int KITINERARY_EXPORT distance(const GeoCoordinates &coord1, const GeoCoordinates &coord2);
56 /** Computes the distance between to geo coordinates in meters. */
57 int KITINERARY_EXPORT distance(float lat1, float lon1, float lat2, float lon2);
58 
59 /** Location comparison accuracy. */
60 enum Accuracy {
61  Exact, ///< Locations match exactly
62  CityLevel, ///< Locations are in the same city
63  WalkingDistance, ///< Locations are close enough together to not need transportation
64 };
65 
66 /** Returns @c true if the given locations are the same.
67  * @param lhs The left hand side in the location condition.
68  * @param rhs The right hand side in the location condition.
69  * @param accuracy Defines how closely the locations have to match.
70  */
71 bool KITINERARY_EXPORT isSameLocation(const QVariant &lhs, const QVariant &rhs, Accuracy accuracy = Exact);
72 
73 /** Returns a geo: URI for the given location. */
74 QUrl KITINERARY_EXPORT geoUri(const QVariant &location);
75 
76 }
77 
78 }
79 
QVariant location(const QVariant &res)
Returns the location of a non-transport reservation.
@ CityLevel
Locations are in the same city.
Definition: locationutil.h:62
QUrl geoUri(const QVariant &location)
Returns a geo: URI for the given location.
Accuracy
Location comparison accuracy.
Definition: locationutil.h:60
QVariant arrivalLocation(const QVariant &res)
Returns the arrival location of the given reservation.
QVariant departureLocation(const QVariant &res)
Returns the departure 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.
Postal address.
Definition: place.h:45
bool isSameLocation(const QVariant &lhs, const QVariant &rhs, Accuracy accuracy=Exact)
Returns true if the given locations are the same.
Geographic coordinates.
Definition: place.h:22
int distance(const GeoCoordinates &coord1, const GeoCoordinates &coord2)
Computes the distance between to geo coordinates in meters.
@ Exact
Locations match exactly.
Definition: locationutil.h:61
@ WalkingDistance
Locations are close enough together to not need transportation.
Definition: locationutil.h:63
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-2022 The KDE developers.
Generated on Thu Oct 6 2022 03:57:55 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.