1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-07 07:13:21 +02:00
GPXSee/src/map/kmzmap.h

121 lines
2.7 KiB
C
Raw Normal View History

2020-12-22 22:32:07 +01:00
#ifndef KMZMAP_H
#define KMZMAP_H
#include "transform.h"
#include "rectd.h"
#include "map.h"
class QXmlStreamReader;
class QZipReader;
class Image;
class KMZMap : public Map
{
Q_OBJECT
public:
KMZMap(const QString &fileName, QObject *parent = 0);
QString name() const;
QRectF bounds();
int zoom() const {return _zoom;}
void setZoom(int zoom);
int zoomFit(const QSize &size, const RectC &br);
int zoomIn();
int zoomOut();
QPointF ll2xy(const Coordinates &c);
Coordinates xy2ll(const QPointF &p);
void draw(QPainter *painter, const QRectF &rect, Flags flags);
void load();
void unload();
bool isValid() const {return _valid;}
QString errorString() const {return _errorString;}
private:
2020-12-23 23:05:12 +01:00
class Overlay {
public:
2020-12-22 22:32:07 +01:00
Overlay(const QString &path, const QSize &size, const RectC &bbox,
double rotation);
bool operator==(const Overlay &other) const
2020-12-23 23:05:12 +01:00
{return _path == other._path;}
2020-12-22 22:32:07 +01:00
QPointF ll2xy(const Coordinates &c) const
2020-12-23 23:05:12 +01:00
{return QPointF(_transform.proj2img(QPointF(c.lon(), c.lat())));}
2020-12-22 22:32:07 +01:00
Coordinates xy2ll(const QPointF &p) const
2020-12-23 23:05:12 +01:00
{
PointD pp(_transform.img2proj(p));
return Coordinates(pp.x(), pp.y());
}
2020-12-22 22:32:07 +01:00
2020-12-23 23:05:12 +01:00
const RectC &bbox() const {return _bbox;}
const QRectF &bounds() const {return _bounds;}
2020-12-22 22:32:07 +01:00
qreal resolution(const QRectF &rect) const;
2020-12-23 23:05:12 +01:00
qreal rotation() const {return _rotation;}
2020-12-22 22:32:07 +01:00
void draw(QPainter *painter, const QRectF &rect, Flags flags);
void load(QZipReader *zip);
void unload();
2020-12-23 23:05:12 +01:00
private:
QString _path;
QRectF _bounds;
RectC _bbox;
qreal _rotation;
Image *_img;
Transform _transform;
2020-12-22 22:32:07 +01:00
};
struct Zoom {
int first;
int last;
Zoom() : first(-1), last(-1) {}
Zoom(int first, int last) : first(first), last(last) {}
};
struct Bounds {
RectC ll;
QRectF xy;
Bounds() {}
Bounds(const RectC &ll, const QRectF &xy) : ll(ll), xy(xy) {}
};
void kml(QXmlStreamReader &reader, QZipReader &zip);
void document(QXmlStreamReader &reader, QZipReader &zip);
void folder(QXmlStreamReader &reader, QZipReader &zip);
void groundOverlay(QXmlStreamReader &reader, QZipReader &zip);
RectC latLonBox(QXmlStreamReader &reader, double *rotation);
QString icon(QXmlStreamReader &reader);
double number(QXmlStreamReader &reader);
void draw(QPainter *painter, const QRectF &rect, int mapIndex, Flags flags);
void computeZooms();
void computeBounds();
static bool resCmp(const Overlay &m1, const Overlay &m2);
static bool xCmp(const Overlay &m1, const Overlay &m2);
static bool yCmp(const Overlay &m1, const Overlay &m2);
QList<Overlay> _maps;
QVector<Zoom> _zooms;
QVector<Bounds> _bounds;
int _zoom;
int _mapIndex;
QZipReader *_zip;
2020-12-23 23:05:12 +01:00
qreal _adjust;
2020-12-22 22:32:07 +01:00
bool _valid;
QString _errorString;
};
#endif // KMZMAP_H