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

Converterclone () const
 Creates a clone of this instance. 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...
 
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 (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...
 
 Converter ()
 Default empty constructor. More...
 
 Converter (int sourceSRID, int targetSRID)
 Constructor with parameters. More...
 
int getSourceSRID () const
 Gets source SRS identifier. More...
 
int getTargetSRID () const
 Gets target SRS identifier. 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...
 
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 (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...
 
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...
 

Static Public Member Functions

static bool convertToGeographic (double &x, double &y, int SRID)
 Converts a coordinate from a projected SRS to its underlying geographic SRS (same Datum). More...
 
static bool convertToProjected (double &lon, double &lat, int SRID)
 Converts a coordinate from a geographic SRS to a projected SRS based on the same Datum. More...
 

Private Member Functions

bool update (std::string &errorString)
 Update the internal state following the current source/target CRS strings. More...
 

Private Attributes

int m_convert_res
 
double m_convert_xOut
 
double m_convert_yOut
 
std::string m_sourceCRS
 
bool m_sourceIsLatLong
 
void * m_sourcePj4Handler
 
int m_sourceSRID
 
std::string m_targetCRS
 
bool m_targetIsLatLong
 
void * m_targetPj4Handler
 
int m_targetSRID
 
void * m_transfPjHandler
 
void * m_transfThreadContextHandler
 

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

◆ Converter() [1/2]

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

Default empty constructor.

◆ Converter() [2/2]

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.

◆ ~Converter()

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

Destructor.

Member Function Documentation

◆ clone()

Converter* te::srs::Converter::clone ( ) const

Creates a clone of this instance.

Returns
A clone of this instance.
Note
The caller of this method must take the ownership of the returned object.

◆ convert() [1/4]

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

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 140 of file Converter.h.

◆ convert() [2/4]

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.

◆ convert() [3/4]

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.

◆ convert() [4/4]

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.

◆ convertToGeographic()

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

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.
Deprecated:
This method is deprecated and will be removed in a near future.

◆ convertToProjected()

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

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.
Deprecated:
This method is deprecated and will be removed in a near future.

◆ getSourceSRID()

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

Gets source SRS identifier.

◆ getTargetSRID()

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

Gets target SRS identifier.

◆ invert() [1/4]

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

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 189 of file Converter.h.

◆ invert() [2/4]

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.

◆ invert() [3/4]

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.

◆ invert() [4/4]

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.

◆ setSourcePJ4txt()

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.

◆ setSourceSRID()

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

Sets the source SRS identifier.

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

◆ setTargetPJ4txt()

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.

◆ setTargetSRID()

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

Sets the target SRS identifier.

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

◆ update()

bool te::srs::Converter::update ( std::string &  errorString)
private

Update the internal state following the current source/target CRS strings.

Parameters
errorStringError string.
Returns
true if OK, false on errros.
Note
This is NOT A THREAD SAFE method.

Member Data Documentation

◆ m_convert_res

int te::srs::Converter::m_convert_res
mutableprivate

Definition at line 248 of file Converter.h.

◆ m_convert_xOut

double te::srs::Converter::m_convert_xOut
private

Definition at line 249 of file Converter.h.

◆ m_convert_yOut

double te::srs::Converter::m_convert_yOut
private

Definition at line 250 of file Converter.h.

◆ m_sourceCRS

std::string te::srs::Converter::m_sourceCRS
private

Definition at line 244 of file Converter.h.

◆ m_sourceIsLatLong

bool te::srs::Converter::m_sourceIsLatLong
private

Definition at line 241 of file Converter.h.

◆ m_sourcePj4Handler

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

Definition at line 237 of file Converter.h.

◆ m_sourceSRID

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

Definition at line 234 of file Converter.h.

◆ m_targetCRS

std::string te::srs::Converter::m_targetCRS
private

Definition at line 245 of file Converter.h.

◆ m_targetIsLatLong

bool te::srs::Converter::m_targetIsLatLong
private

Definition at line 242 of file Converter.h.

◆ m_targetPj4Handler

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

Definition at line 238 of file Converter.h.

◆ m_targetSRID

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

Definition at line 233 of file Converter.h.

◆ m_transfPjHandler

void* te::srs::Converter::m_transfPjHandler
private

Definition at line 239 of file Converter.h.

◆ m_transfThreadContextHandler

void* te::srs::Converter::m_transfThreadContextHandler
private

Definition at line 240 of file Converter.h.


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