Snap.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/Snap.h
22 
23  \brief This class implements geometry snap concept.
24 */
25 
26 #ifndef __TERRALIB_EDIT_INTERNAL_SNAP_H
27 #define __TERRALIB_EDIT_INTERNAL_SNAP_H
28 
29 // TerraLib
30 #include "../srs/Config.h"
31 #include "Config.h"
32 
33 // STL
34 #include <string>
35 
36 namespace te
37 {
38 // Forward declarations
39  namespace da
40  {
41  class DataSet;
42  }
43 
44  namespace gm
45  {
46  struct Coord2D;
47  class Envelope;
48  class Geometry;
49  }
50 
51  namespace map
52  {
54  }
55 
56  namespace edit
57  {
58  /*!
59  \class Snap
60 
61  \brief This class implements geometry snap concept.
62  */
64  {
65  public:
66 
67  Snap(const std::string& source, int srid = TE_UNKNOWN_SRS);
68 
69  virtual ~Snap();
70 
71  std::string getSource() const;
72 
73  int getSRID() const;
74 
75  std::size_t getNGeometries() const;
76 
77  std::size_t getMaxGeometries() const;
78 
79  double getTolerance() const;
80 
81  void setTolerance(const double& t);
82 
83  void setWorld(const double& llx, const double& lly,
84  const double& urx, const double& ury,
85  const std::size_t& width, const std::size_t& height);
86 
87  void build(te::da::DataSet* dataset);
88 
89  void add(te::da::DataSet* dataset);
90 
91  virtual bool search(const te::gm::Coord2D& coord, te::gm::Coord2D& result);
92 
93  virtual void add(te::gm::Geometry* geom) = 0;
94 
95  virtual void clear() = 0;
96 
97  virtual std::string getName() const = 0;
98 
99  virtual std::string getDescription() const = 0;
100 
101  protected:
102 
103  te::gm::Envelope getSearchEnvelope(const te::gm::Coord2D& coord) const;
104 
105  virtual bool search(const te::gm::Envelope& e, te::gm::Coord2D& result) = 0;
106 
107  protected:
108 
109  std::string m_source; //!< The source of the geometries.
110  int m_srid; //!< The SRS of the geometries.
111  std::size_t m_nGeometries; //!< The current number of geometries added to the snap.
112  std::size_t m_maxGeometries; //!< The maximum number of geometries that can be added to the snap. If 0, there will be not limit.
113  double m_tolerance; //!< The tolerance that will be used by the snap. For while, the unit is screen pixels.
114  te::map::WorldDeviceTransformer* m_transformer; //!< For transforming from device coordinate to world coordinate and vice-versa.
115  };
116 
117  } // end namespace edit
118 } // end namespace te
119 
120 #endif // __TERRALIB_EDIT_INTERNAL_SNAP_H
This class implements geometry snap concept.
Definition: Snap.h:63
#define TEEDITEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:64
double m_tolerance
The tolerance that will be used by the snap. For while, the unit is screen pixels.
Definition: Snap.h:113
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
This class implements the logic for transforming from device coordinate to world coordinate and vice-...
std::size_t m_nGeometries
The current number of geometries added to the snap.
Definition: Snap.h:111
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
Definition: Config.h:41
URI C++ Library.
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
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
std::string m_source
The source of the geometries.
Definition: Snap.h:109
te::map::WorldDeviceTransformer * m_transformer
For transforming from device coordinate to world coordinate and vice-versa.
Definition: Snap.h:114
int m_srid
The SRS of the geometries.
Definition: Snap.h:110
std::size_t m_maxGeometries
The maximum number of geometries that can be added to the snap. If 0, there will be not limit...
Definition: Snap.h:112