Utility class with functions to manipulate the canvas and conversion between projections. More...
#include <Utils.h>
Public Member Functions | |
| virtual te::gm::LinearRing * | addCoordsInX (te::gm::Envelope box, double axisCoord, double gap) |
| Creates a line with n points in x axis. Method used to create the grid lines on a map. Horizontal line. More... | |
| virtual te::gm::LinearRing * | addCoordsInY (te::gm::Envelope box, double axisCoord, double gap) |
| Creates a line with n points in y axis. Method used to create the grid lines on a map. Vertical line. More... | |
| int | calculatePlanarZone (te::gm::Envelope latLongBox) |
| Calculates the area from a box in coordinated latlong. More... | |
| virtual void | configCanvas (te::gm::Envelope box, bool resize=true, bool applyZoom=true) |
| Sets the viewport and window of the canvas. The viewport is only changed if the resize parameter is true. More... | |
| virtual std::string | convertDecimalToDegree (const double &value, bool bDegrees, bool bMinutes, bool bSeconds) |
| Converts decimal geo coordinates to degrees. More... | |
| virtual double | convertDegreeToDecimal () |
| Converts degree geo coordinates to decimal. More... | |
| virtual std::string | convertNumberToString (const double &value, int precision) |
| Number to string. More... | |
| virtual void | convertToMillimeter (WorldTransformer transf, te::gm::LinearRing *line) |
| Convert LinearRing from one coordinate system to mm. More... | |
| virtual void | convertToMillimeter (WorldTransformer transf, te::gm::Polygon *poly) |
| Convert Polygon from one coordinate system to mm. More... | |
| virtual te::gm::LinearRing * | createSimpleLine (te::gm::Envelope box) |
| Creates a LinearRing (line) pointer from a box in world coordinates (mm) More... | |
| virtual void | drawLineW (te::gm::LinearRing *line) |
| Draw a line in world coordinates (mm). More... | |
| virtual void | drawRectW (te::gm::Envelope box) |
| Draw a rectangle in world coordinates (mm). More... | |
| virtual bool | getApplyZoom () |
| virtual std::string | getFileExtension (std::string fileName) |
| Returns the file extension. More... | |
| virtual te::color::RGBAColor ** | getImageW (te::gm::Envelope boxmm) |
| Returns a pointer RGBA colors that representing an image. More... | |
| te::layout::WorldTransformer | getTransformGeo (te::gm::Envelope boxgeo, te::gm::Envelope boxmm) |
| Returns a WorldTransformer object to transformations between geo coordinates and millimeter coordinates. More... | |
| virtual char * | imageToChar (std::string fileName, std::ifstream::pos_type &size) |
| Opens the file and loads the image into memory and converts to char*. More... | |
| virtual int | mm2pixel (double mm) |
| Millimeter to pixel. More... | |
| std::string | proj4DescToGeodesic () |
| Returns string wkt with non-planar projection. More... | |
| std::string | proj4DescToPlanar (int zone) |
| Returns string wkt with UTM projection in the specified zone. More... | |
| virtual void | remapToPlanar (te::gm::Envelope *latLongBox, int zone) |
| Map latlong to UTM zone. More... | |
| virtual void | remapToPlanar (te::gm::LinearRing *line, int zone) |
| Map latlong LinearRing (line) to UTM zone. More... | |
| virtual void | remapToPlanar (te::gm::Point *point, int zone) |
| Map latlong Point (point) to UTM zone. More... | |
| virtual void | resetCanvas () |
| Clears the canvas content and fills with the background color. Sets all width with 1. More... | |
| virtual int | roundNumber (const double &value) |
| Rounds double to int. More... | |
| virtual void | setApplyZoom (bool apply) |
| virtual void | textBoundingBox (double &w, double &h, std::string txt) |
| A method that calculates the height and width of a text. More... | |
| te::common::UnitOfMeasurePtr | unitMeasure (int srid) |
| Returns a UnitOfMeasurePtr pointer. More... | |
| Utils () | |
| Constructor. More... | |
| virtual te::gm::Envelope | viewportBox (te::gm::Envelope box) |
| Converts the box world (mm) to screen coordinates (pixel). More... | |
| virtual | ~Utils () |
| Destructor. More... | |
Protected Member Functions | |
| virtual void | changeCanvas (te::gm::Envelope viewport, te::gm::Envelope world, bool resize=true) |
| Sets the viewport and window of the canvas. The viewport is only changed if the resize parameter is true. More... | |
| virtual te::gm::Envelope | transformToViewport (te::map::WorldDeviceTransformer transf, te::gm::Envelope box) |
| Transforms the box (mm) to screen coordinates (pixel). More... | |
| virtual te::gm::Envelope | viewportBoxFromMM (te::gm::Envelope box) |
| Converts the box world (mm) to screen coordinates (pixel). More... | |
Protected Attributes | |
| bool | m_applyZoom |
Utility class with functions to manipulate the canvas and conversion between projections.
|
virtual |
Creates a line with n points in x axis. Method used to create the grid lines on a map. Horizontal line.
| box | in mm |
| axisCoord | axis y value |
| gap | distance between the points on the x axis |
Definition at line 221 of file Utils.cpp.
References te::gm::Envelope::getLowerLeftX(), te::gm::Envelope::getUpperRightX(), te::gm::LineStringType, te::gm::LineString::setNumCoordinates(), and te::gm::LineString::setPointN().
Referenced by te::layout::GridGeodesicModel::drawVerticalLines().
|
virtual |
Creates a line with n points in y axis. Method used to create the grid lines on a map. Vertical line.
| box | in mm |
| axisCoord | axis x value |
| gap | distance between the points on the y axis |
Definition at line 246 of file Utils.cpp.
References te::gm::Envelope::getLowerLeftY(), te::gm::Envelope::getUpperRightY(), te::gm::LineStringType, te::gm::LineString::setNumCoordinates(), and te::gm::LineString::setPointN().
Referenced by te::layout::GridGeodesicModel::drawHorizontalLines().
| int Utils::calculatePlanarZone | ( | te::gm::Envelope | latLongBox | ) |
Calculates the area from a box in coordinated latlong.
| latLongBox | box in latlong |
Definition at line 419 of file Utils.cpp.
References te::gm::Envelope::getCenter(), TeCDR, TeCRD, and te::gm::Coord2D::x.
Referenced by te::layout::GridGeodesicModel::drawHorizontalLines(), te::layout::GridGeodesicModel::drawVerticalLines(), and te::layout::MapModel::getWorldInMeters().
|
protectedvirtual |
Sets the viewport and window of the canvas. The viewport is only changed if the resize parameter is true.
| viewport | viewport box(pixel) |
| world | world box(mm) |
| resize | true if to resize, false otherwise |
Definition at line 145 of file Utils.cpp.
References te::layout::Context::getCanvas(), te::gm::Envelope::getHeight(), te::common::Singleton< Context >::getInstance(), te::gm::Envelope::getLowerLeftX(), te::gm::Envelope::getLowerLeftY(), te::gm::Envelope::getUpperRightX(), te::gm::Envelope::getUpperRightY(), te::gm::Envelope::getWidth(), te::map::Canvas::resize(), te::map::Canvas::setBackgroundColor(), and te::map::Canvas::setWindow().
|
virtual |
Sets the viewport and window of the canvas. The viewport is only changed if the resize parameter is true.
| box | window coordinate (mm) |
Definition at line 138 of file Utils.cpp.
Referenced by te::layout::LegendChildModel::draw(), te::layout::MapModel::draw(), and te::layout::LegendModel::draw().
|
virtual |
Converts decimal geo coordinates to degrees.
| value | in decimal |
| bDegrees | true if should appear in the return string, false otherwise |
| bMinutes | true if should appear in the return string, false otherwise |
| bSeconds | true if should appear in the return string, false otherwise |
Definition at line 314 of file Utils.cpp.
Referenced by te::layout::GridGeodesicModel::drawHorizontalLines(), and te::layout::GridGeodesicModel::drawVerticalLines().
|
virtual |
|
virtual |
Number to string.
| value | |
| precision | decimal places |
Definition at line 353 of file Utils.cpp.
References te::common::uri::convert().
|
virtual |
Convert LinearRing from one coordinate system to mm.
| Object | with logic for transforming |
| line | LinearRing pointer in one coordinate system |
Definition at line 497 of file Utils.cpp.
References te::gm::LineString::computeMBR(), te::gm::AbstractPoint::computeMBR(), te::gm::LineString::getNPoints(), te::gm::LineString::getPointN(), te::gm::Point::getX(), te::gm::Point::getY(), te::gm::LineString::setPoint(), and te::layout::WorldTransformer::system1Tosystem2().
Referenced by te::layout::GridGeodesicModel::drawHorizontalLines(), and te::layout::GridGeodesicModel::drawVerticalLines().
|
virtual |
Convert Polygon from one coordinate system to mm.
| Object | with logic for transforming |
| line | LinearRing pointer in one coordinate system |
Definition at line 517 of file Utils.cpp.
References te::gm::CurvePolygon::computeMBR(), te::gm::CurvePolygon::getInteriorRingN(), and te::gm::CurvePolygon::getNumInteriorRings().
|
virtual |
Creates a LinearRing (line) pointer from a box in world coordinates (mm)
| box | in mm |
Definition at line 99 of file Utils.cpp.
References te::gm::Envelope::getLowerLeftX(), te::gm::Envelope::getLowerLeftY(), te::gm::Envelope::getUpperRightX(), te::gm::Envelope::getUpperRightY(), te::gm::LineStringType, te::gm::LineString::setNumCoordinates(), and te::gm::LineString::setPointN().
Referenced by te::layout::GridPlanarModel::drawHorizontalLines(), and te::layout::GridPlanarModel::drawVerticalLines().
|
virtual |
Draw a line in world coordinates (mm).
| LinearRing | pointer with coordinates in millimeters |
Definition at line 87 of file Utils.cpp.
References te::map::Canvas::draw(), te::layout::Context::getCanvas(), and te::common::Singleton< Context >::getInstance().
Referenced by te::layout::GridPlanarModel::drawHorizontalLines(), te::layout::GridGeodesicModel::drawHorizontalLines(), te::layout::GridPlanarModel::drawVerticalLines(), and te::layout::GridGeodesicModel::drawVerticalLines().
|
virtual |
Draw a rectangle in world coordinates (mm).
| box | in mm |
Definition at line 58 of file Utils.cpp.
References te::map::Canvas::draw(), te::layout::Context::getCanvas(), te::common::Singleton< Context >::getInstance(), te::gm::Envelope::getLowerLeftX(), te::gm::Envelope::getLowerLeftY(), te::gm::Envelope::getUpperRightX(), te::gm::Envelope::getUpperRightY(), te::gm::LineStringType, te::gm::PolygonType, te::gm::LineString::setPointN(), and te::gm::CurvePolygon::setRingN().
Referenced by te::layout::ItemModelObservable::drawBackground(), te::layout::LegendModel::drawGroupingLegend(), te::layout::LegendChildModel::drawLegend(), and te::layout::LegendModel::drawStyleLegend().
|
virtual |
|
virtual |
Returns a pointer RGBA colors that representing an image.
| box | in mm |
Definition at line 111 of file Utils.cpp.
References te::layout::Context::getCanvas(), te::gm::Envelope::getHeight(), te::map::Canvas::getImage(), te::common::Singleton< Context >::getInstance(), te::gm::Envelope::getWidth(), and te::gm::Envelope::isValid().
Referenced by te::layout::LegendChildModel::draw(), te::layout::MapModel::draw(), and te::layout::LegendModel::draw().
| te::layout::WorldTransformer Utils::getTransformGeo | ( | te::gm::Envelope | boxgeo, |
| te::gm::Envelope | boxmm | ||
| ) |
Returns a WorldTransformer object to transformations between geo coordinates and millimeter coordinates.
| box | in geo coordinates |
Definition at line 298 of file Utils.cpp.
References te::gm::Envelope::isValid(), and te::layout::WorldTransformer::setTransformationParameters().
Referenced by te::layout::GridPlanarModel::drawHorizontalLines(), te::layout::GridGeodesicModel::drawHorizontalLines(), te::layout::GridPlanarModel::drawVerticalLines(), te::layout::GridGeodesicModel::drawVerticalLines(), and te::layout::MapModel::generateSystematic().
|
virtual |
|
virtual |
Millimeter to pixel.
| millimeter | value |
Definition at line 131 of file Utils.cpp.
References te::layout::Context::getDpiX(), and te::common::Singleton< Context >::getInstance().
Referenced by te::layout::LegendItem::paint(), and te::layout::LegendItem::updateObserver().
| std::string Utils::proj4DescToGeodesic | ( | ) |
Returns string wkt with non-planar projection.
Definition at line 408 of file Utils.cpp.
Referenced by te::layout::MapModel::getWorldBox(), and te::layout::MapModel::getWorldInDegrees().
| std::string Utils::proj4DescToPlanar | ( | int | zone | ) |
Returns string wkt with UTM projection in the specified zone.
| zone | UTM |
Definition at line 376 of file Utils.cpp.
Referenced by te::layout::MapModel::getWorldInMeters().
|
virtual |
Map latlong to UTM zone.
| box | in latlong |
| zone | returns UTM zone |
Definition at line 447 of file Utils.cpp.
References te::common::Singleton< SpatialReferenceSystemManager >::getInstance(), te::gm::Envelope::isValid(), and te::gm::Envelope::transform().
Referenced by te::layout::GridGeodesicModel::drawHorizontalLines(), and te::layout::GridGeodesicModel::drawVerticalLines().
|
virtual |
Map latlong LinearRing (line) to UTM zone.
| line | line in latlong |
| zone | returns UTM zone |
Definition at line 467 of file Utils.cpp.
References te::gm::LineString::computeMBR(), te::gm::AbstractPoint::computeMBR(), te::gm::Envelope::getLowerLeftX(), te::gm::Envelope::getLowerLeftY(), te::gm::Geometry::getMBR(), te::gm::LineString::getNPoints(), te::gm::LineString::getPointN(), and te::gm::LineString::setPoint().
|
virtual |
Map latlong Point (point) to UTM zone.
| zone | returns UTM zone |
Definition at line 486 of file Utils.cpp.
References te::gm::AbstractPoint::computeMBR(), and te::gm::Geometry::getMBR().
|
virtual |
Clears the canvas content and fills with the background color. Sets all width with 1.
Definition at line 585 of file Utils.cpp.
References te::map::Canvas::clear(), te::layout::Context::getCanvas(), te::common::Singleton< Context >::getInstance(), te::map::Canvas::setLineWidth(), te::map::Canvas::setPointWidth(), te::map::Canvas::setPolygonContourWidth(), te::map::Canvas::setPolygonPatternWidth(), and te::map::Canvas::setTextContourWidth().
Referenced by te::layout::ItemController::redraw().
|
virtual |
|
virtual |
A method that calculates the height and width of a text.
| w | returns the width |
| h | returns the height |
| text |
Definition at line 271 of file Utils.cpp.
References te::layout::Context::getCanvas(), te::gm::Envelope::getHeight(), te::common::Singleton< Context >::getInstance(), te::gm::Geometry::getMBR(), te::map::Canvas::getTextBoundary(), and te::gm::Envelope::getWidth().
Referenced by te::layout::LegendModel::drawGroupingLegend(), te::layout::GridPlanarModel::drawHorizontalLines(), te::layout::LegendChildModel::drawLegend(), te::layout::LegendModel::drawLegend(), te::layout::HorizontalRuler::drawRuler(), te::layout::VerticalRuler::drawRuler(), te::layout::LegendModel::drawStyleLegend(), te::layout::GridPlanarModel::drawVerticalLines(), te::layout::LegendItem::paint(), and te::layout::LegendModel::updateBox().
|
protectedvirtual |
Transforms the box (mm) to screen coordinates (pixel).
| transf | logic for transforming from device coordinate to world coordinate and vice-versa. |
Definition at line 200 of file Utils.cpp.
References te::gm::Envelope::getLowerLeftX(), te::gm::Envelope::getLowerLeftY(), te::gm::Envelope::getUpperRightX(), te::gm::Envelope::getUpperRightY(), and te::map::WorldDeviceTransformer::world2Device().
| te::common::UnitOfMeasurePtr Utils::unitMeasure | ( | int | srid | ) |
Returns a UnitOfMeasurePtr pointer.
| srid | projection number |
Definition at line 435 of file Utils.cpp.
References te::common::Singleton< SpatialReferenceSystemManager >::getInstance().
Referenced by te::layout::MapModel::unitMeasureLayer().
|
virtual |
Converts the box world (mm) to screen coordinates (pixel).
| box | in mm |
Definition at line 167 of file Utils.cpp.
References te::gm::Envelope::isValid().
Referenced by te::layout::MapItem::calculateFrameMargin(), te::layout::MapItem::MapItem(), te::layout::ItemGroup::updateObserver(), and te::layout::MapItem::updateObserver().
|
protectedvirtual |
Converts the box world (mm) to screen coordinates (pixel).
| box | in mm |
Definition at line 178 of file Utils.cpp.
References te::gm::Envelope::getHeight(), te::gm::Envelope::getLowerLeftX(), te::gm::Envelope::getLowerLeftY(), te::gm::Envelope::getUpperRightX(), te::gm::Envelope::getUpperRightY(), te::gm::Envelope::getWidth(), and te::map::WorldDeviceTransformer::setTransformationParameters().