Public Types | Public Member Functions | List of all members
openfluid::landr::VectorDataset Class Reference

Interface for managing Vector Data format. More...

#include <landr/VectorDataset.hpp>

Public Types

typedef std::list< std::pair< OGRFeature *, geos::geom::Geometry * > > FeaturesList_t
 A list of pair of OGRFeature and geos::geom::Geometry related to this VectorDataset entities. More...
 

Public Member Functions

 VectorDataset (const std::string &FileName)
 Creates a new empty OGRDatasource in the openfluid temp directory, with filename suffixes with timestamp. More...
 
 VectorDataset (openfluid::core::GeoVectorValue &Value)
 Creates in the openfluid temp directory a copy of Value OGRDatasource, using Value filename suffixed with timestamp as filename. More...
 
 VectorDataset (const VectorDataset &Other)
 Copy constructor. More...
 
 ~VectorDataset ()
 Delete the OGRDatasource and relative files in openfluid temp directory. More...
 
GDALDataset_COMPATsource ()
 Returns the OGRDataSource associated to this VectorDataset. More...
 
GDALDataset_COMPATsource () const
 Returns the const OGRDataSource associated to this VectorDataset. More...
 
void copyToDisk (const std::string &FilePath, const std::string &FileName, bool ReplaceIfExists)
 Write to disk a copy of the OGRDataSource. More...
 
void addALayer (std::string LayerName="", OGRwkbGeometryType LayerType=wkbUnknown, OGRSpatialReference *SpatialRef=nullptr)
 Add to DataSource an empty new layer. More...
 
OGRLayer * layer (unsigned int LayerIndex=0)
 Get a layer of the shape. More...
 
OGRFeatureDefn * layerDef (unsigned int LayerIndex=0)
 Get the Feature definition of a layer. More...
 
void addAField (const std::string &FieldName, OGRFieldType FieldType=OFTString, unsigned int LayerIndex=0)
 Add a field to a layer. More...
 
bool isLineType (unsigned int LayerIndex=0)
 Returns true if the VectorDataset is line type. More...
 
bool isPolygonType (unsigned int LayerIndex=0)
 Returns true if the VectorDataset is polygon type. More...
 
bool containsField (const std::string &FieldName, unsigned int LayerIndex=0)
 Returns true if a field exists in the LayerIndex layer. More...
 
int getFieldIndex (const std::string &FieldName, unsigned int LayerIndex=0)
 Get the index of a field in the LayerIndex layer. More...
 
bool isFieldOfType (const std::string &FieldName, OGRFieldType FieldType, unsigned int LayerIndex=0)
 Returns true if a field is of the type FieldType in the LayerIndex layer. More...
 
bool isIntValueSet (const std::string &FieldName, int Value, unsigned int LayerIndex=0)
 Returns true if a field has the value Value in the LayerIndex layer. More...
 
FeaturesList_t features (unsigned int LayerIndex=0)
 Gets the list of all features of a layer of this GeoVectorValue. More...
 
geos::geom::Geometry * geometries (unsigned int LayerIndex=0)
 Gets a geos::geom::Geometry representing a collection of all the geometries of the layer LayerIndex of this GeoVectorValue. More...
 
bool isPointType (unsigned int LayerIndex=0)
 Returns true if the VectorDataset is point type. More...
 
void setIndexIntField (const std::string &FieldName, int BeginValue=1, unsigned int LayerIndex=0)
 Sets an integer Field with an index list (increment value one by one) More...
 
OGREnvelope envelope ()
 Returns the OGREnvelope associated to this VectorDataset. More...
 
void snapVertices (double Threshold, unsigned int LayerIndex=0)
 Snap the vertices of this VectorDataset. Only for Polygon or Line Type;. More...
 
std::string checkTopology (double Threshold, unsigned int LayerIndex=0)
 Check the topology of this VectorDataset. Only for Polygon Type. More...
 
std::list< std::pair< OGRFeature *, OGRFeature * > > findOverlap (unsigned int LayerIndex=0)
 Find the overlapping polygons. Only for Polygon Type;. More...
 
std::list< std::pair< OGRFeature *, OGRFeature * > > findGap (double Threshold, unsigned int LayerIndex=0)
 Find gap between polygons. Only for Polygon Type;. More...
 
void cleanOverlap (double Threshold, unsigned int LayerIndex=0)
 Clean the overlapping polygons. Only for Polygon Type;. More...
 
std::list< OGRFeature * > hasDuplicateGeometry (unsigned int LayerIndex=0)
 Identify the duplicate geometry of this VectorDataset. More...
 

Detailed Description

Interface for managing Vector Data format.

Member Typedef Documentation

