SnapManager.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/SnapManager.h
22 
23  \brief This is a singleton for managing geometries snap.
24 */
25 
26 #ifndef __TERRALIB_EDIT_INTERNAL_SNAPMANAGER_H
27 #define __TERRALIB_EDIT_INTERNAL_SNAPMANAGER_H
28 
29 // TerraLib
30 #include "../common/Singleton.h"
31 #include "Config.h"
32 
33 // Boost
34 #include <boost/function.hpp>
35 
36 // STL
37 #include <map>
38 #include <string>
39 #include <vector>
40 
41 namespace te
42 {
43 // Forward declarations
44  namespace da
45  {
46  class DataSet;
47  }
48 
49  namespace gm
50  {
51  struct Coord2D;
52  class Geometry;
53  }
54 
55  namespace edit
56  {
57 // Forward declaration
58  class Snap;
59 
60  /*!
61  \class SnapManager
62 
63  \brief This is a singleton for managing geometries snap.
64  */
65  class TEEDITEXPORT SnapManager : public te::common::Singleton<SnapManager>
66  {
67  friend class te::common::Singleton<SnapManager>;
68 
69  public:
70 
71  typedef boost::function<Snap* (const std::string& source, int srid)> SnapStrategyFnctType;
72  typedef std::map<std::string, SnapStrategyFnctType> SnapStrategies;
73 
74  bool hasSnap(const std::string& source) const;
75 
76  void createSnap(const std::string& source, int srid);
77 
78  void buildSnap(const std::string& source, int srid, te::da::DataSet* dataset);
79 
80  void removeSnap(const std::string& source);
81 
82  const std::map<std::string, Snap*>& getSnaps() const;
83 
84  Snap* getSnap(const std::string& source) const;
85 
86  void clear(const std::string& source);
87 
88  void clearAll();
89 
90  bool search(const te::gm::Coord2D& coord, int srid, te::gm::Coord2D& result);
91 
92  void setWorld(const double& llx, const double& lly,
93  const double& urx, const double& ury,
94  const std::size_t& width, const std::size_t& height);
95 
96  void reg(const std::string& name, const SnapStrategyFnctType& strategy);
97 
99 
100  protected:
101 
102  /*! \brief It initializes the singleton instance of the snap manager. */
104 
105  /*! \brief Singleton destructor. */
107 
108  private:
109 
111  std::map<std::string, Snap*> m_snaps;
112  };
113 
114  } // end namespace edit
115 } // end namespace te
116 
117 #endif // __TERRALIB_EDIT_INTERNAL_SNAPMANAGER_H
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::edit::SnapManager::SnapManager
SnapManager()
It initializes the singleton instance of the snap manager.
te::edit::Snap
This class implements geometry snap concept.
Definition: Snap.h:64
te::edit::SnapManager::setWorld
void setWorld(const double &llx, const double &lly, const double &urx, const double &ury, const std::size_t &width, const std::size_t &height)
te::edit::SnapManager::hasSnap
bool hasSnap(const std::string &source) const
te::edit::SnapManager::reg
void reg(const std::string &name, const SnapStrategyFnctType &strategy)
te::edit::SnapManager::~SnapManager
~SnapManager()
Singleton destructor.
te::edit::SnapManager::SnapStrategies
std::map< std::string, SnapStrategyFnctType > SnapStrategies
Definition: SnapManager.h:72
te::edit::SnapManager::clear
void clear(const std::string &source)
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::SnapManager::SnapStrategyFnctType
boost::function< Snap *(const std::string &source, int srid)> SnapStrategyFnctType
Definition: SnapManager.h:71
te::edit::SnapManager::m_snapStrategies
SnapStrategies m_snapStrategies
Definition: SnapManager.h:110
te::edit::SnapManager
This is a singleton for managing geometries snap.
Definition: SnapManager.h:66
te::edit::SnapManager::getSnaps
const std::map< std::string, Snap * > & getSnaps() const
te::common::Singleton
Template support for singleton pattern.
Definition: Singleton.h:101
te::edit::SnapManager::clearStrategies
void clearStrategies()
te::edit::SnapManager::getSnap
Snap * getSnap(const std::string &source) const
te::edit::SnapManager::removeSnap
void removeSnap(const std::string &source)
te::gm::Coord2D
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:41
te::edit::SnapManager::createSnap
void createSnap(const std::string &source, int srid)
te::da::DataSet
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:114
Config.h
Proxy configuration file for TerraView (see terraview_config.h).
te::edit::SnapManager::search
bool search(const te::gm::Coord2D &coord, int srid, te::gm::Coord2D &result)
te::edit::SnapManager::clearAll
void clearAll()
te::edit::SnapManager::m_snaps
std::map< std::string, Snap * > m_snaps
Definition: SnapManager.h:111
te::edit::SnapManager::buildSnap
void buildSnap(const std::string &source, int srid, te::da::DataSet *dataset)