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)
103 copy(rhs, properties, limit);
117 std::vector<std::size_t> properties;
121 for(std::size_t i = 0; i != np; ++i)
122 properties.push_back(i);
124 copy(src, properties, limit);
129 bool unlimited =
true;
133 limit = std::numeric_limits<std::size_t>::max();
137 m_items->reserve(m_items->size() + limit);
143 const std::size_t nproperties = properties.size();
145 while(src.
moveNext() && (i < limit))
147 std::auto_ptr<DataSetItem> item(
new DataSetItem(
this));
149 for(std::size_t c = 0; c < nproperties; ++c)
151 if(!src.
isNull(properties[c]))
152 item->setValue(c, src.
getValue(properties[c]).release());
154 item->setValue(c, 0);
157 m_items->push_back(item.release());
164 if(!unlimited & (i < limit))
165 throw Exception(
TE_TR(
"The source dataset has few items than requested copy limit!"));
170 m_items->push_back(item);
175 m_items->erase(m_items->begin() + m_i);
180 const std::size_t nitems = m_items->size();
182 for(std::size_t i = 0; i < nitems; ++i)
184 if(&(m_items->operator[](i)) == item)
186 m_items->erase(m_items->begin() + i);
191 throw Exception(
TE_TR(
"Item not found in the dataset!"));
196 m_pnames.push_back(propertyName);
197 m_ptypes.push_back(propertyType);
199 const std::size_t nitems = m_items->size();
201 for(std::size_t i = 0; i < nitems; ++i)
202 m_items->operator[](i).m_data.push_back(defaultValue ? defaultValue->
clone() : 0);
207 const std::size_t nitems = m_items->size();
209 for(std::size_t i = 0; i < nitems; ++i)
210 m_items->operator[](i).m_data.erase( m_items->operator[](i).m_data.begin() + pos);
212 m_pnames.erase(m_pnames.begin() + pos);
213 m_ptypes.erase(m_ptypes.begin() + pos);
224 throw Exception(
"No implemented yet!");
241 const std::size_t nitems = m_items->size();
243 for(std::size_t ii = 0; ii < nitems; ++ii)
245 std::auto_ptr<te::gm::Geometry> geom((*m_items)[ii].getGeometry(i));
247 mbr->Union(*(geom->getMBR()));
255 return m_pnames.size();
260 return m_ptypes[pos];
270 return m_pnames[pos];
275 m_pnames[pos] = name;
281 std::map<int, te::common::CharEncoding>::const_iterator it = m_encodings.find(i);
282 assert(it != m_encodings.end());
289 throw Exception(
"No implemented yet!");
294 return (*m_items)[m_i].
clone().get();
299 return m_items->empty();
309 return m_items->size();
315 return m_i < static_cast<int>(m_items->size());
338 m_i = m_items->size() - 1;
339 return m_i < static_cast<int>(m_items->size());
345 return m_i < static_cast<int>(m_items->size());
360 return m_i == (
static_cast<int>(m_items->size()) - 1);
365 return m_i >
static_cast<int>(m_items->size());
370 return (*m_items)[m_i].getChar(i);
375 (*m_items)[m_i].setChar(i, value);
380 (*m_items)[m_i].setChar(name, value);
385 return (*m_items)[m_i].getUChar(i);
390 (*m_items)[m_i].setUChar(i, value);
395 (*m_items)[m_i].setUChar(name, value);
400 return (*m_items)[m_i].getInt16(i);
405 (*m_items)[m_i].setInt16(i, value);
410 (*m_items)[m_i].setInt16(name, value);
415 return (*m_items)[m_i].getInt32(i);
420 (*m_items)[m_i].setInt32(i, value);
425 (*m_items)[m_i].setInt32(name, value);
430 return (*m_items)[m_i].getInt64(i);
435 (*m_items)[m_i].setInt64(i, value);
440 (*m_items)[m_i].setInt64(name, value);
445 return (*m_items)[m_i].getBool(i);
450 (*m_items)[m_i].setBool(i, value);
455 (*m_items)[m_i].setBool(name, value);
460 return (*m_items)[m_i].getFloat(i);
465 (*m_items)[m_i].setFloat(i, value);
470 (*m_items)[m_i].setFloat(name, value);
475 return (*m_items)[m_i].getDouble(i);
480 (*m_items)[m_i].setDouble(i, value);
485 (*m_items)[m_i].setDouble(name, value);
490 return (*m_items)[m_i].getNumeric(i);
495 (*m_items)[m_i].setNumeric(i, value);
500 (*m_items)[m_i].setNumeric(name, value);
505 return (*m_items)[m_i].getString(i);
510 (*m_items)[m_i].setString(i, value);
515 (*m_items)[m_i].setString(name, value);
520 return (*m_items)[m_i].getByteArray(i);
525 (*m_items)[m_i].setByteArray(i, value);
530 (*m_items)[m_i].setByteArray(name, value);
535 return (*m_items)[m_i].getGeometry(i);
540 (*m_items)[m_i].setGeometry(i, value);
545 (*m_items)[m_i].setGeometry(name, value);
550 return (*m_items)[m_i].getRaster(i);
555 (*m_items)[m_i].setRaster(i, value);
560 (*m_items)[m_i].setRaster(name, value);
565 return std::auto_ptr<te::dt::DateTime>((*m_items)[m_i].getDateTime(i));
570 (*m_items)[m_i].setDateTime(i, value);
575 (*m_items)[m_i].setDateTime(name, value);
580 return std::auto_ptr<te::dt::Array>(0);
585 return (*m_items)[m_i].getValue(i);
590 (*m_items)[m_i].setValue(i, value);
595 (*m_items)[m_i].setValue(name, ad);
600 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.