27 #include "../common/Exception.h"
28 #include "../common/STLUtils.h"
29 #include "../common/Translator.h"
30 #include "../dataaccess/dataset/ObjectId.h"
31 #include "../datatype/SimpleData.h"
32 #include "../geometry/Coord2D.h"
33 #include "../geometry/Envelope.h"
34 #include "../geometry/Geometry.h"
35 #include "../geometry/Point.h"
36 #include "../geometry/Utils.h"
62 assert(!hasIdentifier(
id));
82 std::size_t pos = getPosition(f->
getId());
84 if(pos == std::string::npos)
86 m_features.push_back(f);
88 buildIndex(m_features.size() - 1, f->
getGeometry());
112 std::size_t pos = getPosition(f->
getId());
114 if(pos == std::string::npos)
125 std::size_t pos = getPosition(
id);
127 if(pos == std::string::npos)
131 delete m_features[pos];
134 m_features.erase(m_features.begin() + pos);
144 for(std::size_t i = 0; i < m_features.size(); ++i)
145 if(m_features[i]->isEquals(
id))
148 return std::string::npos;
153 return getPosition(
id) != std::string::npos;
168 std::vector<te::edit::Feature*> result;
170 for(std::size_t i = 0; i < m_features.size(); ++i)
187 std::vector<te::edit::Feature*> result;
190 std::vector<std::size_t> report;
191 m_rtree.search(e, report);
193 for(std::size_t i = 0; i < report.size(); ++i)
195 std::size_t pos = report[i];
197 assert(pos < m_features.size());
199 result.push_back(m_features[pos]);
207 std::vector<te::edit::Feature*> candidates = getFeatures(e, srid);
209 if(candidates.empty())
219 for(std::size_t i = 0; i < candidates.size(); ++i)
223 if(g->
contains(&point) || g->
crosses(geometryFromEnvelope.get()) || geometryFromEnvelope->contains(g))
224 return candidates[i];
240 assert(pos != std::string::npos);
242 assert(pos < m_features.size());
245 delete m_features[pos];
263 for(std::size_t i = 0; i < m_features.size(); ++i)
264 buildIndex(i, m_features[i]->getGeometry());
269 assert(pos != std::string::npos);
275 m_rtree.insert(mbr, pos);
void set(te::da::ObjectId *id, te::gm::Geometry *geom)
Feature * getFeature(const te::gm::Envelope &e, int srid) const
TEEDITEXPORT te::da::ObjectId * GenerateId()
const std::vector< Feature * > & getAllFeatures() const
std::vector< Feature * > getNewFeatures() const
te::da::ObjectId * getId() const
#define NEW_FEATURE_ID_SUFFIX
Repository(const std::string &source, int srid=TE_UNKNOWN_SRS)
te::gm::Geometry * getGeometry() const
An utility struct for representing 2D coordinates.
virtual bool contains(const Geometry *const rhs) const
It returns true if this geometry object spatially contains rhs geometry.
#define TE_TR(message)
It marks a string in order to get translated.
This class represents a geographic feature.
bool hasIdentifier(te::da::ObjectId *id)
virtual bool crosses(const Geometry *const rhs) const
It returns true if the geometry object spatially crosses rhs geometry.
Coord2D getCenter() const
It returns the rectangle's center coordinate.
A point with x and y coordinate values.
An Envelope defines a 2D rectangular region.
void add(te::gm::Geometry *geom)
void remove(te::da::ObjectId *id)
This class represents an unique id for a data set element.
This class represents a repository of geometries and features.
std::string getValueAsString() const
It gets the properties values used to uniquely identify a data set element as string.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
std::vector< Feature * > getFeatures(const te::gm::Envelope &e, int srid) const
std::size_t getPosition(te::da::ObjectId *id)
Utility functions for TerraLib Edit module.
const std::string & getSource() const
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 Envelope * getMBR() const
It returns the minimum bounding rectangle for the geometry in an internal representation.
bool isValid() const
It tells if the rectangle is valid or not.
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.