Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QGeoPolygon Class Reference

\inmodule QtPositioning More...

#include <qgeopolygon.h>

+ Inheritance diagram for QGeoPolygon:
+ Collaboration diagram for QGeoPolygon:

Public Member Functions

 QGeoPolygon ()
 Constructs a new, empty geo polygon.
 
 QGeoPolygon (const QList< QGeoCoordinate > &path)
 Constructs a new geo polygon from the coordinates specified in path.
 
 QGeoPolygon (const QGeoPolygon &other)
 Constructs a new geo polygon from the contents of other.
 
 QGeoPolygon (const QGeoShape &other)
 Constructs a new geo polygon from the contents of other.
 
 ~QGeoPolygon ()
 Destroys this polygon.
 
QGeoPolygonoperator= (const QGeoPolygon &other)
 Assigns other to this geo polygon and returns a reference to this geo polygon.
 
void setPerimeter (const QList< QGeoCoordinate > &path)
 Sets the perimeter of the polygon based on a list of coordinates path.
 
const QList< QGeoCoordinate > & perimeter () const
 Returns all the elements of the polygon's perimeter.
 
Q_INVOKABLE void addHole (const QVariant &holePath)
 Sets the holePath for a hole inside the polygon.
 
void addHole (const QList< QGeoCoordinate > &holePath)
 Overloaded method.
 
Q_INVOKABLE const QVariantList hole (qsizetype index) const
 Returns a QVariant containing a QList<QGeoCoordinate> which represents the hole at index.
 
const QList< QGeoCoordinateholePath (qsizetype index) const
 Returns a QList<QGeoCoordinate> which represents the hole at index.
 
Q_INVOKABLE void removeHole (qsizetype index)
 Removes element at position index from the list of holes.
 
Q_INVOKABLE qsizetype holesCount () const
 Returns the number of holes.
 
Q_INVOKABLE void translate (double degreesLatitude, double degreesLongitude)
 Translates this geo polygon by degreesLatitude northwards and degreesLongitude eastwards.
 
Q_INVOKABLE QGeoPolygon translated (double degreesLatitude, double degreesLongitude) const
 Returns a copy of this geo polygon translated by degreesLatitude northwards and degreesLongitude eastwards.
 
Q_INVOKABLE double 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.
 
Q_INVOKABLE qsizetype size () const
 Returns the number of elements in the polygon.
 
Q_INVOKABLE void addCoordinate (const QGeoCoordinate &coordinate)
 Appends coordinate to the polygon.
 
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 polygon's perimeter contains coordinate as one of the elements.
 
Q_INVOKABLE void removeCoordinate (const QGeoCoordinate &coordinate)
 Removes the last occurrence of coordinate from the polygon.
 
Q_INVOKABLE void removeCoordinate (qsizetype index)
 Removes element at position index from the polygon.
 
Q_INVOKABLE QString toString () const
 Returns the geo polygon 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

QList< QGeoCoordinateperimeter
 
- 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
 

Friends

QDataStreamoperator<< (QDataStream &stream, const QGeoPolygon &polygon)
 
QDataStreamoperator>> (QDataStream &stream, QGeoPolygon &polygon)
 

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

The QGeoPolygon class defines a geographic polygon.

The polygon is defined by an ordered list of \l 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 \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 a \l Q_GADGET. It can be \l{Cpp_value_integration_positioning}{directly used from C++ and QML}.

Definition at line 15 of file qgeopolygon.h.

Constructor & Destructor Documentation

◆ QGeoPolygon() [1/4]

QGeoPolygon::QGeoPolygon ( )

Constructs a new, empty geo polygon.

Definition at line 77 of file qgeopolygon.cpp.

Referenced by QGeoPolygonEager::QGeoPolygonEager().

+ Here is the caller graph for this function:

◆ QGeoPolygon() [2/4]

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

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

Definition at line 86 of file qgeopolygon.cpp.

◆ QGeoPolygon() [3/4]

QGeoPolygon::QGeoPolygon ( const QGeoPolygon & other)

Constructs a new geo polygon from the contents of other.

Definition at line 94 of file qgeopolygon.cpp.

◆ QGeoPolygon() [4/4]

QGeoPolygon::QGeoPolygon ( const QGeoShape & other)

Constructs a new geo polygon from the contents of other.

Definition at line 137 of file qgeopolygon.cpp.

References calculatePeripheralPoints(), QGeoShape::CircleType, QGeoShape::d_ptr, other(), perimeter, QGeoShape::PolygonType, rect, QGeoShape::RectangleType, and QGeoShape::type.

+ Here is the call graph for this function:

◆ ~QGeoPolygon()

QGeoPolygon::~QGeoPolygon ( )

Destroys this polygon.

Definition at line 161 of file qgeopolygon.cpp.

Member Function Documentation

◆ addCoordinate()

void QGeoPolygon::addCoordinate ( const QGeoCoordinate & coordinate)

Appends coordinate to the polygon.

Definition at line 249 of file qgeopolygon.cpp.

References d, kMaxInt, kTooManyElements, and qWarning.

