diff --git a/src/map/mapsforge/rastertile.cpp b/src/map/mapsforge/rastertile.cpp index d68bae72..9487aa74 100644 --- a/src/map/mapsforge/rastertile.cpp +++ b/src/map/mapsforge/rastertile.cpp @@ -200,6 +200,11 @@ QPainterPath RasterTile::painterPath(const Polygon &polygon, bool curve) const { QPainterPath path; + int size = 0; + for (int i = 0; i < polygon.size(); i++) + size += polygon.at(i).size(); + path.reserve(size); + for (int i = 0; i < polygon.size(); i++) { const QVector &subpath = polygon.at(i); diff --git a/src/map/mapsforge/style.cpp b/src/map/mapsforge/style.cpp index 1e21fa27..fe43fe7b 100644 --- a/src/map/mapsforge/style.cpp +++ b/src/map/mapsforge/style.cpp @@ -138,12 +138,13 @@ void Style::area(QXmlStreamReader &reader, const QString &dir, qreal ratio, PathRender ri(rule, _paths.size() + _circles.size()); const QXmlStreamAttributes &attr = reader.attributes(); QString file; + QColor fillColor; int height = 0, width = 0; bool ok; ri._area = true; if (attr.hasAttribute("fill")) - ri._fillColor = QColor(attr.value("fill").toString()); + fillColor = QColor(attr.value("fill").toString()); if (attr.hasAttribute("stroke")) ri._strokeColor = QColor(attr.value("stroke").toString()); if (attr.hasAttribute("stroke-width")) { @@ -171,7 +172,9 @@ void Style::area(QXmlStreamReader &reader, const QString &dir, qreal ratio, } if (!file.isNull()) - ri._fillImage = image(file, width, height, ratio); + ri._brush = QBrush(image(file, width, height, ratio)); + else if (fillColor.isValid()) + ri._brush = QBrush(fillColor); if (ri.rule()._type == Rule::AnyType || ri.rule()._type == Rule::WayType) _paths.append(ri); @@ -652,10 +655,9 @@ QList Style::areaSymbols(int zoom) const QPen Style::PathRender::pen(int zoom) const { - qreal width = (zoom >= 12) - ? pow(1.5, zoom - 12) * _strokeWidth : _strokeWidth; - if (_strokeColor.isValid()) { + qreal width = (zoom >= 12) + ? pow(1.5, zoom - 12) * _strokeWidth : _strokeWidth; QPen p(QBrush(_strokeColor), width, Qt::SolidLine, _strokeCap, _strokeJoin); if (!_strokeDasharray.isEmpty()) { @@ -669,16 +671,6 @@ QPen Style::PathRender::pen(int zoom) const return Qt::NoPen; } -QBrush Style::PathRender::brush() const -{ - if (!_fillImage.isNull()) - return QBrush(_fillImage); - else if (_fillColor.isValid()) - return QBrush(_fillColor); - else - return Qt::NoBrush; -} - qreal Style::CircleRender::radius(int zoom) const { return (_scale && zoom >= 12) ? pow(1.5, zoom - 12) * _radius : _radius; diff --git a/src/map/mapsforge/style.h b/src/map/mapsforge/style.h index 95400d92..93bc8402 100644 --- a/src/map/mapsforge/style.h +++ b/src/map/mapsforge/style.h @@ -11,17 +11,6 @@ class QXmlStreamReader; namespace Mapsforge { -inline bool wcmp(const QByteArray &b1, const QByteArray &b2) -{ - int len = b1.length(); - - if (!len) - return true; - if (len != b2.length()) - return false; - return !memcmp(b1.constData(), b2.constData(), len); -} - class Style { public: @@ -87,10 +76,13 @@ public: bool valueMatches(const QVector &tags) const { - for (int i = 0; i < _vals.size(); i++) - for (int j = 0; j < tags.size(); j++) - if (wcmp(_vals.at(i), tags.at(j).value)) + for (int i = 0; i < _vals.size(); i++) { + for (int j = 0; j < tags.size(); j++) { + const QByteArray &ba = _vals.at(i); + if (!ba.size() || ba == tags.at(j).value) return true; + } + } return false; } @@ -148,7 +140,7 @@ public: int zOrder() const {return _zOrder;} QPen pen(int zoom) const; - QBrush brush() const; + const QBrush &brush() const {return _brush;} bool area() const {return _area;} bool curve() const {return _curve;} @@ -156,12 +148,12 @@ public: friend class Style; int _zOrder; - QColor _fillColor, _strokeColor; + QColor _strokeColor; qreal _strokeWidth; QVector _strokeDasharray; Qt::PenCapStyle _strokeCap; Qt::PenJoinStyle _strokeJoin; - QImage _fillImage; + QBrush _brush; bool _area, _curve; };