dmprectangle.cpp 1.4 KB
/**************************************************************************
* file:              dmprectangle.cpp

* Author:            qingxiongf
* Date:              2021-08-08 23:21:54
* Email:             qingxiongf@chinadci.com
* copyright:         广州城市信息研究所有限公司
***************************************************************************/
#include "dmprectangle.h"
#include <iostream>

void DmpRectangle::set( double xmin, double ymin, double xmax, double ymax )
{
    xmin_ = xmin;
    ymin_ = ymin;
    xmax_ = xmax;
    ymax_ = ymax;
    normalize();
}

void DmpRectangle::normalize()
{
    if (isNull())
        return;

    if (xmin_ > xmax_)
    {
        std::swap(xmin_, xmax_);
    }
    if (ymin_ > ymax_)
    {
        std::swap(ymin_, ymax_);
    }
}


bool DmpRectangle::isNull() 
{
    // rectangle created QgsRectangle() or with rect.setMinimal() ?
    // return ( qgsDoubleNear( xmin_, 0.0 ) && qgsDoubleNear( mXmax, 0.0 ) && qgsDoubleNear( mYmin, 0.0 ) && qgsDoubleNear( mYmax, 0.0 ) ) ||
    //          ( qgsDoubleNear(xmin_, std::numeric_limits<double>::max() ) && qgsDoubleNear( mYmin, std::numeric_limits<double>::max() ) &&
    //            qgsDoubleNear(xmax_, -std::numeric_limits<double>::max() ) && qgsDoubleNear( mYmax, -std::numeric_limits<double>::max() ) );
    return false;
}