22 #include <QTextStream>    42   if ( poly.size() != 1 )
    46   if ( polyline.size() == 5 && polyline.at( 0 ) == polyline.at( 4 ) && geom.
isGeosValid() )
    47     return QgsRectangle( polyline.at( 0 ).x(), polyline.at( 0 ).y(), polyline.at( 2 ).x(), polyline.at( 2 ).y() );
    54   double xMin = center.
x() - width / 2.0;
    55   double xMax = xMin + 
width;
    56   double yMin = center.
y() - height / 2.0;
    57   double yMax = yMin + 
height;
    64   scaledRect.
scale( scaleFactor, center );
    70   double xmin = mXmin - v.
x();
    71   double xmax = mXmax - v.
x();
    72   double ymin = mYmin - v.
y();
    73   double ymax = mYmax - v.
y();
    79   double xmin = mXmin + v.
x();
    80   double xmax = mXmax + v.
x();
    81   double ymin = mYmin + v.
y();
    82   double ymax = mYmax + v.
y();
   116     QLatin1String( 
"POLYGON((" ) +
   122     QStringLiteral( 
"))" );
   136       precision = 
static_cast<int>( std::ceil( -1.0 * std::log10( std::min( 
width(), 
height() ) ) ) ) + 1;
   138       if ( precision > 20 )
   144     rep = QStringLiteral( 
"Empty" );
   146     rep = QStringLiteral( 
"%1,%2 : %3,%4" )
   147           .arg( mXmin, 0, 
'f', precision )
   148           .arg( mYmin, 0, 
'f', precision )
   149           .arg( mXmax, 0, 
'f', precision )
   150           .arg( mYmax, 0, 
'f', precision );
   163   QTextStream foo( &rep );
   165   foo.setRealNumberPrecision( 8 );
   166   foo.setRealNumberNotation( QTextStream::FixedNotation );
   170       << mXmin << 
' ' << mYmin << 
", "   171       << mXmin << 
' ' << mYmax << 
", "   172       << mXmax << 
' ' << mYmax << 
", "   173       << mXmax << 
' ' << mYmin << 
", "   174       << mXmin << 
' ' << mYmin;
   182   return QgsBox3d( mXmin, mYmin, zMin, mXmax, mYmax, zMax );
   188   auto gridifyValue = []( 
double value, 
double spacing ) -> 
double   191       return  std::round( value / spacing ) * spacing;
   197            gridifyValue( mXmin, spacing ),
   198            gridifyValue( mYmin, spacing ),
   199            gridifyValue( mXmax, spacing ),
   200            gridifyValue( mYmax, spacing )
   212   double xmin, ymin, xmax, ymax;
   213   in >> xmin >> ymin >> xmax >> ymax;
 
A rectangle specified with double values. 
 
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type. 
 
void setXMaximum(double x)
Set the maximum x value. 
 
static QgsRectangle fromWkt(const QString &wkt)
Creates a new rectangle from a wkt string. 
 
QgsRectangle operator-(QgsVector v) const
Returns a rectangle offset from this one in the direction of the reversed vector. ...
 
A class to represent a 2D point. 
 
void scale(double scaleFactor, const QgsPointXY *c=nullptr)
Scale the rectangle around its center point. 
 
QDataStream & operator>>(QDataStream &in, QgsRectangle &rectangle)
Reads a rectangle from stream in into rectangle. 
 
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item...
 
A geometry is the spatial representation of a feature. 
 
A 3-dimensional box composed of x, y, z coordinates. 
 
QgsRectangle snappedToGrid(double spacing) const
Returns a copy of this rectangle that is snapped to a grid with the specified spacing between the gri...
 
QString asWktPolygon() const
Returns a string representation of the rectangle as a WKT Polygon. 
 
static QgsRectangle fromCenterAndSize(QgsPointXY center, double width, double height)
Creates a new rectangle, given the specified center point and width and height. 
 
bool isGeosValid(QgsGeometry::ValidityFlags flags=nullptr) const
Checks validity of the geometry using GEOS. 
 
#define QgsDebugMsgLevel(str, level)
 
bool isEmpty() const
Returns true if the rectangle is empty. 
 
QgsPolygonXY asPolygon() const
Returns the contents of the geometry as a polygon. 
 
double width() const
Returns the width of the rectangle. 
 
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double. 
 
void setYMinimum(double y)
Set the minimum y value. 
 
QString asPolygon() const
Returns the rectangle as a polygon. 
 
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
 
QgsRectangle & operator+=(QgsVector v)
Moves this rectangle in the direction of the vector. 
 
QString asWktCoordinates() const
Returns a string representation of the rectangle in WKT format. 
 
A class to represent a vector. 
 
double yMinimum() const
Returns the y minimum value (bottom side of rectangle). 
 
double xMaximum() const
Returns the x maximum value (right side of rectangle). 
 
static QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string. 
 
QVector< QgsPointXY > QgsPolylineXY
Polyline as represented as a vector of two-dimensional points. 
 
QgsRectangle operator+(QgsVector v) const
Returns a rectangle offset from this one in the direction of the vector. 
 
QgsRectangle scaled(double scaleFactor, const QgsPointXY *center=nullptr) const
Scale the rectangle around its center point. 
 
void setYMaximum(double y)
Set the maximum y value. 
 
QgsRectangle()=default
Constructor for a null rectangle. 
 
double xMinimum() const
Returns the x minimum value (left side of rectangle). 
 
double yMaximum() const
Returns the y maximum value (top side of rectangle). 
 
double x() const
Returns the vector's x-component. 
 
QgsPointXY center() const
Returns the center point of the rectangle. 
 
QgsRectangle & operator-=(QgsVector v)
Moves this rectangle in the direction of the reversed vector. 
 
double y() const
Returns the vector's y-component. 
 
QDataStream & operator<<(QDataStream &out, const QgsRectangle &rectangle)
Writes the list rectangle to stream out. 
 
QgsBox3d toBox3d(double zMin, double zMax) const
Converts the rectangle to a 3D box, with the specified zMin and zMax z values. 
 
void setXMinimum(double x)
Set the minimum x value. 
 
double height() const
Returns the height of the rectangle.