27 #include "../common/Exception.h"
28 #include "../common/STLUtils.h"
29 #include "../common/Translator.h"
30 #include "../dataaccess/dataset/DataSet.h"
35 #include <boost/format.hpp>
50 SnapStrategies::iterator it = m_snapStrategies.find(
"vertex");
52 assert(it != m_snapStrategies.end());
54 Snap* snap = it->second(source, srid);
57 m_snaps[source] = snap;
62 Snap* snap = getSnap(source);
67 SnapStrategies::iterator it = m_snapStrategies.find(
"vertex");
69 assert(it != m_snapStrategies.end());
71 snap = it->second(source, srid);
77 m_snaps[source] = snap;
85 std::map<std::string, Snap*>::iterator it = m_snaps.find(source);
87 if(it == m_snaps.end())
101 std::map<std::string, Snap*>::const_iterator it = m_snaps.find(source);
103 if(it == m_snaps.end())
111 Snap* snap = getSnap(source);
125 std::map<std::string, Snap*>::const_iterator it;
126 for(it = m_snaps.begin(); it != m_snaps.end(); ++it)
128 if(it->second->search(coord, result))
136 const double& urx,
const double& ury,
137 const std::size_t& width,
const std::size_t& height)
139 std::map<std::string, Snap*>::const_iterator it;
140 for(it = m_snaps.begin(); it != m_snaps.end(); ++it)
141 it->second->setWorld(llx, lly, urx, ury, width, height);
146 SnapStrategies::iterator it = m_snapStrategies.find(name);
148 if(it != m_snapStrategies.end())
149 throw te::common::Exception((boost::format(
TE_TR(
"There is already a snap strategy registered with the given key %1%.")) % name).str());
151 m_snapStrategies[name] = builder;
This class implements geometry snap concept.
This class implements geometry snap concept.
bool hasSnap(const std::string &source) const
std::map< std::string, Snap * > m_snaps
void buildSnap(const std::string &source, int srid, te::da::DataSet *dataset)
An utility struct for representing 2D coordinates.
#define TE_TR(message)
It marks a string in order to get translated.
void setWorld(const double &llx, const double &lly, const double &urx, const double &ury, const std::size_t &width, const std::size_t &height)
void removeSnap(const std::string &source)
bool search(const te::gm::Coord2D &coord, int srid, te::gm::Coord2D &result)
void createSnap(const std::string &source, int srid)
void build(te::da::DataSet *dataset)
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
This is a singleton for managing geometries snap.
A dataset is the unit of information manipulated by the data access module of TerraLib.
void reg(const std::string &name, const SnapStrategyFnctType &strategy)
~SnapManager()
Singleton destructor.
Snap * getSnap(const std::string &source) const
SnapManager()
It initializes the singleton instance of the snap manager.
void clear(const std::string &source)
boost::function< Snap *(const std::string &source, int srid)> SnapStrategyFnctType
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
const std::map< std::string, Snap * > & getSnaps() const