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
QGeoRectangle Class Reference

\inmodule QtPositioning More...

#include <qgeorectangle.h>

+ Inheritance diagram for QGeoRectangle:
+ Collaboration diagram for QGeoRectangle:

Public Member Functions

 QGeoRectangle ()
 Constructs a new, invalid geo rectangle.
 
 QGeoRectangle (const QGeoCoordinate &center, double degreesWidth, double degreesHeight)
 Constructs a new geo rectangle centered at center with a width in degrees of degreesWidth and a height in degrees of degreesHeight.
 
 QGeoRectangle (const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight)
 Constructs a new geo rectangle with a top left coordinate topLeft and a bottom right coordinate bottomRight.
 
 QGeoRectangle (const QList< QGeoCoordinate > &coordinates)
 Constructs a new geo rectangle, of minimum size, containing all of the coordinates.
 
 QGeoRectangle (const QGeoRectangle &other)
 Constructs a geo rectangle from the contents of other.
 
 QGeoRectangle (const QGeoShape &other)
 Constructs a geo rectangle from the contents of other.
 
 ~QGeoRectangle ()
 Destroys this geo rectangle.
 
QGeoRectangleoperator= (const QGeoRectangle &other)
 Assigns other to this geo rectangle and returns a reference to this geo rectangle.
 
void setTopLeft (const QGeoCoordinate &topLeft)
 Sets the top left coordinate of this geo rectangle to topLeft.
 
QGeoCoordinate topLeft () const
 Returns the top left coordinate of this geo rectangle.
 
void setTopRight (const QGeoCoordinate &topRight)
 Sets the top right coordinate of this geo rectangle to topRight.
 
QGeoCoordinate topRight () const
 Returns the top right coordinate of this geo rectangle.
 
void setBottomLeft (const QGeoCoordinate &bottomLeft)
 Sets the bottom left coordinate of this geo rectangle to bottomLeft.
 
QGeoCoordinate bottomLeft () const
 Returns the bottom left coordinate of this geo rectangle.
 
void setBottomRight (const QGeoCoordinate &bottomRight)
 Sets the bottom right coordinate of this geo rectangle to bottomRight.
 
QGeoCoordinate bottomRight () const
 Returns the bottom right coordinate of this geo rectangle.
 
void setCenter (const QGeoCoordinate &center)
 Sets the center of this geo rectangle to center.
 
QGeoCoordinate center () const
 Returns the center of this geo rectangle.
 
void setWidth (double degreesWidth)
 Sets the width of this geo rectangle in degrees to degreesWidth.
 
double width () const
 Returns the width of this geo rectangle in degrees.
 
void setHeight (double degreesHeight)
 Sets the height of this geo rectangle in degrees to degreesHeight.
 
double height () const
 Returns the height of this geo rectangle in degrees.
 
bool contains (const QGeoRectangle &rectangle) const
 Returns whether the geo rectangle rectangle is contained within this geo rectangle.
 
Q_INVOKABLE bool intersects (const QGeoRectangle &rectangle) const
 Returns whether the geo rectangle rectangle intersects this geo rectangle.
 
Q_INVOKABLE void translate (double degreesLatitude, double degreesLongitude)
 Translates this geo rectangle by degreesLatitude northwards and degreesLongitude eastwards.
 
Q_INVOKABLE QGeoRectangle translated (double degreesLatitude, double degreesLongitude) const
 Returns a copy of this geo rectangle translated by degreesLatitude northwards and degreesLongitude eastwards.
 
Q_INVOKABLE void extendRectangle (const QGeoCoordinate &coordinate)
 Extends the geo rectangle to also cover the coordinate coordinate.
 
Q_INVOKABLE QGeoRectangle united (const QGeoRectangle &rectangle) const
 Returns the smallest geo rectangle which contains both this geo rectangle and rectangle.
 
QGeoRectangle operator| (const QGeoRectangle &rectangle) const
 Returns the smallest geo rectangle which contains both this geo rectangle and rectangle.
 
QGeoRectangleoperator|= (const QGeoRectangle &rectangle)
 Returns the smallest geo rectangle which contains both this geo rectangle and rectangle.
 
Q_INVOKABLE QString toString () const
 Returns the geo rectangle properties as a string.
 
Q_INVOKABLE bool contains (const QGeoCoordinate &coordinate) const
 Returns whether the coordinate coordinate is contained within this geo shape.
 
- 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

