27 #include "../../../common/progress/ProgressManager.h" 
   28 #include "../../../geometry/Envelope.h" 
   29 #include "../../../dataaccess/dataset/DataSet.h" 
   30 #include "../../../dataaccess/utils/Utils.h" 
   31 #include "../../../geometry/Geometry.h" 
   32 #include "../../../geometry/GeometryCollection.h" 
   33 #include "../../../raster/Grid.h" 
   34 #include "../../../raster/Interpolator.h" 
   35 #include "../../../raster/PositionIterator.h" 
   36 #include "../../../raster/Raster.h" 
   37 #include "../../../raster/RasterFactory.h" 
   38 #include "../../../raster/Utils.h" 
   39 #include "../help/HelpPushButton.h" 
   40 #include "../layer/search/LayerSearchWidget.h" 
   41 #include "../layer/search/LayerSearchWizardPage.h" 
   42 #include "../progress/ProgressViewerDialog.h" 
   53 #include <QApplication> 
   54 #include <QMessageBox> 
   61   this->setWizardStyle(QWizard::ModernStyle);
 
   62   this->setWindowTitle(tr(
"Clipping"));
 
   65   this->setOption(QWizard::HaveHelpButton, 
true);
 
   66   this->setOption(QWizard::HelpButtonOnRight, 
false);
 
   70   this->setButton(QWizard::HelpButton, helpButton);
 
   84   if(currentPage() ==  m_layerSearchPage.get())
 
   86     std::list<te::map::AbstractLayerPtr> list = m_layerSearchPage->getSearchWidget()->getSelecteds();
 
   88     if(list.empty() == 
false)
 
   92       m_clippingPage->set(l);
 
   95     return m_layerSearchPage->isComplete();
 
   97   else if(currentPage() ==  m_clippingPage.get())
 
   99     bool res = m_clippingPage->isComplete();
 
  102       QMessageBox::warning(
this, tr(
"Warning"), tr(
"Select at least one band."));
 
  106   else if(currentPage() ==  m_rasterInfoPage.get())
 
  116   m_layerSearchPage->getSearchWidget()->setList(layerList);
 
  117   m_layerSearchPage->getSearchWidget()->filterOnlyByRaster();
 
  119   m_clippingPage->setList(layerList);
 
  124   m_clippingPage->set(layer);
 
  129   return m_outputLayer;
 
  138   addPage(m_layerSearchPage.get());
 
  139   addPage(m_clippingPage.get());
 
  140   addPage(m_rasterInfoPage.get());
 
  143   m_layerSearchPage->getSearchWidget()->enableMultiSelection(
false);
 
  148   if(m_rasterInfoPage->getWidget()->fileExists())
 
  150     QMessageBox::warning(
this, tr(
"Clipping"), tr(
"File already exists."));
 
  158   QApplication::setOverrideCursor(Qt::WaitCursor);
 
  164     if(m_clippingPage->isExtentClipping())
 
  165       res = executeExtentClipping();
 
  166     else if(m_clippingPage->isDimensionClipping())
 
  167       res = executeDimensionClipping();
 
  168     else if(m_clippingPage->isLayerClipping())
 
  169       res = executeLayerClipping();
 
  171   catch(
const std::exception& e)
 
  173     QMessageBox::warning(
this, tr(
"Clipping"), e.what());
 
  177     QApplication::restoreOverrideCursor();
 
  183     QMessageBox::warning(
this, tr(
"Clipping"), tr(
"An exception has occurred!"));
 
  187     QApplication::restoreOverrideCursor();
 
  194   QApplication::restoreOverrideCursor();
 
  203   std::auto_ptr<te::da::DataSet> ds = layer->getData();
 
  206   std::auto_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
 
  211   m_clippingPage->getExtentClipping(env);
 
  215     QMessageBox::warning(
this, tr(
"Clipping"), tr(
"Selected area do not intersects the raster extent."));
 
  219   std::map<std::string, std::string> info = m_rasterInfoPage->getWidget()->getInfo();
 
  230                                                         m_rasterInfoPage->getWidget()->getInfo()));
 
  239   std::auto_ptr<te::da::DataSet> ds = layer->getData();
 
  242   std::auto_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
 
  245   int x, y, width, height;
 
  247   m_clippingPage->getDimensionClipping(x, y, width, height);
 
  249   std::map<std::string, std::string> info = m_rasterInfoPage->getWidget()->getInfo();
 
  251   if(y + height > (
int)inputRst->getNumberOfRows() ||
 
  252      x + width  > (int)inputRst->getNumberOfColumns())
 
  254     QMessageBox::warning(
this, tr(
"Clipping"), tr(
"Selected area beyond the raster boundaries."));
 
  267                                                   m_rasterInfoPage->getWidget()->getInfo()));
 
  277   std::auto_ptr<te::da::DataSet> ds = layer->getData();
 
  280   std::auto_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
 
  283   std::auto_ptr< te::gm::GeometryCollection > geomColl;
 
  284   m_clippingPage->getLayerClipping(geomColl);
 
  286   if(geomColl->isEmpty())
 
  289   if( geomColl->getSRID() != inputRst->getSRID() )
 
  291     geomColl->transform( inputRst->getSRID() );
 
  294   if(m_clippingPage->isSingleRasterResult())
 
  297     std::vector<te::rst::BandProperty*> bands;
 
  299     for(std::size_t t = 0; t < inputRst->getNumberOfBands(); ++t)
 
  306     te::rst::Grid* grid = 
