mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-27 03:29:16 +02:00
Added support for Mapsforge maps
This commit is contained in:
62
src/common/polygon.h
Normal file
62
src/common/polygon.h
Normal file
@ -0,0 +1,62 @@
|
||||
#ifndef POLYGON_H
|
||||
#define POLYGON_H
|
||||
|
||||
#include <QList>
|
||||
#include <QVector>
|
||||
#include "common/rectc.h"
|
||||
|
||||
class Polygon
|
||||
{
|
||||
public:
|
||||
Polygon() {}
|
||||
Polygon(const QVector<Coordinates> &path)
|
||||
{
|
||||
_paths.reserve(1);
|
||||
_paths.append(path);
|
||||
_boundingRect = boundingRect(path);
|
||||
}
|
||||
Polygon(const RectC &rect)
|
||||
{
|
||||
QVector<Coordinates> v(4);
|
||||
|
||||
v[0] = Coordinates(rect.left(), rect.top());
|
||||
v[1] = Coordinates(rect.right(), rect.top());
|
||||
v[2] = Coordinates(rect.right(), rect.bottom());
|
||||
v[3] = Coordinates(rect.left(), rect.bottom());
|
||||
|
||||
_paths.reserve(1);
|
||||
_paths.append(v);
|
||||
_boundingRect = RectC(v.at(0), v.at(2));
|
||||
}
|
||||
|
||||
void append(const QVector<Coordinates> &path)
|
||||
{
|
||||
_paths.append(path);
|
||||
_boundingRect |= boundingRect(path);
|
||||
}
|
||||
void reserve(int size) {_paths.reserve(size);}
|
||||
|
||||
int size() const {return _paths.size();}
|
||||
bool isEmpty() const {return _paths.isEmpty();}
|
||||
const QVector<Coordinates> &at(int i) const {return _paths.at(i);}
|
||||
const QVector<Coordinates> &first() const {return _paths.first();}
|
||||
const QVector<Coordinates> &last() const {return _paths.last();}
|
||||
|
||||
const RectC &boundingRect() const {return _boundingRect;}
|
||||
|
||||
private:
|
||||
static RectC boundingRect(const QVector<Coordinates> &path)
|
||||
{
|
||||
RectC rect;
|
||||
|
||||
for (int i = 0; i < path.size(); i++)
|
||||
rect = rect.united(path.at(i));
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
QList<QVector<Coordinates> > _paths;
|
||||
RectC _boundingRect;
|
||||
};
|
||||
|
||||
#endif // POLYGON_H
|
@ -15,6 +15,7 @@
|
||||
#define GCS_FILE "gcs.csv"
|
||||
#define PCS_FILE "pcs.csv"
|
||||
#define TYP_FILE "style.typ"
|
||||
#define RENDERTHEME_FILE "style.xml"
|
||||
|
||||
|
||||
QString ProgramPaths::mapDir(bool writable)
|
||||
@ -102,3 +103,9 @@ QString ProgramPaths::typFile()
|
||||
return QStandardPaths::locate(QStandardPaths::AppDataLocation,
|
||||
STYLE_DIR "/" TYP_FILE, QStandardPaths::LocateFile);
|
||||
}
|
||||
|
||||
QString ProgramPaths::renderthemeFile()
|
||||
{
|
||||
return QStandardPaths::locate(QStandardPaths::AppDataLocation,
|
||||
STYLE_DIR "/" RENDERTHEME_FILE, QStandardPaths::LocateFile);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ namespace ProgramPaths
|
||||
QString gcsFile();
|
||||
QString pcsFile();
|
||||
QString typFile();
|
||||
QString renderthemeFile();
|
||||
}
|
||||
|
||||
#endif // PROGRAMPATHS_H
|
||||
|
Reference in New Issue
Block a user