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/Utils.h"
36 #include "../geometry/Envelope.h"
37 #include "../geometry/Geometry.h"
38 #include "../geometry/Utils.h"
78 for(std::size_t i = 0; i != properties.size(); ++i)
84 copy(rhs, properties, limit);
98 std::vector<std::size_t> properties;
102 for(std::size_t i = 0; i != np; ++i)
103 properties.push_back(i);
105 copy(src, properties, limit);
110 bool unlimited =
true;
114 limit = std::numeric_limits<std::size_t>::max();
118 m_items->reserve(m_items->size() + limit);
124 const std::size_t nproperties = properties.size();
126 while(src.
moveNext() && (i < limit))
128 std::auto_ptr<DataSetItem> item(
new DataSetItem(
this));
130 for(std::size_t c = 0; c < nproperties; ++c)
132 if(!src.
isNull(properties[c]))
133 item->setValue(c, src.
getValue(properties[c]).release());
135 item->setValue(c, 0);
138 m_items->push_back(item.release());
145 if(!unlimited & (i < limit))
146 throw Exception(
TR_MEMORY(
"The source dataset has few items than requested copy limit!"));
151 m_items->push_back(item);
156 m_items->erase(m_items->begin() + m_i);
161 const std::size_t nitems = m_items->size();
163 for(std::size_t i = 0; i < nitems; ++i)
165 if(&(m_items->operator[](i)) == item)
167 m_items->erase(m_items->begin() + i);
172 throw Exception(
TR_DATAACCESS(
"Item not found in the dataset!"));
177 m_pnames.push_back(propertyName);
178 m_ptypes.push_back(propertyType);
180 const std::size_t nitems = m_items->size();
182 for(std::size_t i = 0; i < nitems; ++i)
183 m_items->operator[](i).m_data.push_back(defaultValue ? defaultValue->
clone() : 0);
188 const std::size_t nitems = m_items->size();
190 for(std::size_t i = 0; i < nitems; ++i)
191 m_items->operator[](i).m_data.erase( m_items->operator[](i).m_data.begin() + pos);
193 m_pnames.erase(m_pnames.begin() + pos);
194 m_ptypes.erase(m_ptypes.begin() + pos);
205 throw Exception(
"No implemented yet!");
222 const std::size_t nitems = m_items->size();
224 for(std::size_t ii = 0; ii < nitems; ++ii)
226 std::auto_ptr<te::gm::Geometry> geom((*m_items)[ii].getGeometry(i));
228 mbr->Union(*(geom->getMBR()));
236 return m_pnames.size();
241 return m_ptypes[pos];
251 return m_pnames[pos];
256 m_pnames[pos] = name;
261 throw Exception(
"No implemented yet!");
266 return (*m_items)[m_i].
clone().get();
271 return m_items->empty();
281 return m_items->size();
287 return m_i < static_cast<int>(m_items->size());
310 m_i = m_items->size() - 1;
311 return m_i < static_cast<int>(m_items->size());
317 return m_i < static_cast<int>(m_items->size());
332 return m_i == (
static_cast<int>(m_items->size()) - 1);
337 return m_i >
static_cast<int>(m_items->size());
342 return (*m_items)[m_i].getChar(i);
347 (*m_items)[m_i].setChar(i, value);
352 (*m_items)[m_i].setChar(name, value);
357 return (*m_items)[m_i].getUChar(i);
362 (*m_items)[m_i].setUChar(i, value);
367 (*m_items)[m_i].setUChar(name, value);
372 return (*m_items)[m_i].getInt16(i);
377 (*m_items)[m_i].setInt16(i, value);
382 (*m_items)[m_i].setInt16(name, value);
387 return (*m_items)[m_i].getInt32(i);
392 (*m_items)[m_i].setInt32(i, value);
397 (*m_items)[m_i].setInt32(name, value);
402 return (*m_items)[m_i].getInt64(i);
407 (*m_items)[m_i].setInt64(i, value);
412 (*m_items)[m_i].setInt64(name, value);
417 return (*m_items)[m_i].getBool(i);
422 (*m_items)[m_i].setBool(i, value);
427 (*m_items)[m_i].setBool(name, value);
432 return (*m_items)[m_i].getFloat(i);
437 (*m_items)[m_i].setFloat(i, value);
442 (*m_items)[m_i].setFloat(name, value);
447 return (*m_items)[m_i].getDouble(i);
452 (*m_items)[m_i].setDouble(i, value);
457 (*m_items)[m_i].setDouble(name, value);
462 return (*m_items)[m_i].getNumeric(i);
467 (*m_items)[m_i].setNumeric(i, value);
472 (*m_items)[m_i].setNumeric(name, value);
477 return (*m_items)[m_i].getString(i);
482 (*m_items)[m_i].setString(i, value);
487 (*m_items)[m_i].setString(name, value);
492 return (*m_items)[m_i].getByteArray(i);
497 (*m_items)[m_i].setByteArray(i, value);
502 (*m_items)[m_i].setByteArray(name, value);
507 return (*m_items)[m_i].getGeometry(i);
512 (*m_items)[m_i].setGeometry(i, value);
517 (*m_items)[m_i].setGeometry(name, value);
522 return (*m_items)[m_i].getRaster(i);
527 (*m_items)[m_i].setRaster(i, value);
532 (*m_items)[m_i].setRaster(name, value);
537 return std::auto_ptr<te::dt::DateTime>((*m_items)[m_i].getDateTime(i));
542 (*m_items)[m_i].setDateTime(i, value);
547 (*m_items)[m_i].setDateTime(name, value);
552 return std::auto_ptr<te::dt::Array>(0);
557 return (*m_items)[m_i].getValue(i);
562 (*m_items)[m_i].setValue(i, value);
567 (*m_items)[m_i].setValue(name, ad);
572 return (*m_items)[m_i].isNull(i);
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
std::auto_ptr< te::dt::DateTime > getDateTime(std::size_t i) const
Method for retrieving a date and time attribute value.
virtual AbstractData * clone() const =0
It returns a clone of this object.
bool isNull(std::size_t i) const
It checks if the attribute value is NULL.
int getPropertyDataType(std::size_t pos) const
It returns the underlying data type of the property at position pos.
std::size_t size() const
It returns the collection size, if it is known.
void drop(std::size_t pos)
It drops a property from the dataset.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
#define TR_MEMORY(message)
std::vector< int > m_ptypes
The list of property types.
void setUChar(std::size_t i, unsigned char value)
std::string getDatasetNameOfProperty(std::size_t pos) const
It returns the underlying dataset name of the property at position pos.
void update(te::dt::Property *prop)
It update a property from the dataset.
void add(DataSetItem *item)
It adds a new item to the dataset and takes its ownership.
std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const
Method for retrieving a geometric attribute value.
DataSet()
Default constructor.
std::string getString(std::size_t i) const
Method for retrieving a string value attribute.
std::auto_ptr< DataSetItem > clone() const
It returns a clone of the DataSetItem.
boost::int32_t getInt32(std::size_t i) const
Method for retrieving a 32-bit integer attribute value (4 bytes long).
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
te::common::AccessPolicy getAccessPolicy() const
It returns the read and write permission associated to the dataset.
An exception class for the TerraLib In-Memory Data Access driver.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
bool isAtEnd() const
It tells if the dataset internal pointer is on the last element of the collection.
std::string getNumeric(std::size_t i) const
Method for retrieving a numeric attribute value.
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
void setRaster(std::size_t i, te::rst::Raster *value)
bool isConnected() const
It returns true if the dataset is connected and false if it is disconnected. A dataset can be connect...
void setInt32(std::size_t i, boost::int32_t value)
bool moveFirst()
It moves the internal pointer to the first item in the collection.
TEDATAACCESSEXPORT void GetPropertyInfo(const DataSetType *const dt, std::vector< std::string > &pnames, std::vector< int > &ptypes)
boost::int16_t getInt16(std::size_t i) const
Method for retrieving a 16-bit integer attribute value (2 bytes long).
AccessPolicy
Supported data access policies (can be used as bitfield).
double getDouble(std::size_t i) const
Method for retrieving a double attribute value.
void copy(te::da::DataSet &src, std::size_t limit=0)
It copies up to limit items from the source dataset.
void setInt16(std::size_t i, boost::int16_t value)
void setGeometry(std::size_t i, te::gm::Geometry *value)
bool moveLast()
It sets the dataset internal pointer to the last item in the collection.
std::auto_ptr< te::dt::ByteArray > getByteArray(std::size_t i) const
Method for retrieving a byte array.
std::vector< std::string > m_pnames
The list of property names.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
bool isAfterEnd() const
It tells if the dataset internal pointer is on the sentinel position after the last element of the co...
void setInt64(std::size_t i, boost::int64_t value)
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 setDateTime(std::size_t i, te::dt::DateTime *value)
bool movePrevious()
It moves the internal pointer to the previous item of the collection.
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
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.
void setValue(std::size_t i, te::dt::AbstractData *value)
boost::int64_t getInt64(std::size_t i) const
Method for retrieving a 64-bit integer attribute value (8 bytes long).
bool isBeforeBegin() const
It tells if the dataset internal pointer is in a position before the first element of the collection ...
std::size_t getNumProperties() const
It returns the number of properties that composes an item of the dataset.
boost::shared_ptr< boost::ptr_vector< DataSetItem > > m_items
The list of dataset items.
TraverseType
A dataset can be traversed in two ways:
void clear()
It clears all the dataset items.
#define TR_DATAACCESS(message)
It marks a string in order to get translated. This is a special mark used in the DataAccess module of...
DataSetItem * getItem() const
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...
A class that models the description of a dataset.
te::common::TraverseType getTraverseType() const
It returns the traverse type associated to the dataset.
bool moveNext()
It moves the internal pointer to the next item of the collection.
It models a property definition.
float getFloat(std::size_t i) const
Method for retrieving a float attribute value.
bool moveBeforeFirst()
It moves the internal pointer to a position before the first item in the collection.
An abstract class for raster data strucutures.
std::auto_ptr< te::gm::Envelope > getExtent(std::size_t i)
It computes the bounding rectangle for a spatial property of the dataset.
bool isEmpty() const
It returns true if the collection is empty.
void setBool(std::size_t i, bool value)
void setNumeric(std::size_t i, const std::string &value)
bool getBool(std::size_t i) const
Method for retrieving a boolean attribute value.
void setByteArray(std::size_t i, te::dt::ByteArray *value)
An Envelope defines a 2D rectangular region.
A class for representing binary data.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
void setChar(std::size_t i, char value)
void setString(std::size_t i, const std::string &value)
void setPropertyDataType(int dt, std::size_t pos)
char getChar(std::size_t i) const
Method for retrieving a signed character attribute value (1 byte long).
void setPropertyName(const std::string &name, std::size_t pos)
bool move(std::size_t i)
It moves the dataset internal pointer to a given position.
A dataset is the unit of information manipulated by the data access module of TerraLib.
std::auto_ptr< te::rst::Raster > getRaster(std::size_t i) const
Method for retrieving a raster attribute value.
bool isAtBegin() const
It tells if the dataset internal pointer is on the first element of the collection or not...
unsigned char getUChar(std::size_t i) const
Method for retrieving an unsigned character attribute value (1 byte long).
void setDouble(std::size_t i, double value)
void remove()
It removes the current dataset item.
void setFloat(std::size_t i, float value)
std::string getPropertyName(std::size_t pos) const
It returns the property name at position pos.
std::auto_ptr< te::dt::Array > getArray(std::size_t i) const
Method for retrieving an array.