All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::iterator
getIterators () 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 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)
 Checks if a SRS with a given id refers to a geographic spatial reference system. 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
SpatialReferenceSystemManager
getInstance ()
 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)> > > 
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 112 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)> > > 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 unuque index by wkt;

Definition at line 103 of file SpatialReferenceSystemManager.h.

Constructor & Destructor Documentation

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

Destructor.

Definition at line 89 of file SpatialReferenceSystemManager.cpp.

References clear().

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

Constructor.

Definition at line 85 of file SpatialReferenceSystemManager.cpp.

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.

Definition at line 130 of file SpatialReferenceSystemManager.cpp.

References m_set, and TE_TR.

Referenced by LoadSpatialReferenceSystemManager().

void te::srs::SpatialReferenceSystemManager::clear ( void  )

Removes all coordinate system representations from the manager.

Definition at line 295 of file SpatialReferenceSystemManager.cpp.

References m_set.

Referenced by init(), and ~SpatialReferenceSystemManager().

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.

Definition at line 247 of file SpatialReferenceSystemManager.cpp.

References m_set, and TE_TR.

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.

Definition at line 257 of file SpatialReferenceSystemManager.cpp.

References m_set, and TE_TR.

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.

Definition at line 266 of file SpatialReferenceSystemManager.cpp.

References m_set, and TE_TR.

It returns a reference to the singleton instance.

Returns
A reference to the singleton instance.

Referenced by te::ogr::Convert2OGRProjection(), te::ogr::Convert2TerraLibProjection(), te::srs::Converter::Converter(), te::srs::Converter::convertToGeographic(), te::srs::Converter::convertToProjected(), te::gdal::CreateRaster(), te::qt::plugins::cellspace::CreateCellularSpaceDialog::getResX(), te::qt::plugins::cellspace::CreateCellularSpaceDialog::getResY(), te::layout::MapModel::getWorldBox(), te::layout::MapModel::getWorldInDegrees(), te::layout::MapModel::getWorldInMeters(), te::srs::Module::initialize(), te::qt::plugins::cellspace::CreateCellularSpaceDialog::initUnitsOfMeasure(), te::qt::widgets::Measure::Measure(), te::qt::plugins::cellspace::CreateCellularSpaceDialog::onColsLineEditEditingFinished(), te::qt::widgets::Measure::onExtentChanged(), te::qt::plugins::cellspace::CreateCellularSpaceDialog::onLayersComboBoxChanged(), te::qt::plugins::cellspace::CreateCellularSpaceDialog::onRowsLineEditEditingFinished(), te::qt::plugins::cellspace::CreateCellularSpaceDialog::onSrsToolButtonClicked(), te::qt::widgets::SRSManagerDialog::onSRSTreeWidgetItemClicked(), te::qt::plugins::cellspace::CreateCellularSpaceDialog::onUnitComboBoxChanged(), te::layout::Utils::remapToPlanar(), te::srs::Converter::setSourceSRID(), te::srs::Converter::setTargetSRID(), te::attributefill::VectorToRasterDialog::showSRS(), te::qt::plugins::cellspace::CreateCellularSpaceDialog::showSRS(), te::qt::plugins::ogr::Plugin::showWindow(), te::qt::widgets::SRSManagerDialog::SRSManagerDialog(), and te::layout::Utils::unitMeasure().

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.

Definition at line 301 of file SpatialReferenceSystemManager.cpp.

References m_set.

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.

Definition at line 181 of file SpatialReferenceSystemManager.cpp.

References m_set.

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.

Definition at line 225 of file SpatialReferenceSystemManager.cpp.

References m_set.

Referenced by te::srs::Converter::convertToGeographic(), te::srs::Converter::convertToProjected(), getUnit(), isGeographic(), te::srs::Converter::setSourceSRID(), and te::srs::Converter::setTargetSRID().

std::auto_ptr< te::srs::SpatialReferenceSystem > 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.

Definition at line 163 of file SpatialReferenceSystemManager.cpp.

References getWkt(), te::srs::WKTReader::read(), and TE_TR.

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.

Definition at line 312 of file SpatialReferenceSystemManager.cpp.

References te::common::UnitsOfMeasureManager::find(), te::common::UnitsOfMeasureManager::findBySymbol(), te::common::Singleton< UnitsOfMeasureManager >::getInstance(), getP4Txt(), and isGeographic().

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.

Definition at line 203 of file SpatialReferenceSystemManager.cpp.

References m_set.

Referenced by getSpatialReferenceSystem().

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.

Definition at line 94 of file SpatialReferenceSystemManager.cpp.

References te::common::FindInTerraLibPath(), m_set, and TE_TR.

Referenced by te::srs::Module::initialize().

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.

Definition at line 110 of file SpatialReferenceSystemManager.cpp.

References clear(), LoadSpatialReferenceSystemManager(), and TE_TR.

bool te::srs::SpatialReferenceSystemManager::isGeographic ( unsigned int  id,
const std::string &  authName 
)

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.

Definition at line 334 of file SpatialReferenceSystemManager.cpp.

References getP4Txt().

Referenced by getUnit().

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.

Definition at line 144 of file SpatialReferenceSystemManager.cpp.

References m_set.

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".

Definition at line 275 of file SpatialReferenceSystemManager.cpp.

References m_set.

size_t te::srs::SpatialReferenceSystemManager::size ( void  ) const

Returns the number of objects in the manager.

Definition at line 307 of file SpatialReferenceSystemManager.cpp.

References m_set.

Friends And Related Function Documentation

Definition at line 70 of file SpatialReferenceSystemManager.h.

Member Data Documentation

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

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