summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2022-10-04 23:46:58 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2022-10-06 13:28:06 +0200
commitc40b5fdffaa4ff23c27974665eebdeacefa5b03a (patch)
treebfc33cf60fc5bb6afea4e374d2d13e454bf5e072 /src
parentf92b88e99f2802f85af10e6e19c9c5e6800ee75c (diff)
downloadqtlocation-c40b5fdffaa4ff23c27974665eebdeacefa5b03a.tar.gz
Clean up: move code into right place, remove dead code
QGeoMapItemGeometry::geoDistanceToScreenWidth was unused, so remove it. Move path/pathMercator projection helpers to QGeoMapItemGeometry, they are used in items other than the rectangle items. In mapbox plugin, call static helper from correct class. Change-Id: I5645f503a24e23e295211da32e98f995b8c17b56 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/location/quickmapitems/qdeclarativepolygonmapitem.cpp2
-rw-r--r--src/location/quickmapitems/qdeclarativepolylinemapitem.cpp4
-rw-r--r--src/location/quickmapitems/qdeclarativerectanglemapitem.cpp4
-rw-r--r--src/location/quickmapitems/qdeclarativerectanglemapitem_p_p.h29
-rw-r--r--src/location/quickmapitems/qgeomapitemgeometry.cpp22
-rw-r--r--src/location/quickmapitems/qgeomapitemgeometry_p.h33
-rw-r--r--src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp2
7 files changed, 35 insertions, 61 deletions
diff --git a/src/location/quickmapitems/qdeclarativepolygonmapitem.cpp b/src/location/quickmapitems/qdeclarativepolygonmapitem.cpp
index ff1bdecb..53a9f8f5 100644
--- a/src/location/quickmapitems/qdeclarativepolygonmapitem.cpp
+++ b/src/location/quickmapitems/qdeclarativepolygonmapitem.cpp
@@ -621,7 +621,7 @@ void QGeoMapPolygonGeometryOpenGL::updateSourcePoints(const QGeoMap &map, const
{
if (!sourceDirty_)
return;
- const QList<QGeoCoordinate> perimeter = QDeclarativeRectangleMapItemPrivateCPU::path(rect);
+ const QList<QGeoCoordinate> perimeter = QGeoMapItemGeometry::path(rect);
updateSourcePoints(map, perimeter);
}
diff --git a/src/location/quickmapitems/qdeclarativepolylinemapitem.cpp b/src/location/quickmapitems/qdeclarativepolylinemapitem.cpp
index c1f6d0bf..5a4e06c3 100644
--- a/src/location/quickmapitems/qdeclarativepolylinemapitem.cpp
+++ b/src/location/quickmapitems/qdeclarativepolylinemapitem.cpp
@@ -891,8 +891,8 @@ void QGeoMapPolylineGeometryOpenGL::updateSourcePoints(const QGeoProjectionWebMe
void QGeoMapPolylineGeometryOpenGL::updateSourcePoints(const QGeoMap &map, const QGeoRectangle &rect)
{
- const QGeoPath path(QDeclarativeRectangleMapItemPrivateCPU::perimeter(rect));
- updateSourcePoints(map, path);
+ const QList<QGeoCoordinate> perimeter = QGeoMapItemGeometry::perimeter(rect);
+ updateSourcePoints(map, QGeoPath(perimeter));
}
void QGeoMapPolylineGeometryOpenGL::updateSourcePoints(const QGeoMap &map, const QGeoCircle &circle)
diff --git a/src/location/quickmapitems/qdeclarativerectanglemapitem.cpp b/src/location/quickmapitems/qdeclarativerectanglemapitem.cpp
index 4c18335b..dcce6f42 100644
--- a/src/location/quickmapitems/qdeclarativerectanglemapitem.cpp
+++ b/src/location/quickmapitems/qdeclarativerectanglemapitem.cpp
@@ -420,8 +420,8 @@ void QDeclarativeRectangleMapItemPrivateCPU::updatePolish()
QScopedValueRollback<bool> rollback(m_rect.m_updatingGeometry);
m_rect.m_updatingGeometry = true;
- const QList<QGeoCoordinate> perimeter = path(m_rect.m_rectangle);
- const QList<QDoubleVector2D> pathMercator_ = pathMercator(perimeter);
+ const QList<QGeoCoordinate> perimeter = QGeoMapItemGeometry::path(m_rect.m_rectangle);
+ const QList<QDoubleVector2D> pathMercator_ = QGeoMapItemGeometry::pathMercator(perimeter);
m_geometry.setPreserveGeometry(true, m_rect.m_rectangle.topLeft());
m_geometry.updateSourcePoints(*m_rect.map(), pathMercator_);
m_geometry.updateScreenPoints(*m_rect.map(), m_rect.m_border.width());
diff --git a/src/location/quickmapitems/qdeclarativerectanglemapitem_p_p.h b/src/location/quickmapitems/qdeclarativerectanglemapitem_p_p.h
index ff2350e5..1c4d2bc0 100644
--- a/src/location/quickmapitems/qdeclarativerectanglemapitem_p_p.h
+++ b/src/location/quickmapitems/qdeclarativerectanglemapitem_p_p.h
@@ -133,35 +133,6 @@ public:
QSGNode * updateMapItemPaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *data) override;
bool contains(const QPointF &point) const override;
- static QList<QGeoCoordinate> path(const QGeoRectangle &rect)
- {
- QList<QGeoCoordinate> res;
- res << rect.topLeft();
- res << QGeoCoordinate(rect.topLeft().latitude(), rect.bottomRight().longitude());
- res << rect.bottomRight();
- res << QGeoCoordinate(rect.bottomRight().latitude(), rect.topLeft().longitude());
- return res;
- }
-
- static QList<QGeoCoordinate> perimeter(const QGeoRectangle &rect)
- {
- QList<QGeoCoordinate> res;
- res << rect.topLeft();
- res << QGeoCoordinate(rect.topLeft().latitude(), rect.bottomRight().longitude());
- res << rect.bottomRight();
- res << QGeoCoordinate(rect.bottomRight().latitude(), rect.topLeft().longitude());
- res << res.first();
- return res;
- }
-
- static QList<QDoubleVector2D> pathMercator(const QList<QGeoCoordinate> &p)
- {
- QList<QDoubleVector2D> res;
- for (const auto &c: p)
- res << QWebMercator::coordToMercator(c);
- return res;
- }
-
QGeoMapPolygonGeometry m_geometry;
QGeoMapPolylineGeometry m_borderGeometry;
MapPolygonNode *m_node = nullptr;
diff --git a/src/location/quickmapitems/qgeomapitemgeometry.cpp b/src/location/quickmapitems/qgeomapitemgeometry.cpp
index 60ff4eec..e93d4190 100644
--- a/src/location/quickmapitems/qgeomapitemgeometry.cpp
+++ b/src/location/quickmapitems/qgeomapitemgeometry.cpp
@@ -124,26 +124,4 @@ QRectF QGeoMapItemGeometry::translateToCommonOrigin(const QList<QGeoMapItemGeome
return brects.boundingRect();
}
-/*!
- \internal
-*/
-double QGeoMapItemGeometry::geoDistanceToScreenWidth(const QGeoMap &map,
- const QGeoCoordinate &fromCoord,
- const QGeoCoordinate &toCoord)
-{
- // Do not wrap around half the globe
- Q_ASSERT(!qFuzzyCompare(fromCoord.longitude(), toCoord.longitude()));
-
- QGeoCoordinate mapMid = map.geoProjection().itemPositionToCoordinate(QDoubleVector2D(map.viewportWidth()/2.0, 0));
- double halfGeoDist = toCoord.longitude() - fromCoord.longitude();
- if (toCoord.longitude() < fromCoord.longitude())
- halfGeoDist += 360;
- halfGeoDist /= 2.0;
- QGeoCoordinate geoDelta = QGeoCoordinate(0,
- QLocationUtils::wrapLong(mapMid.longitude() + halfGeoDist));
- QDoubleVector2D halfScreenDist = map.geoProjection().coordinateToItemPosition(geoDelta, false)
- - QDoubleVector2D(map.viewportWidth()/2.0, 0);
- return halfScreenDist.x() * 2.0;
-}
-
QT_END_NAMESPACE
diff --git a/src/location/quickmapitems/qgeomapitemgeometry_p.h b/src/location/quickmapitems/qgeomapitemgeometry_p.h
index b6c4a515..0b827d4f 100644
--- a/src/location/quickmapitems/qgeomapitemgeometry_p.h
+++ b/src/location/quickmapitems/qgeomapitemgeometry_p.h
@@ -52,12 +52,16 @@
//
#include <QtLocation/private/qlocationglobal_p.h>
+#include <QtLocation/private/qdeclarativegeomapitemutils_p.h>
+#include <QtPositioning/private/qdoublevector2d_p.h>
+#include <QtPositioning/private/qwebmercator_p.h>
#include <QPainterPath>
#include <QPointF>
#include <QRectF>
#include <QList>
#include <QGeoCoordinate>
+#include <QGeoRectangle>
#include <QVector2D>
#include <QList>
@@ -69,6 +73,31 @@ class QGeoMap;
class Q_LOCATION_PRIVATE_EXPORT QGeoMapItemGeometry
{
public:
+ static QList<QGeoCoordinate> path(const QGeoRectangle &rect)
+ {
+ QList<QGeoCoordinate> res;
+ res << rect.topLeft();
+ res << QGeoCoordinate(rect.topLeft().latitude(), rect.bottomRight().longitude());
+ res << rect.bottomRight();
+ res << QGeoCoordinate(rect.bottomRight().latitude(), rect.topLeft().longitude());
+ return res;
+ }
+
+ static QList<QGeoCoordinate> perimeter(const QGeoRectangle &rect)
+ {
+ QList<QGeoCoordinate> res = path(rect);
+ res.append(res.first());
+ return res;
+ }
+
+ static QList<QDoubleVector2D> pathMercator(const QList<QGeoCoordinate> &p)
+ {
+ QList<QDoubleVector2D> res;
+ for (const auto &c: p)
+ res << QWebMercator::coordToMercator(c);
+ return res;
+ }
+
QGeoMapItemGeometry();
virtual ~QGeoMapItemGeometry();
@@ -128,10 +157,6 @@ public:
void allocateAndFill(QSGGeometry *geom) const;
- double geoDistanceToScreenWidth(const QGeoMap &map,
- const QGeoCoordinate &fromCoord,
- const QGeoCoordinate &toCoord);
-
static QRectF translateToCommonOrigin(const QList<QGeoMapItemGeometry *> &geoms);
mutable bool m_dataChanged = false;
diff --git a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
index 581b05e2..c094d51b 100644
--- a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
+++ b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
@@ -97,7 +97,7 @@ QMapbox::Feature featureFromMapCircle(QDeclarativeCircleMapItem *mapItem)
const QGeoProjectionWebMercator &p = static_cast<const QGeoProjectionWebMercator&>(mapItem->map()->geoProjection());
QList<QGeoCoordinate> path;
QGeoCoordinate leftBound;
- QDeclarativeCircleMapItemPrivateCPU::calculatePeripheralPoints(path, mapItem->center(), mapItem->radius(), circleSamples, leftBound);
+ QDeclarativeCircleMapItemPrivate::calculatePeripheralPoints(path, mapItem->center(), mapItem->radius(), circleSamples, leftBound);
QList<QDoubleVector2D> pathProjected;
for (const QGeoCoordinate &c : qAsConst(path))
pathProjected << p.geoToMapProjection(c);