All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "terralib_config.h"
28 #include "../common/STLUtils.h"
29 #include "../common/Translator.h"
30 #include "Config.h"
31 #include "Curve.h"
32 #include "GEOSWriter.h"
33 
34 #ifdef TERRALIB_GEOS_ENABLED
35 // GEOS
36 #include <geos/geom/Geometry.h>
37 #include <geos/util/GEOSException.h>
38 #endif
39 
41  : Geometry(t, srid, mbr)
42 {
43 }
44 
46  : Geometry(rhs)
47 {
48 }
49 
51 {
52 #ifdef TERRALIB_GEOS_ENABLED
53  std::auto_ptr<geos::geom::Geometry> g(GEOSWriter::write(this));
54 
55  return g->getLength();
56 
57 #else
58  throw Exception(TE_TR("getLength routine is supported by GEOS! Please, enable the GEOS support."));
59 #endif
60 }
61 
63 {
65 
66  return *this;
67 }
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.
Definition: Enums.h:41
virtual Geometry & operator=(const Geometry &rhs)
Assignment operator.
Definition: Geometry.cpp:78
bool isRing() const
It returns true if the curve is closed and simple.
Definition: Curve.cpp:69
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 Curve & operator=(const Curve &rhs)
Assignment operator.
Definition: Curve.cpp:62
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
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
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
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.
Definition: Curve.cpp:40
Dimensionality getDimension() const
Curves are 1-dimensional objects.
Definition: Curve.cpp:74
Configuration flags for the Vector Geometry Model of TerraLib.