23 #include <QTextStream>
32 : xmin( newxmin ), ymin( newymin ), xmax( newxmax ), ymax( newymax )
44 xmin = qRectF.topLeft().x();
45 ymin = qRectF.topLeft().y();
46 xmax = qRectF.bottomRight().x();
47 ymax = qRectF.bottomRight().y();
101 double centerX, centerY;
112 scale( scaleFactor, centerX, centerY );
117 double newWidth =
width() * scaleFactor;
118 double newHeight =
height() * scaleFactor;
119 xmin = centerX - newWidth / 2.0;
120 xmax = centerX + newWidth / 2.0;
121 ymin = centerY - newHeight / 2.0;
122 ymax = centerY + newHeight / 2.0;
217 QString(
"POLYGON((" ) +
232 return QRectF(( qreal )
xmin, ( qreal )
ymin, ( qreal )
xmax - xmin, ( qreal )
ymax - ymin );
238 if ( automaticPrecision )
243 precision =
static_cast<int>( ceil( -1.0 * log10( qMin(
width(),
height() ) ) ) ) + 1;
245 if ( precision > 20 )
262 rep = QString(
"%1,%2 : %3,%4" )
263 .arg(
xmin, 0,
'f', thePrecision )
264 .arg(
ymin, 0,
'f', thePrecision )
265 .arg(
xmax, 0,
'f', thePrecision )
266 .arg(
ymax, 0,
'f', thePrecision );
281 QTextStream foo( &rep );
283 foo.setRealNumberPrecision( 8 );
284 foo.setRealNumberNotation( QTextStream::FixedNotation );
310 return ( !
operator==( r1 ) );
void unionRect(const QgsRectangle &rect)
updates rectangle to include passed argument
QgsRectangle & operator=(const QgsRectangle &r1)
bool intersects(const QgsRectangle &rect) const
returns true when rectangle intersects with other rectangle
A rectangle specified with double values.
bool isEmpty() const
test if rectangle is empty.
QRectF toRectF() const
returns a QRectF with same coordinates.
void setMinimal()
Set a rectangle so that min corner is at max and max corner is at min.
void setXMaximum(double x)
Set the maximum x value.
QgsRectangle buffer(double width)
Get rectangle enlarged by buffer.
bool isFinite() const
Returns true if the rectangle has finite boundaries.
double yMaximum() const
Get the y maximum value (top side of rectangle)
QString qgsDoubleToString(const double &a)
bool contains(const QgsRectangle &rect) const
return true when rectangle contains other rectangle
bool isNull() const
test if the rectangle is null (all coordinates zero or after call to setMinimal()).
void set(const QgsPoint &p1, const QgsPoint &p2)
Set the rectangle from two QgsPoints.
double ANALYSIS_EXPORT max(double x, double y)
returns the maximum of two doubles or the first argument if both are equal
void combineExtentWith(QgsRectangle *rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
QgsRectangle(double xmin=0, double ymin=0, double xmax=0, double ymax=0)
Constructor.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
double xMaximum() const
Get the x maximum value (right side of rectangle)
#define QgsDebugMsgLevel(str, level)
void setYMinimum(double y)
Set the minimum y value.
QString asWktCoordinates() const
returns string representation in Wkt form
A class to represent a point geometry.
bool operator!=(const QgsRectangle &r1) const
QString asWktPolygon() const
returns string representation as WKT Polygon
QString asPolygon() const
returns rectangle as a polygon
void setYMaximum(double y)
Set the maximum y value.
QgsRectangle intersect(const QgsRectangle *rect) const
return the intersection with the given rectangle
void normalize()
Normalize the rectangle so it has non-negative width/height.
double width() const
Width of the rectangle.
QString toString(bool automaticPrecision=false) const
returns string representation of form xmin,ymin xmax,ymax
double xMinimum() const
Get the x minimum value (left side of rectangle)
void setXMinimum(double x)
Set the minimum x value.
double height() const
Height of the rectangle.
bool operator==(const QgsRectangle &r1) const
void scale(double scaleFactor, const QgsPoint *c=0)
Scale the rectangle around its center point.