QGeoCoordinate bottomLeft
 This property holds the bottom left coorindate of this geo rectangle.
 
QGeoCoordinate bottomRight
 This property holds the bottom right coordinate of this geo rectangle.
 
QGeoCoordinate topLeft
 This property holds the top left coordinate of this geo rectangle.
 
QGeoCoordinate topRight
 This property holds the top right coordinate of this geo rectangle.
 
QGeoCoordinate center
 This property holds the center of this geo rectangle.
 
double height
 This property holds the height of this geo rectangle in degrees.
 
double width
 This property holds the width of this geo rectangle in degrees.
 
- 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 QGeoRectangle &rectangle)
 
QDataStreamoperator>> (QDataStream &stream, QGeoRectangle &rectangle)
 

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

The QGeoRectangle class defines a rectangular geographic area.

The rectangle is defined in terms of a QGeoCoordinate which specifies the top left coordinate of the rectangle and a QGeoCoordinate which specifies the bottom right coordinate of the rectangle.

A geo rectangle is considered invalid if the top left or bottom right coordinates are invalid or if the top left coordinate is south of the bottom right coordinate.

Geo rectangles can never cross the poles.

Several methods behave as though the geo rectangle is defined in terms of a center coordinate, the width of the geo rectangle in degrees and the height of the geo rectangle in degrees.

If the height or center of a geo rectangle is adjusted such that it would cross one of the poles the height is modified such that the geo rectangle touches but does not cross the pole and that the center coordinate is still in the center of the geo rectangle.

This class is a \l Q_GADGET since Qt 5.5. It can be \l{Cpp_value_integration_positioning}{directly used from C++ and QML}.

Definition at line 13 of file qgeorectangle.h.

Constructor & Destructor Documentation

◆ QGeoRectangle() [1/6]

QGeoRectangle::QGeoRectangle ( )

Constructs a new, invalid geo rectangle.

Definition at line 161 of file qgeorectangle.cpp.

◆ QGeoRectangle() [2/6]

QGeoRectangle::QGeoRectangle ( const QGeoCoordinate & center,
double degreesWidth,
double degreesHeight )

Constructs a new geo rectangle centered at center with a width in degrees of degreesWidth and a height in degrees of degreesHeight.

If degreesHeight would take the geo rectangle beyond one of the poles, the height of the geo rectangle will be truncated such that the geo rectangle only extends up to the pole. The center of the geo rectangle will be unchanged, and the height will be adjusted such that the center point is at the center of the truncated geo rectangle.

Definition at line 176 of file qgeorectangle.cpp.

References center, QGeoShape::d_ptr, setHeight(), and setWidth().

+ Here is the call graph for this function:

◆ QGeoRectangle() [3/6]

QGeoRectangle::QGeoRectangle ( const QGeoCoordinate & topLeft,
const QGeoCoordinate & bottomRight )

Constructs a new geo rectangle with a top left coordinate topLeft and a bottom right coordinate bottomRight.

Definition at line 187 of file qgeorectangle.cpp.

References bottomRight, QGeoShape::d_ptr, and topLeft.

◆ QGeoRectangle() [4/6]

QGeoRectangle::QGeoRectangle ( const QList< QGeoCoordinate > & coordinates)

Constructs a new geo rectangle, of minimum size, containing all of the coordinates.

Definition at line 195 of file qgeorectangle.cpp.

References QGeoShape::d_ptr, and QGeoRectanglePrivate::extendRectangle().

+ Here is the call graph for this function:

◆ QGeoRectangle() [5/6]

QGeoRectangle::QGeoRectangle ( const QGeoRectangle & other)

Constructs a geo rectangle from the contents of other.

Definition at line 211 of file qgeorectangle.cpp.

◆ QGeoRectangle() [6/6]

QGeoRectangle::QGeoRectangle ( const QGeoShape & other)

Constructs a geo rectangle from the contents of other.

Definition at line 219 of file qgeorectangle.cpp.

References QGeoShape::d_ptr, QGeoShape::RectangleType, and QGeoShape::type.

◆ ~QGeoRectangle()

QGeoRectangle::~QGeoRectangle ( )

Destroys this geo rectangle.

Definition at line 229 of file qgeorectangle.cpp.

Member Function Documentation

◆ bottomLeft()

QGeoCoordinate QGeoRectangle::bottomLeft ( ) const

Returns the bottom left coordinate of this geo rectangle.

