27 #include "../common/Exception.h"
28 #include "../common/StringUtils.h"
29 #include "../common/Translator.h"
30 #include "../dataaccess/dataset/DataSetType.h"
31 #include "../datatype/NumericProperty.h"
32 #include "../datatype/Property.h"
33 #include "../datatype/StringProperty.h"
34 #include "../geometry/Enums.h"
35 #include "../geometry/Envelope.h"
36 #include "../geometry/GeometryProperty.h"
37 #include "../raster/BandProperty.h"
38 #include "../raster/Grid.h"
39 #include "../raster/RasterProperty.h"
43 #include <terralib4/kernel/TeBox.h>
44 #include <terralib4/kernel/TeDatabaseFactoryParams.h>
45 #include <terralib4/kernel/TeDecoderDatabase.h>
46 #include <terralib4/kernel/TeProjection.h>
47 #include <terralib4/kernel/TeTable.h>
48 #include <terralib4/kernel/TeRasterParams.h>
51 #include <boost/lexical_cast.hpp>
55 std::string* defaultValue = attRep.defaultValue_.empty() ? 0 :
new std::string(attRep.defaultValue_);
57 bool isRequired = !attRep.null_;
65 if(attRep.numChar_ == 0)
109 case TePOLYGONSETTYPE:
133 std::auto_ptr<TeDatabaseFactoryParams> fparams(
new TeDatabaseFactoryParams());
135 fparams->dbms_name_ = dsInfo.at(
"T4_DRIVER");
136 fparams->database_ = dsInfo.at(
"T4_DB_NAME");
137 fparams->host_ = dsInfo.at(
"T4_HOST");
139 fparams->user_ = dsInfo.at(
"T4_USER");
140 fparams->password_ = dsInfo.at(
"T4_PASSWORD");
178 case TePOLYGONSETTYPE:
219 case TePOLYGONSETTYPE:
261 case TeUNSIGNEDSHORT:
315 return TeUNSIGNEDINT;
340 return TePOLYGONTYPE;
343 return TePOINTSETTYPE;
346 return TeLINESETTYPE;
349 return TePOLYGONSETTYPE;
358 std::auto_ptr<te::gm::Envelope> env(
new te::gm::Envelope(box.x1(), box.y1(), box.x2(), box.y2()));
365 TeAttributeList attrList = table.attributeList();
369 for(std::size_t i = 0; i < attrList.size(); ++i)
371 TeAttributeRep attr = attrList[i].rep_;
375 newDst->add(prop.release());
385 unsigned int ncols = rparams.ncols_;
386 unsigned int nrows = rparams.nlines_;
387 std::auto_ptr<te::gm::Envelope> mbr(
Convert2T5(rparams.boundingBox()));
389 int srid = rparams.projection()->epsgCode();
394 std::auto_ptr<te::rst::Grid> grid(
new te::rst::Grid(ncols, nrows, rparams.resx_, rparams.resy_, cord, srid));
396 rproperty->set(grid.release());
398 std::vector<te::rst::BandProperty::ColorEntry> palette;
399 if(rparams.photometric_[0] == TeRasterParams::TePallete)
401 std::size_t size = rparams.lutr_.size();
403 for(std::size_t j = 0; j < size; ++j)
406 c.
c1 = rparams.lutr_[j];
407 c.
c2 = rparams.lutg_[j];
408 c.
c3 = rparams.lutb_[j];
409 palette.push_back(c);
413 for(
int i = 0; i != rparams.nBands(); ++i)
417 bp->
m_blkh = rparams.blockHeight_;
418 bp->
m_blkw = rparams.blockWidth_;
423 bp->
m_palette.assign(palette.begin(), palette.end());
431 return rproperty.release();
436 bool isDotSeparator =
false;
443 std::string key =
"Control Panel\\International";
444 std::string sepDecimal =
"sDecimal";
445 std::string sepDecimalResult =
"";
447 if (RegOpenKeyExA(HKEY_CURRENT_USER, key.c_str(), 0, KEY_READ, &hk) == ERROR_SUCCESS)
452 if (RegQueryValueExA(hk, sepDecimal.c_str(), NULL, &Type, (LPBYTE)buf, &DataSize) == ERROR_SUCCESS)
453 sepDecimalResult = buf;
457 if (sepDecimalResult ==
".")
458 isDotSeparator =
true;
463 std::replace(value.begin(), value.end(),
',',
'.');
TeAttrDataType Convert2T4GeomType(te::gm::GeomType type)
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
An atomic property like an integer or double.
std::vector< ColorEntry > m_palette
The color palette.
A raster band description.
A class that models the description of a dataset.
int m_nblocksx
The number of blocks in x.
int m_nblocksy
The number of blocks in y.
An utility struct for representing 2D coordinates.
double m_noDataValue
Value to indicate elements where there is no data, default is std::numeric_limits::max().
#define TE_TR(message)
It marks a string in order to get translated.
TECOMMONEXPORT std::string ReplaceSpecialChars(const std::string &str, bool &changed)
It replace special characters of a string.
std::auto_ptr< te::dt::Property > Convert2T5(const TeAttributeRep &attRep)
It creates a valid TerraLib 5 property given a valid TerraLib 4.x attribute representation.
std::auto_ptr< TeDatabaseFactoryParams > Convert2T4DatabaseParams(const std::map< std::string, std::string > &dsInfo)
It converts a data source information to a TerraLib 4.x database params.
te::gm::GeomType Convert2T5GeomType(TeAttrDataType type)
An Envelope defines a 2D rectangular region.
int m_blkw
Block width (pixels).
The type for string types: FIXED_STRING, VAR_STRING or STRING.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
void CheckDecimalSeparator(std::string &value)
short c1
gray, red, cyan or hue.
short c3
blue, yellow, or saturation.
An structure to represent a color tuple.
std::complex< double > m_valuesOffset
Offset is the values (real and imaginary) to add to grid values for this sample dimension, default is 0.
int m_blkh
Block height (pixels).
TeAttrDataType Convert2T4(int type)
It converts a Terralib 5 data type to Terralib 4.x data type.
A rectified grid is the spatial support for raster data.
Utilitary functions for dealing with TerraLib 5 and 4.x conversion.
short c2
green, magenta, or lightness.