All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Utils.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file Utils.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "Utils.h"
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"
37 #include "enum/AbstractType.h"
38 #include "../../srs/SpatialReferenceSystemManager.h"
39 #include "../../common/Translator.h"
40 
41 // STL
42 #include <math.h>
43 #include <string>
44 #include <sstream>
45 #include <exception>
46 
48  m_applyZoom(true)
49 {
50 
51 }
52 
54 {
55 
56 }
57 
59 {
61 
62  if(!canvas)
63  {
64  return;
65  }
66 
68 
70  outRingPtr0->setPointN( 0, te::gm::Point(box.getLowerLeftX(), box.getLowerLeftY()));
71  outRingPtr0->setPointN( 1, te::gm::Point(box.getUpperRightX(), box.getLowerLeftY()));
72  outRingPtr0->setPointN( 2, te::gm::Point(box.getUpperRightX(), box.getUpperRightY()));
73  outRingPtr0->setPointN( 3, te::gm::Point(box.getLowerLeftX(), box.getUpperRightY()));
74  outRingPtr0->setPointN( 4, te::gm::Point(box.getLowerLeftX(), box.getLowerLeftY()));
75 
76  rect->setRingN(0, outRingPtr0);
77 
78  canvas->draw(rect);
79 
80  if(rect)
81  {
82  delete rect;
83  rect = 0;
84  }
85 }
86 
88 {
90 
91  if(!canvas)
92  {
93  return;
94  }
95 
96  canvas->draw(line);
97 }
98 
100 {
102  line->setNumCoordinates(3);
103 
104  line->setPointN(0, te::gm::Point(box.getLowerLeftX(), box.getLowerLeftY()));
105  line->setPointN(1, te::gm::Point(box.getUpperRightX(), box.getUpperRightY()));
106  line->setPointN(2, te::gm::Point(box.getLowerLeftX(), box.getLowerLeftY()));
107 
108  return line;
109 }
110 
112 {
113  te::color::RGBAColor** pixmap = 0;
114 
116 
117  if(!canvas)
118  {
119  return pixmap;
120  }
121 
122  te::gm::Envelope boxViewport = viewportBox(boxmm);
123 
124  if(boxViewport.isValid())
125  {
126  pixmap = canvas->getImage(0, 0, boxViewport.getWidth(), boxViewport.getHeight());
127  }
128  return pixmap;
129 }
130 
132 {
133  int devDpi = Context::getInstance().getDpiX();
134  int px = (mm * devDpi) / 25.4 ;
135  return px;
136 }
137 
138 void te::layout::Utils::configCanvas( te::gm::Envelope box, bool resize, bool applyZoom )
139 {
140  m_applyZoom = applyZoom;
141  te::gm::Envelope boxViewport = viewportBox(box);
142  changeCanvas(boxViewport, box, resize);
143 }
144 
145 void te::layout::Utils::changeCanvas( te::gm::Envelope viewport, te::gm::Envelope world, bool resize /*= true*/ )
146 {
148 
149  if(!canvas)
150  {
151  return;
152  }
153 
154  if(resize)
155  {
156  //Transparent
157  te::color::RGBAColor color(255,255,255, 0);
158  canvas->setBackgroundColor(color);
159 
160  canvas->resize(viewport.getWidth(), viewport.getHeight());
161  }
162 
163  canvas->setWindow(world.getLowerLeftX(), world.getLowerLeftY(),
164  world.getUpperRightX(), world.getUpperRightY());
165 }
166 
168 {
169  te::gm::Envelope boxViewport;
170 
171  if(!box.isValid())
172  return boxViewport;
173 
174  boxViewport = viewportBoxFromMM(box);
175  return boxViewport;
176 }
177 
179 {
180  te::map::WorldDeviceTransformer transf; // World Device Transformer.
181 
182  double zoomFactor = 1.;
183 
184  if(m_applyZoom)
185  {
186  //zoomFactor = Context::getInstance().getZoomFactor();
187  }
188 
189  int pxwidth = mm2pixel(box.getWidth() * zoomFactor);
190  int pxheight = mm2pixel(box.getHeight() * zoomFactor);
191 
192  // Adjust internal renderer transformer
194  box.getUpperRightX(), box.getUpperRightY(), pxwidth, pxheight);
195 
196  te::gm::Envelope boxViewport = transformToViewport(transf, box);
197  return boxViewport;
198 }
199 
201 {
202  double px1 = 0;
203  double py1 = 0;
204  double px2 = 0;
205  double py2 = 0;
206  double pycopy = 0;
207  transf.world2Device(box.getLowerLeftX(), box.getLowerLeftY(), px1, py1);
208  transf.world2Device(box.getUpperRightX(), box.getUpperRightY(), px2, py2);
209 
210  if(py1 > py2 )
211  {
212  pycopy = py1;
213  py1 = py2;
214  py2 = pycopy;
215  }
216 
217  te::gm::Envelope boxViewport(px1, py1, px2, py2);
218  return boxViewport;
219 }
220 
222 {
224  std::map<int, te::gm::Point> coords;
225 
226  int count = 1;
227  for(double sub_x = box.getLowerLeftX(); sub_x < box.getUpperRightX(); sub_x +=(gap / 4.))
228  {
229  coords[count] = te::gm::Point(sub_x, axisCoord);
230  count+=1;
231  }
232 
233  line->setNumCoordinates(count + 1);
234  line->setPointN(0, te::gm::Point(box.getLowerLeftX(), axisCoord));
235 
236  for(int i = 1 ; i < count ; ++i)
237  {
238  line->setPointN(i, coords[i]);
239  }
240 
241  line->setPointN(count, te::gm::Point(box.getUpperRightX(), axisCoord));
242 
243  return line;
244 }
245 
247 {
249  std::map<int, te::gm::Point> coords;
250 
251  int count = 1;
252  for(double sub_y = box.getLowerLeftY(); sub_y < box.getUpperRightY(); sub_y +=(gap / 4.))
253  {
254  coords[count] = te::gm::Point(axisCoord, sub_y);
255  count+=1;
256  }
257 
258  line->setNumCoordinates(count + 1);
259  line->setPointN(0, te::gm::Point(axisCoord, box.getLowerLeftY()));
260 
261  for(int i = 1 ; i < count ; ++i)
262  {
263  line->setPointN(i, coords[i]);
264  }
265 
266  line->setPointN(count, te::gm::Point(axisCoord, box.getUpperRightY()));
267 
268  return line;
269 }
270 
271 void te::layout::Utils::textBoundingBox( double &w, double &h, std::string txt )
272 {
274 
275  if(!canvas)
276  {
277  return;
278  }
279 
280  w = 0;
281  h = 0;
282 
283  te::gm::Polygon* poly = canvas->getTextBoundary(0, 0, txt, 0);
284  if(poly)
285  {
286  //Box = mbr: minimum bounding rectangle
287  const te::gm::Envelope* env = poly->getMBR();
288  te::gm::Envelope* box = 0;
289  box = const_cast<te::gm::Envelope*>(env);
290  if(box)
291  {
292  w = box->getWidth();
293  h = box->getHeight();
294  }
295  }
296 }
297 
299 {
300  WorldTransformer transf; // World Transformer.
301 
302  if(!boxgeo.isValid())
303  return transf;
304 
305  if(!boxmm.isValid())
306  return transf;
307 
308  // Adjust internal renderer transformer
309  transf.setTransformationParameters(boxgeo, boxmm);
310 
311  return transf;
312 }
313 
314 std::string te::layout::Utils::convertDecimalToDegree( const double& value, bool bDegrees, bool bMinutes, bool bSeconds )
315 {
316  std::string degreeValue;
317  double dbValue;
318  double sec;
319  double min;
320 
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.));
324 
325  if(roundNumber(sec) >= 60)
326  {
327  min++;
328  sec=0;
329  }
330 
331  min = std::floor(min);
332  if(min >= 60.0)
333  {
334  min = 0;
335  dbValue++;
336  }
337 
338  char n = (char)-80;
339 
340  if(bDegrees)
341  degreeValue = convertNumberToString(std::floor(dbValue), 0);
342  if(bMinutes)
343  degreeValue += n + convertNumberToString(std::floor(min), 0);
344  if(bSeconds)
345  degreeValue += "' " + convertNumberToString(std::fabs(sec),0) + "''";
346 
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) + "''";
349 
350  return degreeValue;
351 }
352 
353 std::string te::layout::Utils::convertNumberToString( const double& value, int precision )
354 {
355  std::ostringstream convert;
356  convert.precision(precision);
357 
358  double number = value;
359  convert << number;
360  return convert.str();
361 }
362 
363 int te::layout::Utils::roundNumber( const double& value )
364 {
365  if (value >= 0)
366  return (int)(value+.5);
367  else
368  return (int)(value-.5);
369 }
370 
372 {
373  return 0;
374 }
375 
377 {
378  /*
379  PROJ4
380  +proj Projection name
381  +datum Datum name
382  +lat_0 Latitude of origin
383  +lon_0 Central meridian
384  +x_0 False easting
385  +y_0 False northing
386  +lat_1 Latitude of first standard parallel
387  +lat_2 Latitude of second standard parallel
388  +units meters, US survey feet, etc.
389  +lat_ts Latitude of true scale
390  +south Denotes southern hemisphere UTM zone
391  +no_defs Don't use the /usr/share/proj/proj_def.dat defaults file
392  */
393 
394  std::stringstream szone;
395  szone << zone;
396 
397  std::string proj4 = "+proj=utm";
398  proj4+= " +zone="+ szone.str();
399  proj4+= " +south"; // pode ser +noth?
400  proj4+= " +ellps=intl";
401  proj4+= " +towgs84=-206,172,-6,0,0,0,0";
402  proj4+= " +units=m";
403  proj4+= " +no_defs ";
404 
405  return proj4;
406 }
407 
409 {
410  std::string proj4;
411  proj4 += "+proj=longlat";
412  proj4 += " +ellps=aust_SA";
413  proj4 += " +towgs84=-57,1,-41,0,0,0,0";
414  proj4 += " +no_defs ";
415 
416  return proj4;
417 }
418 
420 {
421  double longitude = latLongBox.getCenter().x;
422  int meridiano = (int)(longitude / 6);
423  meridiano = meridiano * 6;
424 
425  meridiano = abs(meridiano) + 3;
426 
427  double long0 = -meridiano * TeCDR;
428 
429  // TeUTM T4
430  int zone = ((int)((long0*TeCRD+183.0)/6.0));
431 
432  return zone;
433 }
434 
436 {
438 
439  // Checks if is Planar Geographic
440  std::string authName = "EPSG"; // Now: So far it is the only one supported by TerraLib 5. Future: Review this line!
441  te::srs::SpatialReferenceSystemManager::getInstance().isGeographic(srid, authName);
442  unitPtr = te::srs::SpatialReferenceSystemManager::getInstance().getUnit(srid, authName);
443 
444  return unitPtr;
445 }
446 
448 {
449  if(!latLongBox->isValid())
450  return;
451 
452  std::string proj4 = proj4DescToPlanar(zone);
453 
454  // Get the id of the projection of destination
455  std::pair<std::string, unsigned int> projMeters = te::srs::SpatialReferenceSystemManager::getInstance().getIdFromP4Txt(proj4);
456 
457  std::string proj4geo = proj4DescToGeodesic();
458 
459  // Get the id of the projection source
460  std::pair<std::string, unsigned int> currentBoxProj = te::srs::SpatialReferenceSystemManager::getInstance().getIdFromP4Txt(proj4geo);
461 
462  // Remapping
463  int srid = currentBoxProj.second;
464  latLongBox->transform(srid, projMeters.second);
465 }
466 
468 {
469  if(!line)
470  return;
471 
472  int npoints = line->getNPoints();
473 
474  for(int i = 0 ; i < npoints ; ++i)
475  {
476  te::gm::Point* p = line->getPointN(i);
477  const te::gm::Envelope* env = p->getMBR();
478  te::gm::Envelope* en = const_cast<te::gm::Envelope*>(env);
479  remapToPlanar(en, zone);
480  line->setPoint(i, env->getLowerLeftX(), env->getLowerLeftY());
481  p->computeMBR(true);
482  }
483  line->computeMBR(true);
484 }
485 
487 {
488  if(!point)
489  return;
490 
491  const te::gm::Envelope* env = point->getMBR();
492  te::gm::Envelope* en = const_cast<te::gm::Envelope*>(env);
493  remapToPlanar(en, zone);
494  point->computeMBR(true);
495 }
496 
498 {
499  if(!line)
500  return;
501 
502  int npoints = line->getNPoints();
503 
504  for(int i = 0 ; i < npoints ; ++i)
505  {
506  te::gm::Point* p = line->getPointN(i);
507  double x = 0;
508  double y = 0;
509  transf.system1Tosystem2(p->getX(), p->getY(), x, y);
510  line->setPoint(i, x, y);
511  p->computeMBR(true);
512  }
513 
514  line->computeMBR(true);
515 }
516 
518 {
519  if(!poly)
520  return;
521 
522  int nrings = poly->getNumInteriorRings();
523 
524  for(int i = 0 ; i < nrings ; ++i)
525  {
526  te::gm::LinearRing* line = dynamic_cast<te::gm::LinearRing*>(poly->getInteriorRingN(i));
527  if(line)
528  {
529  convertToMillimeter(transf, line);
530  }
531  }
532 
533  poly->computeMBR(true);
534 }
535 
536 char* te::layout::Utils::imageToChar( std::string fileName, std::ifstream::pos_type &size )
537 {
538  char* memblock = 0;
539 
540  if(fileName.compare("") == 0)
541  return memblock;
542 
543  try
544  {
545  std::ifstream file (fileName.c_str(), std::ios::in|std::ios::binary|std::ios::ate);
546  if (file.is_open())
547  {
548  size = file.tellg();
549  memblock = new char[size];
550  file.seekg (0, std::ios::beg);
551  file.read((char*)memblock, size); // cast to a char* to give to file.read
552 
553  file.close();
554  }
555  }
556  catch (std::ifstream::failure &e)
557  {
558  std::cerr << e.what() << std::endl;
559  std::string errmsg = "Exception opening/reading/closing file: \n ";
560  te::common::Exception ex(TE_TR(errmsg));
561  }
562  catch (std::exception const& e)
563  {
564  std::cerr << e.what() << std::endl;
565  }
566  return memblock;
567 }
568 
569 std::string te::layout::Utils::getFileExtension( std::string fileName )
570 {
571  std::string extension = fileName.substr(fileName.find_last_of("/\\.") + 1);
572  return extension;
573 }
574 
576 {
577  m_applyZoom = apply;
578 }
579 
581 {
582  return m_applyZoom;
583 }
584 
586 {
588 
589  if(!canvas)
590  {
591  return;
592  }
593 
594  int size = 1;
595 
596  canvas->clear();
597  canvas->setLineWidth(size);
598  canvas->setPointWidth(size);
599  canvas->setPolygonContourWidth(size);
600  canvas->setPolygonPatternWidth(size);
601  canvas->setTextContourWidth(size);
602 }
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).
void system1Tosystem2(double &wx, double &wy) const
It transforms the coordinate wx and wy from world coordinates to other(system) coordinates without us...
virtual te::gm::Envelope viewportBoxFromMM(te::gm::Envelope box)
Converts the box world (mm) to screen coordinates (pixel).
Definition: Utils.cpp:178
virtual void convertToMillimeter(WorldTransformer transf, te::gm::LinearRing *line)
Convert LinearRing from one coordinate system to mm.
Definition: Utils.cpp:497
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.
Definition: Utils.cpp:314
void computeMBR(bool cascade) const
It computes the minimum bounding rectangle for the linestring.
Definition: LineString.cpp:206
virtual void textBoundingBox(double &w, double &h, std::string txt)
A method that calculates the height and width of a text.
Definition: Utils.cpp:271
te::layout::WorldTransformer getTransformGeo(te::gm::Envelope boxgeo, te::gm::Envelope boxmm)
Returns a WorldTransformer object to transformations between geo coordinates and millimeter coordinat...
Definition: Utils.cpp:298
Utils()
Constructor.
Definition: Utils.cpp:47
double x
x-coordinate.
Definition: Coord2D.h:113
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.
Definition: Utils.cpp:376
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).
Definition: Utils.cpp:58
Point * getPointN(std::size_t i) const
It returns the specified point in this LineString.
Definition: LineString.cpp:323
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
Definition: Envelope.h:410
void setTransformationParameters(const double &wllx, const double &wlly, const double &wurx, const double &wury, int deviceWidth, int deviceHeight)
It adjusts a new transformation function that maps between the spatial coordinate system of a feature...
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.
Definition: Envelope.h:400
double getWidth() const
It returns the envelope width.
Definition: Envelope.h:443
std::string proj4DescToGeodesic()
Returns string wkt with non-planar projection.
Definition: Utils.cpp:408
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.
Definition: Envelope.h:420
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
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...
Definition: Utils.cpp:585
virtual te::gm::LinearRing * createSimpleLine(te::gm::Envelope box)
Creates a LinearRing (line) pointer from a box in world coordinates (mm)
Definition: Utils.cpp:99
This class implements the logic for transforming from device coordinate to world coordinate and vice-...
te::common::UnitOfMeasurePtr unitMeasure(int srid)
Returns a UnitOfMeasurePtr pointer.
Definition: Utils.cpp:435
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.
Definition: Envelope.cpp:51
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
void computeMBR(bool cascade) const
It computes the minimum bounding rectangle for the point.
virtual int mm2pixel(double mm)
Millimeter to pixel.
Definition: Utils.cpp:131
virtual void setApplyZoom(bool apply)
Definition: Utils.cpp:575
const double & getY() const
It returns the Point y-coordinate value.
Definition: Point.h:150
static Context & getInstance()
It returns a reference to the singleton instance.
A point with x and y coordinate values.
Definition: Point.h:50
int calculatePlanarZone(te::gm::Envelope latLongBox)
Calculates the area from a box in coordinated latlong.
Definition: Utils.cpp:419
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
Definition: LineString.cpp:353
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
virtual int roundNumber(const double &value)
Rounds double to int.
Definition: Utils.cpp:363
virtual char * imageToChar(std::string fileName, std::ifstream::pos_type &size)
Opens the file and loads the image into memory and converts to char*.
Definition: Utils.cpp:536
void setNumCoordinates(std::size_t size)
It reserves room for the number of coordinates in this LineString.
Definition: LineString.cpp:265
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...
Definition: Utils.cpp:221
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.
Definition: LineString.h:193
virtual void drawLineW(te::gm::LinearRing *line)
Draw a line in world coordinates (mm).
Definition: Utils.cpp:87
virtual void remapToPlanar(te::gm::Envelope *latLongBox, int zone)
Map latlong to UTM zone.
Definition: Utils.cpp:447
virtual std::string convertNumberToString(const double &value, int precision)
Number to string.
Definition: Utils.cpp:353
virtual te::gm::Envelope viewportBox(te::gm::Envelope box)
Converts the box world (mm) to screen coordinates (pixel).
Definition: Utils.cpp:167
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Definition: Exception.h:58
virtual void setPolygonContourWidth(int w)=0
It sets the polygon contour width.
This class implements the logic for transforming from System 1 coordinate to other type of coordinate...
A canvas is an abstraction of a drawing area.
Definition: Canvas.h:91
boost::shared_ptr< UnitOfMeasure > UnitOfMeasurePtr
virtual bool getApplyZoom()
Definition: Utils.cpp:580
virtual te::gm::Envelope transformToViewport(te::map::WorldDeviceTransformer transf, te::gm::Envelope box)
Transforms the box (mm) to screen coordinates (pixel).
Definition: Utils.cpp:200
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
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.
Definition: Utils.cpp:111
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
Definition: Envelope.h:390
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
virtual double convertDegreeToDecimal()
Converts degree geo coordinates to decimal.
Definition: Utils.cpp:371
std::string convert(const path &v)
URI path to string.
Definition: path.cpp:219
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...
Definition: Utils.cpp:138
void world2Device(double &wx, double &wy) const
It transforms the coordinate wx and wy from world coordinates to device (canvas) coordinates without ...
void setPointN(std::size_t i, const Point &p)
It sets the value of the specified point to this new one.
Definition: LineString.cpp:339
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...
Definition: Utils.cpp:246
virtual void setPolygonPatternWidth(int w)=0
It sets the polygon pattern width.
virtual ~Utils()
Destructor.
Definition: Utils.cpp:53
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...
Definition: Utils.cpp:145
void setTransformationParameters(te::gm::Envelope system1Box, te::gm::Envelope system2Box)
It adjusts a new transformation function that maps between the world coordinate system to other coord...
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
Definition: Envelope.cpp:92
const double TeCDR
Conversion factor: degrees to radians.
Definition: Utils.h:49
virtual void draw(const te::gm::Geometry *geom)=0
It draws the geometry on canvas.
double getHeight() const
It returns the envelope height.
Definition: Envelope.h:448
const Envelope * getMBR() const
It returns the minimum bounding rectangle for the geometry in an internal representation.
Definition: Geometry.cpp:104
const double & getX() const
It returns the Point x-coordinate value.
Definition: Point.h:136
bool isValid() const
It tells if the rectangle is valid or not.
Definition: Envelope.h:438
const double TeCRD
Conversion factor: radians to degrees.
Definition: Utils.h:50
te::map::Canvas * getCanvas()
Returns abstraction of a drawing area.
Definition: Context.cpp:143
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.
Definition: Utils.cpp:569