QGeoPolygon Class
QGeoPolygon 类定义了一个地理多边形。更多
头文件: | #include <QGeoPolygon> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Positioning) target_link_libraries(mytarget PRIVATE Qt6::Positioning) |
qmake: | QT += positioning |
继承: | QGeoShape |
公共函数
QGeoPolygon() | |
QGeoPolygon(const QGeoShape &other) | |
QGeoPolygon(const QList<QGeoCoordinate> &path) | |
QGeoPolygon(const QGeoPolygon &other) | |
~QGeoPolygon() | |
void | addCoordinate(const QGeoCoordinate &coordinate) |
void | addHole(const QList<QGeoCoordinate> &holePath) |
void | addHole(const QVariant &holePath) |
bool | containsCoordinate(const QGeoCoordinate &coordinate) const |
QGeoCoordinate | coordinateAt(qsizetype index) const |
const QVariantList | hole(qsizetype index) const |
const QList<QGeoCoordinate> | holePath(qsizetype index) const |
qsizetype | holesCount() const |
void | insertCoordinate(qsizetype index, const QGeoCoordinate &coordinate) |
double | length(qsizetype indexFrom = 0, qsizetype indexTo = -1) const |
(since QtPositioning 5.12) const QList<QGeoCoordinate> & | perimeter() const |
void | removeCoordinate(const QGeoCoordinate &coordinate) |
void | removeCoordinate(qsizetype index) |
void | removeHole(qsizetype index) |
void | replaceCoordinate(qsizetype index, const QGeoCoordinate &coordinate) |
(since QtPositioning 5.12) void | setPerimeter(const QList<QGeoCoordinate> &path) |
qsizetype | size() const |
QString | toString() const |
void | translate(double degreesLatitude, double degreesLongitude) |
QGeoPolygon | translated(double degreesLatitude, double degreesLongitude) const |
QGeoPolygon & | operator=(const QGeoPolygon &other) |
详细说明
多边形由QGeoCoordinate 对象的有序列表定义,该列表代表多边形的周长。
该列表中的每两个相邻元素都是通过经过这两个元素的恒定方位最短线段连接在一起的。这种连接方式可以在纵向上穿过日期线,但绝不能穿过两极。
这与计算QGeoShape::boundingGeoRectangle() 返回的该形状的边框有关,边框左上角的纬度将设置为路径点集中的最大纬度。同样,右下角的纬度将是路径点集中的最小纬度。
该类是Q_GADGET 。可直接从 C++ 和 QML 中使用。
成员函数文档
QGeoPolygon::QGeoPolygon()
构建一个新的、空的地理多边形。
QGeoPolygon::QGeoPolygon(const QGeoShape &other)
根据other 中的内容构建新的地理多边形。
QGeoPolygon::QGeoPolygon(const QList<QGeoCoordinate> &path)
根据path 中指定的坐标构建新的地理多边形。
QGeoPolygon::QGeoPolygon(const QGeoPolygon &other)
根据other 中的内容构建新的地理多边形。
[noexcept]
QGeoPolygon::~QGeoPolygon()
摧毁该多边形。
[invokable]
void QGeoPolygon::addCoordinate(const QGeoCoordinate &coordinate)
将coordinate 添加到多边形。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
void QGeoPolygon::addHole(const QList<QGeoCoordinate> &holePath)
重载方法。设置多边形内孔的holePath 。洞是QList<QGeoCoordinate>。
[invokable]
void QGeoPolygon::addHole(const QVariant &holePath)
设置多边形内孔的holePath 。洞是一个QVariant ,包含QList<QGeoCoordinate>。
注: 可通过元对象系统和 QML 调用此函数。请参阅Q_INVOKABLE 。
[invokable]
bool QGeoPolygon::containsCoordinate(const QGeoCoordinate &coordinate) const
如果多边形的周长元素之一包含coordinate ,则返回 true。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
[invokable]
QGeoCoordinate QGeoPolygon::coordinateAt(qsizetype index) const
返回index 处的坐标。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
[invokable]
const QVariantList QGeoPolygon::hole(qsizetype index) const
返回一个QVariant ,其中包含一个QList<QGeoCoordinate>,表示index 上的孔。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
const QList<QGeoCoordinate> QGeoPolygon::holePath(qsizetype index) const
返回一个QList<QGeoCoordinate>,表示index 上的孔。
[invokable]
qsizetype QGeoPolygon::holesCount() const
返回孔的数量。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
[invokable]
void QGeoPolygon::insertCoordinate(qsizetype index, const QGeoCoordinate &coordinate)
在指定的index 插入coordinate 。
注: 可通过元对象系统和 QML 调用该函数。请参见Q_INVOKABLE 。
[invokable]
double QGeoPolygon::length(qsizetype indexFrom = 0, qsizetype indexTo = -1) const
返回从元素indexFrom 到元素indexTo 的多边形周长(以米为单位)。该长度是每对相邻点的最短距离之和。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
[since QtPositioning 5.12]
const QList<QGeoCoordinate> &QGeoPolygon::perimeter() const
返回多边形周长的所有元素。
注: 属性 perimeter 的获取函数。
此函数在 QtPositioning 5.12 中引入。
另请参阅 setPerimeter()。
[invokable]
void QGeoPolygon::removeCoordinate(const QGeoCoordinate &coordinate)
删除多边形中最后出现的coordinate 。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
[invokable]
void QGeoPolygon::removeCoordinate(qsizetype index)
从多边形中删除位置index 上的元素。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
[invokable]
void QGeoPolygon::removeHole(qsizetype index)
从孔列表中删除位于index 位置的元素。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
[invokable]
void QGeoPolygon::replaceCoordinate(qsizetype index, const QGeoCoordinate &coordinate)
用coordinate 替换指定index 处的路径元素。
注: 可通过元对象系统和 QML 调用该函数。请参见Q_INVOKABLE 。
[since QtPositioning 5.12]
void QGeoPolygon::setPerimeter(const QList<QGeoCoordinate> &path)
根据坐标列表设置多边形的周长path.
注: perimeter 属性的设置函数。
此函数在 QtPositioning 5.12 中引入。
另请参阅 perimeter() 。
[invokable]
qsizetype QGeoPolygon::size() const
返回多边形中元素的个数。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
[invokable]
QString QGeoPolygon::toString() const
以字符串形式返回地理多边形属性。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
[invokable]
void QGeoPolygon::translate(double degreesLatitude, double degreesLongitude)
通过degreesLatitude 向北和degreesLongitude 向东平移该地理多边形。
degreesLatitude 和degreesLongitude 的负值分别对应向南和向西平移。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
[invokable]
QGeoPolygon QGeoPolygon::translated(double degreesLatitude, double degreesLongitude) const
返回按degreesLatitude 向北平移和degreesLongitude 向东平移的该地理多边形的副本。
degreesLatitude 和degreesLongitude 的负值分别对应于向南和向西平移。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
另请参阅 translate() 。
QGeoPolygon &QGeoPolygon::operator=(const QGeoPolygon &other)
为该地理多边形指定other ,并返回对该地理多边形的引用。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.