mirror of
https://github.com/tumic0/QtPBFImagePlugin.git
synced 2024-11-24 03:35:54 +01:00
Display labels overlapping between tiles
(requires unique feature IDs in PBF data - OpenMapTiles >= v3.7)
This commit is contained in:
parent
71895813ab
commit
b7fb925178
@ -69,6 +69,11 @@ private:
|
|||||||
const vector_tile::Tile_Feature *_data;
|
const vector_tile::Tile_Feature *_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool cmp(const Feature &f1, const Feature &f2)
|
||||||
|
{
|
||||||
|
return f1.data()->id() < f2.data()->id();
|
||||||
|
}
|
||||||
|
|
||||||
class Layer
|
class Layer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -84,6 +89,7 @@ public:
|
|||||||
|
|
||||||
for (int i = 0; i < data->features_size(); i++)
|
for (int i = 0; i < data->features_size(); i++)
|
||||||
_features.append(Feature(&(data->features(i)), &keys, &values));
|
_features.append(Feature(&(data->features(i)), &keys, &values));
|
||||||
|
qSort(_features.begin(), _features.end(), cmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<Feature> &features() const {return _features;}
|
const QList<Feature> &features() const {return _features;}
|
||||||
|
10
src/text.cpp
10
src/text.cpp
@ -139,18 +139,10 @@ void Text::addLabel(const QString &text, const QPointF &pos, const QFont &font,
|
|||||||
{
|
{
|
||||||
if (text.isEmpty())
|
if (text.isEmpty())
|
||||||
return;
|
return;
|
||||||
if (!sceneRect().contains(pos))
|
|
||||||
return;
|
|
||||||
|
|
||||||
TextItem *ti = new TextItem(text, pos, font, maxTextWidth);
|
TextItem *ti = new TextItem(text, pos, font, maxTextWidth);
|
||||||
addItem(ti);
|
|
||||||
if (!sceneRect().contains(ti->sceneBoundingRect())) {
|
|
||||||
delete ti;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ti->setPen(pen);
|
ti->setPen(pen);
|
||||||
|
addItem(ti);
|
||||||
QList<QGraphicsItem*> ci = collidingItems(ti);
|
QList<QGraphicsItem*> ci = collidingItems(ti);
|
||||||
for (int i = 0; i < ci.size(); i++)
|
for (int i = 0; i < ci.size(); i++)
|
||||||
ci[i]->setVisible(false);
|
ci[i]->setVisible(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user