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 "../color/RGBAColor.h"
31 #include "../maptools/AbstractLayer.h"
32 #include "Config.h"
33 
34 // STL
35 #include <string>
36 #include <vector>
37 
38 namespace te
39 {
40  // Forward declarations
41  namespace da
42  {
43  class ObjectId;
44  }
45 
46  namespace gm
47  {
48  struct Coord2D;
49  class Envelope;
50  class Geometry;
51  class GeometryCollection;
52  class LineString;
53  class Polygon;
54  }
55 
56  namespace edit
57  {
58  // Forward declaration
59  class Feature;
60 
61  struct VertexIndex
62  {
63  void setIndex(const std::size_t& line, const std::size_t& pos)
64  {
65  m_line = line;
66  m_pos = pos;
67  }
68 
69  void makeInvalid()
70  {
71  m_line = std::string::npos;
72  m_pos = std::string::npos;
73  }
74 
75  bool isValid() const
76  {
77  return m_line != std::string::npos && m_pos != std::string::npos;
78  }
79 
80  std::size_t m_line;
81  std::size_t m_pos;
82  };
83 
84  /*!
85  \enum FeatureType
86 
87  \brief Defines the feature type(Add, Update, Delete ...).
88  */
90  {
91  TO_BLOCKEDIT = 0, //!< block feature to edition.
92  TO_ADD = 1, //!< To be added.
93  TO_UPDATE = 2, //!< To be updated.
94  TO_DELETE = 3 //!< To be removed.
95  };
96 
97  /*!
98  \enum MouseEventEdition
99 
100  \brief Defines which mouse event will be used in the tool to complete an operation.
101  */
103  {
106  };
107 
108  TEEDITEXPORT Feature* PickFeature(const te::map::AbstractLayerPtr& layer, const te::gm::Envelope& env, int srid, FeatureType type);
109 
110  TEEDITEXPORT Feature* PickFeature(const te::map::AbstractLayer* layer, const te::gm::Envelope& env, int srid, FeatureType type);
111 
112  TEEDITEXPORT void GetLines(te::gm::Geometry* geom, std::vector<te::gm::LineString*>& lines);
113 
114  TEEDITEXPORT void GetLines(te::gm::GeometryCollection* gc, std::vector<te::gm::LineString*>& lines);
115 
116  TEEDITEXPORT void GetLines(te::gm::Polygon* p, std::vector<te::gm::LineString*>& lines);
117 
118  TEEDITEXPORT void GetLines(te::gm::LineString* l, std::vector<te::gm::LineString*>& lines);
119 
120  TEEDITEXPORT void MoveVertex(std::vector<te::gm::LineString*>& lines, const VertexIndex& index, const double& x, const double& y);
121 
122  TEEDITEXPORT void RemoveVertex(std::vector<te::gm::LineString*>& lines, const VertexIndex& index);
123 
124  TEEDITEXPORT void AddVertex(std::vector<te::gm::LineString*>& lines, const double& x, const double& y, const te::gm::Envelope& env, int srid);
125 
126  TEEDITEXPORT VertexIndex FindSegment(std::vector<te::gm::LineString*>& lines, const te::gm::Envelope& env, int srid);
127 
128  TEEDITEXPORT void MoveGeometry(te::gm::Geometry* geom, const double& deltax, const double& deltay);
129 
130  TEEDITEXPORT bool IsSpecialRingVertex(te::gm::LineString* l, const VertexIndex& index);
131 
132  TEEDITEXPORT double GetDistance(const te::gm::Coord2D& c1, const te::gm::Coord2D& c2);
133 
134  TEEDITEXPORT void GetCoordinates(te::gm::Geometry* geom, std::vector<te::gm::Coord2D>& coords);
135 
136  TEEDITEXPORT void TrySnap(te::gm::Coord2D& coord, int srid);
137 
139 
141 
142  } // end namespace edit
143 } // end namespace te
144 
145 #endif // __TERRALIB_EDIT_INTERNAL_UTILS_H
FeatureType
Defines the feature type(Add, Update, Delete ...).
Definition: Utils.h:89
TEEDITEXPORT te::gm::Geometry * ConvertGeomType(const te::map::AbstractLayerPtr &layer, te::gm::Geometry *geom, int srid)
TEEDITEXPORT void AddVertex(std::vector< te::gm::LineString * > &lines, const double &x, const double &y, const te::gm::Envelope &env, int srid)
This is the base class for layers.
Definition: AbstractLayer.h:76
To be updated.
Definition: Utils.h:93
#define TEEDITEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:68
TEEDITEXPORT te::da::ObjectId * GenerateId()
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
TEEDITEXPORT void RemoveVertex(std::vector< te::gm::LineString * > &lines, const VertexIndex &index)
TEEDITEXPORT void GetLines(te::gm::Geometry *geom, std::vector< te::gm::LineString * > &lines)
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:63
This class represents an unique id for a data set element.
Definition: ObjectId.h:47
To be added.
Definition: Utils.h:92
URI C++ Library.
To be removed.
Definition: Utils.h:94
TEEDITEXPORT void MoveVertex(std::vector< te::gm::LineString * > &lines, const VertexIndex &index, const double &x, const double &y)
Configuration flags for the TerraLib Edit module.
TEEDITEXPORT VertexIndex FindSegment(std::vector< te::gm::LineString * > &lines, const te::gm::Envelope &env, int srid)
TEEDITEXPORT Feature * PickFeature(const te::map::AbstractLayerPtr &layer, const te::gm::Envelope &env, int srid, FeatureType type)
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:74
TEEDITEXPORT void GetCoordinates(te::gm::Geometry *geom, std::vector< te::gm::Coord2D > &coords)
std::size_t m_pos
Definition: Utils.h:81
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
std::size_t m_line
Definition: Utils.h:80
bool isValid() const
Definition: Utils.h:75
TEEDITEXPORT void TrySnap(te::gm::Coord2D &coord, int srid)
TEEDITEXPORT void MoveGeometry(te::gm::Geometry *geom, const double &deltax, const double &deltay)
block feature to edition.
Definition: Utils.h:91
void makeInvalid()
Definition: Utils.h:69
It is a collection of other geometric objects.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
TEEDITEXPORT bool IsSpecialRingVertex(te::gm::LineString *l, const VertexIndex &index)
TEEDITEXPORT double GetDistance(const te::gm::Coord2D &c1, const te::gm::Coord2D &c2)
MouseEventEdition
Defines which mouse event will be used in the tool to complete an operation.
Definition: Utils.h:102