Definition at line 316 of file qgeorectangle.cpp.

References d, and QGeoShape::isValid.

◆ bottomRight()

QGeoCoordinate QGeoRectangle::bottomRight ( ) const

Returns the bottom right coordinate of this geo rectangle.

Definition at line 340 of file qgeorectangle.cpp.

References d.

◆ center()

QGeoCoordinate QGeoRectangle::center ( ) const

Returns the center of this geo rectangle.

Equivalent to QGeoShape::center().

Definition at line 408 of file qgeorectangle.cpp.

References d.

◆ contains() [1/2]

bool QGeoShape::contains ( const QGeoCoordinate & coordinate) const

Returns whether the coordinate coordinate is contained within this geo shape.

Definition at line 42 of file qgeoshape.cpp.

◆ contains() [2/2]

bool QGeoRectangle::contains ( const QGeoRectangle & rectangle) const

Returns whether the geo rectangle rectangle is contained within this geo rectangle.

Definition at line 593 of file qgeorectangle.cpp.

References bottomLeft, bottomRight, d, topLeft, and topRight.

◆ extendRectangle()

void QGeoRectangle::extendRectangle ( const QGeoCoordinate & coordinate)

Extends the geo rectangle to also cover the coordinate coordinate.

Since
5.9

Definition at line 716 of file qgeorectangle.cpp.

References d.

◆ height()

double QGeoRectangle::height ( ) const

Returns the height of this geo rectangle in degrees.

The return value is undefined if this geo rectangle is invalid.

Definition at line 524 of file qgeorectangle.cpp.

References d, QGeoShape::isValid, and qQNaN().

+ Here is the call graph for this function:

◆ intersects()

bool QGeoRectangle::intersects ( const QGeoRectangle & rectangle) const

Returns whether the geo rectangle rectangle intersects this geo rectangle.

If the top or bottom edges of both geo rectangles are at one of the poles the geo rectangles are considered to be intersecting, since the longitude is irrelevant when the edges are at the pole.

Definition at line 610 of file qgeorectangle.cpp.

References QGeoRectanglePrivate::bottomRight, d, QGeoCoordinate::latitude, QGeoCoordinate::longitude, and QGeoRectanglePrivate::topLeft.

◆ operator=()

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

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

Definition at line 236 of file qgeorectangle.cpp.

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

+ Here is the call graph for this function:

◆ operator|()

QGeoRectangle QGeoRectangle::operator| ( const QGeoRectangle & rectangle) const
inline

Returns the smallest geo rectangle which contains both this geo rectangle and rectangle.

If the centers of the two geo rectangles are separated by exactly 180.0 degrees then the width is set to 360.0 degrees with the leftmost longitude set to -180.0 degrees and the rightmost longitude set to 180.0 degrees. This is done to ensure that the result is independent of the order of the operands.

Definition at line 89 of file qgeorectangle.h.

References united().

+ Here is the call graph for this function:

◆ operator|=()

QGeoRectangle & QGeoRectangle::operator|= ( const QGeoRectangle & rectangle)

Returns the smallest geo rectangle which contains both this geo rectangle and rectangle.

If the centers of the two geo rectangles are separated by exactly 180.0 degrees then the width is set to 360.0 degrees with the leftmost longitude set to -180.0 degrees and the rightmost longitude set to 180.0 degrees. This is done to ensure that the result is independent of the order of the operands.

Definition at line 808 of file qgeorectangle.cpp.

References bottomRight, QGeoRectanglePrivate::bottomRight, center, d, QGeoCoordinate::latitude, QGeoCoordinate::longitude, qMax(), qMin(), QGeoCoordinate::setLatitude(), this, topLeft, QGeoRectanglePrivate::topLeft, and width.

+ Here is the call graph for this function:

◆ setBottomLeft()

void QGeoRectangle::setBottomLeft ( const QGeoCoordinate & bottomLeft)

Sets the bottom left coordinate of this geo rectangle to bottomLeft.

Definition at line 305 of file qgeorectangle.cpp.

References bottomLeft, d, QGeoCoordinate::latitude, and QGeoCoordinate::longitude.

◆ setBottomRight()

void QGeoRectangle::setBottomRight ( const QGeoCoordinate & bottomRight)

Sets the bottom right coordinate of this geo rectangle to bottomRight.

Definition at line 330 of file qgeorectangle.cpp.

References bottomRight, and d.

