All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MultiCurve.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/MultiCurve.cpp
22 
23  \brief MultiCurve is a class that represents a 1-dimensional GeometryCollection whose elements are curves.
24 */
25 
26 // TerraLib
27 #include "Curve.h"
28 #include "MultiCurve.h"
29 
30 // STL
31 #include <cassert>
32 
33 te::gm::MultiCurve::MultiCurve(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 MultiCurve(*this);
53 }
54 
56 {
57  std::size_t n = m_geometries.size();
58 
59  for(std::size_t i = 0; i < n; ++i)
60  {
61  Curve* curve = static_cast<Curve*>(m_geometries[i]);
62  assert(curve);
63 
64  if(curve->isClosed() == false)
65  return false;
66  }
67 
68  return true;
69 }
70 
72 {
73  double sum = 0.0;
74 
75  std::size_t n = m_geometries.size();
76 
77  for(std::size_t i = 0; i < n; ++i)
78  {
79  Curve* curve = static_cast<Curve*>(m_geometries[i]);
80  assert(curve);
81 
82  sum += curve->getLength();
83  }
84 
85  return sum;
86 }
87 
89 {
90  return te::gm::L;
91 }
92 
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
Curve is an abstract class that represents 1-dimensional geometric objects stored as a sequence of co...
Definition: Curve.h:58
virtual double getLength() const
The length of this curve in the unit associated to its spatial reference system.
Definition: Curve.cpp:50
virtual te::dt::AbstractData * clone() const
It clones the linestring.
Definition: MultiCurve.cpp:50
virtual bool isClosed() const =0
It returns true if the curve is closed (startPoint = endPoint).
TE_DEFINE_VISITABLE MultiCurve(std::size_t nGeom, GeomType t, int srid=0, Envelope *mbr=0)
It initializes the multi curve with the specified spatial reference system id and envelope...
Definition: MultiCurve.cpp:33
GeometryCollection & operator=(const GeometryCollection &rhs)
Assignment operator.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
bool isClosed() const
It returns true if this MultiCurve is closed [StartPoint ( ) = EndPoint ( ) for each Curve in this Mu...
Definition: MultiCurve.cpp:55
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
Dimensionality getDimension() const
MultiCurves are 1-dimensional.
Definition: MultiCurve.cpp:88
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
MultiCurve is a class that represents a 1-dimensional GeometryCollection whose elements are curves...
Curve is an abstract class that represents 1-dimensional geometric objects stored as a sequence of co...
MultiCurve is a class that represents a 1-dimensional GeometryCollection whose elements are curves...
Definition: MultiCurve.h:50
double getLength() const
It returns the Length of this MultiCurve which is equal to the sum of the lengths of the element Curv...
Definition: MultiCurve.cpp:71
It is a collection of other geometric objects.
virtual MultiCurve & operator=(const MultiCurve &rhs)
Assignment operator.
Definition: MultiCurve.cpp:43