GeometryFile Class Reference

A class that can parses a file with wkb encoded geometries. More...

#include <GeometryFile.h>

Public Member Functions

te::gm::Geometrynext ()
 Returns the next geometry. More...
 
void openFile (const char *fileName) throw (te::common::Exception)
 Opens the file fileName. More...
 
void setGeometries (const std::vector< unsigned int > &gids)
 Sets the desired geometries to get from file. More...
 
Initializer methods.

Methods for initializing and destructing object.

 GeometryFile ()
 Constructor. More...
 
 ~GeometryFile ()
 Destructor. More...
 

Static Public Member Functions

static void writeGeometries (const char *fileName, const std::map< int, te::gm::Geometry * > &geoms)
 
static void writeGeometries (const char *fileName, const std::vector< te::gm::Geometry * > &geoms)
 

Protected Attributes

std::unique_ptr< std::ifstream > m_file
 Pointer to the geometry file. More...
 
std::vector< unsigned intm_gids
 Selected ids to use on traverse operation. More...
 
unsigned int m_i
 Current position on traversing. More...
 
std::unique_ptr< std::ifstream > m_posFile
 Pointer to the geometry pos file. More...
 

Detailed Description

A class that can parses a file with wkb encoded geometries.

Definition at line 54 of file GeometryFile.h.

Constructor & Destructor Documentation

GeometryFile::GeometryFile ( )

Constructor.

Definition at line 29 of file GeometryFile.cpp.

References m_file, and m_posFile.

GeometryFile::~GeometryFile ( )

Destructor.

Definition at line 36 of file GeometryFile.cpp.

References m_file, and m_posFile.

Member Function Documentation

te::gm::Geometry * GeometryFile::next ( )

Returns the next geometry.

If the setGeometries was used, then the geometries to be returned are the geometries identified by ids given to the function, otherwise it will traverse the entire file.

Returns
The next geometry on the file or NULL if there's no more geometries to get.
Note
The ownership of the returned geometries are given to the caller.

Definition at line 51 of file GeometryFile.cpp.

References m_file, m_gids, m_i, m_posFile, and te::gm::WKBReader::read().

Referenced by GetStashedGeometries().

void GeometryFile::openFile ( const char *  fileName)
throw (te::common::Exception
)

Opens the file fileName.

Parameters
fileNameThe name of geometry file. (File extension is .geom)
Exceptions
Ifthe file could not be opened an te::common::Exception will be raised.
Note
There's no check about the file contents, just for its existence. It means that if an unknown type of file was passed, it will try to open it. The behavior of the class then is unknown.

Definition at line 42 of file GeometryFile.cpp.

References m_file, and m_posFile.

Referenced by GetStashedGeometries().

void GeometryFile::setGeometries ( const std::vector< unsigned int > &  gids)

Sets the desired geometries to get from file.

This is a filter of the traversing file. If this is used before next was called, only geometries indentified by gids will be returned by next function. If not defined the file will be entirely traversed.

Parameters
gidsIds of the geometries to be filtered. These values comes from 'FID' column.

Definition at line 175 of file GeometryFile.cpp.

References m_gids, and m_i.

void GeometryFile::writeGeometries ( const char *  fileName,
const std::map< int, te::gm::Geometry * > &  geoms 
)
static

Definition at line 92 of file GeometryFile.cpp.

Referenced by StashGeometries().

void GeometryFile::writeGeometries ( const char *  fileName,
const std::vector< te::gm::Geometry * > &  geoms 
)
static

Definition at line 133 of file GeometryFile.cpp.

Member Data Documentation

std::unique_ptr<std::ifstream> GeometryFile::m_file
protected

Pointer to the geometry file.

Definition at line 115 of file GeometryFile.h.

Referenced by GeometryFile(), next(), openFile(), and ~GeometryFile().

std::vector<unsigned int> GeometryFile::m_gids
protected

Selected ids to use on traverse operation.

Definition at line 117 of file GeometryFile.h.

Referenced by next(), and setGeometries().

unsigned int GeometryFile::m_i
protected

Current position on traversing.

Definition at line 118 of file GeometryFile.h.

Referenced by next(), and setGeometries().

std::unique_ptr<std::ifstream> GeometryFile::m_posFile
protected

Pointer to the geometry pos file.

Definition at line 116 of file GeometryFile.h.

Referenced by GeometryFile(), next(), openFile(), and ~GeometryFile().


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