te::srs::SpatialReferenceSystemManager Class Reference

A class to manage Coordinate Systems representations within TerraLib environment. More...

#include <SpatialReferenceSystemManager.h>

Inheritance diagram for te::srs::SpatialReferenceSystemManager:
te::common::Singleton< SpatialReferenceSystemManager >

Classes

struct  srs_desc
 

Public Types

typedef boost::multi_index::nth_index< srs_set, 0 >::type::iterator iterator
 An iterator by SRS <id,authority> More...
 

Public Member Functions

void add (const std::string &name, const std::string &p4Txt, const std::string &wkt, unsigned int id, const std::string &authName="EPSG")
 Adds a <id, authority> to the manager. More...
 
void clear ()
 Removes all coordinate system representations from the manager. More...
 
std::pair< std::string, unsigned int > getIdFromName (const std::string &name) const
 Returns a coordinate system identification given a name. More...
 
std::pair< std::string, unsigned int > getIdFromP4Txt (const std::string &p4Txt) const
 Returns a coordinate system identification given a PROJ4 description. More...
 
std::pair< std::string, unsigned int > getIdFromWkt (const std::string &wkt) const
 Returns a coordinate system identification given a WKT description. More...
 
std::pair< te::srs::SpatialReferenceSystemManager::iterator, te::srs::SpatialReferenceSystemManager::iteratorgetIterators () const
 Returns an iterator mechanism over the coordinate system descriptions in the manager. More...
 
std::string getName (unsigned int id, const std::string &authName="EPSG") const
 Returns a coordinate system name given an identification. More...
 
std::string getNewUserDefinedSRID ()
 Returns a SRID, not yet used, to identify an SRS created by an user. More...
 
std::string getP4Txt (unsigned int id, const std::string &authName="EPSG") const
 Returns a coordinate system PROJ4 description given an identification. More...
 
SpatialReferenceSystemPtr getSpatialReferenceSystem (unsigned int id, const std::string &authName="EPSG") const
 Returns a pointer to a coordinate system given an identification. More...
 
te::common::UnitOfMeasurePtr getUnit (unsigned int id, const std::string &authName="EPSG")
 Returns the unit of measure for a SRS with a given id. More...
 
std::string getWkt (unsigned int id, const std::string &authName="EPSG") const
 Returns a coordinate system WKT description given an id. More...
 
void init ()
 Inializes the manager from a JSON file containing instances of SRSs. More...
 
void init (const std::string &fileName)
 Inializes the manager from a JSON file containing instances of SRSs. More...
 
bool isGeographic (unsigned int id, const std::string &authName="EPSG")
 Checks if a SRS with a given id refers to a geographic spatial reference system. More...
 
bool isInitialized ()
 Checks if the System Manager is already initialized. More...
 
bool recognizes (unsigned int id, const std::string &authName="EPSG") const
 Returns true is a pair <id, authority> is recognized by the manager. More...
 
void remove (unsigned int id, const std::string &authName="EPSG")
 Removes a coordinate system representation from the manager, given its identification. More...
 
size_t size () const
 Returns the number of objects in the manager. More...
 
 ~SpatialReferenceSystemManager ()
 Destructor. More...
 

Static Public Member Functions

static SpatialReferenceSystemManagergetInstance ()
 It returns a reference to the singleton instance. More...
 

Protected Member Functions

 SpatialReferenceSystemManager ()
 Constructor. More...
 

Private Types

typedef boost::multi_index_container< srs_desc, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< BOOST_MULTI_INDEX_CONST_MEM_FUN(srs_desc, std::string, srid)>, boost::multi_index::ordered_non_unique< BOOST_MULTI_INDEX_MEMBER(srs_desc, std::string, m_name)>, boost::multi_index::ordered_non_unique< BOOST_MULTI_INDEX_MEMBER(srs_desc, std::string, m_p4txt)>, boost::multi_index::ordered_non_unique< BOOST_MULTI_INDEX_MEMBER(srs_desc, std::string, m_wkt)>, boost::multi_index::ordered_non_unique< BOOST_MULTI_INDEX_MEMBER(srs_desc, std::string, m_auth_name)> > > srs_set
 

Private Member Functions

SpatialReferenceSystemManageroperator= (const SpatialReferenceSystemManager &rhs)
 Assignment operator not allowed. More...
 
 SpatialReferenceSystemManager (const SpatialReferenceSystemManager &rhs)
 Copy constructor not allowed. More...
 

Private Attributes

srs_set m_set
 

Friends

class te::common::Singleton< SpatialReferenceSystemManager >
 

Detailed Description

A class to manage Coordinate Systems representations within TerraLib environment.

