Skip to content

Commit

Permalink
Improved area labels layout
Browse files Browse the repository at this point in the history
  • Loading branch information
tumic0 committed Nov 11, 2024
1 parent 6493d10 commit 6ca1e3b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/map/mapsforge/rastertile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ using namespace Mapsforge;

static double LIMIT = cos(deg2rad(170));

static bool rectNearPolygon(const QPainterPath &path, const QRectF &rect)
{
return (path.boundingRect().contains(rect)
&& (path.contains(rect.topLeft()) || path.contains(rect.topRight())
|| path.contains(rect.bottomLeft()) || path.contains(rect.bottomRight())));
}

static QPointF centroid(const QPainterPath &polygon)
{
qreal area = 0;
Expand Down Expand Up @@ -208,6 +215,7 @@ void RasterTile::processAreaLabels(const QVector<PainterPath> &paths,
PointItem *item = new PointItem(pos.toPoint(), p.lbl, font, img, color,
hColor);
if (item->isValid() && _rect.contains(item->boundingRect().toRect())
&& rectNearPolygon(p.p->pp, item->boundingRect())
&& !item->collides(textItems)) {
textItems.append(item);
if (p.ti && p.lbl)
Expand Down

0 comments on commit 6ca1e3b

Please sign in to comment.