All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
te::srs::Converter Class Reference

A Converter is responsible for the conversion of coordinates between different Coordinate Systems (CS). More...

#include <Converter.h>

Public Member Functions

bool convert (double *xIn, double *yIn, double *xOut, double *yOut, long numCoord, int coordOffset=1) const
 Converts a vector of coordinates from source SRS to target SRS. More...
 
bool convert (double *x, double *y, long numCoord, int coordOffset=1) const
 Converts a vector of coordinates from source SRS to target SRS. More...
 
bool convert (const double xIn, const double yIn, double &xOut, double &yOut) const
 Converts a single coordinate from source SRS to target SRS. More...
 
bool convert (double &x, double &y) const
 Converts a coordinate from source SRS to target SRS. More...
 
 Converter ()
 Default empty constructor. More...
 
 Converter (int sourceSRID, int targetSRID)
 Constructor with parameters. More...
 
bool convertToGeographic (double &x, double &y, int SRID) const
 Converts a coordinate from a projected SRS to its underlying geographic SRS (same Datum). More...
 
bool convertToProjected (double &lon, double &lat, int SRID) const
 Converts a coordinate from a geographic SRS to a projected SRS based on the same Datum. More...
 
int getSourceSRID () const
 Gets source SRS identifier. More...
 
int getTargetSRID () const
 Gets target SRS identifier. More...
 
bool invert (double *xIn, double *yIn, double *xOut, double *yOut, long numCoord, int coordOffset=1) const
 Inverts a vector of coordinates from target SRS to dource SRS. More...
 
bool invert (double *x, double *y, long numCoord, int coordOffset=1) const
 Inverts a vector of coordinates from target SRS to source SRS. More...
 
bool invert (const double xIn, const double yIn, double &xOut, double &yOut) const
 Inverts a coordinate from source SRS to target SRS. More...
 
bool invert (double &x, double &y) const
 Inverts a coordinate from target SRS to source SRS. More...
 
void setSourcePJ4txt (const std::string &pj4txt)
 Sets the source SRS PROJ4 description. More...
 
void setSourceSRID (int sourceSRID)
 Sets the source SRS identifier. More...
 
void setTargetPJ4txt (const std::string &pj4txt)
 Sets the target SRS PROJ4 description. More...
 
void setTargetSRID (int targetSRID)
 Sets the target SRS identifier. More...
 
 ~Converter ()
 Destructor. More...
 

Private Attributes

void * m_sourcePj4Handler
 
int m_sourceSRID
 
void * m_targetPj4Handler
 
int m_targetSRID
 

Detailed Description

A Converter is responsible for the conversion of coordinates between different Coordinate Systems (CS).

A Converter is responsible for the conversion of coordinates between two different Coordinate Systems (CS) or a Spatial Reference System (SRS). A CS can be uniquely identified by a numeric code (SRID). This implementation is based on the PROJ4 cartographic library and only works if it has been enabled.

Definition at line 53 of file Converter.h.

Constructor & Destructor Documentation

te::srs::Converter::Converter ( )

Default empty constructor.

Definition at line 45 of file Converter.cpp.

te::srs::Converter::Converter ( int  sourceSRID,
int  targetSRID 
)

Constructor with parameters.

Parameters
sourceSRIDsource SRS identifier (input).
targetSRIDtarget SRS identifier (input).
Exceptions
te::srs::Exceptionidentifier not recognized.

Definition at line 53 of file Converter.cpp.

References te::common::Singleton< SpatialReferenceSystemManager >::getInstance(), m_sourcePj4Handler, m_targetPj4Handler, and TE_TR.

te::srs::Converter::~Converter ( )

Destructor.

Definition at line 88 of file Converter.cpp.

References TE_UNKNOWN_SRS.

Member Function Documentation

bool te::srs::Converter::convert ( double *  xIn,
double *  yIn,
double *  xOut,
double *  yOut,
long  numCoord,
int  coordOffset = 1 
) const

Converts a vector of coordinates from source SRS to target SRS.

The X and Y dimensions of the coordinates are given in separate vectors. Output vectors must be previously allocaded by the caller of this method and caller is responsible for deallocating them.

