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/** Parses geo coordinates from a given mapping service URLs, such as Google Maps links. */
49GeoCoordinates KITINERARY_EXPORT geoFromUrl(const QUrl &url);
50
51/** Returns the address of the given location. */
52PostalAddress KITINERARY_EXPORT address(const QVariant &location);
53
54/** Returns a description of the location. */
55QString KITINERARY_EXPORT name(const QVariant &location);
56
57/** Computes the distance between to geo coordinates in meters. */
58int KITINERARY_EXPORT distance(const GeoCoordinates &coord1, const GeoCoordinates &coord2);
59/** Computes the distance between to geo coordinates in meters. */
60int KITINERARY_EXPORT distance(double lat1, double lon1, double lat2, double lon2);
61
62/** Location comparison accuracy. */
64 Exact, ///< Locations match exactly
65 CityLevel, ///< Locations are in the same city
66 WalkingDistance, ///< Locations are close enough together to not need transportation
67};
68
69/** Returns @c true if the given locations are the same.
70 * @param lhs The left hand side in the location condition.
71 * @param rhs The right hand side in the location condition.
72 * @param accuracy Defines how closely the locations have to match.
73 */
74bool KITINERARY_EXPORT isSameLocation(const QVariant &lhs, const QVariant &rhs, Accuracy accuracy = Exact);
75
76/** Returns a geo: URI for the given location. */
77QUrl KITINERARY_EXPORT geoUri(const QVariant &location);
78
79}
80
81}
82
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.
GeoCoordinates geoFromUrl(const QUrl &url)
Parses geo coordinates from a given mapping service URLs, such as Google Maps links.
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 Dec 27 2024 11:51:23 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.