27 #include "../../../common/StringUtils.h" 
   28 #include "../../../dataaccess/dataset/DataSet.h" 
   29 #include "../../../dataaccess/dataset/ObjectIdSet.h" 
   30 #include "../../../dataaccess/utils/Utils.h" 
   31 #include "../../../geometry/Geometry.h" 
   32 #include "../../../geometry/GeometryProperty.h" 
   33 #include "../../../geometry/GeometryCollection.h" 
   34 #include "../../../geometry/LinearRing.h" 
   35 #include "../../../geometry/Polygon.h" 
   36 #include "../../../geometry/Utils.h" 
   37 #include "../../../raster/Grid.h" 
   38 #include "../../../raster/Raster.h" 
   39 #include "../canvas/Canvas.h" 
   40 #include "../canvas/MapDisplay.h" 
   43 #include "ui_ClippingWizardPageForm.h" 
   46 #include <QGridLayout> 
   48 #include <QDoubleValidator> 
   49 #include <QIntValidator> 
   50 #include <QMessageBox> 
   58   : QWizardPage(parent),
 
   59     m_ui(new Ui::ClippingWizardPageForm),
 
   68   QGridLayout* displayLayout = 
new QGridLayout(
m_ui->m_frame);
 
   76   displayLayout->setContentsMargins(0,0,0,0);
 
   82   this->setTitle(tr(
"Clipping"));
 
   83   this->setSubTitle(tr(
"Select the type of clipping and set their specific parameters."));
 
   85   m_ui->m_llxLineEdit->setValidator(
new QDoubleValidator(
this));
 
   86   m_ui->m_llyLineEdit->setValidator(
new QDoubleValidator(
this));
 
   87   m_ui->m_urxLineEdit->setValidator(
new QDoubleValidator(
this));
 
   88   m_ui->m_uryLineEdit->setValidator(
new QDoubleValidator(
this));
 
   90   m_ui->m_startRowLineEdit->setValidator(
new QIntValidator(
this));
 
   91   m_ui->m_startColumnLineEdit->setValidator(
new QIntValidator(
this));
 
   92   m_ui->m_widthLineEdit->setValidator(
new QIntValidator(
this));
 
   93   m_ui->m_heightLineEdit->setValidator(
new QIntValidator(
this));
 
  101   connect(
m_ui->m_llxLineEdit, SIGNAL(editingFinished()), 
this, SIGNAL(completeChanged()));
 
  102   connect(
m_ui->m_llyLineEdit, SIGNAL(editingFinished()), 
this, SIGNAL(completeChanged()));
 
  103   connect(
m_ui->m_urxLineEdit, SIGNAL(editingFinished()), 
this, SIGNAL(completeChanged()));
 
  104   connect(
m_ui->m_uryLineEdit, SIGNAL(editingFinished()), 
this, SIGNAL(completeChanged()));
 
  106   connect(
m_ui->m_startRowLineEdit, SIGNAL(editingFinished()), 
this, SIGNAL(completeChanged()));
 
  107   connect(
m_ui->m_startColumnLineEdit, SIGNAL(editingFinished()), 
this, SIGNAL(completeChanged()));
 
  108   connect(
m_ui->m_widthLineEdit, SIGNAL(editingFinished()), 
this, SIGNAL(completeChanged()));
 
  109   connect(
m_ui->m_heightLineEdit, SIGNAL(editingFinished()), 
this, SIGNAL(completeChanged()));
 
  118   int index = m_ui->m_strategyTypeComboBox->currentIndex();
 
  119   int type = m_ui->m_strategyTypeComboBox->itemData(index).toInt();
 
  121   if(type == CLIPPING_EXTENT)
 
  123     if(m_ui->m_llxLineEdit->text().isEmpty() ||
 
  124        m_ui->m_llyLineEdit->text().isEmpty() ||
 
  125        m_ui->m_urxLineEdit->text().isEmpty() ||
 
  126        m_ui->m_uryLineEdit->text().isEmpty()
 
  132   else if(type == CLIPPING_DIMENSION)
 
  134     if(m_ui->m_startRowLineEdit->text().isEmpty() ||
 
  135        m_ui->m_startColumnLineEdit->text().isEmpty() ||
 
  136        m_ui->m_widthLineEdit->text().isEmpty() ||
 
  137        m_ui->m_heightLineEdit->text().isEmpty()
 
  143   else if(type == CLIPPING_LAYER)
 
  145     if(m_ui->m_layerComboBox->currentText().isEmpty())
 
  158   std::list<te::map::AbstractLayerPtr> list;
 
  160   list.push_back(m_layer);
 
  162   m_navigator->set(m_layer);
 
  167   std::list<te::map::AbstractLayerPtr>::iterator it = layerList.begin();
 
  169   while(it != layerList.end())
 
  173     std::auto_ptr<te::da::DataSetType> dsType = l->getSchema();
 
  175     if(dsType->hasGeom())
 
  176       m_ui->m_layerComboBox->addItem(l->getTitle().c_str(), QVariant::fromValue(l));
 
  181   if(m_ui->m_layerComboBox->count() > 0)
 
  182     onLayerComboBoxActivated(0);
 
  192   int index = m_ui->m_strategyTypeComboBox->currentIndex();
 
  193   int type = m_ui->m_strategyTypeComboBox->itemData(index).toInt();
 
  195   return type == CLIPPING_EXTENT;
 
  200   int index = m_ui->m_strategyTypeComboBox->currentIndex();
 
  201   int type = m_ui->m_strategyTypeComboBox->itemData(index).toInt();
 
  203   return type == CLIPPING_DIMENSION;
 
  208   int index = m_ui->m_strategyTypeComboBox->currentIndex();
 
  209   int type = m_ui->m_strategyTypeComboBox->itemData(index).toInt();
 
  211   return type == CLIPPING_LAYER;
 
  216   if(m_ui->m_aggregAllRadioButton->isChecked())
 
  218   if(m_ui->m_groupByRadioButton->isChecked())
 
  220   if(m_ui->m_selectedGeomRadioButton->isChecked())
 
  228   env.
m_llx = m_ui->m_llxLineEdit->text().toDouble();
 
  229   env.
m_lly = m_ui->m_llyLineEdit->text().toDouble();
 
  230   env.
m_urx = m_ui->m_urxLineEdit->text().toDouble();
 
  231   env.
m_ury = m_ui->m_uryLineEdit->text().toDouble();
 
  236   x = m_ui->m_startColumnLineEdit->text().toInt();
 
  237   y = m_ui->m_startRowLineEdit->text().toInt();
 
  238   width = m_ui->m_widthLineEdit->text().toInt();
 
  239   height = m_ui->m_heightLineEdit->text().toInt();
 
  243   std::auto_ptr< te::gm::GeometryCollection >& geomColl)
 
  246   int index = m_ui->m_layerComboBox->currentIndex();
 
  247   QVariant varLayer = m_ui->m_layerComboBox->itemData(index, Qt::UserRole);
 
  251   std::auto_ptr<te::da::DataSetType> dsType = layer->getSchema();
 
  253   std::string name = geomProp->
getName();
 
  257   if(m_ui->m_aggregAllRadioButton->isChecked())
 
  259     std::auto_ptr<te::da::DataSet> ds = layer->getData();
 
  260     ds->moveBeforeFirst();
 
  262     while(ds->moveNext())
 
  264       geomColl->add(static_cast<te::gm::Geometry*>(ds->getGeometry(name)->clone()));
 
  267   if(m_ui->m_selectedGeomRadioButton->isChecked())
 
  272       QMessageBox::information(
this, 
"Clipping", 
"Select the layer objects to perform the clipping operation.");
 
  276     std::auto_ptr<te::da::DataSet> ds = layer->getData(oidSet);
 
  277     ds->moveBeforeFirst();
 
  278     while(ds->moveNext())
 
  280       geomColl->add(static_cast<te::gm::Geometry*>(ds->getGeometry(name)->clone()));
 
  283   if(m_ui->m_groupByRadioButton->isChecked())
 
  285     std::string propName = m_ui->m_layerAttrComboBox->currentText().toStdString();
 
  287     std::map<std::string, std::vector<te::gm::Geometry*> > groups;
 
  288     std::map<std::string, std::vector<te::gm::Geometry*> >::iterator itg;
 
  290     std::auto_ptr<te::da::DataSet> ds = layer->getData();
 
  292     ds->moveBeforeFirst();
 
  293     while(ds->moveNext())
 
  295       std::string value = ds->getAsString(propName);
 
  297       itg = groups.find(value);
 
  298       if (itg==groups.end())
 
  300         std::vector<te::gm::Geometry*> geomVec;
 
  301         geomVec.push_back(static_cast<te::gm::Geometry*>(ds->getGeometry(name)->clone()));
 
  302         groups.insert(std::pair<std::string, std::vector<te::gm::Geometry*> >(value,geomVec));
 
  305         itg->second.push_back(static_cast<te::gm::Geometry*>(ds->getGeometry(name)->clone()));
 
  308     itg = groups.begin();
 
  309     while(itg != groups.end())
 
  312       std::vector<te::gm::Geometry*> aggregVec = itg->second;
 
  313       if(aggregVec.size() < 2)
 
  314         geomColl->add(aggregVec[0]);
 
  315       if(aggregVec.size() == 2)
 
  317         resultGeometry = aggregVec[0]->
Union(aggregVec[1]);
 
  318         geomColl->add(resultGeometry);
 
  320       if(aggregVec.size() > 2)
 
  324         for(std::size_t i = 1; i < aggregVec.size(); ++i)
 
  326           std::auto_ptr<te::gm::Geometry> currentGeom(aggregVec[i]);
 
  328           if(currentGeom->isValid())
 
  329             geomCollTemp->
add(currentGeom.release());
 
  332         resultGeometry = aggregVec[0]->
Union(geomCollTemp);
 
  333         geomColl->add(resultGeometry);
 
  344   emit completeChanged();
 
  353         m_navigator->removeVectorial();
 
  358         m_navigator->removeVectorial();
 
  363         if(m_ui->m_layerComboBox->count() > 0)
 
  365           QVariant varLayer = m_ui->m_layerComboBox->itemData(0, Qt::UserRole);
 
  369             m_navigator->setVectorial(l);
 
  380   m_ui->m_layerAttrComboBox->clear();
 
  382   QVariant varLayer = m_ui->m_layerComboBox->itemData(index, Qt::UserRole);
 
  385   std::auto_ptr<te::da::DataSetType> dsType = l->getSchema();
 
  387   for(std::size_t t = 0; t < dsType->getProperties().size(); ++t)
 
  389     m_ui->m_layerAttrComboBox->addItem(dsType->getProperties()[t]->getName().c_str());
 
  395   if((m_ui->m_strategyTypeComboBox->currentText() == 
"Layer") && m_ui->m_layerComboBox->count() > 0)
 
  397     QVariant varLayer = m_ui->m_layerComboBox->itemData(index, Qt::UserRole);
 
  401       m_navigator->setVectorial(l);
 
  410   int index = m_ui->m_strategyTypeComboBox->currentIndex();
 
  411   int type = m_ui->m_strategyTypeComboBox->itemData(index).toInt();
 
  413   if(type == CLIPPING_EXTENT)
 
  417     m_ui->m_llxLineEdit->setText(QString::number(env.
getLowerLeftX(), 
'f', 5));
 
  418     m_ui->m_llyLineEdit->setText(QString::number(env.
getLowerLeftY(), 
'f', 5));
 
  419     m_ui->m_urxLineEdit->setText(QString::number(env.
getUpperRightX(), 
'f', 5));
 
  420     m_ui->m_uryLineEdit->setText(QString::number(env.
getUpperRightY(), 
'f', 5));
 
  422   else if(type == CLIPPING_DIMENSION)
 
  426     std::auto_ptr<te::da::DataSet> ds = m_layer->getData();
 
  431       std::auto_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
 
  439         m_ui->m_startRowLineEdit->setText(QString::number((
int)ul.
y));
 
  440         m_ui->m_startColumnLineEdit->setText(QString::number((
int)ul.
x));
 
  441         m_ui->m_heightLineEdit->setText(QString::number((
int)(lr.
y - ul.
y)));
 
  442         m_ui->m_widthLineEdit->setText(QString::number((
int)(lr.
x - ul.
x)));
 
  449   emit completeChanged();
 
  454   m_ui->m_strategyTypeComboBox->clear();
 
  456   m_ui->m_strategyTypeComboBox->addItem(tr(
"Extent"), CLIPPING_EXTENT);
 
  457   m_ui->m_strategyTypeComboBox->addItem(tr(
"Dimension"), CLIPPING_DIMENSION);
 
  458   m_ui->m_strategyTypeComboBox->addItem(tr(
"Layer"), CLIPPING_LAYER);
 
  472   canvasInstance.setPolygonContourWidth(2);
 
  478   int index = m_ui->m_strategyTypeComboBox->currentIndex();
 
  479   int type = m_ui->m_strategyTypeComboBox->itemData(index).toInt();
 
  481   if(type == CLIPPING_EXTENT)
 
  483     if(m_envExt.isValid())
 
  486   else if(type == CLIPPING_DIMENSION)
 
  488     if(m_envDim.isValid())
 
  494     canvasInstance.draw(geom);
 
  499   mapDisplay->repaint();
 
void onEnvelopeAcquired(te::gm::Envelope env)
 
std::auto_ptr< Ui::ClippingWizardPageForm > m_ui
 
void getLayerClipping(std::auto_ptr< te::gm::GeometryCollection > &geomColl)
 
void getExtentClipping(te::gm::Envelope &env)
 
const double & getUpperRightX() const 
It returns a constant refernce to the x coordinate of the upper right corner. 
 
ClippingWizardPage(QWidget *parent=0)
 
double m_urx
Upper right corner x-coordinate. 
 
const double & getLowerLeftY() const 
It returns a constant refernce to the y coordinate of the lower left corner. 
 
An utility struct for representing 2D coordinates. 
 
const double & getUpperRightY() const 
It returns a constant refernce to the x coordinate of the upper right corner. 
 
void setList(std::list< te::map::AbstractLayerPtr > &layerList)
 
void onStrategyTypeComboBoxChanged(int index)
 
bool isSingleRasterResult()
 
This file defines a class for a Clipping Wizard page. 
 
te::map::AbstractLayerPtr get()
 
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr)
 
