41 static QList<QGeoCoordinate> path(
const QGeoRectangle &rect)
43 QList<QGeoCoordinate> res;
44 res << rect.topLeft();
45 res << QGeoCoordinate(rect.topLeft().latitude(), rect.bottomRight().longitude());
46 res << rect.bottomRight();
47 res << QGeoCoordinate(rect.bottomRight().latitude(), rect.topLeft().longitude());
51 static QList<QGeoCoordinate> perimeter(
const QGeoRectangle &rect)
53 QList<QGeoCoordinate> res = path(rect);
54 res.append(res.first());
58 static QList<QDoubleVector2D> pathMercator(
const QList<QGeoCoordinate> &p)
60 QList<QDoubleVector2D> res;
61 for (
const auto &c: p)
62 res << QWebMercator::coordToMercator(c);
66 QGeoMapItemGeometry();
67 virtual ~QGeoMapItemGeometry();
69 inline bool isSourceDirty()
const {
return sourceDirty_; }
70 inline bool isScreenDirty()
const {
return screenDirty_; }
71 inline void markSourceDirty() { sourceDirty_ =
true; screenDirty_ =
true; }
72 inline void markScreenDirty() { screenDirty_ =
true; clipToViewport_ =
true; }
73 inline void markFullScreenDirty() { screenDirty_ =
true; clipToViewport_ =
false;}
74 inline void markClean() { screenDirty_ = (sourceDirty_ =
false); clipToViewport_ =
true;}
75 inline void clearScreen() { screenDirty_ =
false; }
77 inline QGeoCoordinate geoLeftBound() {
return geoLeftBound_; }
79 inline QRectF sourceBoundingBox()
const {
return sourceBounds_; }
80 inline QRectF screenBoundingBox()
const {
return screenBounds_; }
81 inline void clearBounds() { sourceBounds_ = screenBounds_ = QRectF(); firstPointOffset_ = QPointF(); }
83 inline QPointF firstPointOffset()
const {
return firstPointOffset_; }
85 inline const QGeoCoordinate &origin()
const {
return srcOrigin_; }
87 QPainterPath screenOutline()
const {
88 return screenOutline_;
91 virtual bool contains(
const QPointF &screenPoint)
const {
92 return screenOutline_.contains(screenPoint);
95 inline QVector2D vertex(quint32 index)
const {
96 return QVector2D(screenVertices_[index]);
99 inline QList<QPointF> vertices()
const {
return screenVertices_; }
100 inline QList<quint32> indices()
const {
return screenIndices_; }
102 inline bool isIndexed()
const {
return (!screenIndices_.isEmpty()); }
105 inline quint32 size()
const
108 return screenIndices_.size() / 3;
110 return screenVertices_.size() / 3;
113 inline void clear() { firstPointOffset_ = QPointF(0,0);
114 screenVertices_.clear(); screenIndices_.clear(); }
116 mutable bool m_dataChanged =
false;
119 Q_DISABLE_COPY(QGeoMapItemGeometry);
122 bool sourceDirty_ =
true;
123 bool screenDirty_ =
true;
124 bool clipToViewport_ =
true;
125 bool preserveGeometry_ =
false;
126 QGeoCoordinate geoLeftBound_;
128 QPointF firstPointOffset_;
130 QPainterPath screenOutline_;
132 QRectF sourceBounds_;
133 QRectF screenBounds_;
135 QGeoCoordinate srcOrigin_;
137 QList<QPointF> screenVertices_;
138 QList<quint32> screenIndices_;