Isis 3 Programmer Reference
Isis::GisTopology Class Reference

This class models GIS topology. More...

#include <GisTopology.h>

Collaboration diagram for Isis::GisTopology:
Collaboration graph

Public Types

enum  Disposition { DestroyGeometry, PreserveGeometry }
 Enumeration to indicate whether the geometry should be preserved. More...
 

Public Member Functions

GEOSGeometry * geomFromWKB (const QString &wkb)
 Reads in the geometry from the given well-known binary formatted string. More...
 
GEOSGeometry * geomFromWKT (const QString &wkt)
 Reads in the geometry from the given well-known text formatted string. More...
 
GEOSGeometry * clone (const GEOSGeometry *geom) const
 Clones the given GEOSGeometry pointer. More...
 
const GEOSPreparedGeometry * preparedGeometry (const GEOSGeometry *geom) const
 Gets a GEOSPreparedGeometry from the given GEOSGeometry. More...
 
QString wkb (const GEOSGeometry *geom, const Disposition &disp=PreserveGeometry)
 Writes a well-known binary string from the given geometry. More...
 
QString wkt (const GEOSGeometry *geom, const Disposition &disp=PreserveGeometry)
 Writes a well-known text string from the given geometry. More...
 
void destroy (GEOSGeometry *geom) const
 Destroys the given GEOS geometry. More...
 
void destroy (const GEOSGeometry *geom) const
 Destroys the given GEOS geometry. More...
 
void destroy (const GEOSPreparedGeometry *ppgeom) const
 Destroys the given prepared GEOS geometry. More...
 
void destroy (GEOSCoordSequence *sequence) const
 Destroys the given GEOS coordinate sequence. More...
 
void destroy (const unsigned char *geos_text) const
 Destroys the given unsigned GEOS text geometry representation. More...
 
void destroy (const char *geos_text) const
 Destroys the given GEOS text geometry representation. More...
 

Static Public Member Functions

static GisTopologyinstance ()
 Gets the singleton instance of this class. More...
 

Private Member Functions

 GisTopology ()
 Private default constructor so that this class is only instatiated through the instance() method. More...
 
 ~GisTopology ()
 Destroy the GisTopology object. More...
 
void initialize ()
 
void geosInit ()
 Initializes the GEOS C API. More...
 
void geosFinish ()
 Shuts down the GEOS C API. More...
 
GEOSWKTReader * wktReader ()
 Accessor for the GEOS well-known text reader. More...
 
GEOSWKTWriter * wktWriter ()
 Accessor for the GEOS well-known text writer. More...
 
GEOSWKBReader * wkbReader ()
 Accessor for the GEOS well-known binary reader. More...
 
GEOSWKBWriter * wkbWriter ()
 Accessor for the GEOS well-known binary writer. More...
 

Static Private Member Functions

static void dieAtExit ()
 Exit termination routine. More...
 
static void notice (const char *fmt,...)
 A static method for handling errors. More...
 
static void error (const char *fmt,...)
 A static method for handling errors. More...
 

Private Attributes

GEOSWKTReader * m_WKTreader
 A GEOS library parser for well-known text format. More...
 
GEOSWKTWriter * m_WKTwriter
 A GEOS library writer for well-known text format. More...
 
GEOSWKBReader * m_WKBreader
 A GEOS library parser for well-known binary format. More...
 
GEOSWKBWriter * m_WKBwriter
 A GEOS library writer for well-known binary format. More...
 

Static Private Attributes

static GisTopologym_gisfactory = 0
 A static member variable representing the GIS factory. More...
 

Detailed Description

This class models GIS topology.

This class allows us to create GEOS geometries from well-known binary (WKB) strings or well-known text (WKT) strings. It also allows us to create WKB or WKT strings from a GEOS geometry.

Author
2012-07-15 Kris Becker
History:

2012-07-15 Kris Becker - Original version.

2015-03-18 Jeannie Backer - Brought class files closer to ISIS coding standards.

2015-03-23 Jeannie Backer - Improved documentation.

2015-04-22 Jeannie Backer - Fixed typo "wkb" where it should have been "wkt".