double m_llx
Lower left corner x-coordinate. 
 
void onLayerComboBoxChanged(int index)
 
int getSRID() const 
It returns the spatial reference system identifier associated to this property. 
 
An Envelope defines a 2D rectangular region. 
 
This class represents a set of unique ids created in the same context. i.e. from the same data set...
 
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque. 
 
GeomType getGeometryType() const 
It returns the geometry subtype allowed for the property. 
 
virtual const te::gm::Envelope & getExtent() const 
It returns the world extent showned by the MapDisplay. 
 
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards. 
 
double m_lly
Lower left corner y-coordinate. 
 
double m_ury
Upper right corner y-coordinate. 
 
void add(Geometry *g)
It adds the geometry into the collection. 
 
const double & getLowerLeftX() const 
It returns a constant reference to the x coordinate of the lower left corner. 
 
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color. 
 
void set(te::map::AbstractLayerPtr layer)
This method is used to set the selected layer for clipping operation. 
 
std::auto_ptr< te::qt::widgets::RasterNavigatorWidget > m_navigator
 
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
 
virtual Geometry * Union(const Geometry *const rhs) const 
It returns a geometric object that represents the point set union with another geometry. 
 
It is a collection of other geometric objects. 
 
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
 
bool isDimensionClipping()
 
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
 
void onStrategyTypeComboBoxActivated(int index)
 
void onLayerComboBoxActivated(int index)
 
void getDimensionClipping(int &x, int &y, int &width, int &height)
 
bool isValid() const 
It tells if the rectangle is valid or not. 
 
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope. 
 
const std::string & getName() const 
It returns the property name.