From 6ae370ac2e2a894f5181df9d5b027896812afaa5 Mon Sep 17 00:00:00 2001 From: Lauri Laanmets Date: Thu, 30 Sep 2021 16:06:43 +0300 Subject: Change QGeoPolygon 'path' to 'perimeter' https://doc.qt.io/qt-6/qtpositioning-changes-qt6.html#rename-qgeopolygon-path This is part of a bigger work to port QtLocation maps to Qt6. Task-number: QTBUG-96795 Change-Id: I34f27f7e21a3e4243b7fc08a93bc6e95d0541814 Reviewed-by: Ivan Solovev Reviewed-by: Alex Blasche Reviewed-by: Andreas Buhr --- .../declarativemaps/qdeclarativepolygonmapitem.cpp | 16 ++++++++-------- .../declarativemaps/qdeclarativepolygonmapitem_p_p.h | 8 ++++---- .../declarativemaps/qdeclarativepolylinemapitem.cpp | 8 ++++---- src/location/labs/qgeojson.cpp | 10 +++++----- src/location/labs/qmappolygonobject.cpp | 10 +++++----- src/location/labs/qsg/qmappolygonobjectqsg.cpp | 2 +- .../geoservices/mapboxgl/qmapboxglstylechange.cpp | 2 +- 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp index 8917dedb..507c5d66 100644 --- a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp +++ b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp @@ -358,7 +358,7 @@ static void wrapPath(const QGeoPolygon &poly for (int i = 0; i < 1+poly.holesCount(); ++i) { QList path; if (!i) { - for (const QGeoCoordinate &c : poly.path()) + for (const QGeoCoordinate &c : poly.perimeter()) path << p.geoToMapProjection(c); } else { for (const QGeoCoordinate &c : poly.holePath(i-1)) @@ -478,7 +478,7 @@ void QGeoMapPolygonGeometryOpenGL::updateSourcePoints(const QGeoMap &map, // 1.1) do the same for the bbox QList wrappedBbox, wrappedBboxPlus1, wrappedBboxMinus1; QGeoPolygon bbox(QGeoPath(perimeter).boundingGeoRectangle()); - QDeclarativeGeoMapItemUtils::wrapPath(bbox.path(), bbox.boundingGeoRectangle().topLeft(), p, + QDeclarativeGeoMapItemUtils::wrapPath(bbox.perimeter(), bbox.boundingGeoRectangle().topLeft(), p, wrappedBbox, wrappedBboxMinus1, wrappedBboxPlus1, &m_bboxLeftBoundWrapped); // 2) Store the triangulated polygon, and the wrapped bbox paths. @@ -513,7 +513,7 @@ void QGeoMapPolygonGeometryOpenGL::updateSourcePoints(const QGeoMap &map, const // 1.1) do the same for the bbox QList wrappedBbox, wrappedBboxPlus1, wrappedBboxMinus1; QGeoPolygon bbox(poly.boundingGeoRectangle()); - QDeclarativeGeoMapItemUtils::wrapPath(bbox.path(), bbox.boundingGeoRectangle().topLeft(), p, + QDeclarativeGeoMapItemUtils::wrapPath(bbox.perimeter(), bbox.boundingGeoRectangle().topLeft(), p, wrappedBbox, wrappedBboxMinus1, wrappedBboxPlus1, &m_bboxLeftBoundWrapped); // 2) Store the triangulated polygon, and the wrapped bbox paths. @@ -729,7 +729,7 @@ void QDeclarativePolygonMapItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *m */ QJSValue QDeclarativePolygonMapItem::path() const { - return fromList(this, m_geopoly.path()); + return fromList(this, m_geopoly.perimeter()); } void QDeclarativePolygonMapItem::setPath(const QJSValue &value) @@ -740,10 +740,10 @@ void QDeclarativePolygonMapItem::setPath(const QJSValue &value) QList pathList = toList(this, value); // Equivalent to QDeclarativePolylineMapItem::setPathFromGeoList - if (m_geopoly.path() == pathList) + if (m_geopoly.perimeter() == pathList) return; - m_geopoly.setPath(pathList); + m_geopoly.setPerimeter(pathList); m_d->onGeoGeometryChanged(); emit pathChanged(); @@ -779,9 +779,9 @@ void QDeclarativePolygonMapItem::addCoordinate(const QGeoCoordinate &coordinate) */ void QDeclarativePolygonMapItem::removeCoordinate(const QGeoCoordinate &coordinate) { - int length = m_geopoly.path().length(); + int length = m_geopoly.perimeter().length(); m_geopoly.removeCoordinate(coordinate); - if (m_geopoly.path().length() == length) + if (m_geopoly.perimeter().length() == length) return; m_d->onGeoGeometryChanged(); diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem_p_p.h b/src/location/declarativemaps/qdeclarativepolygonmapitem_p_p.h index 5b237310..60f32758 100644 --- a/src/location/declarativemaps/qdeclarativepolygonmapitem_p_p.h +++ b/src/location/declarativemaps/qdeclarativepolygonmapitem_p_p.h @@ -346,7 +346,7 @@ public: const QGeoProjectionWebMercator &p = static_cast(m_poly.map()->geoProjection()); m_geopathProjected.clear(); m_geopathProjected.reserve(m_poly.m_geopoly.size()); - for (const QGeoCoordinate &c : m_poly.m_geopoly.path()) + for (const QGeoCoordinate &c : m_poly.m_geopoly.perimeter()) m_geopathProjected << p.geoToMapProjection(c); } void updateCache() @@ -354,7 +354,7 @@ public: if (!m_poly.map() || m_poly.map()->geoProjection().projectionType() != QGeoProjection::ProjectionWebMercator) return; const QGeoProjectionWebMercator &p = static_cast(m_poly.map()->geoProjection()); - m_geopathProjected << p.geoToMapProjection(m_poly.m_geopoly.path().last()); + m_geopathProjected << p.geoToMapProjection(m_poly.m_geopoly.perimeter().last()); } void preserveGeometry() { @@ -390,7 +390,7 @@ public: } void updatePolish() override { - if (m_poly.m_geopoly.path().length() == 0) { // Possibly cleared + if (m_poly.m_geopoly.perimeter().length() == 0) { // Possibly cleared m_geometry.clear(); m_borderGeometry.clear(); m_poly.setWidth(0); @@ -557,7 +557,7 @@ public: } void updatePolish() override { - if (m_poly.m_geopoly.path().length() == 0) { // Possibly cleared + if (m_poly.m_geopoly.perimeter().length() == 0) { // Possibly cleared m_geometry.clear(); m_borderGeometry.clear(); m_poly.setWidth(0); diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp index 88ebef25..ee05503e 100644 --- a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp +++ b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp @@ -751,9 +751,9 @@ void QGeoMapPolylineGeometryOpenGL::updateSourcePoints(const QGeoMap &map, const { if (!sourceDirty_) return; - QGeoPath p(poly.path()); - if (poly.path().size() && poly.path().last() != poly.path().first()) - p.addCoordinate(poly.path().first()); + QGeoPath p(poly.perimeter()); + if (poly.perimeter().size() && poly.perimeter().last() != poly.perimeter().first()) + p.addCoordinate(poly.perimeter().first()); updateSourcePoints(map, p); } @@ -798,7 +798,7 @@ void QGeoMapPolylineGeometryOpenGL::updateSourcePoints(const QGeoProjectionWebMe } QGeoPolygon bbox(QGeoRectangle(topLeft, bottomRight)); QList wrappedBbox, wrappedBboxPlus1, wrappedBboxMinus1; - QDeclarativeGeoMapItemUtils::wrapPath(bbox.path(), bbox.boundingGeoRectangle().topLeft(), p, + QDeclarativeGeoMapItemUtils::wrapPath(bbox.perimeter(), bbox.boundingGeoRectangle().topLeft(), p, wrappedBbox, wrappedBboxMinus1, wrappedBboxPlus1, &m_bboxLeftBoundWrapped); // New pointers, some old LOD task might still be running and operating on the old pointers. diff --git a/src/location/labs/qgeojson.cpp b/src/location/labs/qgeojson.cpp index 163a140f..f5995d9c 100644 --- a/src/location/labs/qgeojson.cpp +++ b/src/location/labs/qgeojson.cpp @@ -587,7 +587,7 @@ static QGeoPolygon importPolygon(const QVariantMap &inputMap) QList> perimeters = importArrayOfArrayOfPositions(valueCoordinates); for (int i = 0; i < perimeters.size(); ++i) { // Import an array of QList if (i == 0) - returnedObject.setPath(perimeters.at(i)); // External perimeter + returnedObject.setPerimeter(perimeters.at(i)); // External perimeter else returnedObject.addHole(perimeters.at(i)); // Inner perimeters } @@ -640,7 +640,7 @@ static QVariantList importMultiPolygon(const QVariantMap &inputMap) for (int j = 0; j < coordinatesList.size(); ++j) { if (j == 0) - singlePoly.setPath(coordinatesList.at(j)); + singlePoly.setPerimeter(coordinatesList.at(j)); else singlePoly.addHole(coordinatesList.at(j)); } @@ -816,7 +816,7 @@ static QJsonObject exportPolygon(const QVariantMap &polygonMap) QJsonValue polyCoordinates; QList> obtainedCoordinatesPoly; QGeoPolygon parsedPoly = polygonVariant.value(); - obtainedCoordinatesPoly << parsedPoly.path(); + obtainedCoordinatesPoly << parsedPoly.perimeter(); if (parsedPoly.holesCount()!=0) for (int i = 0; i < parsedPoly.holesCount(); ++i) { obtainedCoordinatesPoly << parsedPoly.holePath(i); @@ -867,7 +867,7 @@ static QJsonObject exportMultiPolygon(const QVariantMap &multiPolygonMap) int polyHoles = 0; int currentHole; for (int i = 0; i < multiPolygonList.size(); ++i) { // Start parsing Polygon list - extractedCoordinatesValue << multiPolygonList.at(i).value().value(QStringLiteral("data")).value().path(); // Extract external polygon path + extractedCoordinatesValue << multiPolygonList.at(i).value().value(QStringLiteral("data")).value().perimeter(); // Extract external polygon path polyHoles = multiPolygonList.at(i).value().value(QStringLiteral("data")).value().holesCount(); if (polyHoles) // Check if the polygon has holes for (currentHole = 0 ; currentHole < polyHoles; currentHole++) @@ -1158,7 +1158,7 @@ QTextStream &operator << (QTextStream &stream, const QGeoShape &shape) case QGeoShape::PolygonType: { QGeoPolygon poly(shape); stream << "QGeoPolygon("; - for (auto c: poly.path()) + for (auto c: poly.perimeter()) stream << c << ", "; stream << ")"; break; diff --git a/src/location/labs/qmappolygonobject.cpp b/src/location/labs/qmappolygonobject.cpp index 9d679f31..b6415d5c 100644 --- a/src/location/labs/qmappolygonobject.cpp +++ b/src/location/labs/qmappolygonobject.cpp @@ -70,7 +70,7 @@ QMapPolygonObjectPrivateDefault::QMapPolygonObjectPrivateDefault(QGeoMapObject * QMapPolygonObjectPrivateDefault::QMapPolygonObjectPrivateDefault(const QMapPolygonObjectPrivate &other) : QMapPolygonObjectPrivate(other.q) { - m_path.setPath(other.path()); // to stay on the safe side + m_path.setPerimeter(other.path()); // to stay on the safe side QGeoPolygon poly(other.geoShape()); // to handle holes for (int i = 0; i < poly.holesCount(); i++) m_path.addHole(poly.holePath(i)); @@ -91,12 +91,12 @@ QGeoMapObject::Type QMapPolygonObjectPrivate::type() const QList QMapPolygonObjectPrivateDefault::path() const { - return m_path.path(); + return m_path.perimeter(); } void QMapPolygonObjectPrivateDefault::setPath(const QList &path) { - m_path.setPath(path); + m_path.setPerimeter(path); } QColor QMapPolygonObjectPrivateDefault::fillColor() const @@ -147,7 +147,7 @@ void QMapPolygonObjectPrivateDefault::setGeoShape(const QGeoShape &shape) const QGeoPolygon poly(shape); for (int i = 0; i < poly.holesCount(); i++) m_path.addHole(poly.holePath(i)); - setPath(poly.path()); // to handle overrides. Last as it normally emits static_cast(q)->pathChanged(); + setPath(poly.perimeter()); // to handle overrides. Last as it normally emits static_cast(q)->pathChanged(); } bool QMapPolygonObjectPrivate::equals(const QGeoMapObjectPrivate &other) const @@ -174,7 +174,7 @@ void QMapPolygonObjectPrivate::setGeoShape(const QGeoShape &shape) return; const QGeoPolygon poly(shape); - setPath(poly.path()); // to handle overrides + setPath(poly.perimeter()); // to handle overrides emit static_cast(q)->pathChanged(); } diff --git a/src/location/labs/qsg/qmappolygonobjectqsg.cpp b/src/location/labs/qsg/qmappolygonobjectqsg.cpp index a8a1cb4b..5a40a4ef 100644 --- a/src/location/labs/qsg/qmappolygonobjectqsg.cpp +++ b/src/location/labs/qsg/qmappolygonobjectqsg.cpp @@ -126,7 +126,7 @@ void QMapPolygonObjectPrivateQSG::updateGeometry() if (!m_map || m_map->geoProjection().projectionType() != QGeoProjection::ProjectionWebMercator) return; - if (m_path.path().length() == 0) { // Possibly cleared + if (m_path.perimeter().length() == 0) { // Possibly cleared m_geometry.clear(); m_borderGeometry.clear(); return; diff --git a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp index 483f8f6d..520fedb3 100644 --- a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp +++ b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp @@ -135,7 +135,7 @@ QMapbox::Feature featureFromMapPolygon(QDeclarativePolygonMapItem *mapItem) const bool crossesDateline = geoRectangleCrossesDateLine(polygon->boundingGeoRectangle()); QMapbox::CoordinatesCollections geometry; QMapbox::CoordinatesCollection poly; - QMapbox::Coordinates coordinates = qgeocoordinate2mapboxcoordinate(polygon->path(), crossesDateline, true); + QMapbox::Coordinates coordinates = qgeocoordinate2mapboxcoordinate(polygon->perimeter(), crossesDateline, true); poly.push_back(coordinates); for (int i = 0; i < polygon->holesCount(); ++i) { coordinates = qgeocoordinate2mapboxcoordinate(polygon->holePath(i), crossesDateline, true); -- cgit v1.2.1