typedef std::list<std::pair<OGRFeature*, geos::geom::Geometry*> > openfluid::landr::VectorDataset::FeaturesList_t

A list of pair of OGRFeature and geos::geom::Geometry related to this VectorDataset entities.

Constructor & Destructor Documentation

openfluid::landr::VectorDataset::VectorDataset ( const std::string &  FileName)

Creates a new empty OGRDatasource in the openfluid temp directory, with filename suffixes with timestamp.

Parameters
FileNameThe name of the file to create.
Exceptions
openfluid::base::FrameworkExceptionif fails.
openfluid::landr::VectorDataset::VectorDataset ( openfluid::core::GeoVectorValue Value)

Creates in the openfluid temp directory a copy of Value OGRDatasource, using Value filename suffixed with timestamp as filename.

Parameters
ValueThe GeoVectorValue to copy
Exceptions
openfluid::base::FrameworkExceptionif fails.
openfluid::landr::VectorDataset::VectorDataset ( const VectorDataset Other)

Copy constructor.

Exceptions
openfluid::base::FrameworkExceptionif fails.
openfluid::landr::VectorDataset::~VectorDataset ( )

Delete the OGRDatasource and relative files in openfluid temp directory.

Member Function Documentation

void openfluid::landr::VectorDataset::addAField ( const std::string &  FieldName,
OGRFieldType  FieldType = OFTString,
unsigned int  LayerIndex = 0 
)

Add a field to a layer.

Parameters
FieldNameThe name of the field to add.
FieldTypeThe type of the field to add (default OFTString).
LayerIndexThe index of the layer to add the field, default 0.
Exceptions
openfluid::base::FrameworkExceptionif creating field failed.
void openfluid::landr::VectorDataset::addALayer ( std::string  LayerName = "",
OGRwkbGeometryType  LayerType = wkbUnknown,
OGRSpatialReference *  SpatialRef = nullptr 
)

Add to DataSource an empty new layer.

Parameters
LayerNameThe name of the layer to create.
LayerTypeThe type of the layer to create, default wkbUnknown.
SpatialRefThe coordinate system to use for the new layer, or nullptr (default) if no coordinate system is available.
Exceptions
openfluid::base::FrameworkExceptionif the creation of layer failed.
std::string openfluid::landr::VectorDataset::checkTopology ( double  Threshold,
unsigned int  LayerIndex = 0 
)

Check the topology of this VectorDataset. Only for Polygon Type.

Parameters
ThresholdThe maximum distance between polygon to be considered as gap.
LayerIndexThe index of the layer to query, default 0.
Returns
An non-empty string if found errors, otherwise the string is empty.
void openfluid::landr::VectorDataset::cleanOverlap ( double  Threshold,
unsigned int  LayerIndex = 0 
)

Clean the overlapping polygons. Only for Polygon Type;.

Parameters
ThresholdThe snapping threshold value.
LayerIndexThe index of the layer to query, default 0.
bool openfluid::landr::VectorDataset::containsField ( const std::string &  FieldName,
unsigned int  LayerIndex = 0 
)

Returns true if a field exists in the LayerIndex layer.

Parameters
FieldNameThe name of the field to query.
LayerIndexThe index of the layer to query, default 0.
Returns
True if the field FieldName exists, False otherwise.
void openfluid::landr::VectorDataset::copyToDisk ( const std::string &  FilePath,
const std::string &  FileName,
bool  ReplaceIfExists 
)

Write to disk a copy of the OGRDataSource.

Parameters
FilePathThe path to the directory where writing, will be created if needed.
FileNameThe name of the file to write.
ReplaceIfExistsIf true and the file FilePath/FileName already exists, overwrite it.
OGREnvelope openfluid::landr::VectorDataset::envelope ( )

Returns the OGREnvelope associated to this VectorDataset.

FeaturesList_t openfluid::landr::VectorDataset::features ( unsigned int  LayerIndex = 0)

Gets the list of all features of a layer of this GeoVectorValue.

Parameters
LayerIndexThe index of the layer to query, default 0.
Returns
A list of OGRFeature and geos::geom::Geometry of this VectorDataset.
std::list<std::pair<OGRFeature*, OGRFeature*> > openfluid::landr::VectorDataset::findGap ( double  Threshold,
unsigned int  LayerIndex = 0 
)

Find gap between polygons. Only for Polygon Type;.

Parameters
ThresholdThe maximum distance between polygon to be considered as gap.
LayerIndexThe index of the layer to query, default 0.
Returns
A list of pair of OGRFeature* for each overlap between two polygons.
std::list<std::pair<OGRFeature*, OGRFeature*> > openfluid::landr::VectorDataset::findOverlap ( unsigned int  LayerIndex = 0)

