File indexing completed on 2024-05-12 05:21:34

0001 /*
0002     SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "location.h"
0008 
0009 #include <QJsonObject>
0010 
0011 #include <cmath>
0012 
0013 using namespace KPkPass;
0014 
0015 namespace KPkPass
0016 {
0017 class LocationPrivate
0018 {
0019 public:
0020     QJsonObject obj;
0021 };
0022 }
0023 
0024 Location::Location()
0025     : d(new LocationPrivate)
0026 {
0027 }
0028 
0029 Location::Location(const QJsonObject &obj)
0030     : d(new LocationPrivate)
0031 {
0032     d->obj = obj;
0033 }
0034 
0035 Location::~Location() = default;
0036 
0037 double Location::altitude() const
0038 {
0039     return d->obj.value(QLatin1StringView("altitude")).toDouble(NAN);
0040 }
0041 
0042 double Location::latitude() const
0043 {
0044     return d->obj.value(QLatin1StringView("latitude")).toDouble(NAN);
0045 }
0046 
0047 double Location::longitude() const
0048 {
0049     return d->obj.value(QLatin1StringView("longitude")).toDouble(NAN);
0050 }
0051 
0052 QString Location::relevantText() const
0053 {
0054     return d->obj.value(QLatin1StringView("relevantText")).toString();
0055 }
0056 
0057 #include "moc_location.cpp"