All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Repository.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/Repository.h
22 
23  \brief This class represents a repository of geometries and features.
24 */
25 
26 #ifndef __TERRALIB_EDIT_INTERNAL_REPOSITORY_H
27 #define __TERRALIB_EDIT_INTERNAL_REPOSITORY_H
28 
29 // TerraLib
30 #include "../sam/rtree/Index.h"
31 #include "../srs/Config.h"
32 #include "Config.h"
33 
34 // STL
35 #include <vector>
36 #include <string>
37 
38 namespace te
39 {
40 // Forward declaration
41  namespace da
42  {
43  class ObjectId;
44  }
45 
46  namespace gm
47  {
48  class Envelope;
49  class Geometry;
50  }
51 
52  namespace edit
53  {
54 // Forward declaration
55  class Feature;
56 
57  /*!
58  \class Repository
59 
60  \brief This class represents a repository of geometries and features.
61  */
63  {
64  public:
65 
66  Repository(const std::string& source, int srid = TE_UNKNOWN_SRS);
67 
68  ~Repository();
69 
70  void add(te::gm::Geometry* geom);
71 
72  void add(te::da::ObjectId* id, te::gm::Geometry* geom);
73 
74  void add(Feature* f);
75 
76  void set(te::da::ObjectId* id, te::gm::Geometry* geom);
77 
78  void set(Feature* f);
79 
80  void remove(te::da::ObjectId* id);
81 
82  std::size_t getPosition(te::da::ObjectId* id);
83 
84  bool hasIdentifier(te::da::ObjectId* id);
85 
86  const std::string& getSource() const;
87 
88  const std::vector<Feature*>& getAllFeatures() const;
89 
90  std::vector<Feature*> getNewFeatures() const;
91 
92  std::vector<Feature*> getFeatures(const te::gm::Envelope& e, int srid) const;
93 
94  Feature* getFeature(const te::gm::Envelope& e, int srid) const;
95 
96  void clear();
97 
98  private:
99 
100  void set(const std::size_t& pos, Feature* f);
101 
102  void clearIndex();
103 
104  void buildIndex();
105 
106  void buildIndex(const std::size_t& pos, te::gm::Geometry* geom);
107 
108  private:
109 
110  std::string m_source; //!< The source of the features.
111  int m_srid; //!< The SRS of the features.
112  std::vector<Feature*> m_features; //!< The repository features.
113  te::sam::rtree::Index<std::size_t, 8> m_rtree; //!< Internal index used to retrieve geometries spatially.
114  };
115 
116  } // end namespace edit
117 } // end namespace te
118 
119 #endif // __TERRALIB_EDIT_INTERNAL_REPOSITORY_H
te::sam::rtree::Index< std::size_t, 8 > m_rtree
Internal index used to retrieve geometries spatially.
Definition: Repository.h:113
#define TEEDITEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:67
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:44
This class represents an unique id for a data set element.
Definition: ObjectId.h:47
int m_srid
The SRS of the features.
Definition: Repository.h:111
Configuration flags for the TerraLib Edit module.
std::vector< Feature * > m_features
The repository features.
Definition: Repository.h:112
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
std::string m_source
The source of the features.
Definition: Repository.h:110
This class represents a repository of geometries and features.
Definition: Repository.h:62