27 #include "../core/translator/Translator.h" 28 #include "../dataaccess/dataset/DataSetType.h" 29 #include "../datatype/ByteArray.h" 30 #include "../datatype/DateTimeProperty.h" 31 #include "../datatype/StringProperty.h" 32 #include "../datatype/TimeInstant.h" 33 #include "../geometry/Envelope.h" 34 #include "../geometry/Geometry.h" 35 #include "../geometry/WKBReader.h" 36 #include "../srs/Config.h" 43 #include <ogrsf_frmts.h> 45 #include <gdal_priv.h> 58 m_currentFeature(nullptr),
66 layer->ResetReading();
74 OGRSpatialReference* osrs =
m_layer->GetSpatialRef();
116 return !(
size() > 0);
121 OGREnvelope psExtent;
122 OGRErr error =
m_layer->GetExtent(&psExtent);
124 if(error != OGRERR_NONE)
131 return std::unique_ptr<te::gm::Envelope>(env);
136 return static_cast<std::size_t
>(
m_layer->GetFeatureCount());
151 return move(static_cast<size_t>(
m_i - 1));
170 size_t lastPos =
static_cast<size_t>(
m_layer->GetFeatureCount() - 1);
171 return move(lastPos);
176 if(static_cast<size_t>(
m_i) == i)
179 int p =
static_cast<int>(i);
181 OGRErr error =
m_layer->SetNextByIndex(p);
184 if(error == OGRERR_NONE)
202 return m_i ==
static_cast<int>(
size()-1);
207 return m_i >
static_cast<int>(
size());
212 return m_i > -1 && m_i < static_cast<int>(
size());
268 GByte* bytes =
m_currentFeature->GetFieldAsBinary(static_cast<int>(i), &size);
271 byteArray->
copy(reinterpret_cast<char*>(bytes), static_cast<size_t>(size));
273 return std::unique_ptr<te::dt::ByteArray>(byteArray);
278 char* wkb = (
char*)
getWKB();
288 return std::unique_ptr<te::gm::Geometry>(geom);
299 return std::unique_ptr<te::dt::DateTime>(
nullptr);
309 if(
m_currentFeature->GetFieldAsDateTime(static_cast<int>(i), &pnYear, &pnMonth, &pnDay, &pnHour, &pnMinute, &pnSecond, &pnTZFlag) == FALSE)
310 return std::unique_ptr<te::dt::DateTime>(
new te::dt::Date);
318 dateTime =
new te::dt::Date(static_cast<unsigned short>(pnYear), static_cast<unsigned short>(pnMonth), static_cast<unsigned short>(pnDay));
326 te::dt::Date d(static_cast<unsigned short>(pnYear), static_cast<unsigned short>(pnMonth), static_cast<unsigned short>(pnDay));
331 return std::unique_ptr<te::dt::DateTime>(dateTime);
336 return std::unique_ptr<te::dt::Array>();
348 if (geom ==
nullptr || geom->IsEmpty())
350 OGRGeometryFactory::destroyGeometry(geom);
371 if (geom->getGeometryType() == wkbPolygon ||
372 geom->getGeometryType() == wkbPolygonM ||
373 geom->getGeometryType() == wkbPolygonZM ||
374 geom->getGeometryType() == wkbPolygon25D)
376 geom = OGRGeometryFactory::forceToMultiPolygon(geom);
378 else if (geom->getGeometryType() == wkbLineString ||
379 geom->getGeometryType() == wkbLineStringM ||
380 geom->getGeometryType() == wkbLineStringZM ||
381 geom->getGeometryType() == wkbLineString25D)
383 geom = OGRGeometryFactory::forceToMultiLineString(geom);
385 else if (geom->getGeometryType() == wkbPoint ||
386 geom->getGeometryType() == wkbPointM ||
387 geom->getGeometryType() == wkbPointZM ||
388 geom->getGeometryType() == wkbPoint25D)
390 geom = OGRGeometryFactory::forceToMultiPoint(geom);
393 int wkbSize = geom->WkbSize();
402 geom->exportToWkb(wkbNDR,
m_wkbArray, wkbVariantIso);
404 OGRGeometryFactory::destroyGeometry(geom);
406 return static_cast<const unsigned char*
>(
m_wkbArray);
static te::dt::TimeDuration td(20, 30, 50, 11)
Property * getProperty(std::size_t i) const
It returns the i-th property.
bool isEmpty() const
It returns true if the collection is empty.
std::size_t getNumProperties() const
It returns the number of properties that composes an item of the dataset.
te::da::DataSetType * m_dt
DataSetType.
std::string getDatasetNameOfProperty(std::size_t pos) const
It returns the underlying dataset name of the property at position pos.
std::unique_ptr< te::dt::ByteArray > getByteArray(std::size_t i) const
Method for retrieving a byte array.
float getFloat(std::size_t i) const
Method for retrieving a float attribute value.
std::string getPropertyName(std::size_t pos) const
It returns the property name at position pos.
std::unique_ptr< te::rst::Raster > getRaster(std::size_t i) const
Method for retrieving a raster attribute value.
bool isBeforeBegin() const
It tells if the dataset internal pointer is in a position before the first element of the collection ...
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
bool hasGeom() const
It returns true if the DataSetType has at least one geometry property; otherwise, it returns false...
Base exception class for plugin module.
DataSet()
Default constructor.
Utility functions for OGR support.
int m_srid
The SRS id associated to this dataset.
unsigned char getUChar(std::size_t i) const
Method for retrieving an unsigned character attribute value (1 byte long).
#define TE_TR(message)
It marks a string in order to get translated.
boost::int64_t getInt64(std::size_t i) const
Method for retrieving a 64-bit integer attribute value (8 bytes long).
bool isAfterEnd() const
It tells if the dataset internal pointer is on the sentinel position after the last element of the co...
It models a property definition.
A class to represent time instant.
bool isAtEnd() const
It tells if the dataset internal pointer is on the last element of the collection.
std::unique_ptr< te::dt::DateTime > getDateTime(std::size_t i) const
Method for retrieving a date and time attribute value.
bool getBool(std::size_t i) const
Method for retrieving a boolean attribute value.
bool isPositionValid() const
It tells if the dataset internal pointer is on a valid position.
unsigned char * m_wkbArray
An Envelope defines a 2D rectangular region.
double getDouble(std::size_t i) const
Method for retrieving a double attribute value.
A base class for date data types.
bool move(std::size_t i)
It moves the dataset internal pointer to a given position.
std::string getNumeric(std::size_t i) const
Method for retrieving a numeric attribute value.
OGRFeature * m_currentFeature
TEOGREXPORT te::gm::Geometry * Convert2TerraLib(OGRGeometry *ogrGeom)
It converts the OGR Geometry to TerraLib Geometry.
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
std::unique_ptr< te::gm::Envelope > getExtent(std::size_t i)
It computes the bounding rectangle for a spatial property of the dataset.
boost::int16_t getInt16(std::size_t i) const
Method for retrieving a 16-bit integer attribute value (2 bytes long).
std::size_t size() const
It returns the number of properties of the CompositeProperty.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
bool moveNext()
It moves the internal pointer to the next item of the collection.
std::unique_ptr< te::dt::Array > getArray(std::size_t i) const
Method for retrieving an array.
boost::int32_t getInt32(std::size_t i) const
Method for retrieving a 32-bit integer attribute value (4 bytes long).
int getType() const
It returns the property data type.
bool isNull(std::size_t i) const
It checks if the attribute value is NULL.
const unsigned char * getWKB() const
std::string getString(std::size_t i) const
Method for retrieving a string value attribute.
A class to represent time duration with nano-second/micro-second resolution.
A class for data providers of OGR.
The type for date and time types: date, date period, date duration, time duration, time instant, time period, time instant with time zone or time period with time zone.
virtual void setSRID(int srid) _NOEXCEPT_OP(true)=0
It sets the Spatial Reference System ID of the geometry and all its parts if it is a GeometryCollecti...
Implementation of a DataSet for OGR data provider.
bool moveBeforeFirst()
It moves the internal pointer to a position before the first item in the collection.
char getChar(std::size_t i) const
Method for retrieving a signed character attribute value (1 byte long).
DateTimeType
The subtype of date and time type, based on ISO 8621.
int getPropertyDataType(std::size_t pos) const
It returns the underlying data type of the property at position pos.
bool isAtBegin() const
It tells if the dataset internal pointer is on the first element of the collection or not...
An exception class for the OGR module.
std::size_t size() const
It returns the collection size, if it is known.
void copy(char *data, std::size_t size)
It copies the data from the given pointer to the byte array.
bool movePrevious()
It moves the internal pointer to the previous item of the collection.
bool moveLast()
It sets the dataset internal pointer to the last item in the collection.
std::unique_ptr< te::gm::Geometry > getGeometry(std::size_t i) const
Method for retrieving a geometric attribute value.
TEOGREXPORT int Convert2TerraLibProjection(OGRSpatialReference *osrs)
It converts the OGR Projection to TerraLib Projection.
A class for representing binary data.
static Geometry * read(const char *wkb)
It returns a valid geometry from a given WKB.
bool moveFirst()
It moves the internal pointer to the first item in the collection.
const std::string & getName() const
It returns the property name.