Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QGeoPath Class Reference

\inmodule QtPositioning More...

#include <qgeopath.h>

Inheritance diagram for QGeoPath:
Collaboration diagram for QGeoPath:

Public Member Functions

 QGeoPath ()
 Constructs a new, empty geo path.
 QGeoPath (const QList< QGeoCoordinate > &path, const qreal &width=0.0)
 Constructs a new geo path from a list of coordinates (path and width).
 QGeoPath (const QGeoPath &other)
 Constructs a new geo path from the contents of other.
 QGeoPath (const QGeoShape &other)
 Constructs a new geo path from the contents of other.
 ~QGeoPath ()
 Destroys this path.
QGeoPathoperator= (const QGeoPath &other)
 Assigns other to this geo path and returns a reference to this geo path.
void setPath (const QList< QGeoCoordinate > &path)
 Sets all the elements of the path.
const QList< QGeoCoordinate > & path () const
 Returns all the elements of the path.
void clearPath ()
 Clears the path.
void setVariantPath (const QVariantList &path)
 Sets all the elements of the path.
QVariantList variantPath () const
 Returns all the elements of the path.
void setWidth (const qreal &width)
qreal width () const
 Returns the width of the path, in meters.
Q_INVOKABLE void translate (double degreesLatitude, double degreesLongitude)
 Translates this geo path by degreesLatitude northwards and degreesLongitude eastwards.
Q_INVOKABLE QGeoPath translated (double degreesLatitude, double degreesLongitude) const
 Returns a copy of this geo path translated by degreesLatitude northwards and degreesLongitude eastwards.
Q_INVOKABLE double length (qsizetype indexFrom=0, qsizetype indexTo=-1) const
 Returns the length of the path, in meters, from the element indexFrom to the element indexTo.
Q_INVOKABLE qsizetype size () const
 Returns the number of elements in the path.
Q_INVOKABLE void addCoordinate (const QGeoCoordinate &coordinate)
 Appends coordinate to the path.
Q_INVOKABLE void insertCoordinate (qsizetype index, const QGeoCoordinate &coordinate)
 Inserts coordinate at the specified index.
Q_INVOKABLE void replaceCoordinate (qsizetype index, const QGeoCoordinate &coordinate)
 Replaces the path element at the specified index with coordinate.
Q_INVOKABLE QGeoCoordinate coordinateAt (qsizetype index) const
 Returns the coordinate at index .
Q_INVOKABLE bool containsCoordinate (const QGeoCoordinate &coordinate) const
 Returns true if the path contains coordinate as one of the elements.
Q_INVOKABLE void removeCoordinate (const QGeoCoordinate &coordinate)
 Removes the last occurrence of coordinate from the path.
Q_INVOKABLE void removeCoordinate (qsizetype index)
 Removes element at position index from the path.
Q_INVOKABLE QString toString () const
 Returns the geo path properties as a string.
Public Member Functions inherited from QGeoShape
 QGeoShape ()
 Constructs a new invalid geo shape of \l UnknownType.
Q_INVOKABLE QGeoShape (const QGeoShape &other)
 Constructs a new geo shape which is a copy of other.
 ~QGeoShape ()
 Destroys this geo shape.
ShapeType type () const
 Returns the type of this geo shape.
bool isValid () const
 Returns whether this geo shape is valid.
bool isEmpty () const
 Returns whether this geo shape is empty.
Q_INVOKABLE bool contains (const QGeoCoordinate &coordinate) const
 Returns whether the coordinate coordinate is contained within this geo shape.
Q_INVOKABLE QGeoRectangle boundingGeoRectangle () const
 Returns a QGeoRectangle representing the geographical bounding rectangle of the geo shape, that defines the latitudinal/longitudinal bounds of the geo shape.
QGeoCoordinate center () const
 Returns the coordinate located at the geometric center of the geo shape.
QGeoShapeoperator= (const QGeoShape &other)
 Assigns other to this geo shape and returns a reference to this geo shape.
Q_INVOKABLE QString toString () const
 Returns a string representation of this geo shape.

Properties

QVariantList path
 This property holds the list of coordinates for the geo path.
qreal width
 the width of the path in meters.
Properties inherited from QGeoShape
ShapeType type
 This property holds the type of this geo shape.
bool isValid
 This property holds the validity of the geo shape.
bool isEmpty
 This property defines whether this geo shape is empty.
QGeoCoordinate center
 the coordinate at the geometric center of the shape.

Friends

QDataStreamoperator<< (QDataStream &stream, const QGeoPath &path)
QDataStreamoperator>> (QDataStream &stream, QGeoPath &path)

Additional Inherited Members

Public Types inherited from QGeoShape
enum  ShapeType {
  UnknownType , RectangleType , CircleType , PathType ,
  PolygonType
}
 Describes the type of the shape. More...
Protected Member Functions inherited from QGeoShape
 QGeoShape (QGeoShapePrivate *d)
