src/terralib/qt/plugins/mobile/utils/Utils.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2011-2012 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/qt/plugins/mobile/Utils.cpp
22 
23  \brief This file contains a set of utility functions used to export data to a geopackage file
24 */
25 
26 // TerraLib
27 #include "../../../../core/filesystem/FileSystem.h"
28 #include "../../../../common/StringUtils.h"
29 #include "../../../../dataaccess/datasource/DataSource.h"
30 #include "../../../../dataaccess/datasource/DataSourceFactory.h"
31 #include "../../../../dataaccess/datasource/DataSourceTransactor.h"
32 #include "../../../../dataaccess/dataset/DataSetAdapter.h"
33 #include "../../../../dataaccess/dataset/DataSetTypeConverter.h"
34 #include "../../../../dataaccess/utils/Utils.h"
35 #include "../../../../dataaccess/datasource/DataSourceInfoManager.h"
36 #include "../../../../datatype/SimpleData.h"
37 #include "../../../../geometry/GeometryProperty.h"
38 #include "../../../../gdal/Utils.h"
39 #include "../../../../maptools/DataSetLayer.h"
40 #include "../../../../memory/DataSet.h"
41 #include "../../../../memory/DataSetItem.h"
42 #include "../../../../raster/Interpolator.h"
43 #include "../../../../raster/RasterFactory.h"
44 #include "../../../../rp/Functions.h"
45 #include "../../../../rp/RasterHandler.h"
46 #include "../core/form/Serializer.h"
47 #include "../geopackage/Utils.h"
48 #include "Utils.h"
49 
50 //Boost
51 #include <boost/uuid/random_generator.hpp>
52 #include <boost/uuid/uuid_io.hpp>
53 
54 void exportVectortoGPKG(te::map::AbstractLayerPtr layer, te::da::DataSource* dsGPKG, te::da::DataSetType* dataType, std::auto_ptr<te::da::DataSet> dataset, std::string outFileName)
55 {
56  //SRID adaptation
57  int inputSRID = layer->getSRID();
58  int outputSRID = 4326;
59 
60  te::da::DataSetTypeConverter* converter = new te::da::DataSetTypeConverter(dataType, dsGPKG->getCapabilities(), dsGPKG->getEncoding());
61  te::da::AssociateDataSetTypeConverterSRID(converter, inputSRID, outputSRID);
62 
63  te::da::DataSetType* dsTypeResult = converter->getResult();
64 
65  if (dsTypeResult->getProperty("FID"))
66  converter->remove("FID");
67 
68  dsTypeResult->setName(dataType->getName());
69 
70  // Check properties names
71  std::vector<te::dt::Property* > props = dsTypeResult->getProperties();
72  std::map<std::size_t, std::string> invalidNames;
73  for (std::size_t i = 0; i < props.size(); ++i)
74  {
75  if (!dsGPKG->isPropertyNameValid(props[i]->getName()))
76  {
77  invalidNames[i] = props[i]->getName();
78  }
79  }
80 
81  if (!invalidNames.empty())
82  {
83  std::map<std::size_t, std::string>::iterator it = invalidNames.begin();
84  while (it != invalidNames.end())
85  {
86  bool aux;
87  std::string newName = te::common::ReplaceSpecialChars(it->second, aux);
88 
89  props[it->first]->setName(newName);
90 
91  ++it;
92  }
93  }
94 
95  //exporting
96  std::map<std::string, std::string> nopt;
97 
98  std::auto_ptr<te::da::DataSetAdapter> dsAdapter(te::da::CreateAdapter(dataset.get(), converter));
99 
100  if (dataset->moveBeforeFirst())
101  te::da::Create(dsGPKG, dsTypeResult, dsAdapter.get());
102 }
103 
104 void exportRastertoGPKG(te::map::AbstractLayerPtr layer, te::da::DataSource* dsGPKG, std::auto_ptr<te::da::DataSet> dataset, std::string outFileName, const te::gm::Envelope extent)
105 {
106  te::map::DataSetLayer* dsLayer = dynamic_cast<te::map::DataSetLayer*>(layer.get());
107  std::size_t rpos = te::da::GetFirstPropertyPos(dataset.get(), te::dt::RASTER_TYPE);
108  std::auto_ptr<te::rst::Raster> raster = dataset->getRaster(rpos);
109 
110  bool extValid = extent.isValid();
111  int inputSRID = raster->getSRID();
112  int bandType = raster->getBandDataType(0);
113  int multiResLevel = raster->getMultiResLevelsCount();
114 
115  //Adjusting the output raster to tconform with the mobile app needs
116  if ((inputSRID != 4326) || (bandType != te::dt::UCHAR_TYPE) || (multiResLevel > 0))
117  {
118  //Acquiring raster info
119  const std::string& id = dsLayer->getDataSourceId();
121  std::map<std::string, std::string> connInfo = info->getConnInfo();
122  std::string uri = connInfo["SOURCE"];
123 
125  uri += ("/" + dsLayer->getDataSetName());
126 
127  std::map<std::string, std::string> rinfo;
128  rinfo["SOURCE"] = uri;
129  rinfo["FORCE_MEM_DRIVER"] = "TRUE";
130 
131  //Changing the raster to allow it to be exported, must be UCHAR_TYPE & the srid must be 4326
132  if (bandType != te::dt::UCHAR_TYPE)
133  raster = te::qt::plugins::terramobile::NormalizeRaster(raster.get(), 0, 255, rinfo, "MEM");
134 
135  if (inputSRID != 4326 || extValid)
136  {
137  if (extValid && raster->getExtent()->contains(extent) && (inputSRID != 4326)) //Reprojecting and slicing the desired protion of the inut raster
138  raster.reset(raster->transform(4326, extent.getLowerLeftX(), extent.getLowerLeftY(), extent.getUpperRightX(), extent.getUpperRightY(), rinfo));
139  else if (extValid && raster->getExtent()->contains(extent)) //Slicing the desired protion of the input raster
140  raster.reset(raster->transform(inputSRID, extent.getLowerLeftX(), extent.getLowerLeftY(), extent.getUpperRightX(), extent.getUpperRightY(), rinfo));
141  else
142  raster.reset(raster->transform(4326, rinfo)); //Simply reprojecting a raster
143  }
144 
145  //Creating the raster to be exported
146  size_t bandIdx = 0;
147  size_t bands = raster->getNumberOfBands();
148 
149  std::vector< te::rst::BandProperty* > bandsProperties;
150 
151  for (bandIdx = 0; bandIdx < bands; ++bandIdx)
152  {
153  te::rst::BandProperty* bandProp = new te::rst::BandProperty(*(raster->getBand(bandIdx)->getProperty()));
154  bandsProperties.push_back(new te::rst::BandProperty(
155 
156  *(raster->getBand(bandIdx)->getProperty())));
157  }
158 
159  //exporting
160  boost::filesystem::wpath dir = te::core::FileSystem::absolutePath(outFileName);
161  boost::filesystem::wpath file = te::core::FileSystem::absolutePath(dir.parent_path().string() + "/" + dsLayer->getDataSetName());
162  {
163  te::rp::RasterHandler outRasterHandler;
164  te::rp::CreateNewGdalRaster(*(raster->getGrid()), bandsProperties, file.string(), outRasterHandler);
165  te::rst::Raster* outRaster (outRasterHandler.getRasterPtr());
166 
167  //Adjusting the result data on the raster to be exported
168  size_t col = 0;
169  size_t row = 0;
170  size_t bandIdx = 0;
171 
172  double value = 0;
173  const unsigned int inNRows = raster->getNumberOfRows();
174  const unsigned int inNCols = raster->getNumberOfColumns();
175 
176  for (bandIdx = 0; bandIdx < bandsProperties.size(); ++bandIdx)
177  {
178  te::rst::Band& band = *raster->getBand(bandIdx);
179  const double noDataValue = band.getProperty()->m_noDataValue;
180 
181  for (row = 0; row < inNRows; ++row)
182  {
183  for (col = 0; col < inNCols; ++col)
184  {
185  try
186  {
187  band.getValue((unsigned int)col, (unsigned int)row, value);
188  outRaster->setValue((unsigned int)col, (unsigned int)row, value, bandIdx);
189 
190  }
191  catch (...)
192  {
193  continue;
194  }
195  }
196  }
197  }
198 
199  if (multiResLevel > 0)
200  outRaster->createMultiResolution(multiResLevel, te::rst::NearestNeighbor);
201 
202  te::gpkg::copyToGeopackage(outRaster, outFileName);
203  }
204  te::core::FileSystem::remove(file.string());
205  }
206  else
207  te::gpkg::copyToGeopackage(raster.get(), outFileName);
208 }
209 
210 std::auto_ptr<te::da::DataSource> te::qt::plugins::terramobile::createGeopackage(std::string gpkgName)
211 {
212  te::gpkg::createGeopackage(gpkgName);
213 
214  //create data source
215  std::map<std::string, std::string> connInfo;
216  connInfo["URI"] = gpkgName;
217 
218  std::auto_ptr<te::da::DataSource> dsGPKG = te::da::DataSourceFactory::make("GPKG");
219  dsGPKG->setConnectionInfo(connInfo);
220  dsGPKG->open();
221 
222  //Creating tables required by the mobile application
223 
224  //Layer Settings
225  std::string sql1 = "CREATE TABLE IF NOT EXISTS tm_layer_settings";
226  sql1 += "(layer_name TEXT PRIMARY KEY NOT NULL, enabled BOOLEAN NOT NULL, position INTEGER NOT NULL UNIQUE, datasource_uri TEXT, modified INTEGER NOT NULL DEFAULT(0), ";
227  sql1 += "CONSTRAINT fk_layer_name FOREIGN KEY(LAYER_NAME) REFERENCES gpkg_contents(table_name)); ";
228 
229  //Layer style
230  std::string sql2 = "CREATE TABLE IF NOT EXISTS tm_style(layer_name TEXT PRIMARY KEY NOT NULL, sld_xml TEXT); ";
231 
232  //Layer Form
233  std::string sql3 = "CREATE TABLE IF NOT EXISTS tm_layer_form ";
234  sql3 += "(tm_conf_id INTEGER PRIMARY KEY AUTOINCREMENT, gpkg_layer_identify TEXT NOT NULL, tm_form TEXT, tm_media_table TEXT, ";
235  sql3 += "CONSTRAINT fk_layer_identify_id FOREIGN KEY (gpkg_layer_identify) REFERENCES gpkg_contents(table_name));";
236 
237  //General Settings
238  std::string sql4 = "CREATE TABLE IF NOT EXISTS tm_settings(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, key TEXT, value TEXT); ";
239 
240  queryGPKG(sql1, dsGPKG.get());
241  queryGPKG(sql2, dsGPKG.get());
242  queryGPKG(sql3, dsGPKG.get());
243  queryGPKG(sql4, dsGPKG.get());
244 
245  return dsGPKG;
246 }
247 
249 {
250  std::auto_ptr<te::da::DataSetType> dsType = layer->getSchema();
251  std::auto_ptr<te::da::DataSet> dataset;
252 
253  //Checking if the layer contains a raster property
254  if (dsType->hasRaster())
255  {
256  dataset = layer->getData();
257  exportRastertoGPKG(layer, dsGPKG, dataset, outFileName, extent);
258  }
259  else
260  {
261 
262  std::auto_ptr<te::da::DataSetType> dsType = layer->getSchema();
263 
264  if (extent.isValid())
265  {
266  std::string geomName = te::da::GetFirstGeomProperty(dsType.get())->getName();
267  dataset = layer->getData(geomName, &extent);
268  }
269  else
270  dataset = layer->getData();
271 
272  exportVectortoGPKG(layer, dsGPKG, dsType.get(), dataset, outFileName);
273 
274  std::string name = dsType->getName();
275  std::string sldString = te::qt::plugins::terramobile::WriteStyle(layer->getStyle(), (outFileName + "-temp-style.xml"));
276  std::string insert = "INSERT INTO tm_style ('layer_name', 'sld_xml' ) values('" + name + "', '" + sldString + "');";
277 
278  queryGPKG(insert, dsGPKG);
279  }
280 }
281 
282 std::auto_ptr<te::rst::Raster> te::qt::plugins::terramobile::NormalizeRaster(te::rst::Raster* inraster, double nmin, double nmax, std::map<std::string, std::string> rInfo, std::string type)
283 {
284  size_t col = 0;
285  size_t row = 0;
286  size_t bandIdx = 0;
287 
288  double value = 0;
289  double minValue = std::numeric_limits< double >::max();
290  double maxValue = std::numeric_limits< double >::min();
291 
292  const unsigned int inNRows = inraster->getNumberOfRows();
293  const unsigned int inNCols = inraster->getNumberOfColumns();
294 
295  size_t bands = inraster->getNumberOfBands();
296  std::vector<size_t> colorbands;
297 
298  for (bandIdx = 0; bandIdx < bands; ++bandIdx)
299  {
300  te::rst::Band& band = *inraster->getBand(bandIdx);
302  if (color == te::rst::RedCInt ||
303  color == te::rst::GreenCInt ||
304  color == te::rst::BlueCInt ||
305  color == te::rst::AlphaCInt ||
306  color == te::rst::GrayIdxCInt)
307  colorbands.push_back(bandIdx);
308  }
309 
310  //Checking the min & max values from the raster bands
311  for (bandIdx = 0; bandIdx < colorbands.size(); ++bandIdx)
312  {
313  te::rst::Band& band = *inraster->getBand(colorbands[bandIdx]);
314  const double noDataValue = band.getProperty()->m_noDataValue;
315 
316  for (row = 0; row < inNRows; ++row)
317  {
318  for (col = 0; col < inNCols; ++col)
319  {
320  band.getValue((unsigned int)col, (unsigned int)row, value);
321  if (value != noDataValue)
322  {
323  if (value < minValue)
324  minValue = value;
325 
326  if (value > maxValue)
327  maxValue = value;
328  }
329  }
330  }
331  }
332 
333  double gain = (double)(nmax - nmin) / (maxValue - minValue);
334  double offset = -1 * gain*minValue + nmin;
335 
336  //Creating the output Raster file
337  std::vector<te::rst::BandProperty*> bandsProperties;
338 
339  for (bandIdx = 0; bandIdx < colorbands.size(); ++bandIdx)
340  {
341  te::rst::BandProperty* bandProp = new te::rst::BandProperty(colorbands[bandIdx], te::dt::UCHAR_TYPE);
342  te::rst::Band& inBand = *inraster->getBand(colorbands[bandIdx]);
343  bandProp->m_colorInterp = inBand.getProperty()->m_colorInterp;
344  bandProp->m_noDataValue = inBand.getProperty()->m_noDataValue;
345  bandsProperties.push_back(bandProp);
346  }
347 
348  te::rst::Grid* grid = new te::rst::Grid(*(inraster->getGrid()));
349  te::rst::Raster* rasterNormalized = te::rst::RasterFactory::make(type, grid, bandsProperties, rInfo);
350 
351  //Normalizing the values on the output Raster
352 
353  for (bandIdx = 0; bandIdx < colorbands.size(); ++bandIdx)
354  {
355  te::rst::Band& band = *inraster->getBand(colorbands[bandIdx]);
356 
357  const double noDataValue = band.getProperty()->m_noDataValue;
358 
359  for (row = 0; row < inNRows; ++row)
360  {
361  for (col = 0; col < inNCols; ++col)
362  {
363  try
364  {
365  band.getValue((unsigned int)col, (unsigned int)row, value);
366 
367  if (value == noDataValue)
368  {
369  rasterNormalized->setValue((unsigned int)col, (unsigned int)row, value, bandIdx);
370  }
371  else
372  {
373  double normalizeValue = (value * gain + offset);
374  rasterNormalized->setValue((unsigned int)col, (unsigned int)row, normalizeValue, bandIdx);
375  }
376  }
377  catch (...)
378  {
379  continue;
380  }
381  }
382  }
383  }
384 
385  std::auto_ptr<te::rst::Raster> rOut(rasterNormalized);
386 
387  return rOut;
388 }
389 
391 {
392  std::auto_ptr<te::da::DataSourceTransactor> transactor = dsGPKG->getTransactor();
393 
394  try
395  {
396  transactor->execute(query);
397  }
398  catch (...)
399  {
400  transactor->rollBack();
401  throw;
402  }
403 }
404 
405 std::vector<std::string> te::qt::plugins::terramobile::getItemNames(std::string type, te::da::DataSource* dsGPKG)
406 {
407  std::auto_ptr<te::da::DataSourceTransactor> transactor = dsGPKG->getTransactor();
408  std::vector<std::string> names;
409 
410  std::string select = "SELECT name FROM sqlite_master WHERE type = '" + type + "' AND name LIKE 'rtree%'; ";
411 
412  std::auto_ptr<te::da::DataSet> tupleNames;
413 
414  tupleNames = transactor->query(select);
415 
416  tupleNames->moveBeforeFirst();
417 
418  while (tupleNames->moveNext())
419  {
420  std::string trigger = tupleNames->getString("name");
421  names.push_back(trigger);
422  }
423 
424  return names;
425 }
426 
428 {
429  std::auto_ptr<te::da::DataSetType> dsType = ds->getDataSetType(dataSetName);
430 
431  te::mem::DataSet* dataSetMem = new te::mem::DataSet(dsType.get());
432 
433  std::auto_ptr<te::da::DataSet> dataSet = ds->getDataSet(dataSetName);
434 
435  dataSet->moveBeforeFirst();
436 
437  while (dataSet->moveNext())
438  {
439  te::mem::DataSetItem* dsItem = new te::mem::DataSetItem(dataSetMem);
440 
441  for (std::size_t t = 0; t < dataSet->getNumProperties(); ++t)
442  {
443  if (dataSet->getPropertyName(t) == LAYER_GATHERING_OBJID_COLUMN)
444  {
445  if (dataSet->isNull(t))
446  {
447  //Generating a unique id for the geopackage file
448  boost::uuids::basic_random_generator<boost::mt19937> gen;
449  boost::uuids::uuid u = gen();
450  std::string id_ds = boost::uuids::to_string(u);
451 
453  }
454  else
455  {
456  dsItem->setValue(LAYER_GATHERING_OBJID_COLUMN, dataSet->getValue(t).release());
457  }
458  }
459  else if (dataSet->getPropertyName(t) == LAYER_GATHERING_STATUS_COLUMN)
460  {
462  }
463  else
464  {
465  dsItem->setValue(dataSet->getPropertyName(t), dataSet->getValue(t).release());
466  }
467  }
468  dataSetMem->add(dsItem);
469  }
470 
471  std::vector<size_t> ids;
472  ids.push_back(0);
473 
474  std::vector< std::set<int> > properties;
475  std::size_t dsSize = dataSetMem->size();
476 
477  for (std::size_t t = 0; t < dsSize; ++t)
478  {
479  std::set<int> setPos;
480 
481  for (std::size_t p = 0; p < dataSetMem->getNumProperties(); ++p)
482  {
483  if (dataSetMem->getPropertyName(p) == LAYER_GATHERING_STATUS_COLUMN)
484  {
485  setPos.insert(p);
486  }
487  else if (dataSetMem->getPropertyName(p) == LAYER_GATHERING_OBJID_COLUMN)
488  {
489  setPos.insert(p);
490  }
491  }
492  properties.push_back(setPos);
493  }
494 
495  ds->update(dataSetName, dataSetMem, properties, ids);
496 }
Property * getProperty(std::size_t i) const
It returns the i-th property.
std::size_t size() const
It returns the collection size, if it is known.
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.
unsigned int band
virtual bool isPropertyNameValid(const std::string &propertyName)
It checks if the given property name is valid.
TERRAMOBILEPLUGINSDLLEXPORT void copyToGeopackage(te::rst::Raster *raster, std::string outFileName)
static std::unique_ptr< DataSource > make(const std::string &driver, const te::core::URI &connInfo)
Near neighborhood interpolation method.
std::string WriteStyle(const te::se::Style *style, std::string path="style.xml")
Alpha channel color interpretation.
virtual std::unique_ptr< DataSourceTransactor > getTransactor()=0
It returns the set of parameters used to set up the access channel to the underlying repository...
static bool isDirectory(const std::string &path)
Checks if a given path in UTF-8 is a directory.
Definition: FileSystem.cpp:87
Index into a lookup table.
void exportVectortoGPKG(te::map::AbstractLayerPtr layer, te::da::DataSource *dsGPKG, te::da::DataSetType *dataType, std::auto_ptr< te::da::DataSet > dataset, std::string outFileName)
TEDATAACCESSEXPORT void AssociateDataSetTypeConverterSRID(DataSetTypeConverter *converter, const int &inputSRID, const int &outputSRID=TE_UNKNOWN_SRS)
ColorInterp
Color model component use.
A raster band description.
Definition: BandProperty.h:61
A class that models the description of a dataset.
Definition: DataSetType.h:72
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
void queryGPKG(std::string query, te::da::DataSource *dsGPKG)
std::vector< std::string > getItemNames(std::string type, te::da::DataSource *dsGPKG)
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
void setValue(std::size_t i, te::dt::AbstractData *value)
It sets the value of the i-th property.
Red channel color interpretation.
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
static te::dt::Date ds(2010, 01, 01)
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
double m_noDataValue
Value to indicate elements where there is no data, default is std::numeric_limits<double>::max().
Definition: BandProperty.h:136
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
std::auto_ptr< te::da::DataSource > createGeopackage(std::string gpkgName)
std::string ReplaceSpecialChars(const std::string &str, bool &changed)
It replace special characters of a string.
Definition: StringUtils.h:376
void add(DataSetItem *item)
It adds a new item to the dataset and takes its ownership.
virtual te::core::EncodingType getEncoding()
It return the DataSource current encoding.
An converter for DataSetType.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
void setName(const std::string &name)
It sets the property name.
Definition: Property.h:137
virtual const DataSourceCapabilities & getCapabilities() const =0
It returns the known capabilities of the data source.
static std::string absolutePath(const std::string &path)
Retrives the absolute path for the given path in UTF-8.
Definition: FileSystem.cpp:76
const std::vector< Property * > & getProperties() const
It returns the list of properties describing the CompositeProperty.
static bool remove(const std::string &path)
Removes a file or directory from a given path in UTF-8.
Definition: FileSystem.cpp:166
void exportToGPKG(te::map::AbstractLayerPtr layer, te::da::DataSource *dsGPKG, std::string outFileName, const te::gm::Envelope extent)
void exportRastertoGPKG(te::map::AbstractLayerPtr layer, te::da::DataSource *dsGPKG, std::auto_ptr< te::da::DataSet > dataset, std::string outFileName, const te::gm::Envelope extent)
static DataSourceInfoManager & getInstance()
It returns a reference to the singleton instance.
An Envelope defines a 2D rectangular region.
An abstract class for raster data strucutures.
TEDATAACCESSEXPORT void Create(DataSource *ds, DataSetType *dt, DataSet *d, std::size_t limit=0)
It creates the dataset definition in a data source and then fill it with data from the input dataset...
unsigned int getNumberOfRows() const
Returns the raster number of rows.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
BandProperty * getProperty()
Returns the band property.
mydialect insert("+", new te::da::BinaryOpEncoder("+"))
void DataSet()
list bands
Definition: compose.py:2
te::gm::Polygon * p
RasterHandler.
Definition: RasterHandler.h:47
A raster band description.
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
Grid * getGrid()
It returns the raster grid.
Utility functions for the data access module.
virtual std::unique_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
void fillExtraColumns(te::da::DataSource *ds, std::string dataSetName)
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
std::string getPropertyName(std::size_t pos) const
It returns the property name at position pos.
#define LAYER_GATHERING_STATUS_COLUMN
virtual std::unique_ptr< DataSet > getDataSet(const std::string &name, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It gets the dataset identified by the given name. This method always returns a disconnected dataset...
const std::string & getDataSetName() const
void remove(const std::string &propertyName)
This method removes a property of DataSetTypeConverter.
static Raster * make()
It creates and returns an empty raster with default raster driver.
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
#define LAYER_GATHERING_OBJID_COLUMN
te::rst::Raster * getRasterPtr()
Returns a pointer the the handled raster instance or NULL if no instance is handled.
A layer with reference to a dataset.
Definition: DataSetLayer.h:47
bool CreateNewGdalRaster(const te::rst::Grid &rasterGrid, std::vector< te::rst::BandProperty * > bandsProperties, const std::string &fileName, RasterHandler &outRasterHandler)
Create a new raster into a GDAL datasource.
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
A template for atomic data types (integers, floats, strings and others).
Definition: SimpleData.h:59
Blue channel color interpretation.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
A rectified grid is the spatial support for raster data.
Definition: raster/Grid.h:68
Green channel color interpretation.
TEDATAACCESSEXPORT DataSetAdapter * CreateAdapter(DataSet *ds, DataSetTypeConverter *converter, bool isOwner=false)
ColorInterp m_colorInterp
The color interpretation.
Definition: BandProperty.h:140
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
virtual void update(const std::string &datasetName, DataSet *dataset, const std::vector< std::size_t > &properties, const te::da::ObjectIdSet *oids, const std::map< std::string, std::string > &options, std::size_t limit=0)
It updates the contents of a dataset for the set of data items.
std::auto_ptr< te::rst::Raster > NormalizeRaster(te::rst::Raster *inraster, double nmin, double nmax, std::map< std::string, std::string > rInfo, std::string type)
virtual const std::string & getDataSourceId() const
TERRAMOBILEPLUGINSDLLEXPORT void createGeopackage(std::string outFileName)
bool isValid() const
It tells if the rectangle is valid or not.
unsigned int col
file(WRITE ${CMAKE_BINARY_DIR}/config_qhelp.cmake"configure_file (${TERRALIB_ABSOLUTE_ROOT_DIR}/doc/qhelp/help.qhcp.in ${CMAKE_BINARY_DIR}/share/terraview/help/help.qhcp @ONLY)") add_custom_command(OUTPUT del_dir COMMAND $
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr
virtual void getValue(unsigned int c, unsigned int r, double &value) const =0
Returns the cell attribute value.
std::size_t getNumProperties() const
It returns the number of properties that composes an item of the dataset.
const std::string & getName() const
It returns the property name.
Definition: Property.h:127