2016-03-02 Ian Humphrey - Updated for coding standards compliance, fixed minor documentation issues, and added to jwbacker's unit test in preparation for adding this class to ISIS. Fixes #2398.

Definition at line 51 of file GisTopology.h.

Member Enumeration Documentation

◆ Disposition

Enumeration to indicate whether the geometry should be preserved.

Enumerator
DestroyGeometry 

Destroy the geometry.

PreserveGeometry 

Preserve the geometry.

Definition at line 57 of file GisTopology.h.

Constructor & Destructor Documentation

◆ GisTopology()

Isis::GisTopology::GisTopology ( )
private

Private default constructor so that this class is only instatiated through the instance() method.

This ensures that only a singleton object is constructed. The GEOS readers/writers are set to null and the GEOS C API is initialized.

Definition at line 56 of file GisTopology.cpp.

References dieAtExit(), and geosInit().

Referenced by instance().

◆ ~GisTopology()

Isis::GisTopology::~GisTopology ( )
private

Destroy the GisTopology object.

The GEOS readers/writers are destroyed and set to null and the GEOS C API is shut down.

Definition at line 69 of file GisTopology.cpp.

References geosFinish(), m_WKBreader, m_WKBwriter, m_WKTreader, and m_WKTwriter.

Member Function Documentation

◆ clone()

GEOSGeometry * Isis::GisTopology::clone ( const GEOSGeometry *  geom) const

Clones the given GEOSGeometry pointer.

Parameters
geomA pointer to the GEOSGeometry object to be cloned.
Returns
GEOSGeometry* A clone of the given GEOSGeometry pointer.

Definition at line 165 of file GisTopology.cpp.

Referenced by Isis::GisGeometry::clone(), Isis::GisGeometry::GisGeometry(), and Isis::GisGeometry::operator=().

◆ destroy() [1/6]

void Isis::GisTopology::destroy ( GEOSGeometry *  geom) const

Destroys the given GEOS geometry.

Parameters
geomA pointer to the GEOSGeometry to be destroyed.

Definition at line 249 of file GisTopology.cpp.

Referenced by Isis::GisGeometry::centroid(), destroy(), Isis::GisGeometry::destroy(), Isis::GisGeometry::isValidReason(), wkb(), and wkt().

◆ destroy() [2/6]

void Isis::GisTopology::destroy ( const GEOSGeometry *  geom) const

Destroys the given GEOS geometry.

Parameters
geomA pointer to the GEOSGeometry to be destroyed.

Definition at line 262 of file GisTopology.cpp.

References destroy().

◆ destroy() [3/6]

void Isis::GisTopology::destroy ( const GEOSPreparedGeometry *  geom) const

Destroys the given prepared GEOS geometry.

Parameters
geomA pointer to the GEOSPreparedGeometry to be destroyed.

Definition at line 275 of file GisTopology.cpp.

◆ destroy() [4/6]

void Isis::GisTopology::destroy ( GEOSCoordSequence *  sequence) const

Destroys the given GEOS coordinate sequence.

Parameters
sequenceA pointer to the GEOSCoordSequence to be destroyed.

Definition at line 288 of file GisTopology.cpp.

◆ destroy() [5/6]

void Isis::GisTopology::destroy ( const unsigned char *  geos_text) const

Destroys the given unsigned GEOS text geometry representation.

Parameters
geos_textA pointer to the GEOS text char to be destroyed.

Definition at line 314 of file GisTopology.cpp.

◆ destroy() [6/6]

void Isis::GisTopology::destroy ( const char *  geos_text) const

Destroys the given GEOS text geometry representation.

Parameters
geos_textA pointer to the GEOS text char to be destroyed.

Definition at line 301 of file GisTopology.cpp.

◆ dieAtExit()

void Isis::GisTopology::dieAtExit ( )
staticprivate

Exit termination routine.

This (static) method ensures that this object is destroyed when Qt exits.
Note that this should not be added to the system _atexit() routine because this object utilizes Qt classes. At the time the atexit call stack is executed, Qt is long gone resulting in Very Bad Things. Fortunately, Qt has an exit stack function as well. This method is added to the Qt exit call stack.

