QGeoPath Class

The QGeoPath class defines a geographic path. 更多...

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

特性

公共函数

QGeoPath ()
QGeoPath (const QList<QGeoCoordinate> & path , const qreal & width = 0.0)
QGeoPath (const QGeoShape & other )
QGeoPath (const QGeoPath & other )
~QGeoPath ()
void addCoordinate (const QGeoCoordinate & coordinate )
void clearPath ()
bool containsCoordinate (const QGeoCoordinate & coordinate ) const
QGeoCoordinate coordinateAt (qsizetype index ) const
void insertCoordinate (qsizetype index , const QGeoCoordinate & coordinate )
double length (qsizetype indexFrom = 0, qsizetype indexTo = -1) const
const QList<QGeoCoordinate> & path () const
void removeCoordinate (const QGeoCoordinate & coordinate )
void removeCoordinate (qsizetype index )
void replaceCoordinate (qsizetype index , const QGeoCoordinate & coordinate )
void setPath (const QList<QGeoCoordinate> & path )
void setWidth (const qreal & width )
qsizetype size () const
QString toString () const
void translate (double degreesLatitude , double degreesLongitude )
QGeoPath translated (double degreesLatitude , double degreesLongitude ) const
qreal width () const
QGeoPath & operator= (const QGeoPath & other )

详细描述

The path is defined by an ordered list of QGeoCoordinate 对象。

Each two adjacent elements in the path 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 dateline 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 .

A QGeoPath is both invalid and empty if it contains no coordinate.

注意: A default constructed QGeoPath is both invalid and empty as it does not contain any coordinates.

特性文档编制

path : const QVariantList

This property holds the list of coordinates for the geo path.

注意: The coordinates cannot be processed in place. To change the value of this property, retrieve the complete list of coordinates, process them, and assign the new value to the property.

width : qreal

This property holds the width of the path in meters.

访问函数:

qreal width () const
void setWidth (const qreal & width )

成员函数文档编制

QGeoPath:: QGeoPath ()

Constructs a new, empty geo path.

QGeoPath:: QGeoPath (const QList < QGeoCoordinate > & path , const qreal & width = 0.0)

Constructs a new geo path from a list of coordinates ( path and width ).

QGeoPath:: QGeoPath (const QGeoShape & other )

Constructs a new geo path from the contents of other .

QGeoPath:: QGeoPath (const QGeoPath & other )

Constructs a new geo path from the contents of other .

[noexcept] QGeoPath:: ~QGeoPath ()

Destroys this path.

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

追加 coordinate to the path.

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

void QGeoPath:: clearPath ()

Clears the path.

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

Returns true if the path contains coordinate as one of the elements.

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

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

Returns the coordinate at index .

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

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

插入 coordinate at the specified index .

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

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

Returns the length of the path, 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.

indexTo is -1 (the default value), the length will be including the distance between last coordinate and the first (closed loop). To retrieve the length for the path, use 0 for indexFrom and QGeoPath::size () - 1 for indexTo .

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

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

Returns all the elements of the path.

另请参阅 setPath ().

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

Removes the last occurrence of coordinate from the path.

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

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

Removes element at position index from the path.

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

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

Replaces the path element at the specified index with coordinate .

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

void QGeoPath:: setPath (const QList < QGeoCoordinate > & path )

Sets all the elements of the path .

另请参阅 path ().

[invokable] qsizetype QGeoPath:: size () const

Returns the number of elements in the path.

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

[invokable] QString QGeoPath:: toString () const

Returns the geo path properties as a string.

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

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

Translates this geo path by degreesLatitude northwards and degreesLongitude eastwards.

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

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

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

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

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

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

另请参阅 translate ().

qreal QGeoPath:: width () const

Returns the width of the path, in meters. This information is used in the contains method. The default value is 0.

注意: Getter function for property width.

另请参阅 setWidth ().

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

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