Referenced by QT_BEGIN_NAMESPACE::parseLocation(), QDeclarativeRectangleMapItem::setBottomRight(), QDeclarativeGeoMapQuickItem::setCoordinate(), and QGeoCirclePrivate::updateBoundingBox().

+ Here is the caller graph for this function:

◆ setCenter()

void QGeoRectangle::setCenter ( const QGeoCoordinate & center)

Sets the center of this geo rectangle to center.

If this causes the geo rectangle to cross on of the poles the height of the geo rectangle will be truncated such that the geo rectangle only extends up to the pole. The center of the geo rectangle will be unchanged, and the height will be adjusted such that the center point is at the center of the truncated geo rectangle.

Definition at line 357 of file qgeorectangle.cpp.

References center, d, height, QGeoShape::isValid, QGeoCoordinate::latitude, QGeoCoordinate::longitude, width, and QLocationUtils::wrapLong().

+ Here is the call graph for this function:

◆ setHeight()

void QGeoRectangle::setHeight ( double degreesHeight)

Sets the height of this geo rectangle in degrees to degreesHeight.

Definition at line 473 of file qgeorectangle.cpp.

References center, d, and QGeoShape::isValid.

Referenced by QGeoRectangle().

+ Here is the caller graph for this function:

◆ setTopLeft()

void QGeoRectangle::setTopLeft ( const QGeoCoordinate & topLeft)

Sets the top left coordinate of this geo rectangle to topLeft.

Definition at line 260 of file qgeorectangle.cpp.

References d, and topLeft.

Referenced by QT_BEGIN_NAMESPACE::parseLocation(), QDeclarativeGeoMapQuickItem::setCoordinate(), QDeclarativeRectangleMapItem::setTopLeft(), and QGeoCirclePrivate::updateBoundingBox().

+ Here is the caller graph for this function:

◆ setTopRight()

void QGeoRectangle::setTopRight ( const QGeoCoordinate & topRight)

Sets the top right coordinate of this geo rectangle to topRight.

Definition at line 280 of file qgeorectangle.cpp.

References d, QGeoCoordinate::latitude, QGeoCoordinate::longitude, and topRight.

◆ setWidth()

void QGeoRectangle::setWidth ( double degreesWidth)

Sets the width of this geo rectangle in degrees to degreesWidth.

Definition at line 418 of file qgeorectangle.cpp.

References center, d, QGeoShape::isValid, and QLocationUtils::wrapLong().

Referenced by QGeoRectangle().

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

◆ topLeft()

QGeoCoordinate QGeoRectangle::topLeft ( ) const

Returns the top left coordinate of this geo rectangle.

Definition at line 270 of file qgeorectangle.cpp.

References d.

◆ topRight()

QGeoCoordinate QGeoRectangle::topRight ( ) const

Returns the top right coordinate of this geo rectangle.

Definition at line 291 of file qgeorectangle.cpp.

References d, and QGeoShape::isValid.

◆ toString()

QString QGeoRectangle::toString ( ) const

Returns the geo rectangle properties as a string.

Since
5.5

Definition at line 858 of file qgeorectangle.cpp.

References bottomRight, QStringLiteral, qWarning, QGeoShape::RectangleType, topLeft, and QGeoShape::type.

◆ translate()

void QGeoRectangle::translate ( double degreesLatitude,
double degreesLongitude )

Translates this geo rectangle by degreesLatitude northwards and degreesLongitude eastwards.

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

If the translation would have caused the geo rectangle to cross a pole the geo rectangle will be translated until the top or bottom edge of the geo rectangle touches the pole but not further.

Definition at line 667 of file qgeorectangle.cpp.

References d, qMax(), qMin(), and QLocationUtils::wrapLong().

Referenced by QDeclarativeRectangleMapItem::geometryChange(), QGeoPathPrivate::translate(), QGeoPathPrivateEager::translate(), and translatePoly().

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

◆ translated()

QGeoRectangle QGeoRectangle::translated ( double degreesLatitude,
double degreesLongitude ) const

Returns a copy of this geo rectangle 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 704 of file qgeorectangle.cpp.

◆ united()

QGeoRectangle QGeoRectangle::united ( const QGeoRectangle & rectangle) const

Returns the smallest geo rectangle which contains both this geo rectangle and rectangle.

If the centers of the two geo rectangles are separated by exactly 180.0 degrees then the width is set to 360.0 degrees with the leftmost longitude set to -180.0 degrees and the rightmost longitude set to 180.0 degrees. This is done to ensure that the result is independent of the order of the operands.

