KItinerary
locationutil.cpp
51 return JsonLd::isA<FlightReservation>(res) || JsonLd::isA<TrainReservation>(res) || JsonLd::isA<BusReservation>(res) || JsonLd::isA<TaxiReservation>(res) || JsonLd::isA<BoatReservation>(res);
176// if the character has a canonical decomposition use that and skip the combining diacritic markers following it
246static bool isSameLocationName(const QString &lhs, const QString &rhs, LocationUtil::Accuracy accuracy)
262 if (compareSpaceCaseInsenstive(lhsNormalized, rhsNormalized) || compareSpaceCaseInsenstive(lhsNormalized, rhsTransliterated)
263 || compareSpaceCaseInsenstive(lhsTransliterated, rhsNormalized) || compareSpaceCaseInsenstive(lhsTransliterated, rhsTransliterated)) {
274 return hasCommonPrefix(lhsNormalized, rhsNormalized) || hasCommonPrefix(lhsTransliterated, rhsTransliterated);
280bool LocationUtil::isSameLocation(const QVariant &lhs, const QVariant &rhs, LocationUtil::Accuracy accuracy)
287 const auto lhsIsTransportStop = JsonLd::isA<Airport>(lhs) || JsonLd::isA<TrainStation>(lhs) || JsonLd::isA<BusStation>(lhs);
288 const auto rhsIsTransportStop = JsonLd::isA<Airport>(rhs) || JsonLd::isA<TrainStation>(rhs) || JsonLd::isA<BusStation>(rhs);
298 // airports are large but we have no local transport there, so the distance threshold needs to be higher there
309 if (d < 50000 && (lhsAddr.addressLocality().isEmpty() || rhsAddr.addressLocality().isEmpty()) && (!isNameComparable || name(lhs).isEmpty() || name(rhs).isEmpty())) {
320 return lhsAddr.streetAddress() == rhsAddr.streetAddress() && lhsAddr.addressLocality() == rhsAddr.addressLocality();
325 return isSameLocationName(lhsAddr.addressLocality(), rhsAddr.addressLocality(), LocationUtil::Exact);
340 url.setPath(QString::number(geo.latitude()) + QLatin1Char(',') + QString::number(geo.longitude()));
void setStreet(const QString &street)
void setCountry(const QString &country)
void setRegion(const QString ®ion)
void setPostalCode(const QString &code)
void setLocality(const QString &locality)
QString addressCountry
The country this address is in, as ISO 3166-1 alpha 2 code.
Definition place.h:53
bool canConvert(const QVariant &value)
Checks if the given value can be up-cast to T.
Definition datatypes.h:31
GeoCoordinates geo(const QVariant &location)
Returns the geo coordinates of a given location.
Definition locationutil.cpp:118
QString name(const QVariant &location)
Returns a description of the location.
Definition locationutil.cpp:142
QVariant location(const QVariant &res)
Returns the location of a non-transport reservation.
Definition locationutil.cpp:97
bool isLocationChange(const QVariant &res)
Returns true if the given reservation is a location change.
Definition locationutil.cpp:41
int distance(const GeoCoordinates &coord1, const GeoCoordinates &coord2)
Computes the distance between to geo coordinates in meters.
Definition locationutil.cpp:158
bool isSameLocation(const QVariant &lhs, const QVariant &rhs, Accuracy accuracy=Exact)
Returns true if the given locations are the same.
Definition locationutil.cpp:280
QVariant departureLocation(const QVariant &res)
Returns the departure location of the given reservation.
Definition locationutil.cpp:74
QVariant arrivalLocation(const QVariant &res)
Returns the arrival location of the given reservation.
Definition locationutil.cpp:54
PostalAddress address(const QVariant &location)
Returns the address of the given location.
Definition locationutil.cpp:130
@ WalkingDistance
Locations are close enough together to not need transportation.
Definition locationutil.h:63
QUrl geoUri(const QVariant &location)
Returns a geo: URI for the given location.
Definition locationutil.cpp:333
QString transliterate(QStringView s)
Transliterate diacritics or other special characters.
Definition stringutil.cpp:171
Classes for reservation/travel data models, data extraction and data augmentation.
Definition berelement.h:17
Canonical
bool isLetter(char32_t ucs4)
iterator begin()
int compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs)
iterator end()
bool isEmpty() const const
QString number(double n, char format, int precision)
void push_back(QChar ch)
void reserve(qsizetype size)
qsizetype size() const const
QChar at(qsizetype n) const const
qsizetype size() const const
bool startsWith(QChar ch) const const
CaseInsensitive
void setPath(const QString &path, ParsingMode mode)
void setQuery(const QString &query, ParsingMode mode)
void setScheme(const QString &scheme)
T value() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.