21 #include "../../../common/progress/ProgressManager.h" 22 #include "../../../dataaccess/datasource/DataSource.h" 23 #include "../../../dataaccess/datasource/DataSourceInfoManager.h" 24 #include "../../../dataaccess/datasource/DataSourceInfoManager.h" 25 #include "../../../dataaccess/datasource/DataSourceManager.h" 26 #include "../../../dataaccess/utils/Utils.h" 27 #include "../../../core/filesystem/FileSystem.h" 28 #include "../../../datatype/SimpleProperty.h" 29 #include "../../../geometry/Envelope.h" 30 #include "../../../geometry/GeometryProperty.h" 31 #include "../../../memory/DataSet.h" 32 #include "../../../memory/DataSetItem.h" 33 #include "../../../raster/BandProperty.h" 34 #include "../../../qt/widgets/utils/ScopedCursor.h" 35 #include "../../../qt/widgets/rp/Utils.h" 36 #include "../../../raster/Grid.h" 37 #include "../../../raster/RasterFactory.h" 38 #include "../../../se/Categorize.h" 39 #include "../../../se/ColorMap.h" 40 #include "../../../se/MapItem.h" 41 #include "../../../se/ParameterValue.h" 42 #include "../../../se/RasterSymbolizer.h" 43 #include "../../../se/Recode.h" 44 #include "../../../se/Utils.h" 45 #include "../../../maptools/Utils.h" 46 #include "../help/HelpPushButton.h" 47 #include "../layer/search/LayerSearchWidget.h" 48 #include "../layer/search/LayerSearchWizardPage.h" 49 #include "../progress/ProgressViewerDialog.h" 54 #include <boost/algorithm/string.hpp> 55 #include <boost/filesystem.hpp> 56 #include <boost/lexical_cast.hpp> 57 #include <boost/uuid/random_generator.hpp> 58 #include <boost/uuid/uuid_io.hpp> 61 #include <QApplication> 63 #include <QMessageBox> 64 #include <QTableWidget> 69 this->setWizardStyle(QWizard::ModernStyle);
70 this->setWindowTitle(tr(
"Rasterization"));
72 this->setOption(QWizard::HaveHelpButton,
true);
73 this->setOption(QWizard::HelpButtonOnRight,
false);
77 this->setButton(QWizard::HelpButton, helpButton);
81 connect(
this, SIGNAL(currentIdChanged(
int)), SLOT(
onPageChanged(
int)));
92 std::list<te::map::AbstractLayerPtr> list =
m_layerSearchPage->getSearchWidget()->getSelecteds();
94 if(list.empty() ==
false)
135 for (
int r = 0; r < rows; ++r)
137 for (
int c = 0; c < cols; ++c)
148 QMessageBox::warning(
this, tr(
"Rasterization"), tr(
"File already exists."));
161 QMessageBox::warning(
this, tr(
"Rasterization"), e.
what());
175 boost::filesystem::path uri(uriStr);
177 std::string attrName =
m_vectorPage->getAttributeName();
179 std::map<std::string, std::vector<int> > infos =
m_vectorPage->getInformations();
183 QMessageBox::warning(
this, tr(
"Rasterization"), tr(
"None legend was created!"));
190 std::vector<te::rst::BandProperty*> vecBandProp;
195 vecBandProp.push_back(bProp);
197 std::map<std::string, std::string> dsinfo;
198 dsinfo[
"URI"] = uri.string();
207 std::unique_ptr<te::da::DataSetType> schema =
m_inputLayer->getSchema();
208 std::unique_ptr<te::da::DataSet> data =
m_inputLayer->getData();
212 data->moveBeforeFirst();
214 std::vector<te::gm::Geometry*> geoms;
215 std::vector<double> values;
222 while (data->moveNext())
224 std::string classItem = data->getValue(attrName)->toString();
226 if (infos.find(classItem) == infos.end())
229 std::unique_ptr<te::gm::Geometry> geom = data->getGeometry(geomPos);
231 geom->transform(srid);
235 geoms.push_back(geom.release());
236 values.push_back(infos[classItem][0]);
241 QMessageBox::warning(
this, tr(
"Rasterize"), tr(
"Rasterize operation canceled!"));
249 rst->rasterize(geoms, values, 0);
261 std::map<std::string, std::vector<int> >::iterator it = infos.begin();
262 for (it = infos.begin(); it != infos.end(); ++it)
265 color.setRgb(it->second[1], it->second[2], it->second[3]);
267 double dataDouble = it->second[0];
268 std::string colorStr = color.name().toUtf8().data();
288 boost::filesystem::path
p(uri);
289 p.replace_extension(
"leg");
293 QMessageBox::information(
this, tr(
"Rasterization"), tr(
"Rasterization ended sucessfully."));
296 catch (
const std::exception& e)
298 QMessageBox::warning(
this, tr(
"Rasterization"), e.what());
313 dsType->add(idProperty);
317 dsType->add(geomProperty);
320 std::string pkName =
"pk_id";
321 pkName+=
"_" + dataSetName;
332 for(std::size_t t = 0; t < geoms.size(); ++t)
354 std::map<std::string, std::string> options;
356 ds->createDataSet(dsType, options);
358 ds->add(dataSetName, dataSet, options);
363 int nbytes = std::ceil((log((
float) size) / log(2.)) / 8);
367 else if (nbytes <= 2)
369 else if (nbytes <= 4)
virtual void setValue(unsigned int c, unsigned int r, const double value, std::size_t b=0)
Sets the attribute value in a band of a cell.
void setMessage(const std::string &message)
Set the task message.
void add(te::dt::Property *p)
It adds a property to the list of properties of the primary key.
void setGeometry(std::size_t i, te::gm::Geometry *value)
It sets the value of the i-th property.
static bool exists(const std::string &path)
Checks if a given path in UTF-8 exists.
An atomic property like an integer or double.
boost::shared_ptr< DataSource > DataSourcePtr
A raster band description.
A class that models the description of a dataset.
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
virtual const char * what() const
It outputs the exception message.
TESEEXPORT RasterSymbolizer * GetRasterSymbolizer(Style *s)
Try to get raster symbolizer from a style.
This class can be used to inform the progress of a task.
double m_urx
Upper right corner x-coordinate.
void setCategorize(Categorize *c)
static te::dt::Date ds(2010, 01, 01)
double m_noDataValue
Value to indicate elements where there is no data, default is std::numeric_limits<double>::max().
#define TE_TR(message)
It marks a string in order to get translated.
The "ParameterValueType" uses WFS-Filter expressions to give values for SE graphic parameters...
bool isActive() const
Verify if the task is active.
void setTotalSteps(int value)
Set the task total stepes.
void setInt32(std::size_t i, boost::int32_t value)
It sets the value of the i-th property.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
double m_llx
Lower left corner x-coordinate.
TEDATAACCESSEXPORT std::size_t GetFirstSpatialPropertyPos(const te::da::DataSet *dataset)
It returns the first dataset spatial property or NULL if none is found.
void setData(const double &d)
An Envelope defines a 2D rectangular region.
An abstract class for raster data strucutures.
unsigned int getNumberOfRows() const
Returns the raster number of rows.
void setTitle(const std::string &title)
void setLookupValue(ParameterValue *v)
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
The RasterSymbolizer describes how to render raster/matrix-coverage data (e.g., satellite photos...
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Transformation of discrete values to other values.
void setRecode(Recode *i)
double m_lly
Lower left corner y-coordinate.
bool moveBeforeFirst()
It moves the internal pointer to a position before the first item in the collection.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
TEMAPEXPORT te::rst::Raster * GetRaster(AbstractLayer *layer)
It gets the raster referenced by the given data set layer.
void setValue(ParameterValue *v)
double m_ury
Upper right corner y-coordinate.
It describes a primary key (pk) constraint.
static Raster * make()
It creates and returns an empty raster with default raster driver.
void setColorMap(ColorMap *c)
A rectified grid is the spatial support for raster data.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void setInterpolate(Interpolate *i)
A ColorMap defines either the colors of a pallette-type raster source or the mapping of numeric pixel...
void setFallbackValue(const std::string &v)