KItinerary

locationutil.h
1/*
2 SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "kitinerary_export.h"
10
11class QString;
12class QUrl;
13class QVariant;
14
15namespace KItinerary {
16
17class GeoCoordinates;
18class PostalAddress;
19
20/** Utility functions related to location information. */
21namespace 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 */
28bool KITINERARY_EXPORT isLocationChange(const QVariant &res);
29
30/** Returns the departure location of the given reservation.
31 * This assumes isLocationChange(res) == true.
32 */
33QVariant KITINERARY_EXPORT departureLocation(const QVariant &res);
34
35/** Returns the arrival location of the given reservation.
36 * This assumes isLocationChange(res) == true.
37 */
38QVariant KITINERARY_EXPORT arrivalLocation(const QVariant &res);
39
40/** Returns the location of a non-transport reservation.
41 * This assumes isLocationChange(res) == false.
42 */
43QVariant KITINERARY_EXPORT location(const QVariant &res);
44
45/** Returns the geo coordinates of a given location. */
46GeoCoordinates KITINERARY_EXPORT geo(const QVariant &location);
47
48/** Returns the address of the given location. */
49PostalAddress KITINERARY_EXPORT address(const QVariant &location);
50
51/** Returns a description of the location. */
52QString KITINERARY_EXPORT name(const QVariant &location);
53
54/** Computes the distance between to geo coordinates in meters. */
55int KITINERARY_EXPORT distance(const GeoCoordinates &coord1, const GeoCoordinates &coord2);
56/** Computes the distance between to geo coordinates in meters. */
57int KITINERARY_EXPORT distance(float lat1, float lon1, float lat2, float lon2);
58
59/** Location comparison 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 */
71bool KITINERARY_EXPORT isSameLocation(const QVariant &lhs, const QVariant &rhs, Accuracy accuracy = Exact);
72
73/** Returns a geo: URI for the given location. */
74QUrl KITINERARY_EXPORT geoUri(const QVariant &location);
75
76}
77
78}
79
Geographic coordinates.
Definition place.h:23
Postal address.
Definition place.h:46
GeoCoordinates geo(const QVariant &location)
Returns the geo coordinates of a given location.
QVariant location(const QVariant &res)
Returns the location of a non-transport reservation.
bool isLocationChange(const QVariant &res)
Returns true if the given reservation is a location change.
int distance(const GeoCoordinates &coord1, const GeoCoordinates &coord2)
Computes the distance between to geo coordinates in meters.
bool isSameLocation(const QVariant &lhs, const QVariant &rhs, Accuracy accuracy=Exact)
Returns true if the given locations are the same.
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.
Accuracy
Location comparison accuracy.
@ CityLevel
Locations are in the same city.
@ Exact
Locations match exactly.
@ WalkingDistance
Locations are close enough together to not need transportation.
QUrl geoUri(const QVariant &location)
Returns a geo: URI for the given location.
Classes for reservation/travel data models, data extraction and data augmentation.
Definition berelement.h:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:14:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.