QGeoPolygon Class

The QGeoPolygon class defines a geographic polygon. 更多...

头: #include <QGeoPolygon>
CMake: find_package(Qt6 REQUIRED COMPONENTS Positioning)
target_link_libraries(mytarget PRIVATE Qt6::Positioning)
qmake: QT += positioning
继承: QGeoShape

公共函数

QGeoPolygon ()
QGeoPolygon (const QList<QGeoCoordinate> & path )
QGeoPolygon (const QGeoShape & other )
QGeoPolygon (const QGeoPolygon & other )
~QGeoPolygon ()
void addCoordinate (const QGeoCoordinate & coordinate )
void addHole (const QVariant & holePath )
void addHole (const QList<QGeoCoordinate> & 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 )

详细描述

The polygon is defined by an ordered list of QGeoCoordinate objects representing its perimeter.

Each two adjacent elements in this list are intended to be connected together by the shortest line segment of constant bearing passing through both elements. This type of connection can cross the date line in the longitudinal direction, but never crosses the poles.

This is relevant for the calculation of the bounding box returned by QGeoShape::boundingGeoRectangle () for this shape, which will have the latitude of the top left corner set to the maximum latitude in the path point set. Similarly, the latitude of the bottom right corner will be the minimum latitude in the path point set.

This class is a Q_GADGET . It can be directly used from C++ and QML .

成员函数文档编制

QGeoPolygon:: QGeoPolygon ()

Constructs a new, empty geo polygon.

QGeoPolygon:: QGeoPolygon (const QList < QGeoCoordinate > & path )

Constructs a new geo polygon from the coordinates specified in path .

QGeoPolygon:: QGeoPolygon (const QGeoShape & other )

Constructs a new geo polygon from the contents of other .

QGeoPolygon:: QGeoPolygon (const QGeoPolygon & other )

Constructs a new geo polygon from the contents of other .

[noexcept] QGeoPolygon:: ~QGeoPolygon ()

Destroys this polygon.

[invokable] void QGeoPolygon:: addCoordinate (const QGeoCoordinate & coordinate )

追加 coordinate to the polygon.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

[invokable] void QGeoPolygon:: addHole (const QVariant & holePath )

设置 holePath for a hole inside the polygon. The hole is a QVariant 包含 QList < QGeoCoordinate >.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

void QGeoPolygon:: addHole (const QList < QGeoCoordinate > & holePath )

Overloaded method. Sets the holePath for a hole inside the polygon. The hole is a QList < QGeoCoordinate >.

[invokable] bool QGeoPolygon:: containsCoordinate (const QGeoCoordinate & coordinate ) const

Returns true if the polygon's perimeter contains coordinate as one of the elements.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

[invokable] QGeoCoordinate QGeoPolygon:: coordinateAt ( qsizetype index ) const

Returns the coordinate at index .

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

[invokable] const QVariantList QGeoPolygon:: hole ( qsizetype index ) const

返回 QVariant 包含 QList < QGeoCoordinate > which represents the hole at index .

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

const QList < QGeoCoordinate > QGeoPolygon:: holePath ( qsizetype index ) const

返回 QList < QGeoCoordinate > which represents the hole at index .

[invokable] qsizetype QGeoPolygon:: holesCount () const

Returns the number of holes.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

[invokable] void QGeoPolygon:: insertCoordinate ( qsizetype index , const QGeoCoordinate & coordinate )

插入 coordinate at the specified index .

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

[invokable] double QGeoPolygon:: length ( qsizetype indexFrom = 0, qsizetype indexTo = -1) const

Returns the length of the polygon's perimeter, in meters, from the element indexFrom to the element indexTo . The length is intended to be the sum of the shortest distances for each pair of adjacent points.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

[since QtPositioning 5.12] const QList < QGeoCoordinate > &QGeoPolygon:: perimeter () const

Returns all the elements of the polygon's perimeter.

注意: Getter function for property perimeter.

This function was introduced in QtPositioning 5.12.

另请参阅 setPerimeter ().

[invokable] void QGeoPolygon:: removeCoordinate (const QGeoCoordinate & coordinate )

Removes the last occurrence of coordinate from the polygon.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

[invokable] void QGeoPolygon:: removeCoordinate ( qsizetype index )

Removes element at position index from the polygon.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

[invokable] void QGeoPolygon:: removeHole ( qsizetype index )

Removes element at position index from the list of holes.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

[invokable] void QGeoPolygon:: replaceCoordinate ( qsizetype index , const QGeoCoordinate & coordinate )

Replaces the path element at the specified index with coordinate .

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

[since QtPositioning 5.12] void QGeoPolygon:: setPerimeter (const QList < QGeoCoordinate > & path )

Sets the perimeter of the polygon based on a list of coordinates path .

注意: setter 函数对于特性 perimeter .

This function was introduced in QtPositioning 5.12.

另请参阅 perimeter ().

[invokable] qsizetype QGeoPolygon:: size () const

Returns the number of elements in the polygon.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

[invokable] QString QGeoPolygon:: toString () const

Returns the geo polygon properties as a string.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

[invokable] void QGeoPolygon:: translate ( double degreesLatitude , double degreesLongitude )

Translates this geo polygon by degreesLatitude northwards and degreesLongitude eastwards.

Negative values of degreesLatitude and degreesLongitude correspond to southward and westward translation respectively.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

[invokable] QGeoPolygon QGeoPolygon:: translated ( double degreesLatitude , double degreesLongitude ) const

Returns a copy of this geo polygon translated by degreesLatitude northwards and degreesLongitude eastwards.

Negative values of degreesLatitude and degreesLongitude correspond to southward and westward translation respectively.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

另请参阅 translate ().

QGeoPolygon &QGeoPolygon:: operator= (const QGeoPolygon & other )

赋值 other to this geo polygon and returns a reference to this geo polygon.