Find the overlapping polygons. Only for Polygon Type;.

Parameters
LayerIndexThe index of the layer to query, default 0.
Returns
A list of pair of OGRFeature* for each overlap between two polygons.
geos::geom::Geometry* openfluid::landr::VectorDataset::geometries ( unsigned int  LayerIndex = 0)

Gets a geos::geom::Geometry representing a collection of all the geometries of the layer LayerIndex of this GeoVectorValue.

Parameters
LayerIndexThe index of the layer to query, default 0.
Returns
A geos::geom::Geometry.
int openfluid::landr::VectorDataset::getFieldIndex ( const std::string &  FieldName,
unsigned int  LayerIndex = 0 
)

Get the index of a field in the LayerIndex layer.

Parameters
LayerIndexThe index of the layer to query, default 0.
FieldNameThe name of the field to query.
Returns
The index of FieldName or -1 if field FieldName doesn't exist.
std::list<OGRFeature*> openfluid::landr::VectorDataset::hasDuplicateGeometry ( unsigned int  LayerIndex = 0)

Identify the duplicate geometry of this VectorDataset.

Parameters
LayerIndexThe index of the layer to query, default 0.
Returns
A list of OGRFeature* which are duplicate.
bool openfluid::landr::VectorDataset::isFieldOfType ( const std::string &  FieldName,
OGRFieldType  FieldType,
unsigned int  LayerIndex = 0 
)

Returns true if a field is of the type FieldType in the LayerIndex layer.

Parameters
FieldNameThe name of the field to query.
FieldTypeThe type of the field to query.
LayerIndexThe index of the layer to query, default 0.
Returns
True if the field FieldName is type FieldType.
Exceptions
openfluid::base::FrameworkExceptionif the field doesn't exist.
bool openfluid::landr::VectorDataset::isIntValueSet ( const std::string &  FieldName,
int  Value,
unsigned int  LayerIndex = 0 
)

Returns true if a field has the value Value in the LayerIndex layer.

Parameters
FieldNameThe name of the field to query.
ValueThe value to query.
LayerIndexThe index of the layer to query, default 0.
Returns
True if the field has at least a feature containing the value Value, False otherwise.
bool openfluid::landr::VectorDataset::isLineType ( unsigned int  LayerIndex = 0)

Returns true if the VectorDataset is line type.

Parameters
LayerIndexThe index of the layer to compare the type, default 0.
Returns
True if the type of the layer LayerIndex is wkbLineString, false otherwise.
bool openfluid::landr::VectorDataset::isPointType ( unsigned int  LayerIndex = 0)

Returns true if the VectorDataset is point type.

Parameters
LayerIndexThe index of the layer to compare the type, default 0.
Returns
True if the type of the layer LayerIndex is wkbPoint, false otherwise.
bool openfluid::landr::VectorDataset::isPolygonType ( unsigned int  LayerIndex = 0)

Returns true if the VectorDataset is polygon type.

Parameters
LayerIndexThe index of the layer to compare the type, default 0.
Returns
True if the type of the layer LayerIndex is wkbPolygon, false otherwise.
OGRLayer* openfluid::landr::VectorDataset::layer ( unsigned int  LayerIndex = 0)

Get a layer of the shape.

Parameters
LayerIndexThe index of the asked layer, default 0.
Returns
The layer indexed LayerIndex.
OGRFeatureDefn* openfluid::landr::VectorDataset::layerDef ( unsigned int  LayerIndex = 0)

Get the Feature definition of a layer.

Parameters
LayerIndexThe index of the asked layer definition, default 0.
Returns
The OGR Feature definition of the LayerIndex layer.
void openfluid::landr::VectorDataset::setIndexIntField ( const std::string &  FieldName,
int  BeginValue = 1,
unsigned int  LayerIndex = 0 
)

Sets an integer Field with an index list (increment value one by one)

Parameters
FieldNameThe name of the field to query (must exist).
BeginValueThe begin value, default 1.
LayerIndexThe index of the layer to query, default 0.
void openfluid::landr::VectorDataset::snapVertices ( double  Threshold,
unsigned int  LayerIndex = 0 
)

Snap the vertices of this VectorDataset. Only for Polygon or Line Type;.

Parameters
ThresholdThe snapping threshold value.
LayerIndexThe index of the layer to query, default 0.
GDALDataset_COMPAT* openfluid::landr::VectorDataset::source ( )

Returns the OGRDataSource associated to this VectorDataset.

GDALDataset_COMPAT* openfluid::landr::VectorDataset::source ( ) const

Returns the const OGRDataSource associated to this VectorDataset.


The documentation for this class was generated from the following file: