All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
te::layout::Utils Class Reference

Utility class with functions to manipulate the canvas and conversion between projections. More...

#include <Utils.h>

Public Member Functions

virtual te::gm::LinearRingaddCoordsInX (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::LinearRingaddCoordsInY (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::LinearRingcreateSimpleLine (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
 

Detailed Description

Utility class with functions to manipulate the canvas and conversion between projections.

Definition at line 61 of file Utils.h.

Constructor & Destructor Documentation

Utils::Utils ( )

Constructor.

Definition at line 47 of file Utils.cpp.

Utils::~Utils ( )
virtual

Destructor.

Definition at line 53 of file Utils.cpp.

Member Function Documentation

te::gm::LinearRing * Utils::addCoordsInX ( te::gm::Envelope  box,
double  axisCoord,
double  gap 
)
virtual

Creates a line with n points in x axis. Method used to create the grid lines on a map. Horizontal line.

Parameters
boxin mm
axisCoordaxis y value
gapdistance between the points on the x axis
Returns

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().

te::gm::LinearRing * Utils::addCoordsInY ( te::gm::Envelope  box,
double  axisCoord,
double  gap 
)
virtual

Creates a line with n points in y axis. Method used to create the grid lines on a map. Vertical line.

Parameters
boxin mm
axisCoordaxis x value
gapdistance between the points on the y axis
Returns

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.

Parameters
latLongBoxbox in latlong
Returns
UTM zone

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().

void Utils::changeCanvas ( te::gm::Envelope  viewport,
te::gm::Envelope  world,
bool  resize = true 
)
protectedvirtual

Sets the viewport and window of the canvas. The viewport is only changed if the resize parameter is true.

Parameters
viewportviewport box(pixel)
worldworld box(mm)
resizetrue 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().

void Utils::configCanvas ( te::gm::Envelope  box,
bool  resize = true,
bool  applyZoom = true 
)
virtual

Sets the viewport and window of the canvas. The viewport is only changed if the resize parameter is true.

Parameters
boxwindow 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().

std::string Utils::convertDecimalToDegree ( const double &  value,
bool  bDegrees,
bool  bMinutes,
bool  bSeconds 
)
virtual

Converts decimal geo coordinates to degrees.

Parameters
valuein decimal
bDegreestrue if should appear in the return string, false otherwise
bMinutestrue if should appear in the return string, false otherwise
bSecondstrue if should appear in the return string, false otherwise
Returns
string value in degree

Definition at line 314 of file Utils.cpp.

Referenced by te::layout::GridGeodesicModel::drawHorizontalLines(), and te::layout::GridGeodesicModel::drawVerticalLines().

double Utils::convertDegreeToDecimal ( )
virtual

Converts degree geo coordinates to decimal.

Returns
double value in decimal

Definition at line 371 of file Utils.cpp.

std::string Utils::convertNumberToString ( const double &  value,
int  precision 
)
virtual

Number to string.

Parameters
value
precisiondecimal places
Returns
number as string

Definition at line 353 of file Utils.cpp.

References te::common::uri::convert().

void Utils::convertToMillimeter ( WorldTransformer  transf,
te::gm::LinearRing line 
)
virtual
void Utils::convertToMillimeter ( WorldTransformer  transf,
te::gm::Polygon poly 
)
virtual

Convert Polygon from one coordinate system to mm.

Parameters
Objectwith logic for transforming
lineLinearRing 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().

bool Utils::getApplyZoom ( )
virtual
Parameters
return

Definition at line 580 of file Utils.cpp.

std::string Utils::getFileExtension ( std::string  fileName)
virtual

Returns the file extension.

Parameters
fileNamefull path to image
Returns
file extension

Definition at line 569 of file Utils.cpp.

te::color::RGBAColor ** Utils::getImageW ( te::gm::Envelope  boxmm)
virtual
char * Utils::imageToChar ( std::string  fileName,
std::ifstream::pos_type &  size 
)
virtual

Opens the file and loads the image into memory and converts to char*.

Parameters
fileNamefull path to image
Returns
size length of file

Definition at line 536 of file Utils.cpp.

References TE_TR.

int Utils::mm2pixel ( double  mm)
virtual

Millimeter to pixel.

Parameters
millimetervalue
Returns
pixel 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.

Returns
wkt

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.

Parameters
zoneUTM
Returns
string wkt

Definition at line 376 of file Utils.cpp.

Referenced by te::layout::MapModel::getWorldInMeters().

void Utils::remapToPlanar ( te::gm::Envelope latLongBox,
int  zone 
)
virtual
void Utils::remapToPlanar ( te::gm::LinearRing line,
int  zone 
)
virtual
void Utils::remapToPlanar ( te::gm::Point point,
int  zone 
)
virtual

Map latlong Point (point) to UTM zone.

Parameters
zonereturns UTM zone

Definition at line 486 of file Utils.cpp.

References te::gm::AbstractPoint::computeMBR(), and te::gm::Geometry::getMBR().

int Utils::roundNumber ( const double &  value)
virtual

Rounds double to int.

Parameters
value
Returns
number rounded

Definition at line 363 of file Utils.cpp.

void Utils::setApplyZoom ( bool  apply)
virtual
Parameters

Definition at line 575 of file Utils.cpp.

te::gm::Envelope Utils::transformToViewport ( te::map::WorldDeviceTransformer  transf,
te::gm::Envelope  box 
)
protectedvirtual

Transforms the box (mm) to screen coordinates (pixel).

Parameters
transflogic for transforming from device coordinate to world coordinate and vice-versa.
Returns
box in screen coordinates (pixel)

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.

Parameters
sridprojection number
Returns
A UnitOfMeasurePtr pointer

Definition at line 435 of file Utils.cpp.

References te::common::Singleton< SpatialReferenceSystemManager >::getInstance().

Referenced by te::layout::MapModel::unitMeasureLayer().

te::gm::Envelope Utils::viewportBox ( te::gm::Envelope  box)
virtual

Converts the box world (mm) to screen coordinates (pixel).

Parameters
boxin mm
Returns
box in pixel

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().

Member Data Documentation

bool te::layout::Utils::m_applyZoom
protected

Definition at line 335 of file Utils.h.


The documentation for this class was generated from the following files: