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  TEEDITEXPORT Feature* PickFeature(const te::map::AbstractLayerPtr& layer, const te::gm::Envelope& env, int srid);
86 
87  TEEDITEXPORT Feature* PickFeature(const te::map::AbstractLayer* layer, const te::gm::Envelope& env, int srid);
88 
89  TEEDITEXPORT void GetLines(te::gm::Geometry* geom, std::vector<te::gm::LineString*>& lines);
90 
91  TEEDITEXPORT void GetLines(te::gm::GeometryCollection* gc, std::vector<te::gm::LineString*>& lines);
92 
93  TEEDITEXPORT void GetLines(te::gm::Polygon* p, std::vector<te::gm::LineString*>& lines);
94 
95  TEEDITEXPORT void GetLines(te::gm::LineString* l, std::vector<te::gm::LineString*>& lines);
96 
97  TEEDITEXPORT void MoveVertex(std::vector<te::gm::LineString*>& lines, const VertexIndex& index, const double& x, const double& y);
98 
99  TEEDITEXPORT void RemoveVertex(std::vector<te::gm::LineString*>& lines, const VertexIndex& index);
100 
101  TEEDITEXPORT void AddVertex(std::vector<te::gm::LineString*>& lines, const double& x, const double& y, const te::gm::Envelope& env, int srid);
102 
103  TEEDITEXPORT VertexIndex FindSegment(std::vector<te::gm::LineString*>& lines, const te::gm::Envelope& env, int srid);
104 
105  TEEDITEXPORT void MoveGeometry(te::gm::Geometry* geom, const double& deltax, const double& deltay);
106 
108 
109  TEEDITEXPORT double GetDistance(const te::gm::Coord2D& c1, const te::gm::Coord2D& c2);
110 
111  TEEDITEXPORT void GetCoordinates(te::gm::Geometry* geom, std::vector<te::gm::Coord2D>& coords);
112 
113  TEEDITEXPORT void TrySnap(te::gm::Coord2D& coord, int srid);
114 
116 
118 
119  TEEDITEXPORT void Rotate(te::gm::Geometry* geom, double angle);
120 
121  } // end namespace edit
122 } // end namespace te
123 
124 #endif // __TERRALIB_EDIT_INTERNAL_UTILS_H
TEEDITEXPORT void GetLines(te::gm::LineString *l, std::vector< te::gm::LineString * > &lines)
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:77
TEGEOMEXPORT bool Rotate(te::gm::Coord2D pr, te::gm::LineString *l, double angle, te::gm::LineString *lOut)
#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 te::gm::Geometry * Convert2LayerGeomType(const te::map::AbstractLayerPtr &layer, te::gm::Geometry *geom, int srid)
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
TEEDITEXPORT Feature * PickFeature(const te::map::AbstractLayer *layer, const te::gm::Envelope &env, int srid)
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
URI C++ Library.
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)
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:75
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)
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)