Parameters
xInpointer to array of X values in source SRS (input).
yInpointer to array of Y valueS in source SRS (input).
xOutpointer to array of X values in target SRS (output).
yOutpointer to array of X values in target SRS (output).
numCoordnumber of coordinates in the input arrays (input).
coordOffsetthe step size from value to value (measured in doubles) within the xIn/yIn arrays (input).
Returns
true if succeed and false otherwise.

Definition at line 242 of file Converter.cpp.

References TE_TR.

bool te::srs::Converter::convert ( double *  x,
double *  y,
long  numCoord,
int  coordOffset = 1 
) const

Converts a vector of coordinates from source SRS to target SRS.

Parameters
xpointer to array of X values in source SRS as input and modified to target SRS for output.
ypointer to array of Y valueS in source SRS as input and modified to target SRS for output.
numCoordnumber of coordinates in the array (input).
coordOffsetthe step size from value to value (measured in doubles) within the x/y arrays (input).
Returns
true if succeed and false otherwise.

Definition at line 266 of file Converter.cpp.

References TE_TR.

bool te::srs::Converter::convert ( const double  xIn,
const double  yIn,
double &  xOut,
double &  yOut 
) const

Converts a single coordinate from source SRS to target SRS.

Parameters
xIncoordinate X value in source SRS (input).
yIncoordinate Y value in source SRS (input).
xOutcoordinate X value in target SRS (output).
yOutcoordinate Y values in target SRS (output).
Returns
true if succeed and false otherwise.

Definition at line 287 of file Converter.cpp.

References TE_TR.

bool te::srs::Converter::convert ( double &  x,
double &  y 
) const

Converts a coordinate from source SRS to target SRS.

Parameters
xX value in source SRS as input and modified to target SRS for output.
yY value in source SRS as input and modified to target SRS for output.
Returns
true if succeed and false otherwise.

Definition at line 316 of file Converter.cpp.

References TE_TR.

bool te::srs::Converter::convertToGeographic ( double &  x,
double &  y,
int  SRID 
) const

Converts a coordinate from a projected SRS to its underlying geographic SRS (same Datum).

Parameters
xprojected X-coordinate. Will return the geographic longitude coordinate.
yprojected Y-coordinate. Will return the geographic latitude coordinate.
SRIDprojected SRS identifier that x and y refers to.
Returns
true if succeed and false otherwise.

Definition at line 445 of file Converter.cpp.

References te::common::Singleton< SpatialReferenceSystemManager >::getInstance(), te::srs::SpatialReferenceSystemManager::getP4Txt(), and TE_TR.

bool te::srs::Converter::convertToProjected ( double &  lon,
double &  lat,
int  SRID 
) const

Converts a coordinate from a geographic SRS to a projected SRS based on the same Datum.

Parameters
longeographic longitude. Will return the projected x-coordinate.
latgeogrpahic latitude. Will return the projected y-coordinate.
SRIDtarget projected SRS identifier.
Returns
true if succeed and false otherwise.

Definition at line 485 of file Converter.cpp.

References te::common::Singleton< SpatialReferenceSystemManager >::getInstance(), te::srs::SpatialReferenceSystemManager::getP4Txt(), and TE_TR.

int te::srs::Converter::getSourceSRID ( ) const

Gets source SRS identifier.

Definition at line 167 of file Converter.cpp.

int te::srs::Converter::getTargetSRID ( ) const

Gets target SRS identifier.

Definition at line 236 of file Converter.cpp.

bool te::srs::Converter::invert ( double *  xIn,
double *  yIn,
double *  xOut,
double *  yOut,
long  numCoord,
int  coordOffset = 1 
) const

Inverts a vector of coordinates from target SRS to dource SRS.

The X and Y dimensions of the coordinates are given in separate vectors. Output vectors must be previously allocaded by the caller of this method, and caller is responsible for deallocating them.