Referenced by QDeclarativePolygonMapItem::addCoordinate(), and extractor::toVariant().

+ Here is the caller graph for this function:

◆ addHole() [1/2]

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

Overloaded method.

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

Since
5.12

Definition at line 353 of file qgeopolygon.cpp.

References d, holePath(), kMaxInt, kTooManyHoles, and qDebug.

+ Here is the call graph for this function:

◆ addHole() [2/2]

void QGeoPolygon::addHole ( const QVariant & holePath)

Sets the holePath for a hole inside the polygon.

The hole is a QVariant containing a QList<QGeoCoordinate>.

Since
5.12

Definition at line 334 of file qgeopolygon.cpp.

References addHole(), holePath(), QList< T >::toList(), and QList< T >::value().

Referenced by QGeoPolygonEager::QGeoPolygonEager(), and addHole().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ containsCoordinate()

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

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

Definition at line 287 of file qgeopolygon.cpp.

References d.

◆ coordinateAt()

QGeoCoordinate QGeoPolygon::coordinateAt ( qsizetype index) const

Returns the coordinate at index .

Definition at line 278 of file qgeopolygon.cpp.

References d.

◆ hole()

const QVariantList QGeoPolygon::hole ( qsizetype index) const

Returns a QVariant containing a QList<QGeoCoordinate> which represents the hole at index.

Since
5.12

Definition at line 367 of file qgeopolygon.cpp.

References d, and QVariant::fromValue().

+ Here is the call graph for this function:

◆ holePath()

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

Returns a QList<QGeoCoordinate> which represents the hole at index.

Since
5.12

Definition at line 381 of file qgeopolygon.cpp.

References d.

Referenced by addHole(), and addHole().

+ Here is the caller graph for this function:

◆ holesCount()

qsizetype QGeoPolygon::holesCount ( ) const

Returns the number of holes.

Since
5.12

Definition at line 403 of file qgeopolygon.cpp.

References d, kMaxInt, kTooManyHoles, and qWarning.

◆ insertCoordinate()

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

Inserts coordinate at the specified index.

Definition at line 260 of file qgeopolygon.cpp.

References d.

◆ length()

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.

Definition at line 226 of file qgeopolygon.cpp.

References d.

◆ operator=()

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

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

Definition at line 166 of file qgeopolygon.cpp.

References QGeoShape::operator=(), and other().

+ Here is the call graph for this function:

◆ perimeter()

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

Returns all the elements of the polygon's perimeter.

Since
QtPositioning 5.12

Definition at line 188 of file qgeopolygon.cpp.

References d.

◆ removeCoordinate() [1/2]

void QGeoPolygon::removeCoordinate ( const QGeoCoordinate & coordinate)

Removes the last occurrence of coordinate from the polygon.

Definition at line 296 of file qgeopolygon.cpp.

References d.

Referenced by QDeclarativePolygonMapItem::removeCoordinate().

+ Here is the caller graph for this function:

◆ removeCoordinate() [2/2]

void QGeoPolygon::removeCoordinate ( qsizetype index)

Removes element at position index from the polygon.

Definition at line 305 of file qgeopolygon.cpp.

References d.

◆ removeHole()

void QGeoPolygon::removeHole ( qsizetype index)

Removes element at position index from the list of holes.

Since
5.12

Definition at line 392 of file qgeopolygon.cpp.

References d.

◆ replaceCoordinate()

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

Replaces the path element at the specified index with coordinate.

Definition at line 269 of file qgeopolygon.cpp.

References d.

◆ setPerimeter()

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

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

Since
QtPositioning 5.12

Definition at line 177 of file qgeopolygon.cpp.

References d.

Referenced by QGeoPolygonEager::QGeoPolygonEager(), QGeoPolygonPrivate::polygonContains(), and QDeclarativePolygonMapItem::setPath().

+ Here is the caller graph for this function:

◆ size()

qsizetype QGeoPolygon::size ( ) const

Returns the number of elements in the polygon.

Since
5.10

Definition at line 237 of file qgeopolygon.cpp.

References d, kMaxInt, kTooManyElements, and qWarning.

◆ toString()

QString QGeoPolygon::toString ( ) const

Returns the geo polygon properties as a string.

Definition at line 314 of file qgeopolygon.cpp.

References perimeter, QGeoShape::PolygonType, QStringLiteral, qWarning, and QGeoShape::type.

◆ translate()

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.

Definition at line 200 of file qgeopolygon.cpp.

References d.

Referenced by QDeclarativePolygonMapItem::geometryChange().

+ Here is the caller graph for this function:

◆ translated()

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.

See also
translate()

Definition at line 215 of file qgeopolygon.cpp.

Friends And Related Symbol Documentation

◆ operator<<

QDataStream & operator<< ( QDataStream & stream,
const QGeoPolygon & polygon )
friend

Definition at line 58 of file qgeopolygon.h.

◆ operator>>

QDataStream & operator>> ( QDataStream & stream,
QGeoPolygon & polygon )
friend

Definition at line 62 of file qgeopolygon.h.

Property Documentation

◆ perimeter


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