geometry/Curve.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/Curve.cpp
22 
23  \brief Curve is an abstract class that represents 1-dimensional geometric objects stored as a sequence of coordinates.
24 */
25 
26 // TerraLib
27 #include "../common/STLUtils.h"
28 #include "../core/translator/Translator.h"
29 #include "Config.h"
30 #include "Curve.h"
31 #include "GEOSWriter.h"
32 
33 #ifdef TERRALIB_GEOS_ENABLED
34 // GEOS
35 #include <geos/geom/Geometry.h>
36 #include <geos/util/GEOSException.h>
37 #endif
38 
40  : Geometry(t, srid, mbr)
41 {
42 }
43 
44 te::gm::Curve::Curve(const Curve& rhs)
45 
46  = default;
47 
49 {
50 #ifdef TERRALIB_GEOS_ENABLED
51  try
52  {
53  std::unique_ptr<geos::geom::Geometry> g(GEOSWriter::write(this));
54 
55  return g->getLength();
56  }
57  catch(geos::util::GEOSException& e)
58  {
59  throw Exception(e.what());
60  }
61 
62 #else
63  throw Exception(TE_TR("getLength routine is supported by GEOS! Please, enable the GEOS support."));
64 #endif
65 }
66 
67 te::gm::Curve& te::gm::Curve::operator=(const Curve& rhs) = default;
68 
70 {
71  return (isClosed() && isSimple());
72 }
73 
75 {
76  return te::gm::L;
77 }
78 
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
bool isRing() const
It returns true if the curve is closed and simple.
Configuration flags for the Vector Geometry Model of TerraLib.
Base exception class for plugin module.
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 Curve & operator=(const Curve &rhs)
Assignment operator.
virtual bool isClosed() const =0
It returns true if the curve is closed (startPoint = endPoint).
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
virtual bool isSimple() const _NOEXCEPT_OP(false)
It returns true if this geometric object has no anomalous points, such as self intersection or self t...
An Envelope defines a 2D rectangular region.
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".
static geos::geom::Geometry * write(const Geometry *teGeom)
It reads a TerraLib geometry and make a GEOS geometry.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Curve is an abstract class that represents 1-dimensional geometric objects stored as a sequence of co...
A class that converts a TerraLib geometry to a GEOS geometry.
Curve(GeomType t, int srid=0, Envelope *mbr=0)
It initializes the curve with the specified spatial reference system id and envelope.
Dimensionality getDimension() const
Curves are 1-dimensional objects.