Parameters
xInpointer to array of X values in target SRS (input).
yInpointer to array of Y valueS in target SRS (input).
xOutpointer to array of X values in source SRS (output).
yOutpointer to array of Y values in source SRS (output).
numCoordnumber of coordinates in the array (input).
coordOffsetthe step size from value to value (in double size) within the x/y arrays (input).
Returns
true if succeed and false otherwise.

Definition at line 342 of file Converter.cpp.

References TE_TR.

Referenced by InterpolateIn().

bool te::srs::Converter::invert ( double *  x,
double *  y,
long  numCoord,
int  coordOffset = 1 
) const

Inverts a vector of coordinates from target SRS to source SRS.

Parameters
xpointer to array of X values in target SRS as input and modified to source SRS for output.
ypointer to array of Y values in target SRS as input and modified to source SRS for output.
numCoordnumber of coordinates in the array (input).
coordOffsetthe step size from value to value in double size) within the x/y arrays (input).
Returns
true if succeed and false otherwise.

Definition at line 366 of file Converter.cpp.

References TE_TR.

bool te::srs::Converter::invert ( const double  xIn,
const double  yIn,
double &  xOut,
double &  yOut 
) const

Inverts a coordinate from source SRS to target SRS.

Parameters
xInpointer to array of X values in target SRS (input).
yInpointer to array of Y valueS in target SRS (input).
xOutpointer to array of X values in source SRS (output).
yOutpointer to array of Y values in source SRS (output).
Returns
true if succeed and false otherwise.

Definition at line 387 of file Converter.cpp.

References TE_TR.

bool te::srs::Converter::invert ( double &  x,
double &  y 
) const

Inverts a coordinate from target SRS to source SRS.

Parameters
xpointer to array of X values in target SRS as inputand modified to source SRS for output.
ypointer to array of Y values in target SRS as inputand modified to source SRS for output.
Returns
true if succeed and false otherwise.

Definition at line 417 of file Converter.cpp.

References TE_TR.

void te::srs::Converter::setSourcePJ4txt ( const std::string &  pj4txt)

Sets the source SRS PROJ4 description.

Parameters
pj4txtPROJ4 description (input). Do not pass an empty string.
Exceptions
te::srs::ExceptionPROJ4 description is not valid.

Definition at line 143 of file Converter.cpp.

References TE_TR, and TE_UNKNOWN_SRS.

void te::srs::Converter::setSourceSRID ( int  sourceSRID)

Sets the source SRS identifier.

Parameters
sourceSRIDthe source SRS identifier (input).
Exceptions
te::srs::Exceptionidentifier not recognized.

Definition at line 105 of file Converter.cpp.

References te::common::Singleton< SpatialReferenceSystemManager >::getInstance(), te::srs::SpatialReferenceSystemManager::getP4Txt(), te::srs::getStaticMutex(), and TE_TR.

Referenced by te::rst::Reproject().

void te::srs::Converter::setTargetPJ4txt ( const std::string &  pj4txt)

Sets the target SRS PROJ4 description.

Parameters
pj4txtPROJ4 description (input). Do not pass an empty string.
Exceptions
te::srs::ExceptionPROJ4 description is not valid.

Definition at line 212 of file Converter.cpp.

References TE_TR, and TE_UNKNOWN_SRS.

void te::srs::Converter::setTargetSRID ( int  targetSRID)

Sets the target SRS identifier.

Parameters
targetSRIDthe target SRS identifier (input).
Exceptions
te::srs::Exceptionidentifier not recognized.

Definition at line 173 of file Converter.cpp.

References te::common::Singleton< SpatialReferenceSystemManager >::getInstance(), te::srs::SpatialReferenceSystemManager::getP4Txt(), te::srs::getStaticMutex(), and TE_TR.

Referenced by te::rst::Reproject().

Member Data Documentation

void* te::srs::Converter::m_sourcePj4Handler
private

Definition at line 217 of file Converter.h.

Referenced by Converter().

int te::srs::Converter::m_sourceSRID
private

Definition at line 215 of file Converter.h.

void* te::srs::Converter::m_targetPj4Handler
private

Definition at line 218 of file Converter.h.

Referenced by Converter().

int te::srs::Converter::m_targetSRID
private

Definition at line 214 of file Converter.h.


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