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, bool loadAttributes = false);
86 
87  TEEDITEXPORT Feature* PickFeature(const te::map::AbstractLayer* layer, const te::gm::Envelope& env, int srid, bool loadAttributes = false);
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 
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
te::gm::Envelope
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
te::da::ObjectId
This class represents an unique id for a data set element.
Definition: ObjectId.h:48
te::edit::VertexIndex::setIndex
void setIndex(const std::size_t &line, const std::size_t &pos)
Definition: Utils.h:63
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::edit::RemoveVertex
TEEDITEXPORT void RemoveVertex(std::vector< te::gm::LineString * > &lines, const VertexIndex &index)
te::edit::GetCoordinates
TEEDITEXPORT void GetCoordinates(te::gm::Geometry *geom, std::vector< te::gm::Coord2D > &coords)
te::edit::Convert2LayerGeomType
TEEDITEXPORT te::gm::Geometry * Convert2LayerGeomType(const te::map::AbstractLayerPtr &layer, te::gm::Geometry *geom, int srid)
te::map::AbstractLayerPtr
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
Definition: AbstractLayer.h:626
te::edit::VertexIndex::makeInvalid
void makeInvalid()
Definition: Utils.h:69
te::gm::GeometryCollection
It is a collection of other geometric objects.
Definition: GeometryCollection.h:58
TEEDITEXPORT
#define TEEDITEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:68
te::edit::VertexIndex::isValid
bool isValid() const
Definition: Utils.h:75
te::gm::Polygon
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:51
te::edit::GetLines
TEEDITEXPORT void GetLines(te::gm::Geometry *geom, std::vector< te::gm::LineString * > &lines)
te::edit::VertexIndex::m_pos
std::size_t m_pos
Definition: Utils.h:81
te::edit::GenerateId
TEEDITEXPORT te::da::ObjectId * GenerateId()
te::edit::TrySnap
TEEDITEXPORT void TrySnap(te::gm::Coord2D &coord, int srid)
te::map::AbstractLayer
This is the base class for layers.
Definition: AbstractLayer.h:78
te::gm::LineString
LineString is a curve with linear interpolation between points.
Definition: LineString.h:65
te::edit::GetDistance
TEEDITEXPORT double GetDistance(const te::gm::Coord2D &c1, const te::gm::Coord2D &c2)
te::edit::FindSegment
TEEDITEXPORT VertexIndex FindSegment(std::vector< te::gm::LineString * > &lines, const te::gm::Envelope &env, int srid)
te::edit::IsSpecialRingVertex
TEEDITEXPORT bool IsSpecialRingVertex(te::gm::LineString *l, const VertexIndex &index)
te::gm::Coord2D
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:41
te::edit::Feature
Definition: Feature.h:58
te::edit::Rotate
TEEDITEXPORT void Rotate(te::gm::Geometry *geom, double angle)
Config.h
Proxy configuration file for TerraView (see terraview_config.h).
te::edit::VertexIndex
Definition: Utils.h:62
te::edit::VertexIndex::m_line
std::size_t m_line
Definition: Utils.h:80
te::gm::Geometry
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
te::edit::PickFeature
TEEDITEXPORT Feature * PickFeature(const te::map::AbstractLayerPtr &layer, const te::gm::Envelope &env, int srid, bool loadAttributes=false)
te::edit::MoveGeometry
TEEDITEXPORT void MoveGeometry(te::gm::Geometry *geom, const double &deltax, const double &deltay)
te::edit::AddVertex
TEEDITEXPORT void AddVertex(std::vector< te::gm::LineString * > &lines, const double &x, const double &y, const te::gm::Envelope &env, int srid)
te::edit::MoveVertex
TEEDITEXPORT void MoveVertex(std::vector< te::gm::LineString * > &lines, const VertexIndex &index, const double &x, const double &y)