2019-01-25 22:18:21 +01:00
|
|
|
#ifndef GEOJSONPARSER_H
|
|
|
|
#define GEOJSONPARSER_H
|
|
|
|
|
|
|
|
#include <QJsonObject>
|
|
|
|
#include "parser.h"
|
|
|
|
|
|
|
|
class QJsonObject;
|
|
|
|
class QJsonArray;
|
|
|
|
|
|
|
|
class GeoJSONParser : public Parser
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
2019-01-31 01:46:53 +01:00
|
|
|
QList<Area> &areas, QVector<Waypoint> &waypoints);
|
2019-01-25 22:18:21 +01:00
|
|
|
QString errorString() const {return _errorString;}
|
|
|
|
int errorLine() const {return 0;}
|
|
|
|
|
|
|
|
private:
|
2019-01-31 01:46:53 +01:00
|
|
|
enum Type {
|
|
|
|
Unknown,
|
|
|
|
Point,
|
|
|
|
LineString,
|
|
|
|
MultiPoint,
|
|
|
|
Polygon,
|
|
|
|
MultiLineString,
|
|
|
|
MultiPolygon,
|
|
|
|
GeometryCollection,
|
|
|
|
Feature,
|
|
|
|
FeatureCollection
|
|
|
|
};
|
|
|
|
|
|
|
|
Type type(const QJsonObject &json);
|
2019-01-25 22:18:21 +01:00
|
|
|
bool point(const QJsonArray &coordinates, Waypoint &waypoint,
|
2022-09-23 02:34:18 +02:00
|
|
|
const QJsonValue &properties = QJsonValue());
|
2019-01-25 22:18:21 +01:00
|
|
|
bool multiPoint(const QJsonArray &coordinates,
|
2022-09-23 02:34:18 +02:00
|
|
|
QVector<Waypoint> &waypoints, const QJsonValue &properties = QJsonValue());
|
2019-02-11 23:28:08 +01:00
|
|
|
bool lineString(const QJsonArray &coordinates, SegmentData &segment);
|
2019-01-25 22:18:21 +01:00
|
|
|
bool lineString(const QJsonArray &coordinates, TrackData &track,
|
2022-09-23 02:34:18 +02:00
|
|
|
const QJsonValue &properties = QJsonValue());
|
2019-01-25 22:18:21 +01:00
|
|
|
bool multiLineString(const QJsonArray &coordinates,
|
2022-09-23 02:34:18 +02:00
|
|
|
TrackData &track, const QJsonValue &properties = QJsonValue());
|
2019-01-31 01:46:53 +01:00
|
|
|
bool polygon(const QJsonArray &coordinates, ::Polygon &pg);
|
|
|
|
bool polygon(const QJsonArray &coordinates, Area &area,
|
2022-09-23 02:34:18 +02:00
|
|
|
const QJsonValue &properties = QJsonValue());
|
2019-01-31 01:46:53 +01:00
|
|
|
bool multiPolygon(const QJsonArray &coordinates, Area &area,
|
2022-09-23 02:34:18 +02:00
|
|
|
const QJsonValue &properties = QJsonValue());
|
2019-01-25 22:18:21 +01:00
|
|
|
bool geometryCollection(const QJsonObject &json, QList<TrackData> &tracks,
|
2019-01-31 01:46:53 +01:00
|
|
|
QList<Area> &areas, QVector<Waypoint> &waypoints,
|
2022-09-23 02:34:18 +02:00
|
|
|
const QJsonValue &properties = QJsonValue());
|
2019-01-25 22:18:21 +01:00
|
|
|
bool feature(const QJsonObject &json, QList<TrackData> &tracks,
|
2019-01-31 01:46:53 +01:00
|
|
|
QList<Area> &areas, QVector<Waypoint> &waypoints);
|
2019-01-25 22:18:21 +01:00
|
|
|
bool featureCollection(const QJsonObject &json, QList<TrackData> &tracks,
|
2019-01-31 01:46:53 +01:00
|
|
|
QList<Area> &areas, QVector<Waypoint> &waypoints);
|
2019-01-25 22:18:21 +01:00
|
|
|
|
|
|
|
QString _errorString;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GEOJSONPARSER_H
|