All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ProjectedCoordinateSystem.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file ProjectedCoordinateSystem.cpp
22  */
23 
24 // TerraLib
25 #include "../common/Exception.h"
26 #include "../common/Translator.h"
27 #include "../common/UnitOfMeasure.h"
28 #include "../common/UnitsOfMeasureManager.h"
30 #include "Module.h"
32 
33 // STL
34 #include <sstream>
35 #include <assert.h>
36 
38  const std::string& unitName,
40  const std::string& projName):
41  te::srs::SpatialReferenceSystem(name,unitName),
42  m_geogcs(geogcs),
43  m_projection(projName)
44 {}
45 
47 {
48  delete m_geogcs;
49 }
50 
51 void
53 {
54  assert(geogcs);
55 
56  delete geogcs;
57  m_geogcs = geogcs;
58 }
59 
62 {
63  return m_geogcs;
64 }
65 
66 void
68 {
69  m_projection = projname;
70 }
71 
72 const std::string&
74 {
75  return m_projection;
76 }
77 
78 void
79 te::srs::ProjectedCoordinateSystem::setParameters(const std::map<std::string, double>& params)
80 {
81  m_params = params;
82 }
83 
84 const std::map<std::string, double>&
86 {
87  return m_params;
88 }
89 
90 std::string
92 {
93  std::ostringstream sstr;
94  sstr.precision(10);
95 
96  std::string wkt = "PROJCS[\"";
97  wkt += m_name;
98  if (m_geogcs)
99  {
100  wkt += "\",";
101  wkt += m_geogcs->getWKT();
102  }
103  wkt += ",PROJECTION[\"";
104  wkt += m_projection;
105  wkt += "\"]";
106  if (!m_params.empty())
107  {
108  std::map<std::string, double>::const_iterator it = m_params.begin();
109  do {
110  std::ostringstream sstr;
111  sstr.precision(10);
112  wkt += ",PARAMETER[\"";
113  wkt += it->first;
114  wkt += "\",";
115  sstr << it->second;
116  wkt += sstr.str();
117  wkt += "]";
118  ++it;
119  }while (it != m_params.end());
120  }
122  if (unit)
123  {
124  wkt += ", ";
125  wkt += unit->getWKT();
126  }
127  if (m_srid.first > 0 && !m_srid.second.empty())
128  {
129  wkt += ",AUTHORITY[\"";
130  wkt += m_srid.second;
131  wkt += "\",\"";
132  sstr.str("");
133  sstr << m_srid.first;
134  wkt += sstr.str();
135  wkt += "\"]";
136  }
137  wkt += "]";
138  return wkt;
139 }
140 
141 bool
143 {
144  return false;
145 }
void setProjection(const std::string &projname)
Sets the map projection name.
A Geographic Coordinate System (GEOGCS).
const GeographicCoordinateSystem * getGeographicCoordinateSystem() const
Returns the underlying Geographic Coordinate Reference System.
bool isGeographic() const
Returns true is a geographic coordinate system and false otherwise.
const std::map< std::string, double > & getParameters() const
Returns the list of projection parameters.
A Spatial Reference System, also known as a Coordinate System.
This file contains the structs necessary to represent a ProjectedCoordinateSystem.
static UnitsOfMeasureManager & getInstance()
It returns a reference to the singleton instance.
boost::shared_ptr< UnitOfMeasure > UnitOfMeasurePtr
const std::string & getProjection() const
Returns the map projection name.
This file contains the structs necessary to represent a GeographicCoordinateSystem.
ProjectedCoordinateSystem(const std::string &name="", const std::string &unitName="", GeographicCoordinateSystem *geogcs=0, const std::string &projName="")
Constructor with parameters.
void setParameters(const std::map< std::string, double > &params)
Sets the projection parameters.
std::string getWKT() const
Returns an OGC's WKT representation for the SRS.
UnitOfMeasurePtr find(unsigned int id) const
Returns a unit of measure identified by its identificaton.
void setGeographicCoordinateSystem(GeographicCoordinateSystem *geogcs)
Sets the underlying Geographic Coordinate Reference System.