SpatialQueryProcessor.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/dataaccess/query/SpatialQueryProcessor.h
22 
23  \brief A basic query processor for spatial restrictions.
24 */
25 
26 #ifndef __TERRALIB_DATAACCESS_INTERNAL_SPATIALQUERYPROCESSOR_H
27 #define __TERRALIB_DATAACCESS_INTERNAL_SPATIALQUERYPROCESSOR_H
28 
29 // TerraLib
30 #include "../../common/Enums.h"
31 #include "../../geometry/Envelope.h"
32 #include "../dataset/DataSet.h"
33 #include "../dataset/ObjectIdSet.h"
34 #include "../datasource/DataSource.h"
35 
36 // Boost
37 #include <boost/noncopyable.hpp>
38 
39 // STL
40 #include <memory>
41 #include <vector>
42 
43 namespace te
44 {
45  namespace da
46  {
47 // Forward declarations
48  class DataSetType;
49  class DataSourceTransactor;
50  class QueryCapabilities;
51  class Select;
52  struct SpatialRestriction;
53 
54  /*!
55  \class SpatialQueryProcessor
56 
57  \brief A basic query processor for spatial restrictions.
58  */
59  class TEDATAACCESSEXPORT SpatialQueryProcessor : public boost::noncopyable
60  {
61  public:
62 
63  /*! \brief Constructor. */
65 
66  /*! \brief Virtual destructor. */
67  virtual ~SpatialQueryProcessor();
68 
69  virtual std::auto_ptr<DataSet> getDataSet(const DataSourcePtr& ds, const Select& q,
71 
72  virtual std::auto_ptr<DataSet> getDataSet(DataSourceTransactor* t, const QueryCapabilities& capabilities,
73  const Select& q,
75  bool connected = false);
76 
77  virtual std::auto_ptr<ObjectIdSet> getOIDSet(const DataSourcePtr& ds, const Select& q);
78 
79  virtual std::auto_ptr<ObjectIdSet> getOIDSet(DataSourceTransactor* t, const QueryCapabilities& capabilities, const Select& q);
80 
81  protected:
82 
83  virtual std::auto_ptr<ObjectIdSet> getOIDSet(DataSourceTransactor* t, const Select& q);
84 
85  virtual ObjectIdSet* getOIDSet(DataSourceTransactor* t, Select& baseSelect, te::da::Expression* attrRestrictions,
86  SpatialRestriction* restriction, const DataSetType* type,
87  const std::vector<te::gm::Geometry*>& geomRestrictions);
88 
89  private:
90 
91  bool supportsSpatialTopologicOperatos(const QueryCapabilities& capabilities,
92  const std::vector<SpatialRestriction*>& restrictions) const;
93 
94  std::string getDataSetName(const Select& q) const;
95 
96  Expression* getAttrRestrictions(const Select& q) const;
97 
98  private:
99 
100  te::gm::Envelope* computeEnvelope(const std::vector<SpatialRestriction*>& restrictions) const;
101  };
102 
103  } // end namespace da
104 } // end namespace te
105 
106 #endif // __TERRALIB_DATAACCESS_INTERNAL_SPATIALQUERYPROCESSOR_H
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1435
A class that models the description of a dataset.
Definition: DataSetType.h:72
A basic query processor for spatial restrictions.
This is an abstract class that models a query expression.
Definition: Expression.h:47
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:53
A class that informs the query support of a given data source.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:55
te::da::DataSourceCapabilities capabilities
A struct that represents a spatial restriction.
URI C++ Library.
A DataSourceTransactor can be viewed as a connection to the data source for reading/writing things in...
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:97