geometry/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 
40  = default;
41 
43  default;
44 
46 {
47  return new MultiCurve(*this);
48 }
49 
51 {
52  std::size_t n = m_geometries.size();
53 
54  for(std::size_t i = 0; i < n; ++i)
55  {
56  Curve* curve = static_cast<Curve*>(m_geometries[i]);
57  assert(curve);
58 
59  if(curve->isClosed() == false)
60  return false;
61  }
62 
63  return true;
64 }
65 
67 {
68  double sum = 0.0;
69 
70  std::size_t n = m_geometries.size();
71 
72  for(std::size_t i = 0; i < n; ++i)
73  {
74  Curve* curve = static_cast<Curve*>(m_geometries[i]);
75  assert(curve);
76 
77  sum += curve->getLength();
78  }
79 
80  return sum;
81 }
82 
84 {
85  return te::gm::L;
86 }
87 
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
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.
virtual te::dt::AbstractData * clone() const
It clones the linestring.
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...
virtual bool isClosed() const =0
It returns true if the curve is closed (startPoint = endPoint).
An Envelope defines a 2D rectangular region.
bool isClosed() const
It returns true if this MultiCurve is closed [StartPoint ( ) = EndPoint ( ) for each Curve in this Mu...
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".
Dimensionality getDimension() const
MultiCurves are 1-dimensional.
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...
It is a collection of other geometric objects.
virtual MultiCurve & operator=(const MultiCurve &rhs)
Assignment operator.