src/terralib/ws/ogc/wms/qt/WMSLayerSelector.cpp
Go to the documentation of this file.
1 #include "WMSLayerSelector.h"
2 
3 //TerraLib
4 #include "../../../core/Exception.h"
5 #include "../../../../core/translator/Translator.h"
6 #include "../../../../dataaccess/datasource/DataSource.h"
7 #include "../../../../dataaccess/datasource/DataSourceManager.h"
8 #include "../dataaccess/WMS2Layer.h"
10 
11 // STL
12 #include <algorithm>
13 #include <iterator>
14 #include <memory>
15 
17  Qt::WindowFlags /*f*/)
18 {
19 
20 }
21 
23 
24 void te::ws::ogc::wms::qt::WMSLayerSelector::set(const std::list<te::da::DataSourceInfoPtr> &datasources)
25 {
26  m_datasources = datasources;
27 }
28 
29 std::list<te::map::AbstractLayerPtr> te::ws::ogc::wms::qt::WMSLayerSelector::getLayers()
30 {
31  std::list<te::map::AbstractLayerPtr> layers;
32 
33  for(std::list<te::da::DataSourceInfoPtr>::iterator it = m_datasources.begin(); it != m_datasources.end(); ++it)
34  {
35  te::da::DataSourcePtr datasource = te::da::DataSourceManager::getInstance().find((*it)->getId());
36 
37  if(datasource.get() == nullptr)
38  {
39  datasource = te::da::DataSourceManager::getInstance().get((*it)->getId(), (*it)->getAccessDriver(), (*it)->getConnInfo());
40 
41  if(datasource.get() == nullptr)
42  throw te::ws::core::Exception() << te::ErrorDescription(TE_TR("Could not retrieve the data source instance!"));
43  }
44 
45  if(!datasource->isOpened())
46  datasource->open();
47 
48  std::unique_ptr<te::ws::ogc::wms::qt::WMSLayerSelectorDialog> ldialog(new te::ws::ogc::wms::qt::WMSLayerSelectorDialog(static_cast<QWidget*>(parent())));
49 
50  ldialog->set(*it, true);
51 
52  int retval = ldialog->exec();
53 
54  if(retval == QDialog::Rejected)
55  continue;
56 
57  std::vector<te::ws::ogc::wms::WMSGetMapRequest> requests = ldialog->getCheckedRequests();
58 
59  std::transform(requests.begin(), requests.end(), std::back_inserter(layers), te::ws::ogc::wms::WMS2Layer((*it)->getId()));
60  }
61 
62  return layers;
63 }
64 
boost::shared_ptr< DataSource > DataSourcePtr
This set of XML Schema Documents for GML Version has been edited to reflect the corrigendum to documents and OGC that is based on the change requests
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
boost::error_info< struct tag_error_description, std::string > ErrorDescription
The base type for error report messages.
A simple widget that allows the selection of datasets from a given WMS server.
static DataSourceManager & getInstance()
It returns a reference to the singleton instance.
Base exception class for WS Core Runtime Library.
A dialog window to show GetCapabilities data from a WMS Server.
A dialog window to show GetCapabilities data from a WMS Server.
void set(const std::list< te::da::DataSourceInfoPtr > &datasources)