File indexing completed on 2024-04-14 03:47:46

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2014 Levente Kurusa <levex@linux.com>
0004 //
0005 
0006 #ifndef MARBLE_GEOURIPARSER_H
0007 #define MARBLE_GEOURIPARSER_H
0008 
0009 #include "Planet.h"
0010 #include "GeoDataCoordinates.h"
0011 #include "marble_export.h"
0012 
0013 namespace Marble {
0014 
0015 /**
0016  * A class for parsing Geo: URIs.
0017  * Wikipage: https://en.wikipedia.org/wiki/Geo_URI
0018  * RFC: 5870 (8 June 2010)
0019  */
0020 class MARBLE_EXPORT GeoUriParser {
0021 
0022 public:
0023     /**
0024      * Constructs a new GeoUriParser with the given Geo URI
0025      */
0026     explicit GeoUriParser( const QString& geoUri = QString() );
0027 
0028     /**
0029      * Returns the Geo URI stored in this parser
0030      */
0031     QString geoUri() const;
0032     /**
0033      * Set the Geo URI to be parsed.
0034      */
0035     void setGeoUri( const QString& geoUri );
0036 
0037     /**
0038      * Returns the coordinates parsed.
0039      * null is returned when parsing was not successful.
0040      */
0041     GeoDataCoordinates coordinates() const;
0042 
0043     /**
0044      * Returns the Planet on which the coordinates are valid.
0045      */
0046     Planet planet() const;
0047 
0048     /**
0049      * Parse the given Geo URI
0050      *
0051      * \returns true iff the GeoURI is valid and was successfully parsed
0052      */
0053     bool parse();
0054 
0055 private:
0056     static QString queryValue( const QUrl& url, const QString& key, const QString& secondaryKey=QString() );
0057 
0058     QString m_geoUri;
0059     GeoDataCoordinates m_coordinates;
0060     Planet m_planet;
0061 };
0062 
0063 }
0064 
0065 #endif