27 #include "../common/progress/TaskProgress.h" 28 #include "../common/STLUtils.h" 29 #include "../core/translator/Translator.h" 30 #include "../dataaccess/utils/Utils.h" 31 #include "../geometry/Envelope.h" 32 #include "../geometry/Utils.h" 33 #include "../maptools/Canvas.h" 34 #include "../maptools/CanvasConfigurer.h" 35 #include "../maptools/RasterTransform.h" 36 #include "../maptools/RasterTransformConfigurer.h" 37 #include "../raster/Grid.h" 38 #include "../raster/RasterProperty.h" 39 #include "../raster/RasterSummary.h" 40 #include "../raster/RasterSummaryManager.h" 41 #include "../raster/Utils.h" 42 #include "../se/CoverageStyle.h" 43 #include "../se/ImageOutline.h" 44 #include "../se/RasterSymbolizer.h" 45 #include "../se/Rule.h" 46 #include "../se/Utils.h" 47 #include "../srs/Config.h" 48 #include "../srs/Converter.h" 54 #include <boost/format.hpp> 55 #include <boost/lexical_cast.hpp> 73 const double& scale,
bool* cancel)
87 draw(wmsLayer, canvas, bbox, srid);
99 else if(layer->
getSRID() != srid)
111 std::auto_ptr<te::map::LayerSchema> schema(layer->
getSchema());
112 assert(schema.get());
125 throw Exception((boost::format(
TE_TR(
"Could not create a default coverage style for the layer %1%!")) % layer->
getTitle()).str());
133 throw Exception(
TE_TR(
"The layer style is not a Coverage Style!"));
142 if(dataset.get() == 0)
143 throw Exception((boost::format(
TE_TR(
"Could not retrieve the WMS data from the layer %1%!")) % layer->
getTitle()).str());
148 std::auto_ptr<te::rst::Raster> raster(dataset->getRaster(rpos));
149 if(dataset.get() == 0)
150 throw Exception((boost::format(
TE_TR(
"Could not retrieve the WMS data from the layer %1%!")) % layer->
getTitle()).str());
167 std::auto_ptr<te::rst::Grid> gridCanvas(
new te::rst::Grid(static_cast<unsigned int>(canvas->
getWidth()), static_cast<unsigned int>(canvas->
getHeight()), gmbr, srid));
178 const std::complex<double>* cmin = rsMin->at(0).m_minVal;
179 const std::complex<double>* cmax = rsMax->at(0).m_maxVal;
180 double min = cmin->real();
181 double max = cmax->real();
183 rasterTransform.setLinearTransfParameters(min, max, 0, 255);
187 rasterTransform.setLinearTransfParameters(0, 255, 0, 255);
191 std::size_t nRules = style->
getRules().size();
197 const std::vector<te::se::Symbolizer*>& symbolizers = rule->
getSymbolizers();
198 assert(!symbolizers.empty());
202 assert(rasterSymbolizer);
216 bool needRemap =
false;
221 std::string message =
TE_TR(
"Drawing the WMS layer");
222 !layerTitle.empty() ? message +=
" " + layerTitle +
". " : message +=
"...";
239 converter->setSourceSRID(srid);
240 converter->setTargetSRID(bboxSRID);
244 for(
unsigned int r = 0; r < gridCanvas->getNumberOfRows(); ++r)
246 for(
unsigned int c = 0; c < gridCanvas->getNumberOfColumns(); ++c)
251 converter->convert(inputGeo.
x, inputGeo.
y, inputGeo.
x, inputGeo.
y);
263 color = rasterTransform.apply(x, y);
296 if(rasterSymbolizer->getImageOutline() == 0)
300 te::se::Symbolizer* outlineSymbolizer = rasterSymbolizer->getImageOutline()->getSymbolizer();
301 if(outlineSymbolizer == 0)
306 cc.
config(outlineSymbolizer);
312 geom->setSRID(bboxSRID);
313 geom->transform(srid);
316 canvas->
draw(geom.get());
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
TEDATAACCESSEXPORT te::rst::RasterProperty * GetFirstRasterProperty(const DataSetType *dt)
std::auto_ptr< te::map::LayerSchema > getSchema() const
It returns the layer schema.
bool intersects(const Envelope &rhs) const
It returns true if the envelopes "spatially intersects".
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
This is the base class for layers.
virtual const te::gm::Envelope & getExtent() const
It returns the Layer extent (or minimum bounding box).
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
virtual const std::string & getTitle() const
It returns the layer title.
Base exception class for plugin module.
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
A Symbolizer describes how a feature is to appear on a map.
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.
The CoverageStyle defines the styling that is to be applied to a subset of Coverage data...
TESEEXPORT Style * CreateCoverageStyle(const std::vector< te::rst::BandProperty * > &properties)
Try creates an appropriate coverage style based on given band properties.
This class can be used to inform the progress of a task.
An utility struct for representing 2D coordinates.
#define TE_TR(message)
It marks a string in order to get translated.
void geoToGrid(const double &x, const double &y, double &col, double &row) const
Get the grid point associated to a spatial location.
Rule * getRule(std::size_t i) const
const std::vector< Rule * > & getRules() const
void draw(te::map::AbstractLayer *layer, te::map::Canvas *canvas, const te::gm::Envelope &bbox, int srid, const double &scale, bool *cancel)
It draws the layer geographic objects in the given canvas using the SRS informed. ...
void Free(std::vector< T * > *v)
This function can be applied to a pointer to a vector of pointers.
A layer with reference to a WMS Layer.
static RasterSummaryManager & getInstance()
It returns a reference to the singleton instance.
An Envelope defines a 2D rectangular region.
An abstract class for raster data strucutures.
unsigned int getNumberOfRows() const
Returns the raster number of rows.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
virtual te::se::Style * getStyle() const
It returns the Style associated to the layer.
void setWidth(const std::size_t &width)
TERASTEREXPORT int Round(double val)
Round a double value to a integer value.
virtual int getHeight() const =0
It returns the canvas height.
virtual int getBandDataType(std::size_t i) const =0
Returns the data type in a particular band (or dimension).
boost::ptr_vector< BandSummary > RasterSummary
RasterSummary is just a typedef of a boost::ptr_vector.
The RasterSymbolizer describes how to render raster/matrix-coverage data (e.g., satellite photos...
virtual void drawImage(char *src, std::size_t size, ImageType t)=0
It draws the src image over the canvas.
Grid * getGrid()
It returns the raster grid.
const std::vector< Symbolizer * > & getSymbolizers() const
A Converter is responsible for the conversion of coordinates between different Coordinate Systems (CS...
A canvas is an abstraction of a drawing area.
A Rule is used to attach property/scale conditions to and group the individual symbols used for rende...
virtual void setStyle(te::se::Style *style)
It sets the Style associated to the layer.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
virtual int getSRID() const
It returns the Spatial Reference System ID associated to the Layer.
void drawRaster(const std::string &layerTitle, te::rst::Raster *raster, te::map::Canvas *canvas, const te::gm::Envelope &bbox, int bboxSRID, const te::gm::Envelope &visibleArea, int srid, te::se::CoverageStyle *style)
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
Envelope intersection(const Envelope &rhs) const
It returns an envelope that represents the point set intersection with another envelope.
A rectified grid is the spatial support for raster data.
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
virtual void draw(const te::gm::Geometry *geom)=0
It draws the geometry on canvas.
bool isValid() const
It tells if the rectangle is valid or not.
virtual int getWidth() const =0
It returns the canvas width.
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
void setHeight(const std::size_t &height)