File indexing completed on 2024-04-21 03:50:28

0001 /*
0002     SPDX-License-Identifier: LGPL-2.1-or-later
0003 
0004     SPDX-FileCopyrightText: 2013 Ander Pijoan <ander.pijoan@deusto.es>
0005     SPDX-FileCopyrightText: 2019 John Zaitseff <J.Zaitseff@zap.org.au>
0006 */
0007 
0008 #ifndef MARBLE_JSONPARSER_H
0009 #define MARBLE_JSONPARSER_H
0010 
0011 class QIODevice;
0012 class QJsonObject;
0013 
0014 #include <QVector>
0015 
0016 namespace Marble {
0017 
0018 class GeoDataDocument;
0019 class GeoDataGeometry;
0020 class GeoDataIconStyle;
0021 class GeoDataLineStyle;
0022 class GeoDataPolyStyle;
0023 class GeoDataLabelStyle;
0024 
0025 class JsonParser
0026 {
0027 public:
0028     JsonParser();
0029     ~JsonParser();
0030 
0031     /**
0032      * @brief parse the GeoJSON file
0033      * @return true if parsing of the file was successful
0034      */
0035     bool read(QIODevice*);
0036 
0037     /**
0038      * @brief retrieve the parsed document and reset the parser
0039      * If parsing was successful, retrieve the resulting document
0040      * and set the contained m_document pointer to 0.
0041      */
0042     GeoDataDocument* releaseDocument();
0043 
0044 private:
0045 
0046     GeoDataDocument* m_document;
0047 
0048     GeoDataIconStyle*  m_iconStylePoints;
0049     GeoDataIconStyle*  m_iconStyleOther;
0050     GeoDataLineStyle*  m_lineStyle;
0051     GeoDataPolyStyle*  m_polyStyle;
0052     GeoDataLabelStyle* m_labelStyle;
0053 
0054     /**
0055      * @brief parse a top-level GeoJSON object (FeatureCollection or Feature)
0056      * @param jsonObject  the object to parse
0057      * @return true if parsing of the top-level object was successful
0058      */
0059     bool parseGeoJsonTopLevel(const QJsonObject&);
0060 
0061     /**
0062       * @brief parse a sub-level GeoJSON object
0063       * @param jsonObject    the object to parse
0064       * @param geometryList  a list of geometries pass back to the caller
0065       * @param hasPoints     a boolean passed back to the caller: true if Points exist in geometry
0066       * @return true if parsing of the object was successful
0067       */
0068     bool parseGeoJsonSubLevel(const QJsonObject&, QVector<GeoDataGeometry*>&, bool&);
0069 };
0070 
0071 }
0072 
0073 #endif // MARBLE_JSONPARSER_H