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