All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Utils.h
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/edit/Utils.h
22 
23  \brief Utility functions for TerraLib Edit module.
24 */
25 
26 #ifndef __TERRALIB_EDIT_INTERNAL_UTILS_H
27 #define __TERRALIB_EDIT_INTERNAL_UTILS_H
28 
29 // TerraLib
30 #include "../maptools/AbstractLayer.h"
31 #include "Config.h"
32 
33 // STL
34 #include <string>
35 #include <vector>
36 
37 namespace te
38 {
39 // Forward declarations
40  namespace da
41  {
42  class ObjectId;
43  }
44 
45  namespace gm
46  {
47  struct Coord2D;
48  class Envelope;
49  class Geometry;
50  class GeometryCollection;
51  class LineString;
52  class Polygon;
53  }
54 
55  namespace edit
56  {
57 // Forward declaration
58  class Feature;
59 
60  struct VertexIndex
61  {
62  void setIndex(const std::size_t& line, const std::size_t& pos)
63  {
64  m_line = line;
65  m_pos = pos;
66  }
67 
68  void makeInvalid()
69  {
70  m_line = std::string::npos;
71  m_pos = std::string::npos;
72  }
73 
74  bool isValid() const
75  {
76  return m_line != std::string::npos && m_pos != std::string::npos;
77  }
78 
79  std::size_t m_line;
80  std::size_t m_pos;
81  };
82 
83  TEEDITEXPORT Feature* PickFeature(const te::map::AbstractLayerPtr& layer, const te::gm::Envelope& env, int srid);
84 
85  TEEDITEXPORT void GetLines(te::gm::Geometry* geom, std::vector<te::gm::LineString*>& lines);
86 
87  TEEDITEXPORT void GetLines(te::gm::GeometryCollection* gc, std::vector<te::gm::LineString*>& lines);
88 
89  TEEDITEXPORT void GetLines(te::gm::Polygon* p, std::vector<te::gm::LineString*>& lines);
90 
91  TEEDITEXPORT void GetLines(te::gm::LineString* l, std::vector<te::gm::LineString*>& lines);
92 
93  TEEDITEXPORT void MoveVertex(std::vector<te::gm::LineString*>& lines, const VertexIndex& index, const double& x, const double& y);
94 
95  TEEDITEXPORT void RemoveVertex(std::vector<te::gm::LineString*>& lines, const VertexIndex& index);
96 
97  TEEDITEXPORT void AddVertex(std::vector<te::gm::LineString*>& lines, const double& x, const double& y, const te::gm::Envelope& env, int srid);
98 
99  TEEDITEXPORT VertexIndex FindSegment(std::vector<te::gm::LineString*>& lines, const te::gm::Envelope& env, int srid);
100 
101  TEEDITEXPORT void MoveGeometry(te::gm::Geometry* geom, const double& deltax, const double& deltay);
102 
104 
105  TEEDITEXPORT double GetDistance(const te::gm::Coord2D& c1, const te::gm::Coord2D& c2);
106 
107  TEEDITEXPORT void GetCoordinates(te::gm::Geometry* geom, std::vector<te::gm::Coord2D>& coords);
108 
109  TEEDITEXPORT void TrySnap(te::gm::Coord2D& coord, int srid);
110 
112 
113  } // end namespace edit
114 } // end namespace te
115 
116 #endif // __TERRALIB_EDIT_INTERNAL_UTILS_H
TEEDITEXPORT void MoveVertex(std::vector< te::gm::LineString * > &lines, const VertexIndex &index, const double &x, const double &y)
Definition: Utils.cpp:158
TEEDITEXPORT te::da::ObjectId * GenerateId()
Definition: Utils.cpp:361
#define TEEDITEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:67
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
TEEDITEXPORT void GetCoordinates(te::gm::Geometry *geom, std::vector< te::gm::Coord2D > &coords)
Definition: Utils.cpp:300
TEEDITEXPORT void RemoveVertex(std::vector< te::gm::LineString * > &lines, const VertexIndex &index)
Definition: Utils.cpp:176
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
void setIndex(const std::size_t &line, const std::size_t &pos)
Definition: Utils.h:62
This class represents an unique id for a data set element.
Definition: ObjectId.h:47
TEEDITEXPORT Feature * PickFeature(const te::map::AbstractLayerPtr &layer, const te::gm::Envelope &env, int srid)
Definition: Utils.cpp:55
TEEDITEXPORT double GetDistance(const te::gm::Coord2D &c1, const te::gm::Coord2D &c2)
Definition: Utils.cpp:295
Configuration flags for the TerraLib Edit module.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
TEEDITEXPORT void MoveGeometry(te::gm::Geometry *geom, const double &deltax, const double &deltay)
Definition: Utils.cpp:273
std::size_t m_pos
Definition: Utils.h:80
TEEDITEXPORT void AddVertex(std::vector< te::gm::LineString * > &lines, const double &x, const double &y, const te::gm::Envelope &env, int srid)
Definition: Utils.cpp:208
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
TEEDITEXPORT void TrySnap(te::gm::Coord2D &coord, int srid)
Definition: Utils.cpp:343
std::size_t m_line
Definition: Utils.h:79
TEEDITEXPORT void GetLines(te::gm::Geometry *geom, std::vector< te::gm::LineString * > &lines)
Definition: Utils.cpp:109
bool isValid() const
Definition: Utils.h:74
TEEDITEXPORT bool IsSpecialRingVertex(te::gm::LineString *l, const VertexIndex &index)
Definition: Utils.cpp:290
void makeInvalid()
Definition: Utils.h:68
It is a collection of other geometric objects.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
TEEDITEXPORT VertexIndex FindSegment(std::vector< te::gm::LineString * > &lines, const te::gm::Envelope &env, int srid)
Definition: Utils.cpp:237