27 #include "../color/RGBAColor.h" 28 #include "../common/progress/TaskProgress.h" 29 #include "../common/Globals.h" 30 #include "../common/STLUtils.h" 31 #include "../core/translator/Translator.h" 32 #include "../dataaccess/dataset/DataSet.h" 33 #include "../dataaccess/dataset/DataSetType.h" 34 #include "../dataaccess/query/And.h" 35 #include "../dataaccess/query/EqualTo.h" 36 #include "../dataaccess/query/GreaterThanOrEqualTo.h" 37 #include "../dataaccess/query/LessThanOrEqualTo.h" 38 #include "../dataaccess/query/LiteralDouble.h" 39 #include "../dataaccess/query/LiteralEnvelope.h" 40 #include "../dataaccess/query/LiteralString.h" 41 #include "../dataaccess/query/PropertyName.h" 42 #include "../dataaccess/query/ST_Intersects.h" 43 #include "../dataaccess/utils/Utils.h" 44 #include "../fe/Filter.h" 45 #include "../fe/Utils.h" 46 #include "../geometry/Coord2D.h" 47 #include "../geometry/Envelope.h" 48 #include "../geometry/GeometryProperty.h" 49 #include "../geometry/Line.h" 50 #include "../geometry/MultiPolygon.h" 51 #include "../geometry/Polygon.h" 52 #include "../geometry/Utils.h" 53 #include "../raster/Raster.h" 54 #include "../raster/RasterProperty.h" 55 #include "../se/AnchorPoint.h" 56 #include "../se/CoverageStyle.h" 57 #include "../se/Displacement.h" 58 #include "../se/Fill.h" 59 #include "../se/FeatureTypeStyle.h" 60 #include "../se/Halo.h" 61 #include "../se/LabelPlacement.h" 62 #include "../se/LinePlacement.h" 63 #include "../se/ParameterValue.h" 64 #include "../se/PointPlacement.h" 65 #include "../se/Rule.h" 66 #include "../se/TextSymbolizer.h" 67 #include "../se/Utils.h" 68 #include "../srs/Config.h" 81 #include <boost/format.hpp> 82 #include <boost/lexical_cast.hpp> 103 const double& scale,
bool* cancel)
121 else if(layer->
getSRID() != srid)
123 throw Exception(
TE_TR(
"The layer or map don't have a valid SRID!"));
135 std::unique_ptr<LayerSchema> schema(layer->
getSchema());
136 assert(schema.get());
141 if(schema->hasGeom())
145 if(spatialPropertyName.empty())
150 assert(geometryProperty);
168 throw Exception((boost::format(
TE_TR(
"Could not create a default feature type style to the layer %1%.")) % layer->
getTitle()).str());
176 throw Exception(
TE_TR(
"The layer style is not a Feature Type Style!"));
180 else if(schema->hasRaster())
187 if(spatialPropertyName.empty())
192 assert(rasterProperty);
202 throw Exception((boost::format(
TE_TR(
"Could not create a default coverage style to the layer %1%.")) % layer->
getTitle()).str());
210 throw Exception(
TE_TR(
"The layer style is not a Coverage Style!"));
214 if (raster.get() ==
nullptr)
215 throw Exception(
TE_TR(
"Could not get the raster referenced by the layer!"));
222 throw Exception(
TE_TR(
"The layer don't have a geometry or raster property!"));
227 const std::string& geomPropertyName,
232 const double& scale,
bool* cancel)
234 assert(!geomPropertyName.empty());
240 std::size_t nRules = style->
getRules().size();
242 for(std::size_t i = 0; i < nRules; ++i)
259 std::unique_ptr<te::da::DataSet> dataset;
283 throw Exception(
TE_TR(
"Could not convert the OGC Filter expression to TerraLib expression!"));
296 dataset = layer->
getData(restriction);
298 catch(std::exception& )
300 throw Exception((boost::format(
TE_TR(
"Could not retrieve the data set from the layer %1%.")) % layer->
getTitle()).str());
304 if(dataset.get() ==
nullptr)
305 throw Exception((boost::format(
TE_TR(
"Could not retrieve the data set from the layer %1%.")) % layer->
getTitle()).str());
307 if(dataset->moveNext() ==
false)
311 const std::vector<te::se::Symbolizer*>& symbolizers = rule->
getSymbolizers();
314 std::string message =
TE_TR(
"Drawing the layer");
315 message +=
" " + layer->
getTitle() +
". ";
316 message +=
TE_TR(
"Rule");
317 message +=
" " + boost::lexical_cast<std::string>(i + 1) +
" " +
TE_TR(
"of") +
" ";
318 message += boost::lexical_cast<std::string>(nRules) +
".";
322 task.setTotalSteps(0);
327 if(symbolizers.empty())
330 std::unique_ptr<te::gm::Geometry> g(dataset->getGeometry(gpos));
338 dataset->moveFirst();
341 std::size_t nSymbolizers = symbolizers.size();
343 for(std::size_t j = 0; j < nSymbolizers; ++j)
351 if (symb->
getType() ==
"TextSymbolizer")
360 if (j != nSymbolizers - 1)
367 dataset->moveFirst();
374 const std::string& geomPropertyName,
377 int srid,
bool* cancel)
379 assert(!geomPropertyName.empty());
389 assert(!propertyName.empty());
399 std::size_t nGroupItems = layerRules.size();
402 std::string message =
TE_TR(
"Drawing the grouping of layer");
403 message +=
" " + layer->
getTitle() +
".";
408 for(std::size_t i = 0; i < nGroupItems; ++i)
422 std::string uniqueValue;
431 std::string lowerLimitStr;
432 std::string upperLimitStr;
467 std::unique_ptr<te::da::DataSet> dataset;
470 dataset = layer->
getData(restriction);
472 catch(std::exception& )
477 if(dataset.get() ==
nullptr)
478 throw Exception((boost::format(
TE_TR(
"Could not retrieve the data set from the layer %1%.")) % layer->
getTitle()).str());
480 if(dataset->moveNext() ==
false)
484 const std::vector<te::se::Symbolizer*>& symbolizers = ruleItem->
getSymbolizers();
485 std::size_t nSymbolizers = symbolizers.size();
490 for(std::size_t j = 0; j < nSymbolizers; ++j)
498 if (symb->
getType() ==
"TextSymbolizer")
507 if (j != nSymbolizers - 1)
514 dataset->moveFirst();
527 const std::string& geomPropertyName,
531 const double& scale,
bool* cancel)
533 assert(!geomPropertyName.empty());
548 assert(!propertyName.empty());
554 const std::size_t& precision = grouping->
getPrecision();
559 std::map<std::string, te::se::Rule*> uniqueRuleMap;
562 std::map<std::pair< double, double>,
te::se::Rule* > othersRuleMap;
564 for (std::size_t i = 0; i < layerRules.size(); ++i)
571 std::string uniqueValue;
575 uniqueRuleMap[uniqueValue] = ruleItem;
579 std::string lowerLimitStr;
580 std::string upperLimitStr;
584 double lowerLimit = atof(lowerLimitStr.c_str());
585 double upperLimit = atof(upperLimitStr.c_str());
586 std::pair<double, double> range(lowerLimit, upperLimit);
588 othersRuleMap[range] = ruleItem;
593 std::string message =
TE_TR(
"Drawing the grouping of layer");
594 message +=
" " + layer->
getTitle() +
".";
599 std::unique_ptr<te::da::DataSet> dataset;
604 catch(std::exception& )
609 if(dataset.get() ==
nullptr)
610 throw Exception((boost::format(
TE_TR(
"Could not retrieve the data set from the layer %1%.")) % layer->
getTitle()).str());
612 if(dataset->moveNext() ==
false)
619 std::unique_ptr<te::map::LayerSchema>
dt(layer->
getSchema());
623 bool needRemap =
false;
637 if(dataset->isNull(propertyPos))
640 value = dataset->getAsString(propertyPos, static_cast<int>(precision));
644 std::map<std::string, te::se::Rule*>::const_iterator it = uniqueRuleMap.find(value);
645 if (it == uniqueRuleMap.end())
652 double dvalue = atof(value.c_str());
653 std::map<std::pair< double, double>,
te::se::Rule*>::const_iterator it;
654 for (it = othersRuleMap.begin(); it != othersRuleMap.end(); ++it)
656 if(dvalue >= it->first.first && dvalue < it->first.second)
660 if (it != othersRuleMap.end())
672 std::unique_ptr<te::gm::Geometry> geom;
675 geom = dataset->getGeometry(gpos);
676 if(geom.get() ==
nullptr)
679 catch(std::exception& )
684 std::vector<te::se::Symbolizer*> symbolizers = rule->
getSymbolizers();
687 std::size_t nSymbolizers = symbolizers.size();
689 for(std::size_t j = 0; j < nSymbolizers; ++j)
700 geom->setSRID(layer->
getSRID());
701 geom->transform(srid);
704 canvas->
draw(geom.get());
706 if(chart && j == nSymbolizers - 1)
710 if(cancel !=
nullptr && (*cancel))
713 }
while(dataset->moveNext());
721 static_cast<int>(chart->
getWidth()),
737 const std::vector<te::se::Symbolizer*>& symbolizers = rule->
getSymbolizers();
739 std::size_t nSymbolizers = symbolizers.size();
741 for (std::size_t j = 0; j < nSymbolizers; ++j)
747 if (symb->
getType() ==
"TextSymbolizer")
753 dataset->moveFirst();
764 int fromSRID,
int toSRID,
771 bool needRemap =
false;
786 std::unique_ptr<te::gm::Geometry> geom;
790 if(geom.get() ==
nullptr)
793 catch(std::exception& )
801 geom->setSRID(fromSRID);
802 geom->transform(toSRID);
805 canvas->
draw(geom.get());
810 if(cancel !=
nullptr && (*cancel))
821 static_cast<int>(chart->
getWidth()),
835 bool needRemap =
false;
841 if (propName.empty())
863 std::unique_ptr<te::gm::Geometry> geom;
867 if (geom.get() ==
nullptr)
870 catch (std::exception& )
878 geom->setSRID(fromSRID);
879 geom->transform(toSRID);
882 std::string label = dataset->
getString(propIdx);
889 double posX = cCenter.
getX();
890 double posY = cCenter.
getY();
896 double anchorX = 0.5;
897 double anchorY = 0.5;
898 int displacementX = 0;
899 int displacementY = 0;
929 std::unique_ptr<te::gm::Point> point(
new te::gm::Point(cCenter.
x, cCenter.
y, geom->getSRID()));
933 posX = coordGeom.
getX();
934 posY = coordGeom.
getY();
945 te::gm::Coord2D cStart(line->getStartPoint()->getX(), line->getStartPoint()->getY());
946 te::gm::Coord2D cEnd(line->getEndPoint()->getX(), line->getEndPoint()->getY());
961 std::unique_ptr<te::gm::Point> p0(dynamic_cast<te::gm::Point*>(lineRotate->intersection(line.get())));
962 std::unique_ptr<te::gm::Point> p1(lineRotate->getPointN(1));
975 std::unique_ptr<te::gm::Polygon> poly(canvas->
getTextBoundary(posX, posY, label, angle, anchorX, anchorY, displacementX, displacementY));
980 std::vector<std::size_t> report;
981 rtree.
search(mbr, report);
985 canvas->
drawText(posX, posY, label, angle, anchorX, anchorY, displacementX, displacementY);
990 if (cancel !=
nullptr && (*cancel))
1002 std::unique_ptr<te::gm::Coord2D> worldCoord;
1026 if(worldCoord.get() ==
nullptr)
1033 double dx = 0.0;
double dy = 0.0;
1036 double dw = dx + chart->
getWidth();
1045 std::vector<std::size_t> report;
1059 std::size_t width = 0;
A TextSymbolizer is used to render text labels according to various graphical parameters.
virtual std::unique_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
TEDATAACCESSEXPORT te::rst::RasterProperty * GetFirstRasterProperty(const DataSetType *dt)
MultiPolygon is a MultiSurface whose elements are Polygons.
const ParameterValue * getDisplacementX() const
~AbstractLayerRenderer()
Destructor.
const AnchorPoint * getAnchorPoint() const
if(WIN32) add_definitions(-D_SCL_SECURE_NO_WARNINGS-DTEWCSDLL) endif() file(GLOB TERRALIB_SRC_FILES $
const LabelPlacement * getLabelPlacement() const
bool intersects(const Envelope &rhs) const
It returns true if the envelopes "spatially intersects".
It models the inequality operator less than or equal to (<=).
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
virtual void drawText(int x, int y, const std::string &txt, float angle=0.0, double anchorX=0.5, double anchorY=0.5, int displacementX=0, int displacementY=0)=0
It draws a text.
Spatial intersects operator.
This is the base class for layers.
virtual const te::gm::Envelope & getExtent() const
It returns the Layer extent (or minimum bounding box).
int getPropertyType() const
It gets the property type whose values will be grouped.
TESEEXPORT Symbolizer * CreateSymbolizer(const te::gm::GeomType &geomType)
Try creates an appropriate symbolizer based on given geometry type.
TEGEOMEXPORT bool Rotate(te::gm::Coord2D pr, te::gm::LineString *l, double angle, te::gm::LineString *lOut)
te::sam::rtree::Index< std::size_t, 8 > m_rtree
static te::dt::Date dx(2010, 12, 31)
#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.
const Displacement * getDisplacement() const
A class that models the name of any property of an object.
Base exception class for plugin module.
const size_t getPrecision() const
It gets the precision used for the property values.
A Symbolizer describes how a feature is to appear on a map.
const double & getMinScaleDenominator() const
GeomType getGeomTypeId() const _NOEXCEPT_OP(true)
It returns the geometry subclass type identifier.
A visitor that converts a OGC Filter Expression to TerraLib Expression.
The CoverageStyle defines the styling that is to be applied to a subset of Coverage data...
This is the base class for Layers.
std::string getPropertyName() const
It gets the property name whose values will be grouped.
TESEEXPORT Style * CreateCoverageStyle(const std::vector< te::rst::BandProperty * > &properties)
Try creates an appropriate coverage style based on given band properties.
TEGEOMEXPORT bool AdjustSegment(te::gm::Point *P0, te::gm::Point *P1, double d0, te::gm::Coord2D &P0out, te::gm::Coord2D &P1out)
virtual void drawDatSetGeometries(te::da::DataSet *dataset, const std::size_t &gpos, Canvas *canvas, int fromSRID, int toSRID, Chart *chart, bool *cancel, te::common::TaskProgress *task=0)
It draws the data set geometries in the given canvas using the informed SRS.
This class can be used to inform the progress of a task.
TEDATAACCESSEXPORT std::size_t GetPropertyPos(const DataSet *dataset, const std::string &name)
This is a singleton for managing chart renderer instance available in the system. ...
virtual te::gm::Polygon * getTextBoundary(int x, int y, const std::string &txt, float angle=0.0, double anchorX=0.5, double anchorY=0.5, int displacementX=0, int displacementY=0)=0
It returns the text boundary (its enclose rectangle).
double m_urx
Upper right corner x-coordinate.
te::da::Expression * getExpression(const te::fe::Filter *f)
It converts the OGC Filter Expression to a TerraLib Expression.
It models the inequality operator greater than or equal to (>=).
TESEEXPORT double GetDouble(const te::se::ParameterValue *param)
It gets the parameter value as a double.
An utility struct for representing 2D coordinates.
double getY() const
It returns the y-coordinate.
const te::fe::Filter * getFilter() const
const ParameterValue * getRotation() const
#define TE_TR(message)
It marks a string in order to get translated.
void push_back(Symbolizer *s)
It renders the objects associated to an abstract layer. i.e. a generic renderer.
TEDATAACCESSEXPORT int GetPropertyIndex(te::da::DataSet *dataSet, const std::string propName)
bool isActive() const
Verify if the task is active.
Boolean logic operator: AND.
This is an abstract class that models a query expression.
virtual te::map::Chart * getChart() const
It returns the Chart associated to the Layer.
const ParameterValue * getDisplacementY() const
Expression * clone() const
It creates a new copy of this expression.
TESEEXPORT Style * CreateFeatureTypeStyle(const te::gm::GeomType &geomType)
Try creates an appropriate feature type style based on given geometry type.
Rule * getRule(std::size_t i) const
const std::vector< Rule * > & getRules() const
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
A PointPlacement specifies how a text label should be rendered relative to a geometric point...
This class contains the parameters needed for grouping the values of a Property.
virtual void setWindow(const double &llx, const double &lly, const double &urx, const double &ury)=0
It sets the world (or window) coordinates area (supposing a cartesian reference system).
Coord2D getCenter() const
It returns the rectangle's center coordinate.
void Free(std::vector< T * > *v)
This function can be applied to a pointer to a vector of pointers.
TEFEEXPORT void GetFilterStepValues(const te::fe::Filter *filter, std::string &valueMin, std::string &valueMax)
TEMAPEXPORT void DrawRaster(te::da::DataSetType *type, te::da::DataSourcePtr ds, Canvas *canvas, const te::gm::Envelope &bbox, int bboxSRID, const te::gm::Envelope &visibleArea, int srid, te::se::CoverageStyle *style, te::map::RasterContrast *rc, const double &scale, bool *cancel)
std::vector< te::color::RGBAColor ** > m_chartImages
double m_llx
Lower left corner x-coordinate.
LineString is a curve with linear interpolation between points.
This class represents the informations needed to build map charts.
static T & getInstance()
It returns a reference to the singleton instance.
A point with x and y coordinate values.
const Envelope * getMBR() const _NOEXCEPT_OP(true)
It returns the minimum bounding rectangle for the geometry in an internal representation.
An Envelope defines a 2D rectangular region.
The FeatureTypeStyle defines the styling that is to be applied to a dataset that can be viewed as a f...
virtual void buildChart(Chart *chart, te::da::DataSet *dataset, te::gm::Geometry *geom)
virtual te::se::Style * getStyle() const
It returns the Style associated to the layer.
virtual std::unique_ptr< LayerSchema > getSchema() const =0
It returns the layer schema.
std::size_t getHeight() const
bool isVisible() const
It gets the chart visibility.
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
static te::dt::TimeDuration dt(20, 30, 50, 11)
virtual int getHeight() const =0
It returns the canvas height.
A visitor that converts a OGC Filter Expression to TerraLib Expression.
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
virtual void drawImage(char *src, std::size_t size, ImageType t)=0
It draws the src image over the canvas.
const ParameterValue * getAnchorPointX() const
A filter is any valid predicate expression.
A class that models a literal for double values.
int search(const te::gm::Envelope &mbr, std::vector< DATATYPE > &report) const
Range search query.
This class represents the informations needed to build map charts.
Utility functions for the data access module.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
virtual void drawDatSetTexts(te::da::DataSet *dataset, const std::size_t &gpos, Canvas *canvas, int fromSRID, int toSRID, te::se::TextSymbolizer *symb, bool *cancel, te::common::TaskProgress *task=0)
const std::vector< Symbolizer * > & getSymbolizers() const
double m_lly
Lower left corner y-coordinate.
TEGEOMEXPORT void ClosestPoints(te::gm::Geometry *geomA, te::gm::Geometry *geomB, te::gm::Coord2D &coordA, te::gm::Coord2D &coordB)
Compute the the closest points of two geometries.
virtual te::map::RasterContrast * getRasterContrast() const
It returns the raster contrast associated to the Layer.
virtual void drawLayerGrouping(AbstractLayer *layer, const std::string &geomPropertyName, Canvas *canvas, const te::gm::Envelope &bbox, int srid, bool *cancel)
It draws the grouping of the abstract layer in the given canvas using the SRS informed.
TEGEOMEXPORT double GetAngle(te::gm::Coord2D coordA, te::gm::Coord2D coordB)
TEMAPEXPORT te::rst::Raster * GetRaster(AbstractLayer *layer)
It gets the raster referenced by the given data set layer.
A dataset is the unit of information manipulated by the data access module of TerraLib.
A canvas is an abstraction of a drawing area.
bool isVisible() const
It gets the grouping visibility.
virtual void draw(AbstractLayer *layer, 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. ...
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
double getX() const
It returns the x-coordinate.
GroupingType
The grouping type associated to the layer.
const LinePlacement * getLinePlacement() const
A Rule is used to attach property/scale conditions to and group the individual symbols used for rende...
virtual std::unique_ptr< te::da::DataSet > getData(te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess) const =0
It gets the dataset identified by the layer name.
void insert(const te::gm::Envelope &mbr, const DATATYPE &data)
It inserts an item into the tree.
const ParameterValue * getLabel() const
virtual te::map::Grouping * getGrouping() const
It returns the Grouping associated to the Layer.
double m_ury
Upper right corner y-coordinate.
virtual void drawLayerGroupingMem(AbstractLayer *layer, const std::string &geomPropertyName, Canvas *canvas, const te::gm::Envelope &bbox, int srid, const double &scale, bool *cancel)
It draws the grouping of the abstract layer in the given canvas using the SRS informed.
It models the comparison operator.
virtual const std::string & getType() const =0
It returns the symbolizer type.
Coord2D * getCentroidCoord() const
It returns the mathematical centroid for this surface as a coordinate.
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.
TESEEXPORT int GetInt(const te::se::ParameterValue *param)
It gets the parameter value as an integer.
std::vector< te::gm::Coord2D > m_chartCoordinates
WorldDeviceTransformer m_transformer
const GroupingType getType() const
It gets the grouping type.
bool getAvoidConflicts() const
A class that models a literal for Envelope values.
const ParameterValue * getAnchorPointY() const
virtual const std::string & getGeomPropertyName() const
const double & getMaxScaleDenominator() const
virtual int getSRID() const
It returns the Spatial Reference System ID associated to the Layer.
This class contains the parameters needed for grouping the values of a Property.
std::vector< te::rst::BandProperty * > & getBandProperties()
Returns a reference to the list of bands definitions.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
TEGEOMEXPORT te::gm::Line * GetIntersectionLine(te::gm::Geometry *geom, te::gm::Coord2D coord)
const PointPlacement * getPointPlacement() const
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
const ParameterValue * getPerpendicularOffset() const
virtual void draw(const te::gm::Geometry *geom)=0
It draws the geometry on canvas.
TESEEXPORT std::string GetString(const te::se::ParameterValue *param)
It gets the parameter value as a string.
bool isValid() const
It tells if the rectangle is valid or not.
virtual void drawLayerGeometries(AbstractLayer *layer, const std::string &geomPropertyName, te::se::FeatureTypeStyle *style, Canvas *canvas, const te::gm::Envelope &bbox, int srid, const double &scale, bool *cancel)
It draws the abstract layer in the given canvas using the SRS informed.
virtual std::string getString(std::size_t i) const =0
Method for retrieving a string value attribute.
virtual int getWidth() const =0
It returns the canvas width.
Coord2D * getCentroidCoord() const
std::size_t getWidth() const
This class models a string Literal value.
static const std::string sm_nanStr
Not a number string value.
const std::string & getName() const
It returns the property name.
TEFEEXPORT void GetFilterUniqueValue(const te::fe::Filter *filter, std::string &value)