A Coordinate System used to describe coordinates are also known as Spatial Reference System. It can be represented by either one of these properties:

  • A pair <id,authority>: a unique numeric id given by a particular authority;
  • A simple, human-readable, interface-friendly, name;
  • An OGC's WKT description;
  • A PROJ4 text: to support coordinate conversion.

    Refer to the Spatial Reference website for more information about EPSG codes for SRS.

Definition at line 68 of file SpatialReferenceSystemManager.h.

Member Typedef Documentation

typedef boost::multi_index::nth_index<srs_set,0>::type::iterator te::srs::SpatialReferenceSystemManager::iterator

An iterator by SRS <id,authority>

Definition at line 114 of file SpatialReferenceSystemManager.h.

typedef boost::multi_index_container< srs_desc, boost::multi_index::indexed_by< boost::multi_index::ordered_unique<BOOST_MULTI_INDEX_CONST_MEM_FUN(srs_desc,std::string,srid)>, boost::multi_index::ordered_non_unique<BOOST_MULTI_INDEX_MEMBER(srs_desc,std::string,m_name)>, boost::multi_index::ordered_non_unique<BOOST_MULTI_INDEX_MEMBER(srs_desc,std::string,m_p4txt)>, boost::multi_index::ordered_non_unique<BOOST_MULTI_INDEX_MEMBER(srs_desc,std::string,m_wkt)>, boost::multi_index::ordered_non_unique<BOOST_MULTI_INDEX_MEMBER(srs_desc,std::string,m_auth_name)> > > te::srs::SpatialReferenceSystemManager::srs_set
private

A mult-index container with the following indexes: 1) an unique index by <auth_name, id>; 2) a non-unique index by name; 3) a non-unique index by p4txt; 4) a non-unique index by wkt; 5) a non-unique index by auth_name;

Definition at line 105 of file SpatialReferenceSystemManager.h.

Constructor & Destructor Documentation

te::srs::SpatialReferenceSystemManager::~SpatialReferenceSystemManager ( )

Destructor.

te::srs::SpatialReferenceSystemManager::SpatialReferenceSystemManager ( )
protected

Constructor.

te::srs::SpatialReferenceSystemManager::SpatialReferenceSystemManager ( const SpatialReferenceSystemManager rhs)
private

Copy constructor not allowed.

Parameters
rhsThe right-hand-side copy that would be used to copy from.

Member Function Documentation

void te::srs::SpatialReferenceSystemManager::add ( const std::string &  name,
const std::string &  p4Txt,
const std::string &  wkt,
unsigned int  id,
const std::string &  authName = "EPSG" 
)

Adds a <id, authority> to the manager.

Parameters
nameA simple, human-readable, interface-friendly, name;
p4Txta PROJ4 library description of coordinate system;
wktAn OGC's WKT description for the coordinate system;
idSRS id.
authNameThe authority responsible for the id. Default "EPSG".
Exceptions
te::srs::Exceptionif the coordinate system id is already registered in the manager.
void te::srs::SpatialReferenceSystemManager::clear ( )

Removes all coordinate system representations from the manager.

std::pair<std::string,unsigned int> te::srs::SpatialReferenceSystemManager::getIdFromName ( const std::string &  name) const

Returns a coordinate system identification given a name.

Parameters
nameThe coordinate system name.
Returns
A pair composed by the coordinate system identification and the name of the authority responsible for it.
Exceptions
te::srs::Exceptionif the coordinate system name is not found in the manager.
std::pair<std::string,unsigned int> te::srs::SpatialReferenceSystemManager::getIdFromP4Txt ( const std::string &  p4Txt) const

Returns a coordinate system identification given a PROJ4 description.

Parameters
p4TxtThe coordinate system PROJ4 description.
Returns
A pair composed by the coordinate system identification and the name of the authority responsible for it.
Exceptions
te::srs::Exceptionif the coordinate system PROJ4 description is not found in the manager.
std::pair<std::string,unsigned int> te::srs::SpatialReferenceSystemManager::getIdFromWkt ( const std::string &  wkt) const

Returns a coordinate system identification given a WKT description.

Parameters
wktThe coordinate system WKT.
Returns
A pair composed by the coordinate system identification and the name of the authority responsible for it.
Exceptions
te::srs::Exceptionif the coordinate system WKT is not found in the manager.

It returns a reference to the singleton instance.

Returns
A reference to the singleton instance.
std::pair<te::srs::SpatialReferenceSystemManager::iterator,te::srs::SpatialReferenceSystemManager::iterator> te::srs::SpatialReferenceSystemManager::getIterators ( ) const

Returns an iterator mechanism over the coordinate system descriptions in the manager.

