added asPolygon function to return the rectangle as a set of polyogn coordinates

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@862 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
gsherman 2004-02-16 22:44:47 +00:00
parent 6a7590c880
commit 472544329e
2 changed files with 13 additions and 8 deletions

View File

@ -107,20 +107,23 @@ bool QgsRect::isEmpty()
return FALSE;
}
}
// Return a string representation of the rectangle with high precision
QString QgsRect::stringRep() const
{
QString tmp;
QString rep = tmp.setNum(xmin);;
rep += " ";
rep += tmp.setNum(ymin);
rep += ",";
rep += tmp.setNum(xmax);
rep += " ";
rep += tmp.setNum(ymax);
QString rep = tmp.sprintf("%16f %16f,%16f %16f", xmin, ymin, xmax, ymax);
return rep;
}
// Return the rectangle as a set of polygon coordinates
QString QgsRect::asPolygon() const
{
QString tmp;
QString rep = tmp.sprintf("%16f %16f,%16f %16f,%16f %16f,%16f %16f,%16f %16f",
xmin, ymin, xmin, ymax, xmax, ymax, xmax, ymin, xmin, ymin);
return rep;
}
bool QgsRect::operator==(const QgsRect & r1)
{
return (r1.xMax() == this->xMax() && r1.xMin() == this->xMin() && r1.yMax() == this->yMax() && r1.yMin() == this->yMin());

View File

@ -71,6 +71,8 @@ class QgsRect{
bool isEmpty();
//! returns string representation of form xmin,ymin xmax,ymax
QString stringRep() const;
//! returns rectangle s a polygon
QString asPolygon() const;
/*! Comparison operator
@return True if rectangles are equal
*/