WMSClient.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/client/WCSClient.h
22 
23  \brief WS Client for OGC WMS
24 
25  \author Emerson Moraes
26 */
27 
28 #ifndef __TERRALIB_WS_OGC_WCS_CLIENT_WMS_H
29 #define __TERRALIB_WS_OGC_WCS_CLIENT_WMS_H
30 
31 // STL
32 #include <memory>
33 #include <vector>
34 #include <map>
35 #include <string>
36 
37 // TerraLib
38 #include "../../../../core/uri/URI.h"
39 #include "../../../core/CurlWrapper.h"
40 #include "Config.h"
41 #include "DataTypes.h"
42 #include "XMLParser.h"
43 
44 
45 namespace te
46 {
47  namespace ws
48  {
49  namespace ogc
50  {
51 
52  /*!
53  \class WMSClient
54 
55  \brief A class to retrieve information and data from a Web Map Service.
56  */
58  {
59  public:
60 
61  /*!
62  \brief Class constructor. It initializes the m_uri and m_version class members
63 
64  \param usrDataDir Directory to store used temporary XML and images from WMS server.
65  \param uri The adress of WMS server.
66  \param version The WMS version.
67  */
68  WMSClient(const std::string usrDataDir = "",const std::string uri = "", const std::string version = "1.3.0");
69 
70  /*!
71  \brief Default destructor.
72  */
73  ~WMSClient();
74 
75  /*!
76  \brief Method to get the capabilities from a WMS server and store in m_capabilities member
77 
78  To access the information contained in the m_capabilities, use the getCapabilities() method.
79 
80  */
81  void updateCapabilities();
82 
83  /*!
84  \brief Return the WMSCapabilities member.
85 
86  The WMSCapabilities will be empty until the updateCapabilities() method its called.
87 
88  \return Returns the WMSCapabilities member.
89  */
90  const te::ws::ogc::wms::WMSCapabilities& getCapabilities() const;
91 
92  void setCapabilities(const te::ws::ogc::wms::WMSCapabilities& capabilities);
93 
94  /*!
95  \brief Return the WMSGetMapResponse member.
96 
97  Make the GetMapRequest and return the server answer as a WMSGetMapResponse.
98 
99  \return Returns a path to a file
100  */
102 
103  /*!
104  \brief It execute a WMS GetMap and save the result image on disk.
105  The request will be based on WMSGetMapRequest setted to this WMSLayer.
106 
107  \return std::string with saved image path.
108  */
109  const std::string saveGetMap(const te::ws::ogc::wms::WMSGetMapRequest &request, const std::string& filename);
110 
111  /*!
112  \brief It execute a WMS GetFeatureInfo and returns a WMSGetFeatureInfoResponse with the result.
113 
114  \return a WMSGetFeatureInfoResponse with server response.
115  */
117 
118  /*!
119  \brief Executes a request on a WMS server
120 
121  \param url The complete url of request
122 
123  \return Returns a path to a file
124  */
125  std::string makeFileRequest(const std::string url, const std::string fileName) const;
126 
127  /*!
128  \brief Executes a request on a WMS server
129 
130  \param url The complete url of request
131 
132  \return Returns the buffer with the content of the server response
133  */
134  std::string makeRequest(const std::string url) const;
135 
136 
137  /*!
138  * \brief Sets the TerraLib CurlWrapper to be used internally.
139  *
140  * By default it is an instance of te::ws::core::CurlWrapper class.
141  *
142  * \param curlWrapper Wrapper to be used.
143  */
144  void setCurlWrapper(te::ws::core::CurlWrapper* curlWrapper);
145 
146  private:
147 
148  std::string buildGetMapRequestURL(const te::ws::ogc::wms::WMSGetMapRequest &request) const;
149 
150  std::string build130GetMapRequestURL(const te::ws::ogc::wms::WMSGetMapRequest &request) const;
151 
152  std::string build111GetMapRequestURL(const te::ws::ogc::wms::WMSGetMapRequest &request) const;
153 
154  std::string buildGetFeatureInfoURL(const te::ws::ogc::wms::WMSGetFeatureInfoRequest& request) const;
155 
156  std::string build130GetFeatureInfoURL(const te::ws::ogc::wms::WMSGetFeatureInfoRequest& request) const;
157 
158  std::string build111GetFeatureInfoURL(const te::ws::ogc::wms::WMSGetFeatureInfoRequest& request) const;
159 
160  private:
161  std::string m_version;
162  std::string m_dataDir;
165  std::shared_ptr<te::ws::core::CurlWrapper> m_curl;
166  std::unique_ptr<te::ws::ogc::wms::XMLParser> m_parser;
167 
168  };
169  }
170  }
171 }
172 
173 #endif //__TERRALIB_WS_OGC_WCS_CLIENT_WMS_H
#define TEOGCWMSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:111
std::unique_ptr< te::ws::ogc::wms::XMLParser > m_parser
Definition: WMSClient.h:166
te::ws::ogc::wms::WMSCapabilities m_capabilities
Definition: WMSClient.h:164
te::core::URI m_uri
Definition: WMSClient.h:163
An abstraction to Lib Curl functions.
Definition: CurlWrapper.h:61
std::string m_version
Definition: WMSClient.h:161
The Capability WMS 1.3.0 struct.
Definition: DataTypes.h:275
te::da::DataSourceCapabilities capabilities
Configuration flags for the Terrralib WS OGC WMS module.
TerraLib.
std::string m_dataDir
Definition: WMSClient.h:162
The WMSGetFeatureInfoRequest WMS 1.3.0 struct.
Definition: DataTypes.h:329
The WMSGetMapResponse WMS 1.3.0 struct.
Definition: DataTypes.h:352
The WMSGetMapResponse WMS 1.3.0 struct.
Definition: DataTypes.h:316
A class to store the proxy information that must be used to access data located in URIs...
Definition: URI.h:49
Specifies containers for WMS data types.
std::shared_ptr< te::ws::core::CurlWrapper > m_curl
Definition: WMSClient.h:165
A class to retrieve information and data from a Web Map Service.
Definition: WMSClient.h:57
The WMSGetMapRequest WMS 1.3.0 struct.
Definition: DataTypes.h:286