mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-04-21 20:59:11 +02:00
Compare commits
No commits in common. "7e10e6640ca7aee9daea7a0d6b6b773f8500c27e" and "092c56468ccb08af7c0fc839d2f86aaed300ee49" have entirely different histories.
7e10e6640c
...
092c56468c
@ -14,13 +14,16 @@ namespace Mapsforge {
|
|||||||
class RasterTile
|
class RasterTile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/* Mapsforge maps zoom levels are offset by one against the standard OSM
|
||||||
|
zoom levels! We decrease the zoom level internaly here when initializing
|
||||||
|
_zoom and return the propper/increased value back in zoom() */
|
||||||
RasterTile(const Projection &proj, const Transform &transform,
|
RasterTile(const Projection &proj, const Transform &transform,
|
||||||
const Style *style, MapData *data, int zoom, const QRect &rect,
|
const Style *style, MapData *data, int zoom, const QRect &rect,
|
||||||
qreal ratio) : _proj(proj), _transform(transform), _style(style),
|
qreal ratio) : _proj(proj), _transform(transform), _style(style),
|
||||||
_data(data), _zoom(zoom), _rect(rect), _ratio(ratio),
|
_data(data), _zoom(zoom - 1), _rect(rect), _ratio(ratio),
|
||||||
_pixmap(rect.width() * ratio, rect.height() * ratio), _valid(false) {}
|
_pixmap(rect.width() * ratio, rect.height() * ratio), _valid(false) {}
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom + 1;}
|
||||||
QPoint xy() const {return _rect.topLeft();}
|
QPoint xy() const {return _rect.topLeft();}
|
||||||
const QPixmap &pixmap() const {return _pixmap;}
|
const QPixmap &pixmap() const {return _pixmap;}
|
||||||
bool isValid() const {return _valid;}
|
bool isValid() const {return _valid;}
|
||||||
|
@ -177,7 +177,7 @@ bool Style::Rule::match(int zoom, const QVector<MapData::Tag> &tags) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Style::area(QXmlStreamReader &reader, const QString &dir, qreal ratio,
|
void Style::area(QXmlStreamReader &reader, const QString &dir, qreal ratio,
|
||||||
qreal baseStrokeWidth, const Rule &rule)
|
const Rule &rule)
|
||||||
{
|
{
|
||||||
PathRender ri(rule, _paths.size() + _circles.size());
|
PathRender ri(rule, _paths.size() + _circles.size());
|
||||||
const QXmlStreamAttributes &attr = reader.attributes();
|
const QXmlStreamAttributes &attr = reader.attributes();
|
||||||
@ -192,8 +192,7 @@ void Style::area(QXmlStreamReader &reader, const QString &dir, qreal ratio,
|
|||||||
if (attr.hasAttribute("stroke"))
|
if (attr.hasAttribute("stroke"))
|
||||||
ri._strokeColor = QColor(attr.value("stroke").toString());
|
ri._strokeColor = QColor(attr.value("stroke").toString());
|
||||||
if (attr.hasAttribute("stroke-width")) {
|
if (attr.hasAttribute("stroke-width")) {
|
||||||
ri._strokeWidth = attr.value("stroke-width").toFloat(&ok)
|
ri._strokeWidth = attr.value("stroke-width").toFloat(&ok);
|
||||||
* baseStrokeWidth;
|
|
||||||
if (!ok || ri._strokeWidth < 0) {
|
if (!ok || ri._strokeWidth < 0) {
|
||||||
reader.raiseError("invalid stroke-width value");
|
reader.raiseError("invalid stroke-width value");
|
||||||
return;
|
return;
|
||||||
@ -241,8 +240,7 @@ void Style::area(QXmlStreamReader &reader, const QString &dir, qreal ratio,
|
|||||||
reader.skipCurrentElement();
|
reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Style::line(QXmlStreamReader &reader, qreal baseStrokeWidth,
|
void Style::line(QXmlStreamReader &reader, const Rule &rule)
|
||||||
const Rule &rule)
|
|
||||||
{
|
{
|
||||||
PathRender ri(rule, _paths.size() + _circles.size());
|
PathRender ri(rule, _paths.size() + _circles.size());
|
||||||
const QXmlStreamAttributes &attr = reader.attributes();
|
const QXmlStreamAttributes &attr = reader.attributes();
|
||||||
@ -253,8 +251,7 @@ void Style::line(QXmlStreamReader &reader, qreal baseStrokeWidth,
|
|||||||
if (attr.hasAttribute("stroke"))
|
if (attr.hasAttribute("stroke"))
|
||||||
ri._strokeColor = QColor(attr.value("stroke").toString());
|
ri._strokeColor = QColor(attr.value("stroke").toString());
|
||||||
if (attr.hasAttribute("stroke-width")) {
|
if (attr.hasAttribute("stroke-width")) {
|
||||||
ri._strokeWidth = attr.value("stroke-width").toFloat(&ok)
|
ri._strokeWidth = attr.value("stroke-width").toFloat(&ok);
|
||||||
* baseStrokeWidth;
|
|
||||||
if (!ok || ri._strokeWidth < 0) {
|
if (!ok || ri._strokeWidth < 0) {
|
||||||
reader.raiseError("invalid stroke-width value");
|
reader.raiseError("invalid stroke-width value");
|
||||||
return;
|
return;
|
||||||
@ -302,7 +299,7 @@ void Style::line(QXmlStreamReader &reader, qreal baseStrokeWidth,
|
|||||||
ri._curve = true;
|
ri._curve = true;
|
||||||
}
|
}
|
||||||
if (attr.hasAttribute("dy")) {
|
if (attr.hasAttribute("dy")) {
|
||||||
ri._dy = attr.value("dy").toDouble(&ok) * baseStrokeWidth;
|
ri._dy = attr.value("dy").toDouble(&ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
reader.raiseError("invalid dy value");
|
reader.raiseError("invalid dy value");
|
||||||
return;
|
return;
|
||||||
@ -315,8 +312,7 @@ void Style::line(QXmlStreamReader &reader, qreal baseStrokeWidth,
|
|||||||
reader.skipCurrentElement();
|
reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Style::circle(QXmlStreamReader &reader, qreal baseStrokeWidth,
|
void Style::circle(QXmlStreamReader &reader, const Rule &rule)
|
||||||
const Rule &rule)
|
|
||||||
{
|
{
|
||||||
CircleRender ri(rule, _paths.size() + _circles.size());
|
CircleRender ri(rule, _paths.size() + _circles.size());
|
||||||
const QXmlStreamAttributes &attr = reader.attributes();
|
const QXmlStreamAttributes &attr = reader.attributes();
|
||||||
@ -329,14 +325,14 @@ void Style::circle(QXmlStreamReader &reader, qreal baseStrokeWidth,
|
|||||||
if (attr.hasAttribute("stroke"))
|
if (attr.hasAttribute("stroke"))
|
||||||
strokeColor = QColor(attr.value("stroke").toString());
|
strokeColor = QColor(attr.value("stroke").toString());
|
||||||
if (attr.hasAttribute("stroke-width")) {
|
if (attr.hasAttribute("stroke-width")) {
|
||||||
strokeWidth = attr.value("stroke-width").toFloat(&ok) * baseStrokeWidth;
|
strokeWidth = attr.value("stroke-width").toFloat(&ok);
|
||||||
if (!ok || strokeWidth < 0) {
|
if (!ok || strokeWidth < 0) {
|
||||||
reader.raiseError("invalid stroke-width value");
|
reader.raiseError("invalid stroke-width value");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (attr.hasAttribute("radius")) {
|
if (attr.hasAttribute("radius")) {
|
||||||
ri._radius = attr.value("radius").toDouble(&ok) * baseStrokeWidth;
|
ri._radius = attr.value("radius").toDouble(&ok);
|
||||||
if (!ok || ri._radius <= 0) {
|
if (!ok || ri._radius <= 0) {
|
||||||
reader.raiseError("invalid radius value");
|
reader.raiseError("invalid radius value");
|
||||||
return;
|
return;
|
||||||
@ -499,8 +495,8 @@ void Style::symbol(QXmlStreamReader &reader, const QString &dir, qreal ratio,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Style::rule(QXmlStreamReader &reader, const QString &dir,
|
void Style::rule(QXmlStreamReader &reader, const QString &dir,
|
||||||
const MapData &data, qreal ratio, qreal baseStrokeWidth,
|
const MapData &data, qreal ratio, const QSet<QString> &cats,
|
||||||
const QSet<QString> &cats, const Rule &parent)
|
const Rule &parent)
|
||||||
{
|
{
|
||||||
Rule r(parent);
|
Rule r(parent);
|
||||||
const QXmlStreamAttributes &attr = reader.attributes();
|
const QXmlStreamAttributes &attr = reader.attributes();
|
||||||
@ -545,13 +541,13 @@ void Style::rule(QXmlStreamReader &reader, const QString &dir,
|
|||||||
|
|
||||||
while (reader.readNextStartElement()) {
|
while (reader.readNextStartElement()) {
|
||||||
if (reader.name() == QLatin1String("rule"))
|
if (reader.name() == QLatin1String("rule"))
|
||||||
rule(reader, dir, data, ratio, baseStrokeWidth, cats, r);
|
rule(reader, dir, data, ratio, cats, r);
|
||||||
else if (reader.name() == QLatin1String("area"))
|
else if (reader.name() == QLatin1String("area"))
|
||||||
area(reader, dir, ratio, baseStrokeWidth, r);
|
area(reader, dir, ratio, r);
|
||||||
else if (reader.name() == QLatin1String("line"))
|
else if (reader.name() == QLatin1String("line"))
|
||||||
line(reader, baseStrokeWidth, r);
|
line(reader, r);
|
||||||
else if (reader.name() == QLatin1String("circle"))
|
else if (reader.name() == QLatin1String("circle"))
|
||||||
circle(reader, baseStrokeWidth, r);
|
circle(reader, r);
|
||||||
else if (reader.name() == QLatin1String("pathText")) {
|
else if (reader.name() == QLatin1String("pathText")) {
|
||||||
QList<QList<TextRender>*> list;
|
QList<QList<TextRender>*> list;
|
||||||
list.append(&_pathLabels);
|
list.append(&_pathLabels);
|
||||||
@ -639,21 +635,10 @@ void Style::rendertheme(QXmlStreamReader &reader, const QString &dir,
|
|||||||
{
|
{
|
||||||
Rule r;
|
Rule r;
|
||||||
QSet<QString> cats;
|
QSet<QString> cats;
|
||||||
qreal baseStrokeWidth = 1.0;
|
|
||||||
|
|
||||||
const QXmlStreamAttributes &attr = reader.attributes();
|
|
||||||
if (attr.hasAttribute("base-stroke-width")) {
|
|
||||||
bool ok;
|
|
||||||
baseStrokeWidth = attr.value("base-stroke-width").toFloat(&ok);
|
|
||||||
if (!ok || baseStrokeWidth < 0) {
|
|
||||||
reader.raiseError("invalid base-stroke-width value");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (reader.readNextStartElement()) {
|
while (reader.readNextStartElement()) {
|
||||||
if (reader.name() == QLatin1String("rule"))
|
if (reader.name() == QLatin1String("rule"))
|
||||||
rule(reader, dir, data, ratio, baseStrokeWidth, cats, r);
|
rule(reader, dir, data, ratio, cats, r);
|
||||||
else if (reader.name() == QLatin1String("stylemenu")) {
|
else if (reader.name() == QLatin1String("stylemenu")) {
|
||||||
Menu menu(stylemenu(reader));
|
Menu menu(stylemenu(reader));
|
||||||
cats = menu.cats();
|
cats = menu.cats();
|
||||||
|
@ -298,13 +298,11 @@ private:
|
|||||||
Menu stylemenu(QXmlStreamReader &reader);
|
Menu stylemenu(QXmlStreamReader &reader);
|
||||||
QString cat(QXmlStreamReader &reader);
|
QString cat(QXmlStreamReader &reader);
|
||||||
void rule(QXmlStreamReader &reader, const QString &dir, const MapData &data,
|
void rule(QXmlStreamReader &reader, const QString &dir, const MapData &data,
|
||||||
qreal ratio, qreal baseStrokeWidth, const QSet<QString> &cats,
|
qreal ratio, const QSet<QString> &cats, const Rule &parent);
|
||||||
const Rule &parent);
|
|
||||||
void area(QXmlStreamReader &reader, const QString &dir, qreal ratio,
|
void area(QXmlStreamReader &reader, const QString &dir, qreal ratio,
|
||||||
qreal baseStrokeWidth, const Rule &rule);
|
|
||||||
void line(QXmlStreamReader &reader, qreal baseStrokeWidth, const Rule &rule);
|
|
||||||
void circle(QXmlStreamReader &reader, qreal baseStrokeWidth,
|
|
||||||
const Rule &rule);
|
const Rule &rule);
|
||||||
|
void line(QXmlStreamReader &reader, const Rule &rule);
|
||||||
|
void circle(QXmlStreamReader &reader, const Rule &rule);
|
||||||
void text(QXmlStreamReader &reader, const MapData &data, const Rule &rule,
|
void text(QXmlStreamReader &reader, const MapData &data, const Rule &rule,
|
||||||
QList<QList<TextRender> *> &lists);
|
QList<QList<TextRender> *> &lists);
|
||||||
void symbol(QXmlStreamReader &reader, const QString &dir, qreal ratio,
|
void symbol(QXmlStreamReader &reader, const QString &dir, qreal ratio,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user