The first iterator of the returned pair points to first coordinate system description. The second iterator of the returned pair points to the last plus one ccoordinate system description.

Returns
a pair of iterators pointing to the first and last coordnate system representation in the manager.
std::string te::srs::SpatialReferenceSystemManager::getName ( unsigned int  id,
const std::string &  authName = "EPSG" 
) const

Returns a coordinate system name given an identification.

Parameters
idThe coordinate system identification.
authNameThe authority responsible for the id. Default "EPSG".
Returns
the Coordinate System name if the identification is recognized or and empty string otherwise.
std::string te::srs::SpatialReferenceSystemManager::getNewUserDefinedSRID ( )

Returns a SRID, not yet used, to identify an SRS created by an user.

Returns
a string represent a SRID, not yet used, to identify an SRS created by an user.
std::string te::srs::SpatialReferenceSystemManager::getP4Txt ( unsigned int  id,
const std::string &  authName = "EPSG" 
) const

Returns a coordinate system PROJ4 description given an identification.

Parameters
idThe coordinate system identification.
authNameThe authority responsible for the id. Default "EPSG".
Returns
The coordinate system PROJ4 description if the identification is recognized or an empty string otherwise.
SpatialReferenceSystemPtr te::srs::SpatialReferenceSystemManager::getSpatialReferenceSystem ( unsigned int  id,
const std::string &  authName = "EPSG" 
) const

Returns a pointer to a coordinate system given an identification.

Parameters
idThe coordinate system identification.
authNameThe authority responsible for the id. Default "EPSG".
Returns
A pointer to a coordinate system if the identification is recognized or a null pointer otherwise. Caller is responsible for deleting the returned pointer.
te::common::UnitOfMeasurePtr te::srs::SpatialReferenceSystemManager::getUnit ( unsigned int  id,
const std::string &  authName = "EPSG" 
)

Returns the unit of measure for a SRS with a given id.

Returns
A pointer to the unit of measure or a null pointer if it the SRS could not be founded.
std::string te::srs::SpatialReferenceSystemManager::getWkt ( unsigned int  id,
const std::string &  authName = "EPSG" 
) const

Returns a coordinate system WKT description given an id.

Parameters
idThe coordinate system identification.
authNameThe authority responsible for the id. Default "EPSG".
Returns
The coordinate system OGC WKT if the identification is recognized or an empty string otherwise.
void te::srs::SpatialReferenceSystemManager::init ( )

Inializes the manager from a JSON file containing instances of SRSs.

This methods reads the file "TE_JSON_FILES_LOCATION/srs.json" for SRSs definitions and insert them on the manager if it is empty.

Exceptions
te::srs::Exceptionif the JSON file is not well formed.
void te::srs::SpatialReferenceSystemManager::init ( const std::string &  fileName)

Inializes the manager from a JSON file containing instances of SRSs.

Parameters
fileNameName of the JSON file.
Exceptions
te::srs::Exceptionif the JSON file is not well formed.
bool te::srs::SpatialReferenceSystemManager::isGeographic ( unsigned int  id,
const std::string &  authName = "EPSG" 
)

Checks if a SRS with a given id refers to a geographic spatial reference system.

Returns
True if the SRS with a given id refers to a geographic spatial reference system or false if not or not founded in the Manager.
bool te::srs::SpatialReferenceSystemManager::isInitialized ( )

Checks if the System Manager is already initialized.

SpatialReferenceSystemManager& te::srs::SpatialReferenceSystemManager::operator= ( const SpatialReferenceSystemManager rhs)
private

Assignment operator not allowed.

Parameters
rhsThe right-hand-side copy that would be used to copy from.
Returns
A reference to this object.
bool te::srs::SpatialReferenceSystemManager::recognizes ( unsigned int  id,
const std::string &  authName = "EPSG" 
) const

Returns true is a pair <id, authority> is recognized by the manager.

Parameters
idThe coordinate system identification.
authNameThe authority responsible for the id. Default "EPSG".
Returns
True if the pair <id,authority> is already registered in the manager and false otherwise.
void te::srs::SpatialReferenceSystemManager::remove ( unsigned int  id,
const std::string &  authName = "EPSG" 
)

Removes a coordinate system representation from the manager, given its identification.

Parameters
idThe coordinate system identification.
authNameThe authority responsible for the id. Default "EPSG".
size_t te::srs::SpatialReferenceSystemManager::size ( ) const

Returns the number of objects in the manager.

Friends And Related Function Documentation

Definition at line 70 of file SpatialReferenceSystemManager.h.

Member Data Documentation

srs_set te::srs::SpatialReferenceSystemManager::m_set
private

Definition at line 109 of file SpatialReferenceSystemManager.h.


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