examples/ogc-wcs/main.cpp
Go to the documentation of this file.
1 // STL
2 #include <cstdlib>
3 #include <string>
4 #include <iostream>
5 
6 // TerraLib
7 #include "../../src/terralib/ws/ogc/wcs/client/WCSClient.h"
8 #include "../../src/terralib/qt/af/ApplicationController.h"
9 #include "../../src/terralib/common/TerraLib.h"
10 
11 //QT
12 #include <QApplication>
13 
14 int main(int argc, char *argv[])
15 {
16 
18 
19  QApplication app(argc, argv);
20 
22 
23  // Directory where temporary WCS data will be stored.
24  std::string usrDataDir = te::qt::af::AppCtrlSingleton::getInstance().getUserDataDir().toUtf8().data();
25 
26  // WCS server URL.
27  std::string url = "http://demo.geo-solutions.it/geoserver/ows";
28 
29  // Version that will be used on WCS Requests.
30  std::string version = "2.0.1";
31 
32  {
33  std::cout << "GetCapabilities Example." << std::endl;
34 
35  te::ws::ogc::WCSClient client (usrDataDir, url, version);
36 
37  // Makes GetCapabilities Request.
38  client.updateCapabilities();
39 
41 
42  std::vector<std::string> coverages = capabilities.coverages;
43 
44  for (unsigned int i = 0; i < coverages.size(); ++i)
45  {
46  std::cout << "Coverage Name: " << coverages[i] << std::endl;
47  }
48  }
49 
50  {
51  std::cout << "DescribeCoverage Example." << std::endl;
52 
53  te::ws::ogc::WCSClient client (usrDataDir, url, version);
54 
55  // Coverage name that could be retrieved on GetCapabilities.
56  std::string coverageName = "nurc__mosaic";
57 
58  te::ws::ogc::wcs::CoverageDescription description = client.describeCoverage(coverageName);
59 
60  std::cout << "CoverageId: " << description.coverageId << std::endl;
61 
62  te::ws::ogc::wcs::EnvelopeWithTimePeriod boundedBy = description.envelope;
63 
64  std::cout << "--- boundedBy attributes ---" << std::endl;
65  std::cout << "Lower Corner X: " << boundedBy.lowerCorner_X << std::endl;
66  std::cout << "Lower Corner Y: " << boundedBy.lowerCorner_Y << std::endl;
67  std::cout << "Upper Corner X: " << boundedBy.upperCorner_X << std::endl;
68  std::cout << "Upper Corner Y: " << boundedBy.upperCorner_Y << std::endl;
69 
70  std::cout << "SRS Name: " << boundedBy.srsName << std::endl;
71  std::cout << "SRS Dimension: " << boundedBy.srsDimension << std::endl;
72  std::cout << "--- boundedBy attributes ---" << std::endl;
73 
74  std::vector<std::string> rangeTypes = description.fieldNames;
75 
76 
77  std::cout << "--- rangeTypes ---" << std::endl;
78  for (unsigned int i = 0; i < rangeTypes.size(); ++i)
79  {
80  std::cout << "Field Name: " << rangeTypes[i] << std::endl;
81  }
82  std::cout << "--- rangeTypes ---" << std::endl;
83  }
84 
85  {
86  std::cout << "GetCoverage Example." << std::endl;
87 
88  te::ws::ogc::WCSClient client (usrDataDir, url, version);
89 
90  // Coverage ID that could be retrieved on DescribeCoverage.
91  std::string coverageId = "nurc__mosaic";
92 
93  // Simple image request by id.
95  request.coverageID = coverageId;
96 
97  std::string coverageDiskPath = client.getCoverage(request);
98 
99  std::cout << "Path to Requested Image: " << coverageDiskPath << std::endl;
100  }
101 
103 
104  return EXIT_SUCCESS;
105 }
int main(int argc, char *argv[])
te::ws::ogc::wcs::CoverageDescription describeCoverage(const std::string coverage)
Method to get the information about a coverage in the WCS server.
Definition: WCSClient.cpp:122
void updateCapabilities()
Method to get the capabilities from a WCS server and store in m_capabilities member.
Definition: WCSClient.cpp:92
void finalize()
It finalizes the TerraLib Platform.
static TerraLib & getInstance()
It returns a reference to the singleton instance.
te::da::DataSourceCapabilities capabilities
A struct to set the parameters of requested coverage.
A class to retrieve information and data from a Web Coverage Service.
Definition: WCSClient.h:58
void initialize()
It initializes the TerraLib Platform.
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.
Definition: WCSClient.cpp:178
const te::ws::ogc::wcs::Capabilities & getCapabilities() const
Return the m_capabilities member.
Definition: WCSClient.cpp:263