27 #include "../common/STLUtils.h"
28 #include "../common/Translator.h"
29 #include "../dataaccess/dataset/DataSetType.h"
30 #include "../dataaccess/utils/Utils.h"
31 #include "../datatype/ByteArray.h"
32 #include "../datatype/DataType.h"
33 #include "../datatype/Property.h"
34 #include "../datatype/SimpleData.h"
35 #include "../datatype/StringProperty.h"
36 #include "../datatype/Utils.h"
37 #include "../geometry/Envelope.h"
38 #include "../geometry/Geometry.h"
39 #include "../geometry/Utils.h"
54 for(std::size_t i = 0; i < dt->
size(); ++i)
69 for(std::size_t i = 0; i <
m_ptypes.size(); ++i)
83 for(std::size_t i = 0; i <
m_ptypes.size(); ++i)
97 for(std::size_t i = 0; i != properties.size(); ++i)
107 copy(rhs, properties, limit);
121 std::vector<std::size_t> properties;
125 for(std::size_t i = 0; i != np; ++i)
126 properties.push_back(i);
128 copy(src, properties, limit);
133 bool unlimited =
true;
137 limit = std::numeric_limits<std::size_t>::max();
141 m_items->reserve(m_items->size() + limit);
147 const std::size_t nproperties = properties.size();
149 while(src.
moveNext() && (i < limit))
151 std::auto_ptr<DataSetItem> item(
new DataSetItem(
this));
153 for(std::size_t c = 0; c < nproperties; ++c)
155 if(!src.
isNull(properties[c]))
156 item->setValue(c, src.
getValue(properties[c]).release());
158 item->setValue(c, 0);
161 m_items->push_back(item.release());
168 if(!unlimited & (i < limit))
169 throw Exception(
TE_TR(
"The source dataset has few items than requested copy limit!"));
174 m_items->push_back(item);
179 m_items->erase(m_items->begin() + m_i);
184 const std::size_t nitems = m_items->size();
186 for(std::size_t i = 0; i < nitems; ++i)
188 if(&(m_items->operator[](i)) == item)
190 m_items->erase(m_items->begin() + i);
195 throw Exception(
TE_TR(
"Item not found in the dataset!"));
200 m_pnames.push_back(propertyName);
201 m_ptypes.push_back(propertyType);
203 const std::size_t nitems = m_items->size();
205 for(std::size_t i = 0; i < nitems; ++i)
206 m_items->operator[](i).m_data.push_back(defaultValue ? defaultValue->
clone() : 0);
211 const std::size_t nitems = m_items->size();
213 for(std::size_t i = 0; i < nitems; ++i)
214 m_items->operator[](i).m_data.erase( m_items->operator[](i).m_data.begin() + pos);
216 m_pnames.erase(m_pnames.begin() + pos);
217 m_ptypes.erase(m_ptypes.begin() + pos);
228 throw Exception(
"No implemented yet!");
245 const std::size_t nitems = m_items->size();
247 for(std::size_t ii = 0; ii < nitems; ++ii)
249 std::auto_ptr<te::gm::Geometry> geom((*m_items)[ii].getGeometry(i));
251 mbr->Union(*(geom->getMBR()));
259 return m_pnames.size();
264 return m_ptypes[pos];
274 return m_pnames[pos];
279 m_pnames[pos] = name;
285 std::map<int, te::common::CharEncoding>::const_iterator it = m_encodings.find(i);
286 assert(it != m_encodings.end());
293 throw Exception(
"No implemented yet!");
298 return (*m_items)[m_i].
clone().get();
303 return m_items->empty();
313 return m_items->size();
319 return m_i < static_cast<int>(m_items->size());
342 m_i = m_items->size() - 1;
343 return m_i < static_cast<int>(m_items->size());
349 return m_i < static_cast<int>(m_items->size());
364 return m_i == (
static_cast<int>(m_items->size()) - 1);
369 return m_i >
static_cast<int>(m_items->size());
374 return (*m_items)[m_i].getChar(i);
379 (*m_items)[m_i].setChar(i, value);
384 (*m_items)[m_i].setChar(name, value);
389 return (*m_items)[m_i].getUChar(i);
394 (*m_items)[m_i].setUChar(i, value);
399 (*m_items)[m_i].setUChar(name, value);
404 return (*m_items)[m_i].getInt16(i);
409 (*m_items)[m_i].setInt16(i, value);
414 (*m_items)[m_i].setInt16(name, value);
419 return (*m_items)[m_i].getInt32(i);
424 (*m_items)[m_i].setInt32(i, value);
429 (*m_items)[m_i].setInt32(name, value);
434 return (*m_items)[m_i].getInt64(i);
439 (*m_items)[m_i].setInt64(i, value);
444 (*m_items)[m_i].setInt64(name, value);
449 return (*m_items)[m_i].getBool(i);
454 (*m_items)[m_i].setBool(i, value);
459 (*m_items)[m_i].setBool(name, value);
464 return (*m_items)[m_i].getFloat(i);
469 (*m_items)[m_i].setFloat(i, value);
474 (*m_items)[m_i].setFloat(name, value);
479 return (*m_items)[m_i].getDouble(i);
484 (*m_items)[m_i].setDouble(i, value);
489 (*m_items)[m_i].setDouble(name, value);
494 return (*m_items)[m_i].getNumeric(i);
499 (*m_items)[m_i].setNumeric(i, value);
504 (*m_items)[m_i].setNumeric(name, value);
509 return (*m_items)[m_i].getString(i);
514 (*m_items)[m_i].setString(i, value);
519 (*m_items)[m_i].setString(name, value);
524 return (*m_items)[m_i].getByteArray(i);
529 (*m_items)[m_i].setByteArray(i, value);
534 (*m_items)[m_i].setByteArray(name, value);
539 return (*m_items)[m_i].getGeometry(i);
544 (*m_items)[m_i].setGeometry(i, value);
549 (*m_items)[m_i].setGeometry(name, value);
554 return (*m_items)[m_i].getRaster(i);
559 (*m_items)[m_i].setRaster(i, value);
564 (*m_items)[m_i].setRaster(name, value);
569 return std::auto_ptr<te::dt::DateTime>((*m_items)[m_i].getDateTime(i));
574 (*m_items)[m_i].setDateTime(i, value);
579 (*m_items)[m_i].setDateTime(name, value);
584 return std::auto_ptr<te::dt::Array>(0);
589 return (*m_items)[m_i].getValue(i);
594 (*m_items)[m_i].setValue(i, value);
599 (*m_items)[m_i].setValue(name, ad);
604 return (*m_items)[m_i].isNull(i);
std::auto_ptr< te::dt::DateTime > getDateTime(std::size_t i) const
Method for retrieving a date and time attribute value.
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.
void setString(std::size_t i, const std::string &value)
boost::shared_ptr< boost::ptr_vector< DataSetItem > > m_items
The list of dataset items.
bool move(std::size_t i)
It moves the dataset internal pointer to a given position.
std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const
Method for retrieving a geometric attribute value.
boost::int16_t getInt16(std::size_t i) const
Method for retrieving a 16-bit integer attribute value (2 bytes long).
bool isAfterEnd() const
It tells if the dataset internal pointer is on the sentinel position after the last element of the co...
te::common::CharEncoding getCharEncoding() const
It returns the string property character encoding.
CharEncoding
Supported charsets (character encoding).
void setByteArray(std::size_t i, te::dt::ByteArray *value)
A class that models the description of a dataset.
te::common::TraverseType getTraverseType() const
It returns the traverse type associated to the dataset.
te::common::AccessPolicy getAccessPolicy() const
It returns the read and write permission associated to the dataset.
DataSet()
Default constructor.
void setInt16(std::size_t i, boost::int16_t value)
bool isAtEnd() const
It tells if the dataset internal pointer is on the last element of the collection.
bool isConnected() const
It returns true if the dataset is connected and false if it is disconnected. A dataset can be connect...
bool getBool(std::size_t i) const
Method for retrieving a boolean attribute value.
void setInt32(std::size_t i, boost::int32_t value)
bool moveFirst()
It moves the internal pointer to the first item in the collection.
std::string getString(std::size_t i) const
Method for retrieving a string value attribute.
#define TE_TR(message)
It marks a string in order to get translated.
std::map< int, te::common::CharEncoding > m_encodings
The list of string properties char-encoding.
An exception class for the TerraLib In-Memory Data Access driver.
int getPropertyDataType(std::size_t pos) const
It returns the underlying data type of the property at position pos.
bool isNull(std::size_t i) const
It checks if the attribute value is NULL.
bool isEmpty() const
It returns true if the collection is empty.
It models a property definition.
std::vector< int > m_ptypes
The list of property types.
void drop(std::size_t pos)
It drops a property from the dataset.
std::auto_ptr< te::dt::AbstractData > getValue(std::size_t i) const
Method for retrieving any other type of data value stored in the data source.
void add(DataSetItem *item)
It adds a new item to the dataset and takes its ownership.
std::auto_ptr< DataSetItem > clone() const
It returns a clone of the DataSetItem.
void setInt64(std::size_t i, boost::int64_t value)
std::string getDatasetNameOfProperty(std::size_t pos) const
It returns the underlying dataset name of the property at position pos.
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
AccessPolicy
Supported data access policies (can be used as bitfield).
void setValue(std::size_t i, te::dt::AbstractData *value)
TraverseType
A dataset can be traversed in two ways:
float getFloat(std::size_t i) const
Method for retrieving a float attribute value.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
std::auto_ptr< te::dt::ByteArray > getByteArray(std::size_t i) const
Method for retrieving a byte array.
boost::int32_t getInt32(std::size_t i) const
Method for retrieving a 32-bit integer attribute value (4 bytes long).
An Envelope defines a 2D rectangular region.
An abstract class for raster data strucutures.
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
virtual te::common::CharEncoding getPropertyCharEncoding(std::size_t i) const =0
It returns the property character encoding at position pos.
bool moveLast()
It sets the dataset internal pointer to the last item in the collection.
std::auto_ptr< te::gm::Envelope > getExtent(std::size_t i)
It computes the bounding rectangle for a spatial property of the dataset.
bool isBeforeBegin() const
It tells if the dataset internal pointer is in a position before the first element of the collection ...
std::vector< std::string > m_pnames
The list of property names.
A base class for values that can be retrieved from the data access module.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
The type for string types: FIXED_STRING, VAR_STRING or STRING.
std::size_t size() const
It returns the number of properties of the CompositeProperty.
void setNumeric(std::size_t i, const std::string &value)
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
void remove()
It removes the current dataset item.
void setDateTime(std::size_t i, te::dt::DateTime *value)
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
void setFloat(std::size_t i, float value)
bool isAtBegin() const
It tells if the dataset internal pointer is on the first element of the collection or not...
DataSetItem * getItem() const
std::auto_ptr< te::rst::Raster > getRaster(std::size_t i) const
Method for retrieving a raster attribute value.
std::string getNumeric(std::size_t i) const
Method for retrieving a numeric attribute value.
unsigned char getUChar(std::size_t i) const
Method for retrieving an unsigned character attribute value (1 byte long).
bool moveBeforeFirst()
It moves the internal pointer to a position before the first item in the collection.
bool moveNext()
It moves the internal pointer to the next item of the collection.
void setGeometry(std::size_t i, te::gm::Geometry *value)
boost::int64_t getInt64(std::size_t i) const
Method for retrieving a 64-bit integer attribute value (8 bytes long).
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
A dataset is the unit of information manipulated by the data access module of TerraLib.
void copy(te::da::DataSet &src, std::size_t limit=0)
It copies up to limit items from the source dataset.
std::string getPropertyName(std::size_t pos) const
It returns the property name at position pos.
void update(te::dt::Property *prop)
It update a property from the dataset.
double getDouble(std::size_t i) const
Method for retrieving a double attribute value.
char getChar(std::size_t i) const
Method for retrieving a signed character attribute value (1 byte long).
void setChar(std::size_t i, char value)
void clear()
It clears all the dataset items.
te::common::CharEncoding getPropertyCharEncoding(std::size_t i) const
It returns the property character encoding at position pos.
void setBool(std::size_t i, bool value)
void setUChar(std::size_t i, unsigned char value)
bool movePrevious()
It moves the internal pointer to the previous item of the collection.
virtual AbstractData * clone() const =0
It returns a clone of this object.
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
void setRaster(std::size_t i, te::rst::Raster *value)
void setPropertyName(const std::string &name, std::size_t pos)
std::auto_ptr< te::dt::Array > getArray(std::size_t i) const
Method for retrieving an array.
void setDouble(std::size_t i, double value)
virtual std::auto_ptr< te::dt::AbstractData > getValue(std::size_t i) const
Method for retrieving any other type of data value stored in the data source.
A class for representing binary data.
void setPropertyDataType(int dt, std::size_t pos)
TEDATAACCESSEXPORT void GetPropertyInfo(const DataSetType *const dt, std::vector< std::string > &pnames, std::vector< int > &ptypes)
std::size_t getNumProperties() const
It returns the number of properties that composes an item of the dataset.