29 #include <curl/curl.h> 32 #include "../../../../core/filesystem/FileSystem.h" 33 #include "../../../../core/translator/Translator.h" 34 #include "../../../../core/uri/Utils.h" 35 #include "../../../core/CurlWrapper.h" 36 #include "../../../core/Exception.h" 44 #include <boost/filesystem.hpp> 74 size_t endsWith = query.rfind(
"&");
76 if (endsWith != (query.size() - 1))
81 baseUrl = baseUrl + query;
98 url = url +
"SERVICE=WCS" +
"&VERSION=" +
m_version +
"&REQUEST=GetCapabilities";
105 m_curl->setTaskMessage(
TE_TR(
"Getting Capabilities"));
136 url = url +
"SERVICE=WCS" +
"&VERSION=" +
m_version +
"&REQUEST=DescribeCoverage&CoverageID=" +
coverage;
143 m_curl->setTaskMessage(
TE_TR(
"Getting Coverage Description"));
167 std::string fileExtension;
169 if(format ==
"image/tiff")
171 fileExtension =
".tif";
174 return fileExtension;
180 std::string coveragePath;
186 url = url +
"SERVICE=WCS" +
"&VERSION=" +
m_version +
"&REQUEST=GetCoverage&COVERAGEID=" + coverageRequest.
coverageID;
188 if(!coverageRequest.
format.empty())
189 url +=
"&FORMAT=" + coverageRequest.
format;
192 url +=
"&MEDIATYPE=" + coverageRequest.
mediaType;
197 std::string y1 = envelope->lowerCorner_Y;
198 std::string x2 = envelope->upperCorner_X;
199 std::string y2 = envelope->upperCorner_Y;
201 std::string subset1, subset2;
203 if(!x1.empty() && !x2.empty())
204 subset1 =
"&SUBSET=" + envelope->firstLabel +
"(" + x1 + (!x1.empty() && !x2.empty()?
",":
"") + x2 +
")";
206 if(!y1.empty() && !y2.empty())
207 subset2 =
"&SUBSET=" + envelope->secondLabel +
"(" + y1 + (!y1.empty() && !y2.empty()?
",":
"") + y2 +
")";
209 url += subset1 + subset2;
211 if(!envelope->timeLabel.empty())
215 if(coverageRequest.
time.empty())
216 url += envelope->endPosition;
218 url += coverageRequest.
time;
225 url +=
"&" + parameter->first +
"=" + parameter->second;
235 std::string fileName = coverageRequest.
coverageID;
237 if(!coverageRequest.
time.empty())
238 fileName +=
"_" + coverageRequest.
time;
258 m_curl->downloadFile(url, path, taskProgress);
270 m_curl.reset(curlWrapper);
std::string path() const
Retrieving the path.
std::string scheme() const
Retrieving the scheme.
static bool exists(const std::string &path)
Checks if a given path in UTF-8 exists.
static bool isDirectory(const std::string &path)
Checks if a given path in UTF-8 is a directory.
static bool createDirectories(const std::string &path)
Creates a directory for any element of path that does not exist.
TECOREEXPORT std::string URIEncode(const std::string &srcUri)
Encodes an decoded URI. The algorithm implementation is based on http://www.codeguru.com/cpp/cpp/algorithms/strings/article.php/c12759/URI-Encoding-and-Decoding.htm.
CoverageDescription parseDescribeCoverage(const std::string &xmlPath)
std::string makeFileRequest(const std::string url, const std::string fileName, te::common::TaskProgress *taskProgress=0) const
Executes a request on a WCS server.
te::ws::ogc::wcs::Capabilities m_capabilities
This class can be used to inform the progress of a task.
te::ws::ogc::wcs::XMLParser m_parser
std::string password() const
Retrieving the password information.
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.
std::map< std::string, std::string > additionalParameters
te::ws::ogc::wcs::CoverageDescription describeCoverage(const std::string coverage)
Method to get the information about a coverage in the WCS server.
void updateCapabilities()
Method to get the capabilities from a WCS server and store in m_capabilities member.
~WCSClient()
Default destructor.
void setCurlWrapper(te::ws::core::CurlWrapper *curlWrapper)
Sets the TerraLib CurlWrapper to be used internally.
WCSClient(const std::string usrDataDir="", const std::string uri="", const std::string version="2.0.1")
Class constructor. It initializes the m_uri and m_version class members.
std::string port() const
Retrieving the port.
std::string host() const
Retrieving the host.
EnvelopeWithTimePeriod envelope
A struct to set the parameters of requested coverage.
const std::string & uri() const
Retrieving the full URI.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Base exception class for WS Core Runtime Library.
A class for representing an Uniform Resource Identifier (URI).
std::string getFileExtension(const std::string &format) const
std::string getCoverage(const te::ws::ogc::wcs::CoverageRequest coverageRequest, te::common::TaskProgress *taskProgress=0) const
Method to get the coverage from the WCS server.
Capabilities parseCapabilities(const std::string &xmlPath)
std::map< std::string, te::ws::ogc::wcs::CoverageDescription > m_descriptionMap
std::string lowerCorner_X
const te::ws::ogc::wcs::Capabilities & getCapabilities() const
Return the m_capabilities member.
std::string user() const
Retrieving the user information.
std::shared_ptr< te::ws::core::CurlWrapper > m_curl