31 #include "../../color/RGBAColor.h"
32 #include "../../geometry/Polygon.h"
33 #include "../../geometry/Enums.h"
34 #include "../../geometry/LinearRing.h"
35 #include "../../geometry/Point.h"
36 #include "../../qt/widgets/canvas/Canvas.h"
38 #include "../../srs/SpatialReferenceSystemManager.h"
39 #include "../../common/Translator.h"
134 int px = (mm * devDpi) / 25.4 ;
140 m_applyZoom = applyZoom;
142 changeCanvas(boxViewport, box, resize);
174 boxViewport = viewportBoxFromMM(box);
182 double zoomFactor = 1.;
189 int pxwidth = mm2pixel(box.
getWidth() * zoomFactor);
190 int pxheight = mm2pixel(box.
getHeight() * zoomFactor);
224 std::map<int, te::gm::Point> coords;
236 for(
int i = 1 ; i < count ; ++i)
249 std::map<int, te::gm::Point> coords;
261 for(
int i = 1 ; i < count ; ++i)
316 std::string degreeValue;
321 dbValue = std::fabs(180.* value/(4.*atan(1.)));
322 min = std::fabs((dbValue-(
int)dbValue)*60.);
323 sec = std::fabs(std::fabs((min-
int(min))*60.));
325 if(roundNumber(sec) >= 60)
331 min = std::floor(min);
341 degreeValue = convertNumberToString(std::floor(dbValue), 0);
343 degreeValue += n + convertNumberToString(std::floor(min), 0);
345 degreeValue +=
"' " + convertNumberToString(std::fabs(sec),0) +
"''";
347 if(bDegrees ==
false && bMinutes ==
false && bSeconds ==
false)
348 degreeValue = convertNumberToString(std::floor(dbValue),0) + n + convertNumberToString(std::fabs(min),0) +
"' " + convertNumberToString(std::fabs(sec),0) +
"''";
356 convert.precision(precision);
358 double number = value;
360 return convert.str();
366 return (
int)(value+.5);
368 return (
int)(value-.5);
394 std::stringstream szone;
397 std::string proj4 =
"+proj=utm";
398 proj4+=
" +zone="+ szone.str();
400 proj4+=
" +ellps=intl";
401 proj4+=
" +towgs84=-206,172,-6,0,0,0,0";
403 proj4+=
" +no_defs ";
411 proj4 +=
"+proj=longlat";
412 proj4 +=
" +ellps=aust_SA";
413 proj4 +=
" +towgs84=-57,1,-41,0,0,0,0";
414 proj4 +=
" +no_defs ";
422 int meridiano = (int)(longitude / 6);
423 meridiano = meridiano * 6;
425 meridiano = abs(meridiano) + 3;
427 double long0 = -meridiano *
TeCDR;
430 int zone = ((int)((long0*
TeCRD+183.0)/6.0));
440 std::string authName =
"EPSG";
452 std::string proj4 = proj4DescToPlanar(zone);
457 std::string proj4geo = proj4DescToGeodesic();
463 int srid = currentBoxProj.second;
464 latLongBox->
transform(srid, projMeters.second);
474 for(
int i = 0 ; i < npoints ; ++i)
479 remapToPlanar(en, zone);
493 remapToPlanar(en, zone);
504 for(
int i = 0 ; i < npoints ; ++i)
524 for(
int i = 0 ; i < nrings ; ++i)
529 convertToMillimeter(transf, line);
540 if(fileName.compare(
"") == 0)
545 std::ifstream file (fileName.c_str(), std::ios::in|std::ios::binary|std::ios::ate);
549 memblock =
new char[size];
550 file.seekg (0, std::ios::beg);
551 file.read((
char*)memblock, size);
556 catch (std::ifstream::failure &e)
558 std::cerr << e.what() << std::endl;
559 std::string errmsg =
"Exception opening/reading/closing file: \n ";
562 catch (std::exception
const& e)
564 std::cerr << e.what() << std::endl;
571 std::string extension = fileName.substr(fileName.find_last_of(
"/\\.") + 1);
Curve * getInteriorRingN(std::size_t i) const
It returns the n-th interior ring for this curve polygon as a curve.
virtual void resize(int w, int h)=0
It adjusts the canvas size (width and height).
virtual te::gm::Envelope viewportBoxFromMM(te::gm::Envelope box)
Converts the box world (mm) to screen coordinates (pixel).
virtual void convertToMillimeter(WorldTransformer transf, te::gm::LinearRing *line)
Convert LinearRing from one coordinate system to mm.
virtual void setPointWidth(int w)=0
It sets the point width. If point has a patterns, this pattern is scaled to width.
virtual std::string convertDecimalToDegree(const double &value, bool bDegrees, bool bMinutes, bool bSeconds)
Converts decimal geo coordinates to degrees.
void computeMBR(bool cascade) const
It computes the minimum bounding rectangle for the linestring.
virtual void textBoundingBox(double &w, double &h, std::string txt)
A method that calculates the height and width of a text.
te::layout::WorldTransformer getTransformGeo(te::gm::Envelope boxgeo, te::gm::Envelope boxmm)
Returns a WorldTransformer object to transformations between geo coordinates and millimeter coordinat...
std::size_t getNumInteriorRings() const
It returns the number of interior rings in this CurvePolygon.
std::string proj4DescToPlanar(int zone)
Returns string wkt with UTM projection in the specified zone.
virtual te::gm::Polygon * getTextBoundary(int x, int y, const std::string &txt, float angle=0.0, te::at::HorizontalAlignment hAlign=te::at::Start, te::at::VerticalAlignment vAlign=te::at::Baseline)=0
It returns the text boundary (its enclose rectangle).
virtual void drawRectW(te::gm::Envelope box)
Draw a rectangle in world coordinates (mm).
Point * getPointN(std::size_t i) const
It returns the specified point in this LineString.
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
virtual void setLineWidth(int w)=0
It sets the line width.
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
double getWidth() const
It returns the envelope width.
std::string proj4DescToGeodesic()
Returns string wkt with non-planar projection.
virtual void clear()=0
It clears the canvas content and fills with the background color.
Singleton class responsible for keeping active objects while the plugin is loaded in memory and make ...
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
#define TE_TR(message)
It marks a string in order to get translated.
virtual void setBackgroundColor(const te::color::RGBAColor &color)=0
It sets the canvas background color.
virtual void resetCanvas()
Clears the canvas content and fills with the background color. Sets all width with 1...
virtual te::gm::LinearRing * createSimpleLine(te::gm::Envelope box)
Creates a LinearRing (line) pointer from a box in world coordinates (mm)
te::common::UnitOfMeasurePtr unitMeasure(int srid)
Returns a UnitOfMeasurePtr pointer.
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.
A LinearRing is a LineString that is both closed and simple.
void computeMBR(bool cascade) const
It computes the minimum bounding rectangle for the point.
virtual int mm2pixel(double mm)
Millimeter to pixel.
virtual void setApplyZoom(bool apply)
const double & getY() const
It returns the Point y-coordinate value.
static Context & getInstance()
It returns a reference to the singleton instance.
A point with x and y coordinate values.
int calculatePlanarZone(te::gm::Envelope latLongBox)
Calculates the area from a box in coordinated latlong.
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
An Envelope defines a 2D rectangular region.
virtual int roundNumber(const double &value)
Rounds double to int.
virtual char * imageToChar(std::string fileName, std::ifstream::pos_type &size)
Opens the file and loads the image into memory and converts to char*.
void setNumCoordinates(std::size_t size)
It reserves room for the number of coordinates in this LineString.
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...
virtual void setTextContourWidth(int width)=0
It sets the text contour width.
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
virtual void drawLineW(te::gm::LinearRing *line)
Draw a line in world coordinates (mm).
virtual void remapToPlanar(te::gm::Envelope *latLongBox, int zone)
Map latlong to UTM zone.
virtual std::string convertNumberToString(const double &value, int precision)
Number to string.
virtual te::gm::Envelope viewportBox(te::gm::Envelope box)
Converts the box world (mm) to screen coordinates (pixel).
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
virtual void setPolygonContourWidth(int w)=0
It sets the polygon contour width.
A canvas is an abstraction of a drawing area.
boost::shared_ptr< UnitOfMeasure > UnitOfMeasurePtr
virtual bool getApplyZoom()
virtual te::gm::Envelope transformToViewport(te::map::WorldDeviceTransformer transf, te::gm::Envelope box)
Transforms the box (mm) to screen coordinates (pixel).
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
void computeMBR(bool cascade) const
It computes the minimum bounding rectangle for the curve polygon.
virtual te::color::RGBAColor ** getImageW(te::gm::Envelope boxmm)
Returns a pointer RGBA colors that representing an image.
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
virtual double convertDegreeToDecimal()
Converts degree geo coordinates to decimal.
std::string convert(const path &v)
URI path to string.
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 t...
void setPointN(std::size_t i, const Point &p)
It sets the value of the specified point to this new one.
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...
virtual void setPolygonPatternWidth(int w)=0
It sets the polygon pattern width.
virtual ~Utils()
Destructor.
virtual char * getImage(ImageType t, std::size_t &size, int quality=75, int fg=0) const =0
It returns the internal content as an image in a specific format (PNG, JPEG, ...).
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 t...
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
const double TeCDR
Conversion factor: degrees to radians.
virtual void draw(const te::gm::Geometry *geom)=0
It draws the geometry on canvas.
double getHeight() const
It returns the envelope height.
const Envelope * getMBR() const
It returns the minimum bounding rectangle for the geometry in an internal representation.
const double & getX() const
It returns the Point x-coordinate value.
bool isValid() const
It tells if the rectangle is valid or not.
const double TeCRD
Conversion factor: radians to degrees.
te::map::Canvas * getCanvas()
Returns abstraction of a drawing area.
void setRingN(std::size_t i, Curve *r)
It sets the informed position ring to the new one.
virtual std::string getFileExtension(std::string fileName)
Returns the file extension.