27 #include "../common/Translator.h"
28 #include "../dataaccess/utils/Utils.h"
29 #include "../maptools/AbstractRenderer.h"
30 #include "../maptools/RendererFactory.h"
35 #include <boost/format.hpp>
36 #include <boost/lexical_cast.hpp>
41 : te::map::AbstractLayer(parent),
42 m_rendererType(
"WMS_LAYER_RENDERER"),
51 : te::map::AbstractLayer(id, parent),
52 m_rendererType(
"WMS_LAYER_RENDERER"),
61 const std::string& title,
63 : te::map::AbstractLayer(id, title, parent),
64 m_rendererType(
"WMS_LAYER_RENDERER"),
79 return std::auto_ptr<te::map::LayerSchema>(static_cast<te::map::LayerSchema*>(m_schema->clone()));
81 assert(!m_datasetName.empty());
85 m_schema = ds->getDataSetType(m_datasetName);
87 return std::auto_ptr<te::map::LayerSchema>(
static_cast<te::map::LayerSchema*
>(m_schema->clone()));
93 std::string request = buildRequest();
97 return ds->getDataSet(request, travType, accessPolicy);
106 std::string request = buildRequest();
110 return ds->getDataSet(request, propertyName, e, r, travType, accessPolicy);
119 std::string request = buildRequest();
123 return ds->getDataSet(request, propertyName, g, r, travType, accessPolicy);
130 throw Exception(
TE_TR(
"Query operations are not supported by the WMS Layer!"));
137 throw Exception(
TE_TR(
"The ObjectIdSet concept is not supported by the WMS Layer!"));
142 if(m_datasourceId.empty() || m_datasetName.empty())
145 if(m_width == 0 || m_height == 0 || m_format.empty())
158 if(ds.get() == 0 || !ds->isValid() || !ds->isOpened())
166 if(m_rendererType.empty())
167 throw Exception((boost::format(
TE_TR(
"Could not draw the WMS layer %1%. The renderer type is empty!")) % getTitle()).str());
171 if(renderer.get() == 0)
172 throw Exception((boost::format(
TE_TR(
"Could not draw the WMS layer %1%. The renderer %2% could not be created!")) % getTitle() % m_rendererType).str());
174 renderer->draw(
this, canvas, bbox, srid);
184 return m_datasetName;
189 m_datasetName = name;
194 return m_datasourceId;
204 return m_rendererType;
229 assert(!m_datasetName.empty());
231 assert(m_height > 0);
232 assert(!m_format.empty());
234 std::string request =
"LAYER=" + m_datasetName;
235 request +=
"&WIDTH=" + boost::lexical_cast<std::string>(m_width);
236 request +=
"&HEIGHT=" + boost::lexical_cast<std::string>(m_height);
237 request +=
"&FORMAT=" + m_format;
A layer with reference to a WMS Layer.
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
void setDataSourceId(const std::string &id)
std::auto_ptr< te::map::LayerSchema > getSchema() const
It returns the layer schema.
#define TE_WMS_DEFAULT_WIDTH
It specifies the default width used on GetMap request.
This is the base class for layers.
boost::shared_ptr< DataSource > DataSourcePtr
A class that models the description of a dataset.
std::auto_ptr< te::da::DataSet > getData(te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess) const
It gets the dataset identified by the layer name.
#define TE_WMS_DEFAULT_IMAGE_FORMAT
It specifies the default image format used on GetMap request.
void setFormat(const std::string &format)
const std::string & getType() const
It returns the layer type.
SpatialRelation
Spatial relations between geometric objects.
const std::string & getDataSetName() const
void setDataSetName(const std::string &name)
#define TE_TR(message)
It marks a string in order to get translated.
static const std::string sm_type
A static data member used in the implementation of getType method.
This is an abstract class that models a query expression.
AccessPolicy
Supported data access policies (can be used as bitfield).
TraverseType
A dataset can be traversed in two ways:
An exception class for the TerraLib WMS module.
const std::string & getDataSourceId() const
WMSLayer(te::map::AbstractLayer *parent=0)
It initializes a new layer.
#define TE_WMS_DEFAULT_HEIGHT
It specifies the default height used on GetMap request.
An Envelope defines a 2D rectangular region.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
void setWidth(const std::size_t &width)
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
static AbstractRenderer * make(const std::string &factoryKey)
It creates an object with the appropriated factory.
std::string buildRequest() const
A canvas is an abstraction of a drawing area.
bool isValid() const
It returns true if the layer can be used for instance to draw, otherwise, it returns false...
const std::string & getRendererType() const
void draw(te::map::Canvas *canvas, const te::gm::Envelope &bbox, int srid)
It draws the layer geographic objects in the given canvas using the informed SRS. ...
void setRendererType(const std::string &t)
void setHeight(const std::size_t &height)