Protected Attributes inherited from QGeoShape
QSharedDataPointer< QGeoShapePrivated_ptr

Detailed Description

\inmodule QtPositioning

Since
5.9

The QGeoPath class defines a geographic path.

The path is defined by an ordered list of \l QGeoCoordinate objects.

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 \l 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 also accessible in QML as \l[QML]{geoPath}.

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

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

Definition at line 15 of file qgeopath.h.

Constructor & Destructor Documentation

◆ QGeoPath() [1/4]

QGeoPath::QGeoPath ( )

Constructs a new, empty geo path.

Definition at line 73 of file qgeopath.cpp.

◆ QGeoPath() [2/4]

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

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

Definition at line 82 of file qgeopath.cpp.

◆ QGeoPath() [3/4]

QGeoPath::QGeoPath ( const QGeoPath & other)

Constructs a new geo path from the contents of other.

Definition at line 90 of file qgeopath.cpp.

◆ QGeoPath() [4/4]

QGeoPath::QGeoPath ( const QGeoShape & other)

Constructs a new geo path from the contents of other.

Definition at line 98 of file qgeopath.cpp.

◆ ~QGeoPath()

QGeoPath::~QGeoPath ( )

Destroys this path.

Definition at line 108 of file qgeopath.cpp.

Member Function Documentation

◆ addCoordinate()

void QGeoPath::addCoordinate ( const QGeoCoordinate & coordinate)

Appends coordinate to the path.

Definition at line 258 of file qgeopath.cpp.

◆ clearPath()

void QGeoPath::clearPath ( )

Clears the path.

Since
5.12

Definition at line 142 of file qgeopath.cpp.

◆ containsCoordinate()

bool QGeoPath::containsCoordinate ( const QGeoCoordinate & coordinate) const

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

Definition at line 296 of file qgeopath.cpp.

◆ coordinateAt()

QGeoCoordinate QGeoPath::coordinateAt ( qsizetype index) const

Returns the coordinate at index .

Definition at line 287 of file qgeopath.cpp.

◆ insertCoordinate()

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

Inserts coordinate at the specified index.

Definition at line 269 of file qgeopath.cpp.

◆ length()

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.

If 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 \l QGeoPath::size() - 1 for indexTo.

Definition at line 235 of file qgeopath.cpp.

◆ operator=()

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

Assigns other to this geo path and returns a reference to this geo path.

Definition at line 113 of file qgeopath.cpp.

◆ path()

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

Returns all the elements of the path.

Definition at line 131 of file qgeopath.cpp.

◆ removeCoordinate() [1/2]

void QGeoPath::removeCoordinate ( const QGeoCoordinate & coordinate)

Removes the last occurrence of coordinate from the path.

Definition at line 305 of file qgeopath.cpp.

◆ removeCoordinate() [2/2]

void QGeoPath::removeCoordinate ( qsizetype index)

Removes element at position index from the path.

Definition at line 314 of file qgeopath.cpp.

◆ replaceCoordinate()

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

Replaces the path element at the specified index with coordinate.

Definition at line 278 of file qgeopath.cpp.

◆ setPath()

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

Sets all the elements of the path.

Definition at line 122 of file qgeopath.cpp.

◆ setVariantPath()

void QGeoPath::setVariantPath ( const QVariantList & path)

Sets all the elements of the path.

Definition at line 153 of file qgeopath.cpp.

◆ setWidth()

void QGeoPath::setWidth ( const qreal & width)

Definition at line 183 of file qgeopath.cpp.

◆ size()

qsizetype QGeoPath::size ( ) const

Returns the number of elements in the path.

Since
5.10

Definition at line 246 of file qgeopath.cpp.

◆ toString()

QString QGeoPath::toString ( ) const

Returns the geo path properties as a string.

Definition at line 323 of file qgeopath.cpp.

◆ translate()

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.

Definition at line 205 of file qgeopath.cpp.

◆ translated()

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.

See also
translate()

Definition at line 220 of file qgeopath.cpp.

◆ variantPath()

QVariantList QGeoPath::variantPath ( ) const

Returns all the elements of the path.

Definition at line 168 of file qgeopath.cpp.

◆ width()

qreal QGeoPath::width ( ) const

Returns the width of the path, in meters.

This information is used in the \l contains method. The default value is 0.

Definition at line 193 of file qgeopath.cpp.

◆ operator<<

QDataStream & operator<< ( QDataStream & stream,
const QGeoPath & path )
friend

Definition at line 59 of file qgeopath.h.

◆ operator>>

QDataStream & operator>> ( QDataStream & stream,
QGeoPath & path )
friend

Definition at line 63 of file qgeopath.h.

Property Documentation

◆ path

QVariantList QGeoPath::path
readwrite

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

Note
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.

Definition at line 18 of file qgeopath.h.

◆ width

qreal QGeoPath::width
readwrite

the width of the path in meters.

Definition at line 19 of file qgeopath.h.


The documentation for this class was generated from the following files: