WMSLayer.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/ws/ogc/wms/WMSLayer.h
22 
23  \brief A layer with reference to a WMS Layer.
24 */
25 
26 #ifndef __TERRALIB_WS_OGC_WMSLAYER_H
27 #define __TERRALIB_WS_OGC_WMSLAYER_H
28 
29 //TerraLib
30 
31 #include "../../../../maptools/AbstractLayer.h"
32 #include "Config.h"
33 
34 #include "../client/DataTypes.h"
35 #include "../../../../raster/Raster.h"
36 #include <memory>
37 
38 namespace te
39 {
40  namespace ws
41  {
42  namespace ogc
43  {
44  namespace wms
45  {
46 
47  /*!
48  \class WMSLayer
49 
50  \brief A layer with reference to a WMS Layer.
51  */
53  {
54 
55  public:
56 
57  /*!
58  \brief It initializes a new layer.
59 
60  \param parent The parent layer (NULL if it has no parent).
61  */
63 
64  /*!
65  \brief It initializes a new layer.
66 
67  \param id The layer id.
68  \param parent The parent layer (NULL if it has no parent).
69  */
70  WMSLayer(const std::string& id, te::map::AbstractLayer* parent = 0);
71 
72  /*!
73  \brief It initializes a new Layer.
74 
75  \param id The layer id.
76  \param title The title is a brief description about the layer.
77  \param parent The parent layer (NULL if it has no parent).
78  */
79  WMSLayer(const std::string& id, const std::string& title, te::map::AbstractLayer* parent = 0);
80 
81  /*! \brief Destructor. */
83 
85 
86  virtual std::unique_ptr<te::map::LayerSchema> getSchema() const;
87 
88  std::unique_ptr<te::da::DataSet> getData(te::common::TraverseType travType = te::common::FORWARDONLY,
89  const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
90 
91  std::unique_ptr<te::da::DataSet> getData(const std::string& propertyName,
92  const te::gm::Envelope* e,
95  const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
96 
97  std::unique_ptr<te::da::DataSet> getData(const std::string& propertyName,
98  const te::gm::Geometry* g,
101  const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
102 
103  std::unique_ptr<te::da::DataSet> getData(te::da::Expression* restriction,
105  const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
106 
107  std::unique_ptr<te::da::DataSet> getData(const te::da::ObjectIdSet* oids,
109  const te::common::AccessPolicy accessPolicy = te::common::RAccess) const;
110 
111  bool isValid() const;
112 
113  void draw(te::map::Canvas* canvas, const te::gm::Envelope& bbox, int srid, const double& scale, bool* cancel);
114 
115  const std::string& getType() const;
116 
117  const std::string& getDataSourceId() const;
118 
119  void setDataSourceId(const std::string& datadourceId);
120 
121  const std::string& getRendererType() const;
122 
123  void setRendererType(const std::string& rendererType);
124 
126 
128 
129  /*!
130  \brief It gets a WMS GetMap response with the image on a buffer.
131  The request will be based on WMSGetMapRequest setted to this WMSLayer.
132 
133  \return WMSGetMapResponse with the image, size and format.
134  */
136 
137  /*!
138  \brief It execute a WMS GetMap and save the result image on disk.
139  The request will be based on WMSGetMapRequest setted to this WMSLayer.
140 
141  \return std::string with saved image path.
142  */
143  const std::string saveGetMap(const std::string& filename) const;
144 
146 
147  virtual const te::gm::Envelope& getExtent() const;
148 
149  virtual int getSRID() const;
150 
151  private:
152 
153  void setCurrentSRID(const int& srid);
154 
155  private:
156 
157  std::string m_datasourceId; //!< The DataSource associated to this layer.
158  std::string m_rendererType; //!< A pointer to the internal renderer used to paint this layer.
160  int m_currentSRID; //!< SRID used when the layer is drawn.
161  te::gm::Envelope m_currentExtent; //!< Layer extent in current SRID.
162 
163  mutable std::unique_ptr<te::map::LayerSchema> m_schema; //!< The WMS layer schema.
164 
165  static const std::string sm_type; //!< A static data member used in the implementation of getType method.
166  };
167 
168  typedef boost::intrusive_ptr<WMSLayer> WMSLayerPtr;
169  }
170  }
171  }
172 }
173 
174 #endif // __TERRALIB_WS_OGC_WMSLAYER_H
This is an abstract class that models a query expression.
Definition: Expression.h:48
This class represents a set of unique ids created in the same context. i.e. from the same data set.
Definition: ObjectIdSet.h:56
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
This is the base class for layers.
Definition: AbstractLayer.h:78
A canvas is an abstraction of a drawing area.
Definition: Canvas.h:93
A layer with reference to a WMS Layer.
Definition: WMSLayer.h:53
std::string m_datasourceId
The DataSource associated to this layer.
Definition: WMSLayer.h:157
const te::ws::ogc::wms::WMSGetFeatureInfoResponse getFeatureInfo(const te::ws::ogc::wms::WMSGetFeatureInfoRequest &request)
const std::string & getDataSourceId() const
const std::string saveGetMap(const std::string &filename) const
It execute a WMS GetMap and save the result image on disk. The request will be based on WMSGetMapRequ...
static const std::string sm_type
A static data member used in the implementation of getType method.
Definition: WMSLayer.h:165
te::ws::ogc::wms::WMSGetMapRequest getRequest() const
std::unique_ptr< te::da::DataSet > getData(te::da::Expression *restriction, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess) const
It gets the dataset identified by the layer name using the given restriction.
void setCurrentSRID(const int &srid)
WMSLayer(const std::string &id, const std::string &title, te::map::AbstractLayer *parent=0)
It initializes a new Layer.
std::unique_ptr< te::da::DataSet > getData(te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess) const
It gets the dataset identified by the layer name.
te::ws::ogc::wms::WMSGetMapRequest m_getMapRequest
Definition: WMSLayer.h:159
void setDataSourceId(const std::string &datadourceId)
WMSLayer(te::map::AbstractLayer *parent=0)
It initializes a new layer.
const te::ws::ogc::wms::WMSGetMapResponse getMap() const
It gets a WMS GetMap response with the image on a buffer. The request will be based on WMSGetMapReque...
virtual const te::gm::Envelope & getExtent() const
It returns the Layer extent (or minimum bounding box).
int m_currentSRID
SRID used when the layer is drawn.
Definition: WMSLayer.h:160
std::string m_rendererType
A pointer to the internal renderer used to paint this layer.
Definition: WMSLayer.h:158
std::unique_ptr< te::da::DataSet > getData(const te::da::ObjectIdSet *oids, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess) const
It gets the dataset from the given set of objects identification.
void setGetMapRequest(const te::ws::ogc::wms::WMSGetMapRequest &getMapRequest)
void draw(te::map::Canvas *canvas, const te::gm::Envelope &bbox, int srid, const double &scale, bool *cancel)
It draws the layer geographic objects in the given canvas using the informed SRS.
bool isValid() const
It returns true if the layer can be used for instance to draw, otherwise, it returns false.
WMSLayer(const std::string &id, te::map::AbstractLayer *parent=0)
It initializes a new layer.
virtual int getSRID() const
It returns the Spatial Reference System ID associated to the Layer.
std::unique_ptr< te::map::LayerSchema > m_schema
The WMS layer schema.
Definition: WMSLayer.h:163
std::unique_ptr< te::da::DataSet > getData(const std::string &propertyName, const te::gm::Geometry *g, te::gm::SpatialRelation r, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess) const
It gets the dataset identified by the layer name using a spatial filter over the given geometric prop...
virtual std::unique_ptr< te::map::LayerSchema > getSchema() const
It returns the layer schema.
const std::string & getType() const
It returns the layer type.
void setRendererType(const std::string &rendererType)
std::unique_ptr< te::da::DataSet > getData(const std::string &propertyName, const te::gm::Envelope *e, te::gm::SpatialRelation r=te::gm::INTERSECTS, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess) const
It gets the dataset identified by the layer name using a spatial filter over the specified property.
te::gm::Envelope m_currentExtent
Layer extent in current SRID.
Definition: WMSLayer.h:161
const std::string & getRendererType() const
te::map::AbstractLayer * clone()
It returns a clone of the object.
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:54
@ FORWARDONLY
Definition: Enums.h:55
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:41
@ RAccess
Definition: Enums.h:43
SpatialRelation
Spatial relations between geometric objects.
Definition: Enums.h:128
@ INTERSECTS
Definition: Enums.h:130
boost::intrusive_ptr< WMSLayer > WMSLayerPtr
Definition: WMSLayer.h:168
TerraLib.
The WMSGetFeatureInfoRequest WMS 1.3.0 struct.
Definition: DataTypes.h:330
The WMSGetMapResponse WMS 1.3.0 struct.
Definition: DataTypes.h:353
The WMSGetMapRequest WMS 1.3.0 struct.
Definition: DataTypes.h:287
The WMSGetMapResponse WMS 1.3.0 struct.
Definition: DataTypes.h:317
#define TEOGCWMSDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:71
Proxy configuration file for TerraView (see terraview_config.h).