QGeoRectangle Class
The QGeoRectangle class defines a rectangular geographic area. More...
Header: | #include <QGeoRectangle> |
qmake: | QT += positioning |
Since: | Qt 5.2 |
Inherits: | QGeoShape. |
Public Functions
QGeoRectangle() | |
QGeoRectangle(const QGeoCoordinate & center, double degreesWidth, double degreesHeight) | |
QGeoRectangle(const QGeoCoordinate & topLeft, const QGeoCoordinate & bottomRight) | |
QGeoRectangle(const QList<QGeoCoordinate> & coordinates) | |
QGeoRectangle(const QGeoRectangle & other) | |
QGeoRectangle(const QGeoShape & other) | |
~QGeoRectangle() | |
QGeoCoordinate | bottomLeft() const |
QGeoCoordinate | bottomRight() const |
QGeoCoordinate | center() const |
bool | contains(const QGeoCoordinate & coordinate) const |
bool | contains(const QGeoRectangle & rectangle) const |
double | height() const |
bool | intersects(const QGeoRectangle & rectangle) const |
void | setBottomLeft(const QGeoCoordinate & bottomLeft) |
void | setBottomRight(const QGeoCoordinate & bottomRight) |
void | setCenter(const QGeoCoordinate & center) |
void | setHeight(double degreesHeight) |
void | setTopLeft(const QGeoCoordinate & topLeft) |
void | setTopRight(const QGeoCoordinate & topRight) |
void | setWidth(double degreesWidth) |
QGeoCoordinate | topLeft() const |
QGeoCoordinate | topRight() const |
void | translate(double degreesLatitude, double degreesLongitude) |
QGeoRectangle | translated(double degreesLatitude, double degreesLongitude) const |
QGeoRectangle | united(const QGeoRectangle & rectangle) const |
double | width() const |
bool | operator!=(const QGeoShape & other) const |
bool | operator!=(const QGeoRectangle & other) const |
QGeoRectangle & | operator=(const QGeoRectangle & other) |
bool | operator==(const QGeoShape & other) const |
bool | operator==(const QGeoRectangle & other) const |
QGeoRectangle | operator|(const QGeoRectangle & rectangle) const |
QGeoRectangle & | operator|=(const QGeoRectangle & rectangle) |
- 8 public functions inherited from QGeoShape
Detailed Description
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.
Member Function Documentation
QGeoRectangle::QGeoRectangle()
Constructs a new, invalid geo rectangle.
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.
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.
QGeoRectangle::QGeoRectangle(const QList<QGeoCoordinate> & coordinates)
Constructs a new geo rectangle, of minimum size, containing all of the coordinates.
QGeoRectangle::QGeoRectangle(const QGeoRectangle & other)
Constructs a geo rectangle from the contents of other.
QGeoRectangle::QGeoRectangle(const QGeoShape & other)
Constructs a geo rectangle from the contents of other.
QGeoRectangle::~QGeoRectangle()
Destroys this geo rectangle.
QGeoCoordinate QGeoRectangle::bottomLeft() const
Returns the bottom left coordinate of this geo rectangle.
See also setBottomLeft().
QGeoCoordinate QGeoRectangle::bottomRight() const
Returns the bottom right coordinate of this geo rectangle.
See also setBottomRight().
QGeoCoordinate QGeoRectangle::center() const
Returns the center of this geo rectangle.
See also setCenter().
bool QGeoRectangle::contains(const QGeoCoordinate & coordinate) const
Returns true if coordinate is within this geo rectangle; otherwise returns false.
bool QGeoRectangle::contains(const QGeoRectangle & rectangle) const
Returns whether the geo rectangle rectangle is contained within this geo rectangle.
double QGeoRectangle::height() const
Returns the height of this geo rectangle in degrees.
The return value is undefined if this geo rectangle is invalid.
See also setHeight().
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.
void QGeoRectangle::setBottomLeft(const QGeoCoordinate & bottomLeft)
Sets the bottom left coordinate of this geo rectangle to bottomLeft.
See also bottomLeft().
void QGeoRectangle::setBottomRight(const QGeoCoordinate & bottomRight)
Sets the bottom right coordinate of this geo rectangle to bottomRight.
See also bottomRight().
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.
See also center().
void QGeoRectangle::setHeight(double degreesHeight)
Sets the height of this geo rectangle in degrees to degreesHeight.
If degreesHeight 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 setCenter() first in order 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 might otherwise be expected.
If degreesHeight is greater than 180.0 then 180.0 is used as the height.
See also height().
void QGeoRectangle::setTopLeft(const QGeoCoordinate & topLeft)
Sets the top left coordinate of this geo rectangle to topLeft.
See also topLeft().
void QGeoRectangle::setTopRight(const QGeoCoordinate & topRight)
Sets the top right coordinate of this geo rectangle to topRight.
See also topRight().
void QGeoRectangle::setWidth(double degreesWidth)
Sets the width of this geo rectangle in degrees to degreesWidth.
If degreesWidth 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 setCenter() first in order to make the geo rectangle valid.
If degreesWidth is greater than 360.0 then 360.0 is used as the width, 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.
See also width().
QGeoCoordinate QGeoRectangle::topLeft() const
Returns the top left coordinate of this geo rectangle.
See also setTopLeft().
QGeoCoordinate QGeoRectangle::topRight() const
Returns the top right coordinate of this geo rectangle.
See also setTopRight().
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.
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().
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.
double QGeoRectangle::width() const
Returns the width of this geo rectangle in degrees.
The return value is undefined if this geo rectangle is invalid.
See also setWidth().
bool QGeoRectangle::operator!=(const QGeoShape & other) const
Returns true if other is not equivalent to this geo rectangle; otherwise returns false.
bool QGeoRectangle::operator!=(const QGeoRectangle & other) const
Returns whether this geo rectangle is not equal to other.
QGeoRectangle & QGeoRectangle::operator=(const QGeoRectangle & other)
Assigns other to this geo rectangle and returns a reference to this geo rectangle.
bool QGeoRectangle::operator==(const QGeoShape & other) const
Returns true if other is equivalent to this geo rectangle; otherwise returns false.
bool QGeoRectangle::operator==(const QGeoRectangle & other) const
Returns whether this geo rectangle is equal to other.
QGeoRectangle QGeoRectangle::operator|(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.
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.
© 2015 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.