4 #include "../../../../core/filesystem/FileSystem.h" 5 #include "../../../../core/translator/Translator.h" 6 #include "../../../core/CurlWrapper.h" 7 #include "../../../core/Utils.h" 8 #include "../../../core/Exception.h" 13 #include <boost/filesystem.hpp> 14 #include <boost/lexical_cast.hpp> 46 size_t endsWith = query.rfind(
"&");
48 if (endsWith != (query.size() - 1))
53 baseUrl = baseUrl + query;
71 url = url +
"SERVICE=WMS" +
"&VERSION=" +
m_version +
"&REQUEST=GetCapabilities";
73 m_curl->setTaskMessage(
TE_TR(
"Getting Capabilities"));
90 if (m_version ==
"1.3.0")
96 else if (m_version ==
"1.1.1")
128 m_curl->get(wmsRequest, buffer);
131 response.
m_size =
static_cast<int>(buffer.size());
158 m_curl->get(wmsRequest, buffer);
170 m_curl->downloadFile(url, path);
177 m_curl.reset(curlWrapper);
203 url = url +
"SERVICE=WMS" +
"&VERSION=" +
m_version +
"&REQUEST=GetMap";
209 for(
size_t i = 0; i < request.
m_layers.size(); i++)
213 if(i != request.
m_layers.size() - 1)
224 for(
size_t i = 0; i < request.
m_styles.size(); i++)
228 if(i != request.
m_styles.size() - 1)
235 if(!request.
m_srs.empty())
237 url +=
"&CRS=" + request.
m_srs;
267 url +=
"&WIDTH=" + boost::lexical_cast<std::string>(request.
m_width);
268 url +=
"&HEIGHT=" + boost::lexical_cast<std::string>(request.
m_height);
270 url +=
"&FORMAT=" + request.
m_format;
274 url +=
"&TRANSPARENT=TRUE";
282 if(!request.
m_time.empty())
284 url +=
"&TIME=" + request.
m_time;
296 url = url +
"SERVICE=WMS" +
"&VERSION=" +
m_version +
"&REQUEST=GetMap";
302 for(
size_t i = 0; i < request.
m_layers.size(); i++)
306 if(i != request.
m_layers.size() - 1)
317 for(
size_t i = 0; i < request.
m_styles.size(); i++)
321 if(i != request.
m_styles.size() - 1)
328 if(!request.
m_srs.empty())
330 url +=
"&SRS=" + request.
m_srs;
343 url +=
"&WIDTH=" + boost::lexical_cast<std::string>(request.
m_width);
344 url +=
"&HEIGHT=" + boost::lexical_cast<std::string>(request.
m_height);
346 url +=
"&FORMAT=" + request.
m_format;
350 url +=
"&TRANSPARENT=TRUE";
358 if(!request.
m_time.empty())
360 url +=
"&TIME=" + request.
m_time;
388 url = url +
"SERVICE=WMS" +
"&VERSION=" +
m_version +
"&REQUEST=GetFeatureInfo";
450 url +=
"&WIDTH=" + boost::lexical_cast<std::string>(request.
m_getMap.
m_width);
451 url +=
"&HEIGHT=" + boost::lexical_cast<std::string>(request.
m_getMap.
m_height);
455 url +=
"&QUERY_LAYERS=";
473 url +=
"&FEATURE_COUNT=" + boost::lexical_cast<std::string>(request.
m_featureCount);
475 url +=
"&i=" + boost::lexical_cast<std::string>(request.
m_i);
476 url +=
"&j=" + boost::lexical_cast<std::string>(request.
m_j);
491 url = url +
"SERVICE=WMS" +
"&VERSION=" +
m_version +
"&REQUEST=GetFeatureInfo";
538 url +=
"&WIDTH=" + boost::lexical_cast<std::string>(request.
m_getMap.
m_width);
539 url +=
"&HEIGHT=" + boost::lexical_cast<std::string>(request.
m_getMap.
m_height);
543 url +=
"&QUERY_LAYERS=";
561 url +=
"&FEATURE_COUNT=" + boost::lexical_cast<std::string>(request.
m_featureCount);
563 url +=
"&X=" + boost::lexical_cast<std::string>(request.
m_i);
564 url +=
"&Y=" + boost::lexical_cast<std::string>(request.
m_j);
std::string path() const
Retrieving the path.
void setCurlWrapper(te::ws::core::CurlWrapper *curlWrapper)
Sets the TerraLib CurlWrapper to be used internally.
std::string buildGetFeatureInfoURL(const te::ws::ogc::wms::WMSGetFeatureInfoRequest &request) const
std::vector< std::string > m_layers
const te::ws::ogc::wms::WMSGetMapResponse getMap(const te::ws::ogc::wms::WMSGetMapRequest &request) const
Return the WMSGetMapResponse member.
std::string scheme() const
Retrieving the scheme.
static bool exists(const std::string &path)
Checks if a given path in UTF-8 exists.
const te::ws::ogc::wms::WMSCapabilities & getCapabilities() const
Return the WMSCapabilities member.
static bool isDirectory(const std::string &path)
Checks if a given path in UTF-8 is a directory.
std::string build111GetFeatureInfoURL(const te::ws::ogc::wms::WMSGetFeatureInfoRequest &request) const
static bool createDirectories(const std::string &path)
Creates a directory for any element of path that does not exist.
std::vector< std::string > m_queryLayers
This XML Schema Document named xlinks xsd has been stored here based on the change request
std::unique_ptr< te::ws::ogc::wms::XMLParser > m_parser
WMSGetMapRequest m_getMap
te::ws::ogc::wms::WMSCapabilities m_capabilities
~WMSClient()
Default destructor.
std::string password() const
Retrieving the password information.
TEWSCOREEXPORT bool IsInvertedEPSG(const std::string &epsg)
This function gets true for EPSGs that has inverted axis-order. Otherwise false. This implementation ...
std::string makeFileRequest(const std::string url, const std::string fileName) const
Executes a request on a WMS server.
This is the abstraction factory for WMS XMLParser.
An abstraction to Lib Curl functions.
#define TE_TR(message)
It marks a string in order to get translated.
std::string query() const
Retrieving the query.
boost::error_info< struct tag_error_description, std::string > ErrorDescription
The base type for error report messages.
The Capability WMS 1.3.0 struct.
std::vector< std::string > m_styles
BoundingBox m_boundingBox
te::da::DataSourceCapabilities capabilities
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.
The WMSGetFeatureInfoRequest WMS 1.3.0 struct.
std::string port() const
Retrieving the port.
The WMSGetMapResponse WMS 1.3.0 struct.
The WMSGetMapResponse WMS 1.3.0 struct.
std::string host() const
Retrieving the host.
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...
void setCapabilities(const te::ws::ogc::wms::WMSCapabilities &capabilities)
std::string buildGetMapRequestURL(const te::ws::ogc::wms::WMSGetMapRequest &request) const
const std::string & uri() const
Retrieving the full URI.
static XMLParser * make(const std::string &factoryKey)
It creates an object with the appropriated factory.
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.
Base exception class for WS Core Runtime Library.
std::string build111GetMapRequestURL(const te::ws::ogc::wms::WMSGetMapRequest &request) const
A class for representing an Uniform Resource Identifier (URI).
std::string build130GetFeatureInfoURL(const te::ws::ogc::wms::WMSGetFeatureInfoRequest &request) const
Exception to be used when a XML has an unsupported version by WMSClient or WCSClient.
void updateCapabilities()
Method to get the capabilities from a WMS server and store in m_capabilities member.
std::shared_ptr< te::ws::core::CurlWrapper > m_curl
Exception to be used when a XML has an unsupported version by XMLParser.
std::string build130GetMapRequestURL(const te::ws::ogc::wms::WMSGetMapRequest &request) const
std::string user() const
Retrieving the user information.
std::string m_featureInfoContent
The WMSGetMapRequest WMS 1.3.0 struct.