A class to manage Coordinate Systems representations within TerraLib environment. More...
#include <SpatialReferenceSystemManager.h>
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 | |
SpatialReferenceSystemManager & | operator= (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 > |
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 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.
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.
|
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.
te::srs::SpatialReferenceSystemManager::~SpatialReferenceSystemManager | ( | ) |
|
protected |
Constructor.
Definition at line 85 of file SpatialReferenceSystemManager.cpp.
|
private |
Copy constructor not allowed.
rhs | The right-hand-side copy that would be used to copy from. |
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.
name | A simple, human-readable, interface-friendly, name; |
p4Txt | a PROJ4 library description of coordinate system; |
wkt | An OGC's WKT description for the coordinate system; |
id | SRS id. |
authName | The authority responsible for the id. Default "EPSG". |
te::srs::Exception | if the coordinate system id is already registered in the manager. |
Definition at line 130 of file SpatialReferenceSystemManager.cpp.
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.
name | The coordinate system name. |
te::srs::Exception | if the coordinate system name is not found in the manager. |
Definition at line 247 of file SpatialReferenceSystemManager.cpp.
std::pair< std::string, unsigned int > te::srs::SpatialReferenceSystemManager::getIdFromP4Txt | ( | const std::string & | p4Txt | ) | const |
Returns a coordinate system identification given a PROJ4 description.
p4Txt | The coordinate system PROJ4 description. |
te::srs::Exception | if the coordinate system PROJ4 description is not found in the manager. |
Definition at line 257 of file SpatialReferenceSystemManager.cpp.
std::pair< std::string, unsigned int > te::srs::SpatialReferenceSystemManager::getIdFromWkt | ( | const std::string & | wkt | ) | const |
Returns a coordinate system identification given a WKT description.
wkt | The coordinate system WKT. |
te::srs::Exception | if the coordinate system WKT is not found in the manager. |
Definition at line 266 of file SpatialReferenceSystemManager.cpp.
|
staticinherited |
It 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.
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.
id | The coordinate system identification. |
authName | The authority responsible for the id. Default "EPSG". |
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.
id | The coordinate system identification. |
authName | The authority responsible for the id. Default "EPSG". |
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.
id | The coordinate system identification. |
authName | The authority responsible for the id. Default "EPSG". |
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.
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.
id | The coordinate system identification. |
authName | The authority responsible for the id. Default "EPSG". |
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.
te::srs::Exception | if 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.
fileName | Name of the JSON file. |
te::srs::Exception | if 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.
Definition at line 334 of file SpatialReferenceSystemManager.cpp.
References getP4Txt().
Referenced by getUnit().
|
private |
Assignment operator not allowed.
rhs | The right-hand-side copy that would be used to copy from. |
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.
id | The coordinate system identification. |
authName | The authority responsible for the id. Default "EPSG". |
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.
id | The coordinate system identification. |
authName | The 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.
|
friend |
Definition at line 70 of file SpatialReferenceSystemManager.h.
|
private |
Definition at line 107 of file SpatialReferenceSystemManager.h.
Referenced by add(), clear(), getIdFromName(), getIdFromP4Txt(), getIdFromWkt(), getIterators(), getName(), getP4Txt(), getWkt(), init(), recognizes(), remove(), and size().