File indexing completed on 2025-01-05 03:59:27

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