Definition at line 731 of file qgeorectangle.cpp.

References QGeoShape::isValid.

Referenced by operator|().

+ Here is the caller graph for this function:

◆ width()

double QGeoRectangle::width ( ) const

Returns the width of this geo rectangle in degrees.

The return value is undefined if this geo rectangle is invalid.

Definition at line 454 of file qgeorectangle.cpp.

References d, QGeoShape::isValid, and qQNaN().

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ operator<<

QDataStream & operator<< ( QDataStream & stream,
const QGeoRectangle & rectangle )
friend

Definition at line 76 of file qgeorectangle.h.

◆ operator>>

QDataStream & operator>> ( QDataStream & stream,
QGeoRectangle & rectangle )
friend

Definition at line 80 of file qgeorectangle.h.

Property Documentation

◆ bottomLeft

QGeoRectangle::bottomLeft
readwrite

This property holds the bottom left coorindate of this geo rectangle.

While this property is introduced in Qt 5.5, the related accessor functions exist since the first version of this class.

Since
5.5

Definition at line 16 of file qgeorectangle.h.

Referenced by contains(), and setBottomLeft().

◆ bottomRight

QGeoRectangle::bottomRight
readwrite

This property holds the bottom right coordinate of this geo rectangle.

While this property is introduced in Qt 5.5, the related accessor functions exist since the first version of this class.

Since
5.5

Definition at line 17 of file qgeorectangle.h.

Referenced by QGeoRectangle(), contains(), QGeoProjectionWebMercator::fitViewportToGeoRectangle(), QDeclarativeRectangleMapItem::geometryChange(), operator|=(), PlaceManagerEngineEsri::search(), QPlaceManagerEngineOsm::search(), setBottomRight(), QDeclarativeRectangleMapItem::setBottomRight(), QDeclarativeRectangleMapItem::setGeoShape(), QDeclarativeGeoMap::setVisibleRegion(), toString(), and updateBBox().

◆ center

QGeoRectangle::center
readwrite

This property holds the center of this geo rectangle.

While this property is introduced in Qt 5.5, the related accessor functions exist since the first version of this class.

See also
QGeoShape::center
Since
5.5

Definition at line 20 of file qgeorectangle.h.

Referenced by QGeoRectangle(), operator|=(), setCenter(), setHeight(), and setWidth().

◆ height

QGeoRectangle::height
readwrite

This property holds the height of this geo rectangle in degrees.

The property value is undefined if this geo rectangle is invalid.

If the new height is less than 0.0 or if this geo rectangle is invalid, the property is not changed. To set up the values of an invalid geo rectangle based on the center, width, and height, you should use \l setCenter() first to make the geo rectangle valid.

If the change in height would cause the geo rectangle to cross a pole, the height is adjusted such that the geo rectangle only touches the pole.

This change is done such that the center coordinate is still at the center of the geo rectangle, which may result in a geo rectangle with a smaller height than expected.

180.0 is the height used only if the new height is greater or equal than 180.

While this property is introduced in Qt 5.5, the related accessor functions exist since the first version of this class.

Since
5.5

Definition at line 21 of file qgeorectangle.h.

Referenced by setCenter().

◆ topLeft

◆ topRight

QGeoRectangle::topRight
readwrite

This property holds the top right coordinate of this geo rectangle.

While this property is introduced in Qt 5.5, the related accessor functions exist since the first version of this class.

Since
5.5

Definition at line 19 of file qgeorectangle.h.

Referenced by contains(), and setTopRight().

◆ width

QGeoRectangle::width
readwrite

This property holds the width of this geo rectangle in degrees.

The property value is undefined if this geo rectangle is invalid.

If the new width is less than 0.0 or if this geo rectangle is invalid, this function does nothing. To set up the values of an invalid geo rectangle based on the center, width, and height, you should use \l setCenter() first to make the geo rectangle valid.

360.0 is the width used only if the new width is equal or greater than 360. In such cases the leftmost longitude of the geo rectangle is set to -180.0 degrees and the rightmost longitude of the geo rectangle is set to 180.0 degrees.

While this property is introduced in Qt 5.5, the related accessor functions exist since the first version of this class.

Since
5.5

Definition at line 22 of file qgeorectangle.h.

Referenced by operator|=(), and setCenter().


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