sgsPy
structurally guided sampling
Loading...
Searching...
No Matches
sgs::vector::GDALVectorWrapper

#include <vector.h>

Public Member Functions

 GDALVectorWrapper (std::string filename, std::string projDBPath)
 GDALVectorWrapper (GDALDataset *p_dataset, std::string projection)
 GDALVectorWrapper (std::string bytes, std::string projection, std::string name, std::string projDBPath)
GDALDataset * getDataset ()
std::vector< std::string > getLayerNames ()
std::unordered_map< std::string, std::string > getLayerInfo (std::string layerName)
OGRLayer * getLayer (std::string layerName)
std::vector< std::vector< double > > getPoints (std::string layerName)
std::vector< std::string > getPointsAsWkt (std::string layerName)
std::vector< std::vector< std::vector< double > > > getLineStrings (std::string layerName)
void write (std::string filename)
std::string getFullProjectionInfo ()
OGRSpatialReference * getSRS (void)

Detailed Description

Wrapper class for GDAL dataset containing a vector image.

This class provides getter methods for important vector data and metadata, as well as access to individual layers as OGRLayer * pointers.

The Python side of the application only has access to metadata on each layer.

The C++ side of the application has access to the getLayer() function.

Constructor & Destructor Documentation

◆ GDALVectorWrapper() [1/3]

sgs::vector::GDALVectorWrapper::GDALVectorWrapper ( std::string filename,
std::string projDBPath )
inline

Constructor for GDALVectorWrapper class. this method registers drivers, and creates a GDALDataset object. Set the search path for the proj.db file, because this function may be the first called from the Python side of the application, meaning this instance of GDAL may not have found a proj.db file

Parameters
std::stringfilename
std::stringprojDBPath

◆ GDALVectorWrapper() [2/3]

sgs::vector::GDALVectorWrapper::GDALVectorWrapper ( GDALDataset * p_dataset,
std::string projection )
inline

Constructor for GDALVectorWrapper class.

Parameters
GDALDataset*
std::stringprojection

◆ GDALVectorWrapper() [3/3]

sgs::vector::GDALVectorWrapper::GDALVectorWrapper ( std::string bytes,
std::string projection,
std::string name,
std::string projDBPath )
inline

Constructor for GDALVectorWrapper class. This constructor is meant to be used when importing data from another Python geospatial library, like geopandas. The geodataset is converted to a geojson string and passed to the GDALOpenEx() function to create a GDALDataset. This dataset unfortunately won't have the correcct layer name, and may have an incorrect spatial reference system. Because of this, a GDALDataset is created with a new OGRLayer containing the correct layer name and spatial reference system. The geometries with their fields are then copied from the geojson-created dataset to the new initialized dataset. Set the search path for the proj.db file, because this function may be the first called from the Python side of the application, meaning this instance of GDAL may not have found a proj.db file yet.

Parameters
std::vector<std::string>geometries
std::stringprojection
std::stringname
std::stringprojDBPath

Member Function Documentation

◆ getDataset()

GDALDataset * sgs::vector::GDALVectorWrapper::getDataset ( )
inline

Getter method for the dataset pointer.

Returns
GDALDataset *

◆ getFullProjectionInfo()

std::string sgs::vector::GDALVectorWrapper::getFullProjectionInfo ( )
inline

Getter method for the full projection information as wkt.

Returns
std::string

◆ getLayer()

OGRLayer * sgs::vector::GDALVectorWrapper::getLayer ( std::string layerName)
inline

Getter method for a particular layer.

Parameters
std::stringlayerName
Returns
OGRLayer *

◆ getLayerInfo()

std::unordered_map< std::string, std::string > sgs::vector::GDALVectorWrapper::getLayerInfo ( std::string layerName)
inline

Getter method for layer parameters. Including: feature count field count geometry type xmin xmax ymin ymax

Parameters
std::stringlayer name
Returns
std::unordered_map<std::string, std::string>

◆ getLayerNames()

std::vector< std::string > sgs::vector::GDALVectorWrapper::getLayerNames ( )
inline

Getter method for vector layer names.

Returns
std::vector<std::string>

◆ getLineStrings()

std::vector< std::vector< std::vector< double > > > sgs::vector::GDALVectorWrapper::getLineStrings ( std::string layerName)
inline

Getter method for the layer Geometries. Note that every geometry within the layer must be of type LineString or MultiLineString.

The LineStrings are stored and returned as a 3d array of doubles. (std::vector<std::vector<std::vector<double>>>) Indexing the outer array gives the Line, which is a 2d array of points. The X coordinates are stored in index 0, Y in 1.

The array should be indexed like so: arr[line_index][0 if x or 1 if y][point_index]

For example, to get the x and y coordinates of the 2nd point in the 5th line: x = arr[4][0][1]; y = arr[4][1][1];

Parameters
std::stringlayerName
Returns
std::vector<std::vector<std::vector<double>>>

◆ getPoints()

std::vector< std::vector< double > > sgs::vector::GDALVectorWrapper::getPoints ( std::string layerName)
inline

Getter method for the layer Geometries. Note that every geometry within the layer must be of type Point or MultiPoint.

The points are stored and returned as a 2d array of doubles (std::vector<std::vector<double>>) The X coordinates are stored in index 0, Y in 1.

The array should be indexed like so: arr[0 if x or 1 if y][point_index]

For example, to get the x and y coordinates of the 3rd point: x = arr[0][2]; y = arr[1][2]

Parameters
std::stringlayerName
Returns
std::vector<std::vector<double>>

◆ getPointsAsWkt()

std::vector< std::string > sgs::vector::GDALVectorWrapper::getPointsAsWkt ( std::string layerName)
inline

Getter method for the layer geometries, where every geometry must be of type Point or MultiPoint.

the points are stored as wkt (well known text) strings in the return vector.

Parameters
std::stringlayerName
Returns
std::vector<std::string>

◆ getSRS()

OGRSpatialReference * sgs::vector::GDALVectorWrapper::getSRS ( void )
inline

Getter method for OGRSpatialReference.

Returns
OGRSpatialReference *

◆ write()

void sgs::vector::GDALVectorWrapper::write ( std::string filename)
inline

method for writing the existing dataset to a file.

This is intended to be used to write in-memory datasets generated by sampling methods to disk, however it should work for any dataset.

Parameters
std::stringfilename

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