geometry/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 
40  = default;
41 
43  default;
44 
46 {
47  return new MultiSurface(*this);
48 }
49 
51 {
52  double sum = 0.0;
53 
54  std::size_t n = m_geometries.size();
55 
56  for(std::size_t i = 0; i < n; ++i)
57  {
58  Surface* surface = static_cast<Surface*>(m_geometries[i]);
59  assert(surface);
60 
61  sum += surface->getArea();
62  }
63 
64  return sum;
65 }
66 
68 {
69  return nullptr;
70 }
71 
73 {
74  return nullptr;
75 }
76 
78 {
79  return nullptr;
80 }
81 
83 {
84  return nullptr;
85 }
86 
88 {
89  double sum = 0.0;
90 
91  std::size_t n = m_geometries.size();
92 
93  for(std::size_t i = 0; i < n; ++i)
94  {
95  Surface* surface = static_cast<Surface*>(m_geometries[i]);
96  assert(surface);
97 
98  sum += surface->getPerimeter();
99  }
100 
101  return sum;
102 }
103 
105 {
106  return te::gm::A;
107 }
108 
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
virtual double getPerimeter() const =0
It returns the length of the boundary for the surface.
Point * getCentroid() const
It returns the mathematical centroid for this MultiSurface as a point.
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
double getPerimeter() const
It returns the length of the boundary for the surface.
virtual double getArea() const =0
It returns the area of the surface measured in the spatial reference system of 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.
std::vector< Geometry * > m_geometries
The array of geometries that forms the collection.
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".
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
Point * getPointOnSurface() const
It returns a point guaranteed to be on this MultiSurface.
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