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  */
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  */
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  */
91 
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  */
145 
146  //!< Checks if we have access to the current URI
147  bool isAccessible();
148 
149  private:
150 
152 
154 
156 
158 
160 
162 
163  private:
164  std::string m_version;
165  std::string m_dataDir;
168  std::shared_ptr<te::ws::core::CurlWrapper> m_curl;
169  std::unique_ptr<te::ws::ogc::wms::XMLParser> m_parser;
170 
171  };
172  }
173  }
174 }
175 
176 #endif //__TERRALIB_WS_OGC_WCS_CLIENT_WMS_H
te::da::DataSourceCapabilities capabilities
A class to store the proxy information that must be used to access data located in URIs.
Definition: URI.h:50
An abstraction to Lib Curl functions.
Definition: CurlWrapper.h:62
A class to retrieve information and data from a Web Map Service.
Definition: WMSClient.h:58
te::ws::ogc::wms::WMSCapabilities m_capabilities
Definition: WMSClient.h:167
te::core::URI m_uri
Definition: WMSClient.h:166
WMSClient(const std::string &usrDataDir="", const std::string &uri="", const std::string &version="1.3.0")
Class constructor. It initializes the m_uri and m_version class members.
void setCurlWrapper(te::ws::core::CurlWrapper *curlWrapper)
Sets the TerraLib CurlWrapper to be used internally.
void updateCapabilities()
Method to get the capabilities from a WMS server and store in m_capabilities member.
const std::string saveGetMap(const te::ws::ogc::wms::WMSGetMapRequest &request, const std::string &filename)
It execute a WMS GetMap and save the result image on disk. The request will be based on WMSGetMapRequ...
~WMSClient()
Default destructor.
std::unique_ptr< te::ws::ogc::wms::XMLParser > m_parser
Definition: WMSClient.h:169
void setCapabilities(const te::ws::ogc::wms::WMSCapabilities &capabilities)
std::shared_ptr< te::ws::core::CurlWrapper > m_curl
Definition: WMSClient.h:168
const te::ws::ogc::wms::WMSCapabilities & getCapabilities() const
Return the WMSCapabilities member.
std::string buildGetMapRequestURL(const te::ws::ogc::wms::WMSGetMapRequest &request) const
const te::ws::ogc::wms::WMSGetMapResponse getMap(const te::ws::ogc::wms::WMSGetMapRequest &request) const
Return the WMSGetMapResponse member.
const te::ws::ogc::wms::WMSGetFeatureInfoResponse getFeatureInfo(const te::ws::ogc::wms::WMSGetFeatureInfoRequest &request) const
It execute a WMS GetFeatureInfo and returns a WMSGetFeatureInfoResponse with the result.
std::string makeFileRequest(const std::string &url, const std::string &fileName) const
Executes a request on a WMS server.
std::string m_dataDir
Definition: WMSClient.h:165
std::string build130GetMapRequestURL(const te::ws::ogc::wms::WMSGetMapRequest &request) const
std::string build111GetMapRequestURL(const te::ws::ogc::wms::WMSGetMapRequest &request) const
std::string m_version
Definition: WMSClient.h:164
std::string buildGetFeatureInfoURL(const te::ws::ogc::wms::WMSGetFeatureInfoRequest &request) const
std::string build111GetFeatureInfoURL(const te::ws::ogc::wms::WMSGetFeatureInfoRequest &request) const
std::string makeRequest(const std::string &url) const
Executes a request on a WMS server.
std::string build130GetFeatureInfoURL(const te::ws::ogc::wms::WMSGetFeatureInfoRequest &request) const
TerraLib.
The Capability WMS 1.3.0 struct.
Definition: DataTypes.h:276
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 TEOGCWMSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:111
Proxy configuration file for TerraView (see terraview_config.h).
Specifies containers for WMS data types.