All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AbstractPoint.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008-2013 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/geometry/AbstractPoint.cpp
22 
23  \brief A base abstract class for 0-dimensional geometric objects that represents a single location in coordinate space.
24 */
25 
26 // TerraLib
27 #include "../Defines.h"
28 #include "../common/Translator.h"
29 #include "../srs/Converter.h"
30 #include "AbstractPoint.h"
31 #include "Envelope.h"
32 #include "Exception.h"
33 
34 // STL
35 #include <memory>
36 
37 const std::string te::gm::AbstractPoint::sm_typeName("Point");
38 
39 const double te::gm::AbstractPoint::sm_notNumber(TE_DOUBLE_NOT_A_NUMBER);
40 
42  : Geometry(t, srid, mbr)
43 {
44 }
45 
47  : Geometry(rhs)
48 {
49 }
50 
52 {
54 
55  return *this;
56 }
57 
59 {
60  return te::gm::P;
61 }
62 
63 const std::string& te::gm::AbstractPoint::getGeometryType() const throw()
64 {
65  return sm_typeName;
66 }
67 
68 void te::gm::AbstractPoint::setSRID(int srid) throw()
69 {
70  m_srid = srid;
71 }
72 
74 {
75 #ifdef TERRALIB_MOD_SRS_ENABLED
76  if(srid == m_srid)
77  return;
78 
79  std::auto_ptr<te::srs::Converter> converter(new te::srs::Converter());
80 
81  converter->setSourceSRID(m_srid);
82  converter->setTargetSRID(srid);
83 
84  double x = getX();
85  double y = getY();
86 
87  converter->convert(x,y);
88 
89  setX(x);
90  setY(y);
91 
92  m_srid = srid;
93 
94  if(m_mbr)
95  computeMBR(false);
96 #else
97  throw Exception(TE_TR("transform method is not supported!"));
98 #endif // TERRALIB_MOD_SRS_ENABLED
99 }
100 
101 void te::gm::AbstractPoint::computeMBR(bool /*cascade*/) const throw()
102 {
103  if(m_mbr == 0)
104  m_mbr = new Envelope(getX(), getY(), getX(), getY());
105  else
106  m_mbr->init(getX(), getY(), getX(), getY());
107 }
108 
109 
110 
111 
A base abstract class for 0-dimensional geometric objects that represents a single location in coordi...
void transform(int srid)
It converts the coordinate values of the point to the new spatial reference system.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
virtual Geometry & operator=(const Geometry &rhs)
Assignment operator.
Definition: Geometry.cpp:77
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:345
void computeMBR(bool cascade) const
It computes the minimum bounding rectangle for the point.
An Envelope defines a 2D rectangular region.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
void setSRID(int srid)
It sets the Spatial Reference System ID of the Point.
Dimensionality
From Wikipedia: "in mathematics, the dimension of an object is an intrinsic property, independent of the space in which the object may happen to be embedded".
Definition: Enums.h:142
virtual AbstractPoint & operator=(const AbstractPoint &rhs)
Assignment operator.
Dimensionality getDimension() const
Points are 0-dimensional objects.
TE_DEFINE_VISITABLE AbstractPoint(GeomType t, int srid=0, Envelope *mbr=0)
It initializes the point with the specified spatial reference system id and envelope.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Definition: Exception.h:58
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
An exception class for the Geometry module.
A Converter is responsible for the conversion of coordinates between different Coordinate Systems (CS...
Definition: Converter.h:53
static const double sm_notNumber
Just a special value to return in the case of an invalid geometry.
static const std::string sm_typeName
Geometry type name for AbstractPoint.
const std::string & getGeometryType() const
The name of instantiable subtype is: Point.
A base abstract class for 0-dimensional geometric objects that represents a single location in coordi...
Definition: AbstractPoint.h:50