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 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 "terralib_config.h"
28 #include "../Defines.h"
29 #include "../common/Translator.h"
30 #include "../srs/Converter.h"
31 #include "AbstractPoint.h"
32 #include "Envelope.h"
33 #include "Exception.h"
34 
35 // STL
36 #include <memory>
37 
38 const std::string te::gm::AbstractPoint::sm_typeName("Point");
39 
40 const double te::gm::AbstractPoint::sm_notNumber(TE_DOUBLE_NOT_A_NUMBER);
41 
43  : Geometry(t, srid, mbr)
44 {
45 }
46 
48  : Geometry(rhs)
49 {
50 }
51 
53 {
55 
56  return *this;
57 }
58 
60 {
61  return te::gm::P;
62 }
63 
64 const std::string& te::gm::AbstractPoint::getGeometryType() const throw()
65 {
66  return sm_typeName;
67 }
68 
69 void te::gm::AbstractPoint::setSRID(int srid) throw()
70 {
71  m_srid = srid;
72 }
73 
75 {
76 #ifdef TERRALIB_MOD_SRS_ENABLED
77  if(srid == m_srid)
78  return;
79 
80  std::auto_ptr<te::srs::Converter> converter(new te::srs::Converter());
81 
82  converter->setSourceSRID(m_srid);
83  converter->setTargetSRID(srid);
84 
85  double x = getX();
86  double y = getY();
87 
88  converter->convert(x,y);
89 
90  setX(x);
91  setY(y);
92 
93  m_srid = srid;
94 
95  if(m_mbr)
96  computeMBR(false);
97 #else
98  throw Exception(TE_TR("transform method is not supported!"));
99 #endif // TERRALIB_MOD_SRS_ENABLED
100 }
101 
102 void te::gm::AbstractPoint::computeMBR(bool /*cascade*/) const throw()
103 {
104  if(m_mbr == 0)
105  m_mbr = new Envelope(getX(), getY(), getX(), getY());
106  else
107  m_mbr->init(getX(), getY(), getX(), getY());
108 }
109 
110 
111 
112 
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:78
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
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