345 return d->bottomRight;
397 if (
width == 360.0) {
424 if (degreesWidth < 0.0)
429 if (degreesWidth >= 360.0) {
430 d->topLeft.setLongitude(-180.0);
431 d->bottomRight.setLongitude(180.0);
435 double tlLat =
d->topLeft.latitude();
436 double brLat =
d->bottomRight.latitude();
440 double tlLon =
c.longitude() - degreesWidth / 2.0;
443 double brLon =
c.longitude() + degreesWidth / 2.0;
462 double result =
d->bottomRight.longitude() -
d->topLeft.longitude();
479 if (degreesHeight < 0.0)
482 if (degreesHeight >= 180.0) {
483 degreesHeight = 180.0;
488 double tlLon =
d->topLeft.longitude();
489 double brLon =
d->bottomRight.longitude();
493 double tlLat =
c.latitude() + degreesHeight / 2.0;
494 double brLat =
c.latitude() - degreesHeight / 2.0;
497 brLat = 2*
c.latitude() - 90.0;
512 tlLat = 2 *
c.latitude() + 90.0;
532 return d->topLeft.latitude() -
d->bottomRight.latitude();
553 if ((lat == 90.0) && (
top == 90.0))
556 if ((lat == -90.0) && (
bottom == -90.0))
598 return (
d->contains(rectangle.
topLeft())
615 double left1 =
d->topLeft.longitude();
616 double right1 =
d->bottomRight.longitude();
617 double top1 =
d->topLeft.latitude();
618 double bottom1 =
d->bottomRight.latitude();
631 if ((top1 == 90.0) && (top1 == top2))
634 if ((bottom1 == -90.0) && (bottom1 == bottom2))
637 if (left1 < right1) {
638 if (left2 < right2) {
639 if ((left1 > right2) || (right1 < left2))
642 if ((left1 > right2) && (right1 < left2))
646 if (left2 < right2) {
647 if ((left2 > right1) && (right2 < left1))
674 double tlLat =
d->topLeft.latitude();
675 double tlLon =
d->topLeft.longitude();
676 double brLat =
d->bottomRight.latitude();
677 double brLon =
d->bottomRight.longitude();
679 if (degreesLatitude >= 0.0)
680 degreesLatitude =
qMin(degreesLatitude, 90.0 - tlLat);
682 degreesLatitude =
qMax(degreesLatitude, -90.0 - brLat);
684 if ( (tlLon != -180.0) || (brLon != 180.0) ) {
689 tlLat += degreesLatitude;
690 brLat += degreesLatitude;
708 result.translate(degreesLatitude, degreesLongitude);
720 d->extendRectangle(coordinate);
758 double inputLat = coordinate.
latitude();
759 double inputLon = coordinate.
longitude();
772 if (inputLon <
left) {
773 if (360 - (
right - inputLon) <
left - inputLon)
777 }
else if (inputLon >
right) {
778 if (360 - (inputLon -
left) < inputLon -
right)
819 {
top,
d->topLeft.longitude()},
824 {
bottom,
d->bottomRight.longitude()}
826 double unwrappedWidth = (candidate.width() < rectangle.
width() ? 360 : 0) + candidate.
width();
827 double otherUnwrappedWidth = (otherCandidate.width() <
width() ? 360 : 0) + otherCandidate.width();
828 if (otherUnwrappedWidth < unwrappedWidth) {
829 candidate = otherCandidate;
830 unwrappedWidth = otherUnwrappedWidth;
832 if (360 <= unwrappedWidth) {
833 candidate.d_func()->topLeft.setLongitude(-180.0);
834 candidate.d_func()->bottomRight.setLongitude(180.0);
837 candidate = (candidate.width() <
width() ? *
this : candidate);
838 candidate = (candidate.width() < rectangle.
width() ? rectangle : candidate);
842 if ((middle1 <= middle2 ? 0 : 360) + middle2 - middle1 == 180) {
843 candidate.d_func()->topLeft.setLongitude(-180.0);
844 candidate.d_func()->bottomRight.setLongitude(180.0);
889 bottomRight(
other.bottomRight)
902 if (!QGeoShapePrivate::operator==(
other))
917#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.
bool isEmpty() const noexcept
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)