#include #include #include #include "map/dem.h" #include "map/rectd.h" #include "map/hillshading.h" #include "map/filter.h" #include "map/bitmapline.h" #include "rastertile.h" using namespace Mapsforge; #define TEXT_EXTENT 160 #define PATHS_EXTENT 20 #define SEARCH_EXTENT -0.5 static double LIMIT = cos(deg2rad(170)); static const QByteArray *label(unsigned key, const QVector &tags) { for (int i = 0; i < tags.size(); i++) { const MapData::Tag &tag = tags.at(i); if (tag.key == key) return tag.value.isEmpty() ? 0 : &tag.value; } return 0; } static const QColor *haloColor(const Style::TextRender *ti) { return (ti->strokeColor() != ti->fillColor() && ti->strokeWidth() > 0) ? &ti->strokeColor() : 0; } static QPainterPath parallelPath(const QPainterPath &p, double dy) { int n = p.elementCount() - 1; QVector u(n); QPainterPath h; h.reserve(p.elementCount()); for (int k = 0; k < n; k++) { qreal c = p.elementAt(k + 1).x - p.elementAt(k).x; qreal s = p.elementAt(k + 1).y - p.elementAt(k).y; qreal l = sqrt(c * c + s * s); u[k] = (l == 0) ? QPointF(0, 0) : QPointF(c / l, s / l); if (k == 0) continue; if (u.at(k).x() * u.at(k-1).x() + u.at(k).y() * u.at(k-1).y() < LIMIT) return p; } h.moveTo(QPointF(p.elementAt(0).x - dy * u.at(0).y(), p.elementAt(0).y + dy * u.at(0).x())); for (int k = 1; k < n; k++) { qreal l = dy / (1 + u.at(k).x() * u.at(k-1).x() + u.at(k).y() * u.at(k-1).y()); QPainterPath::Element e(p.elementAt(k)); h.lineTo(QPointF(e.x - l * (u.at(k).y() + u.at(k-1).y()), e.y + l * (u.at(k).x() + u.at(k-1).x()))); } h.lineTo(QPointF(p.elementAt(n).x - dy * u.at(n-1).y(), p.elementAt(n).y + dy * u.at(n-1).x())); return h; } void RasterTile::processLabels(const QList &points, QList &textItems) const { QList