All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MultiSurface.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/MultiSurface.cpp
22 
23  \brief MultiSurface is a class that represents a 2-dimensional GeometryCollection whose elements are surfaces.
24 */
25 
26 // TerraLib
27 #include "MultiSurface.h"
28 #include "Surface.h"
29 
30 // STL
31 #include <cassert>
32 
33 te::gm::MultiSurface::MultiSurface(std::size_t nGeom, GeomType t, int srid, Envelope* mbr)
34  : GeometryCollection(nGeom, t, srid, mbr)
35 {
36 }
37 
39  : GeometryCollection(rhs)
40 {
41 }
42 
44 {
46 
47  return *this;
48 }
49 
51 {
52  return new MultiSurface(*this);
53 }
54 
56 {
57  double sum = 0.0;
58 
59  std::size_t n = m_geometries.size();
60 
61  for(std::size_t i = 0; i < n; ++i)
62  {
63  Surface* surface = static_cast<Surface*>(m_geometries[i]);
64  assert(surface);
65 
66  sum += surface->getArea();
67  }
68 
69  return sum;
70 }
71 
73 {
74  return 0;
75 }
76 
78 {
79  return 0;
80 }
81 
83 {
84  return 0;
85 }
86 
88 {
89  return 0;
90 }
91 
93 {
94  double sum = 0.0;
95 
96  std::size_t n = m_geometries.size();
97 
98  for(std::size_t i = 0; i < n; ++i)
99  {
100  Surface* surface = static_cast<Surface*>(m_geometries[i]);
101  assert(surface);
102 
103  sum += surface->getPerimeter();
104  }
105 
106  return sum;
107 }
108 
110 {
111  return te::gm::A;
112 }
113 
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
Point * getCentroid() const
It returns the mathematical centroid for this MultiSurface as a point.
GeometryCollection & operator=(const GeometryCollection &rhs)
Assignment operator.
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
double getPerimeter() const
It returns the length of the boundary for the surface.
Dimensionality getDimension() const
MultiSurface is 2-dimenional.
virtual te::dt::AbstractData * clone() const
It clones the multi surface.
Coord2D * getCoordOnSurface() const
It returns a coordinate guaranteed to be on this MultiSurface.
Coord2D * getCentroidCoord() const
It returns the mathematical centroid for this MultiSurface as a coordinate.
virtual MultiSurface & operator=(const MultiSurface &rhs)
Assignment operator.
A point with x and y coordinate values.
Definition: Point.h:50
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
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
Surface is an abstract class that represents a 2-dimensional geometric objects.
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
virtual double getPerimeter() const =0
It returns the length of the boundary for the surface.
Definition: Surface.cpp:47
Point * getPointOnSurface() const
It returns a point guaranteed to be on this MultiSurface.
virtual double getArea() const =0
It returns the area of the surface measured in the spatial reference system of the surface...
double getArea() const
It returns the area of this MultiSurface, as measured in the spatial reference system of this multisu...
MultiSurface is a class that represents a 2-dimensional GeometryCollection whose elements are surface...
Definition: MultiSurface.h:54
TE_DEFINE_VISITABLE MultiSurface(std::size_t nGeom, GeomType t, int srid=0, Envelope *mbr=0)
It initializes the Geometry with the specified spatial reference system id and envelope.
MultiSurface is a class that represents a 2-dimensional GeometryCollection whose elements are surface...
It is a collection of other geometric objects.
Surface is an abstract class that represents a 2-dimensional geometric objects.
Definition: Surface.h:54