new te::rst::Grid(inputRst->getGrid()->getResolutionX(), inputRst->getGrid()->getResolutionY(), env, inputRst->getSRID());
 
  308     std::string type = m_rasterInfoPage->getWidget()->getType();
 
  310     std::map<std::string, std::string> rinfo =  m_rasterInfoPage->getWidget()->getInfo();
 
  312     te::rst::FillRaster(outputRst.get(), outputRst->getBand( 0 )->getProperty()->m_noDataValue );
 
  317     std::vector<double> doubleVec;
 
  321     for(std::size_t i = 0; i < geomColl->getNumGeometries(); ++i)
 
  332         inputCoord = inputRst->getGrid()->gridToGeo(it.
getColumn(), it.
getRow());
 
  333         outputCoord = outputRst->getGrid()->geoToGrid(inputCoord.
x, inputCoord.
y);
 
  339               ( outputCoord.
x >= 0 )
 
  341               ( outputCoord.
x < (
int)outputRst->getNumberOfColumns() )
 
  345               ( outputCoord.
y >= 0 )
 
  347               ( outputCoord.
y < (
int)outputRst->getNumberOfRows() )
 
  351           outputRst->setValues(outputCoord.
x, outputCoord.
y, doubleVec);
 
  362                                                         m_rasterInfoPage->getWidget()->getInfo()));
 
  366     for(std::size_t i = 0; i < geomColl->getNumGeometries(); ++i)
 
  369       std::vector<te::rst::BandProperty*> bands;
 
  371       for(std::size_t t = 0; t < inputRst->getNumberOfBands(); ++t)
 
  378       te::rst::Grid* grid = 
new te::rst::Grid(inputRst->getGrid()->getResolutionX(), inputRst->getGrid()->getResolutionY(), env, inputRst->getSRID());
 
  380       std::string type = m_rasterInfoPage->getWidget()->getType();
 
  382       std::map<std::string, std::string> rinfo =  m_rasterInfoPage->getWidget()->getInfo(i);
 
  394         std::vector<double> doubleVec;
 
  398         te::gm::Coord2D outputCoord = outputRst->getGrid()->geoToGrid(inputCoord.
x, inputCoord.
y);
 
  411                                                           m_rasterInfoPage->getWidget()->getInfo(i)));
 
Near neighborhood interpolation method. 
 
Utility functions for the data access module. 
 
bool intersects(const Envelope &rhs) const 
It returns true if the envelopes "spatially intersects". 
 
A raster band description. 
 
virtual Raster * trim(const te::gm::Envelope *env, const std::map< std::string, std::string > &rinfo) const 
Subsetting operation for trimming (cropping) the raster. 
 
This class implements the strategy to iterate with spatial restriction, the iteration occurs inside a...
 
virtual Raster * resample(int method, unsigned int drow, unsigned int dcolumn, unsigned int height, unsigned int width, unsigned int newheight, unsigned int newwidth, const std::map< std::string, std::string > &rinfo) const 
Resample a subset of the raster, given a box. 
 
TERASTEREXPORT void FillRaster(te::rst::Raster *rin, const std::complex< double > &value)
Fill a Raster with provided value (all bands). 
 
unsigned int getRow() const 
Returns the current row in iterator. 
 
An utility struct for representing 2D coordinates. 
 
A Qt dialog that allows users to run a clipping operation defined by RP module. 
 
This file defines a class for a Raster Info Wizard page. 
 
This file defines a class for a Clipping Wizard page. 
 
static PolygonIterator end(const te::rst::Raster *r, const te::gm::Polygon *p)
Returns an iterator referring to after the end of the iterator. 
 
void removeViewer(int viewerId)
Dettach a progress viewer. 
 
static ProgressManager & getInstance()
It returns a reference to the singleton instance. 
 
TERASTEREXPORT int Round(double val)
Round a double value to a integer value. 
 
An Envelope defines a 2D rectangular region. 
 
An abstract class for raster data strucutures. 
 
This class is GUI used to define the raster info parameters for raster factory. 
 
int addViewer(AbstractProgressViewer *apv)
Attach a progress viewer. 
 
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings. 
 
static PolygonIterator begin(const te::rst::Raster *r, const te::gm::Polygon *p)
Returns an iterator referring to the first value of the band. 
 
static Raster * make()
It creates and returns an empty raster with default raster driver. 
 
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
 
unsigned int getColumn() const 
Returns the current column in iterator. 
 
A rectified grid is the spatial support for raster data. 
 
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
 
This class is GUI used to define the clipping parameters for the RP constast operation.