42 static QList<QGeoCoordinate> path(
const QGeoRectangle &rect)
44 QList<QGeoCoordinate> res;
45 res << rect.topLeft();
46 res << QGeoCoordinate(rect.topLeft().latitude(), rect.bottomRight().longitude());
47 res << rect.bottomRight();
48 res << QGeoCoordinate(rect.bottomRight().latitude(), rect.topLeft().longitude());
52 static QList<QGeoCoordinate> perimeter(
const QGeoRectangle &rect)
54 QList<QGeoCoordinate> res = path(rect);
55 res.append(res.first());
59 static QList<QDoubleVector2D> pathMercator(
const QList<QGeoCoordinate> &p)
61 QList<QDoubleVector2D> res;
62 for (
const auto &c: p)
63 res << QWebMercator::coordToMercator(c);
67 QGeoMapItemGeometry();
68 virtual ~QGeoMapItemGeometry();
70 inline bool isSourceDirty()
const {
return sourceDirty_; }
71 inline bool isScreenDirty()
const {
return screenDirty_; }
72 inline void markSourceDirty() { sourceDirty_ =
true; screenDirty_ =
true; }
73 inline void markScreenDirty() { screenDirty_ =
true; clipToViewport_ =
true; }
74 inline void markFullScreenDirty() { screenDirty_ =
true; clipToViewport_ =
false;}
75 inline void markClean() { screenDirty_ = (sourceDirty_ =
false); clipToViewport_ =
true;}
76 inline void clearScreen() { screenDirty_ =
false; }
78 inline QGeoCoordinate geoLeftBound() {
return geoLeftBound_; }
80 inline QRectF sourceBoundingBox()
const {
return sourceBounds_; }
81 inline QRectF screenBoundingBox()
const {
return screenBounds_; }
82 inline void clearBounds() { sourceBounds_ = screenBounds_ = QRectF(); firstPointOffset_ = QPointF(); }
84 inline QPointF firstPointOffset()
const {
return firstPointOffset_; }
86 inline const QGeoCoordinate &origin()
const {
return srcOrigin_; }
88 QPainterPath screenOutline()
const {
89 return screenOutline_;
92 virtual bool contains(
const QPointF &screenPoint)
const {
93 return screenOutline_.contains(screenPoint);
96 inline QVector2D vertex(quint32 index)
const {
97 return QVector2D(screenVertices_[index]);
100 inline QList<QPointF> vertices()
const {
return screenVertices_; }
101 inline QList<quint32> indices()
const {
return screenIndices_; }
103 inline bool isIndexed()
const {
return (!screenIndices_.isEmpty()); }
106 inline quint32 size()
const
109 return screenIndices_.size() / 3;
111 return screenVertices_.size() / 3;
114 inline void clear() { firstPointOffset_ = QPointF(0,0);
115 screenVertices_.clear(); screenIndices_.clear(); }
117 mutable bool m_dataChanged =
false;
120 Q_DISABLE_COPY(QGeoMapItemGeometry);
123 bool sourceDirty_ =
true;
124 bool screenDirty_ =
true;
125 bool clipToViewport_ =
true;
126 bool preserveGeometry_ =
false;
127 QGeoCoordinate geoLeftBound_;
129 QPointF firstPointOffset_;
131 QPainterPath screenOutline_;
133 QRectF sourceBounds_;
134 QRectF screenBounds_;
136 QGeoCoordinate srcOrigin_;
138 QList<QPointF> screenVertices_;
139 QList<quint32> screenIndices_;