197 if (coordinates.isEmpty()) {
344 return d->bottomRight;
396 if (
width == 360.0) {
423 if (degreesWidth < 0.0)
428 if (degreesWidth >= 360.0) {
429 d->topLeft.setLongitude(-180.0);
430 d->bottomRight.setLongitude(180.0);
434 double tlLat =
d->topLeft.latitude();
435 double brLat =
d->bottomRight.latitude();
439 double tlLon =
c.longitude() - degreesWidth / 2.0;
442 double brLon =
c.longitude() + degreesWidth / 2.0;
461 double result =
d->bottomRight.longitude() -
d->topLeft.longitude();
478 if (degreesHeight < 0.0)
481 if (degreesHeight >= 180.0) {
482 degreesHeight = 180.0;
487 double tlLon =
d->topLeft.longitude();
488 double brLon =
d->bottomRight.longitude();
492 double tlLat =
c.latitude() + degreesHeight / 2.0;
493 double brLat =
c.latitude() - degreesHeight / 2.0;
496 brLat = 2*
c.latitude() - 90.0;
511 tlLat = 2 *
c.latitude() + 90.0;
531 return d->topLeft.latitude() -
d->bottomRight.latitude();
552 if ((lat == 90.0) && (
top == 90.0))
555 if ((lat == -90.0) && (
bottom == -90.0))
597 return (
d->contains(rectangle.
topLeft())
614 double left1 =
d->topLeft.longitude();
615 double right1 =
d->bottomRight.longitude();
616 double top1 =
d->topLeft.latitude();
617 double bottom1 =
d->bottomRight.latitude();
630 if ((top1 == 90.0) && (top1 == top2))
633 if ((bottom1 == -90.0) && (bottom1 == bottom2))
636 if (left1 < right1) {
637 if (left2 < right2) {
638 if ((left1 > right2) || (right1 < left2))
641 if ((left1 > right2) && (right1 < left2))
645 if (left2 < right2) {
646 if ((left2 > right1) && (right2 < left1))
673 double tlLat =
d->topLeft.latitude();
674 double tlLon =
d->topLeft.longitude();
675 double brLat =
d->bottomRight.latitude();
676 double brLon =
d->bottomRight.longitude();
678 if (degreesLatitude >= 0.0)
679 degreesLatitude =
qMin(degreesLatitude, 90.0 - tlLat);
681 degreesLatitude =
qMax(degreesLatitude, -90.0 - brLat);
683 if ( (tlLon != -180.0) || (brLon != 180.0) ) {
688 tlLat += degreesLatitude;
689 brLat += degreesLatitude;
707 result.translate(degreesLatitude, degreesLongitude);
719 d->extendRectangle(coordinate);
757 double inputLat = coordinate.
latitude();
758 double inputLon = coordinate.
longitude();
771 if (inputLon <
left) {
772 if (360 - (
right - inputLon) <
left - inputLon)
776 }
else if (inputLon >
right) {
777 if (360 - (inputLon -
left) < inputLon -
right)
818 {
top,
d->topLeft.longitude()},
823 {
bottom,
d->bottomRight.longitude()}
825 double unwrappedWidth = (candidate.width() < rectangle.
width() ? 360 : 0) + candidate.
width();
826 double otherUnwrappedWidth = (otherCandidate.width() <
width() ? 360 : 0) + otherCandidate.width();
827 if (otherUnwrappedWidth < unwrappedWidth) {
828 candidate = otherCandidate;
829 unwrappedWidth = otherUnwrappedWidth;
831 if (360 <= unwrappedWidth) {
832 candidate.d_func()->topLeft.setLongitude(-180.0);
833 candidate.d_func()->bottomRight.setLongitude(180.0);
836 candidate = (candidate.width() <
width() ? *
this : candidate);
837 candidate = (candidate.width() < rectangle.
width() ? rectangle : candidate);
841 if ((middle1 <= middle2 ? 0 : 360) + middle2 - middle1 == 180) {
842 candidate.d_func()->topLeft.setLongitude(-180.0);
843 candidate.d_func()->bottomRight.setLongitude(180.0);
888 bottomRight(
other.bottomRight)
901 if (!QGeoShapePrivate::operator==(
other))
916#include "moc_qgeorectangle.cpp"
double longitude
This property holds the longitude in decimal degrees.
double latitude
This property holds the latitude in decimal degrees.
void setLatitude(double latitude)
Sets the latitude (in decimal degrees) to latitude.
bool isValid
This property holds the validity of this geo coordinate.
QGeoCoordinate bottomRight
QGeoShapePrivate * clone() const override
void extendRectangle(const QGeoCoordinate &coordinate)
Extends the rectangle in the smallest possible way to include coordinate in the shape.
bool isEmpty() const override
QGeoRectangle boundingGeoRectangle() const override
bool operator==(const QGeoShapePrivate &other) const override
size_t hash(size_t seed) const override
bool contains(const QGeoCoordinate &coordinate) const override
bool isValid() const override
QGeoCoordinate center() const override
double height
This property holds the height of this geo rectangle in degrees.
Q_INVOKABLE bool intersects(const QGeoRectangle &rectangle) const
Returns whether the geo rectangle rectangle intersects this geo rectangle.
QGeoCoordinate topLeft
This property holds the top left coordinate of this geo rectangle.
QGeoCoordinate bottomRight
This property holds the bottom right coordinate of this geo rectangle.
void setTopLeft(const QGeoCoordinate &topLeft)
Sets the top left coordinate of this geo rectangle to topLeft.
Q_INVOKABLE QGeoRectangle united(const QGeoRectangle &rectangle) const
Returns the smallest geo rectangle which contains both this geo rectangle and rectangle.
void setBottomRight(const QGeoCoordinate &bottomRight)
Sets the bottom right coordinate of this geo rectangle to bottomRight.
bool contains(const QGeoRectangle &rectangle) const
Returns whether the geo rectangle rectangle is contained within this geo rectangle.
QGeoRectangle & operator=(const QGeoRectangle &other)
Assigns other to this geo rectangle and returns a reference to this geo rectangle.
QGeoCoordinate center
This property holds the center of this geo rectangle.
void setTopRight(const QGeoCoordinate &topRight)
Sets the top right coordinate of this geo rectangle to topRight.
QGeoRectangle()
Constructs a new, invalid geo rectangle.
void setCenter(const QGeoCoordinate ¢er)
Sets the center of this geo rectangle to center.
Q_INVOKABLE QString toString() const
Returns the geo rectangle properties as a string.
void setWidth(double degreesWidth)
Sets the width of this geo rectangle in degrees to degreesWidth.
void setHeight(double degreesHeight)
Sets the height of this geo rectangle in degrees to degreesHeight.
QGeoRectangle & operator|=(const QGeoRectangle &rectangle)
Returns the smallest geo rectangle which contains both this geo rectangle and rectangle.
~QGeoRectangle()
Destroys this geo rectangle.
Q_INVOKABLE QGeoRectangle translated(double degreesLatitude, double degreesLongitude) const
Returns a copy of this geo rectangle translated by degreesLatitude northwards and degreesLongitude ea...
QGeoCoordinate bottomLeft
This property holds the bottom left coorindate of this geo rectangle.
Q_INVOKABLE void extendRectangle(const QGeoCoordinate &coordinate)
Extends the geo rectangle to also cover the coordinate coordinate.
QGeoCoordinate topRight
This property holds the top right coordinate of this geo rectangle.
double width
This property holds the width of this geo rectangle in degrees.
void setBottomLeft(const QGeoCoordinate &bottomLeft)
Sets the bottom left coordinate of this geo rectangle to bottomLeft.
Q_INVOKABLE void translate(double degreesLatitude, double degreesLongitude)
Translates this geo rectangle by degreesLatitude northwards and degreesLongitude eastwards.
bool isValid
This property holds the validity of the geo shape.
QGeoShape & operator=(const QGeoShape &other)
Assigns other to this geo shape and returns a reference to this geo shape.
QSharedDataPointer< QGeoShapePrivate > d_ptr
ShapeType type
This property holds the type of this geo shape.
static double wrapLong(double lng)
const T * constData() const noexcept
Returns a const pointer to the shared data object.
T * data()
Returns a pointer to the shared data object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Combined button and popup list for selecting options.
constexpr QtPrivate::QHashMultiReturnType< T... > qHashMulti(size_t seed, const T &... args) noexcept(std::conjunction_v< QtPrivate::QNothrowHashable< T >... >)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION double qQNaN()
GLint GLsizei GLsizei height
GLdouble GLdouble GLdouble GLdouble top
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
static QT_BEGIN_NAMESPACE QAsn1Element wrap(quint8 type, const QAsn1Element &child)
#define QStringLiteral(str)