Definition at line 439 of file GisTopology.cpp.

References m_gisfactory.

Referenced by GisTopology().

◆ error()

void Isis::GisTopology::error ( const char *  fmt,
  ... 
)
staticprivate

A static method for handling errors.

Parameters
fmt
Exceptions
IException::Programmer

Definition at line 363 of file GisTopology.cpp.

References _FILEINFO_, and Isis::IException::Programmer.

Referenced by geosInit().

◆ geomFromWKB()

GEOSGeometry * Isis::GisTopology::geomFromWKB ( const QString &  wkb)

Reads in the geometry from the given well-known binary formatted string.

Parameters
wkbThe well-known binary formatted string containing the geometry information to be parsed.
Returns
GEOSGeometry* A pointer to a GEOSGeometry object created from the parsed wkb.
Exceptions
IException::Programmer"Unable convert the given well-known binary to a GEOSGeometry.

Definition at line 117 of file GisTopology.cpp.

References _FILEINFO_, Isis::IException::Programmer, wkb(), and wkbReader().

Referenced by Isis::GisGeometry::GisGeometry().

◆ geomFromWKT()

GEOSGeometry * Isis::GisTopology::geomFromWKT ( const QString &  wkt)

Reads in the geometry from the given well-known text formatted string.

Parameters
wktThe well-known text formatted string containing the geometry information to be parsed.
Returns
GEOSGeometry* A pointer to a GEOSGeometry object created from the parsed wkt.
Exceptions
IException::Programmer"Unable convert the given well-known text to a GEOSGeometry.

Definition at line 145 of file GisTopology.cpp.

References _FILEINFO_, Isis::IException::Programmer, wkt(), and wktReader().

Referenced by Isis::GisGeometry::fromCube(), and Isis::GisGeometry::GisGeometry().

◆ geosFinish()

void Isis::GisTopology::geosFinish ( )
private

Shuts down the GEOS C API.

Definition at line 334 of file GisTopology.cpp.

Referenced by ~GisTopology().

◆ geosInit()

void Isis::GisTopology::geosInit ( )
private

Initializes the GEOS C API.

Definition at line 325 of file GisTopology.cpp.

References error(), and notice().

Referenced by GisTopology().

◆ instance()

GisTopology * Isis::GisTopology::instance ( )
static

Gets the singleton instance of this class.

If it has not been instantiated yet, the default constructor is called.

Returns
GisTopology A pointer to the GisTopology singleton object.

Definition at line 100 of file GisTopology.cpp.

References GisTopology(), and m_gisfactory.

Referenced by Isis::GisGeometry::centroid(), Isis::GisGeometry::clone(), Isis::GisGeometry::destroy(), Isis::GisGeometry::fromCube(), Isis::GisGeometry::GisGeometry(), Isis::GisGeometry::isValidReason(), Isis::GisGeometry::makePrepared(), and Isis::GisGeometry::operator=().

◆ notice()

void Isis::GisTopology::notice ( const char *  fmt,
  ... 
)
staticprivate

A static method for handling errors.

Parameters
fmt
Exceptions
IException::Programmer

Definition at line 346 of file GisTopology.cpp.

References _FILEINFO_, and Isis::IException::Programmer.

Referenced by geosInit().

◆ preparedGeometry()

const GEOSPreparedGeometry * Isis::GisTopology::preparedGeometry ( const GEOSGeometry *  geom) const

Gets a GEOSPreparedGeometry from the given GEOSGeometry.

Parameters
geomA pointer to a GEOSGeometry object to be converted.
Returns
GEOSPreparedGeometry A pointer to a prepared geometry from the given geometry pointer.
Exceptions
IException::Programmer"Unable to convert the given GEOSGeometry to a GEOSPreparedGeometry."

Definition at line 180 of file GisTopology.cpp.

References _FILEINFO_, and Isis::IException::Programmer.

Referenced by Isis::GisGeometry::makePrepared().

◆ wkb()

QString Isis::GisTopology::wkb ( const GEOSGeometry *  geom,
const Disposition disp = PreserveGeometry 
)

