All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GeographicCoordinateSystem.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 terralib/srs/GeographicCoordinateSystem.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"
29 #include "Datum.h"
31 
32 //STL
33 #include <cassert>
34 #include <sstream>
35 
37  const std::string unitName,
38  double primem) :
39  te::srs::SpatialReferenceSystem(name, unitName),
40  m_datum(0),
41  m_primem(primem)
42 {}
43 
45 {
46  delete m_datum;
47 }
48 
50 {
51  assert(datum);
52 
53  delete m_datum;
54  m_datum = datum;
55 }
56 
58 {
59  return m_datum;
60 }
61 
63 {
64  return m_primem;
65 }
66 
68 {
69  m_primem = primen;
70 }
71 
73 {
74  std::ostringstream sstr;
75  sstr.precision(10);
76 
77  std::string wkt = "GEOGCS[\"";
78  wkt += m_name;
79  if (m_datum)
80  {
81  wkt += "\",";
82  wkt += m_datum->getWKT();
83  }
84  wkt += ",";
85  wkt += "PRIMEM[\"";
86  if (m_primem == 0)
87  wkt += "Greenwich";
88  else
89  wkt += "Unknown";
90  wkt += "\",";
91  sstr << m_primem;
92  wkt += sstr.str();
93  wkt += "]";
95  if (unit.get())
96  {
97  wkt += ", ";
98  wkt += unit->getWKT();
99  }
100  if (m_srid.first > 0 && !m_srid.second.empty())
101  {
102  wkt += ",AUTHORITY[\"";
103  wkt += m_srid.second;
104  wkt += "\",\"";
105  sstr.str("");
106  sstr << m_srid.first;
107  wkt += sstr.str();
108  wkt += "\"]";
109  }
110  wkt += "]";
111  return wkt;
112 }
113 
114 bool
116 {
117  return true;
118 }
A geodetic datum defines a reference to measure Earth's surface.
Definition: Datum.h:35
GeographicCoordinateSystem(const std::string &name="", const std::string unitName="degree", double primem=0.0)
Constructor with parameters.
This file contains the support to represent a geodetic datum.
const Datum * getDatum() const
Returns the associated Datum.
A Spatial Reference System, also known as a Coordinate System.
void setDatum(Datum *datum)
Sets the associated Datum.
static UnitsOfMeasureManager & getInstance()
It returns a reference to the singleton instance.
void setPrimem(double primen)
Sets the meridian used to take longitude measurements from.
double getPrimem() const
Returns the meridian used to take longitude measurements from.
std::string getWKT() const
Returns an OGC's WKT representation for the SRS.
boost::shared_ptr< UnitOfMeasure > UnitOfMeasurePtr
This file contains the structs necessary to represent a GeographicCoordinateSystem.
bool isGeographic() const
Returns true is a geographic coordinate system and false otherwise.
UnitOfMeasurePtr find(unsigned int id) const
Returns a unit of measure identified by its identificaton.