Writes a well-known binary string from the given geometry.

This method will destroy the given GEOSGeometry pointer if so indicated by the given Disposition enumeration.

Parameters
geomA pointer to the geometry to be represented as a WKT string
dispA reference to a topology disposition enumeration indicating whether to preserve or destroy the passed in geometry.
Returns
QString A well-known binary string containg the geometry information.

Definition at line 229 of file GisTopology.cpp.

References destroy(), DestroyGeometry, and wkbWriter().

Referenced by geomFromWKB().

◆ wkbReader()

GEOSWKBReader * Isis::GisTopology::wkbReader ( )
private

Accessor for the GEOS well-known binary reader.

This method creates the reader if it doesn't exist.

Returns
GEOSWKBReader A pointer to a GEOS library parser for well-known binary format.

Definition at line 407 of file GisTopology.cpp.

References m_WKBreader.

Referenced by geomFromWKB().

◆ wkbWriter()

GEOSWKBWriter * Isis::GisTopology::wkbWriter ( )
private

Accessor for the GEOS well-known binary writer.

This method creates the writer if it doesn't exist.

Returns
GEOSWKBWriter A pointer to a GEOS library writer for well-known binary format.

Definition at line 421 of file GisTopology.cpp.

References m_WKBwriter.

Referenced by wkb().

◆ wkt()

QString Isis::GisTopology::wkt ( const GEOSGeometry *  geom,
const Disposition disp = PreserveGeometry 
)

Writes a well-known text string from the given geometry.

This method will destroy the given GEOSGeometry pointer if so indicated by the given Disposition enumeration.

Parameters
geomA pointer to the geometry to be represented as a WKT string
dispA reference to a topology disposition enumeration indicating whether to preserve or destroy the passed in geometry.
Returns
QString A well-known text string containg the geometry information.

Definition at line 203 of file GisTopology.cpp.

References destroy(), DestroyGeometry, and wktWriter().

Referenced by geomFromWKT().

◆ wktReader()

GEOSWKTReader * Isis::GisTopology::wktReader ( )
private

Accessor for the GEOS well-known text reader.

This method creates the reader if it doesn't exist.

Returns
GEOSWKTReader A pointer to a GEOS library parser for well-known text format.

Definition at line 379 of file GisTopology.cpp.

References m_WKTreader.

Referenced by geomFromWKT().

◆ wktWriter()

GEOSWKTWriter * Isis::GisTopology::wktWriter ( )
private

Accessor for the GEOS well-known text writer.

This method creates the writer if it doesn't exist.

Returns
GEOSWKTWriter A pointer to a GEOS library writer for well-known text format.

Definition at line 393 of file GisTopology.cpp.

References m_WKTwriter.

Referenced by wkt().

Member Data Documentation

◆ m_gisfactory

GisTopology * Isis::GisTopology::m_gisfactory = 0
staticprivate

A static member variable representing the GIS factory.

A static instance of the GIS topology class.

It is initialized to NULL and instantiated when the instance() method is called.

Definition at line 104 of file GisTopology.h.

Referenced by dieAtExit(), and instance().

◆ m_WKBreader

GEOSWKBReader* Isis::GisTopology::m_WKBreader
private

A GEOS library parser for well-known binary format.

Definition at line 107 of file GisTopology.h.

Referenced by wkbReader(), and ~GisTopology().

◆ m_WKBwriter

GEOSWKBWriter* Isis::GisTopology::m_WKBwriter
private

A GEOS library writer for well-known binary format.

Definition at line 108 of file GisTopology.h.

Referenced by wkbWriter(), and ~GisTopology().

◆ m_WKTreader

GEOSWKTReader* Isis::GisTopology::m_WKTreader
private

A GEOS library parser for well-known text format.

Definition at line 105 of file GisTopology.h.

Referenced by wktReader(), and ~GisTopology().

◆ m_WKTwriter

GEOSWKTWriter* Isis::GisTopology::m_WKTwriter
private

A GEOS library writer for well-known text format.

Definition at line 106 of file GisTopology.h.

Referenced by wktWriter(), and ~GisTopology().


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