src/terralib/maptools/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 terralib/maptools/Utils.cpp
22 
23  \brief Utility functions for MapTools module.
24 */
25 
26 // TerraLib
27 #include "../common/progress/TaskProgress.h"
28 #include "../core/translator/Translator.h"
29 #include "../common/STLUtils.h"
30 #include "../common/StringUtils.h"
31 #include "../dataaccess/dataset/DataSetType.h"
32 #include "../dataaccess/query/And.h"
33 #include "../dataaccess/query/DataSetName.h"
34 #include "../dataaccess/query/Field.h"
35 #include "../dataaccess/query/LiteralEnvelope.h"
36 #include "../dataaccess/query/PropertyName.h"
37 #include "../dataaccess/query/Select.h"
38 #include "../dataaccess/query/ST_Intersects.h"
39 #include "../dataaccess/query/Where.h"
40 #include "../dataaccess/utils/Utils.h"
41 #include "../fe/Literal.h"
42 #include "../geometry/GeometryProperty.h"
43 #include "../geometry/Utils.h"
44 #include "../memory/DataSet.h"
45 #include "../raster/Grid.h"
46 #include "../raster/Raster.h"
47 #include "../raster/RasterFactory.h"
48 #include "../raster/RasterProperty.h"
49 #include "../raster/RasterSummary.h"
50 #include "../raster/RasterSummaryManager.h"
51 #include "../raster/Utils.h"
52 #include "../se/ChannelSelection.h"
53 #include "../se/CoverageStyle.h"
54 #include "../se/FeatureTypeStyle.h"
55 #include "../se/ImageOutline.h"
56 #include "../se/RasterSymbolizer.h"
57 #include "../se/Rule.h"
58 #include "../se/Utils.h"
59 #include "../srs/Config.h"
60 #include "../srs/Converter.h"
61 #include "../srs/SpatialReferenceSystemManager.h"
62 
63 #include "Canvas.h"
64 #include "CanvasConfigurer.h"
65 #include "Chart.h"
66 #include "DataSetLayer.h"
67 #include "Exception.h"
68 #include "Grouping.h"
69 #include "QueryEncoder.h"
70 #include "RasterContrast.h"
71 #include "RasterTransform.h"
73 #include "Utils.h"
74 
75 // Boost
76 #include <boost/format.hpp>
77 #include <boost/lexical_cast.hpp>
78 #include <boost/uuid/random_generator.hpp>
79 #include <boost/uuid/uuid_io.hpp>
80 
81 // STL
82 #include <cassert>
83 #include <cstdlib>
84 #include <memory>
85 
86 #ifndef TeCDR
87 #define TeCDR 0.01745329251994329576 //!< Conversion factor: degrees to radians
88 #endif
89 
90 #ifndef TeCRD
91 #define TeCRD 57.29577951308232087679 //!< Conversion factor: radians to degrees
92 #endif
93 
94 te::gm::Envelope te::map::GetSelectedExtent(const std::list<te::map::AbstractLayerPtr> layers, int srid, bool onlyVisibles)
95 {
96  std::list<te::map::AbstractLayerPtr>::const_iterator it = layers.begin();
97 
98  te::gm::Envelope finalEnv;
99 
100  while(it != layers.end())
101  {
102  if(it == layers.begin())
103  finalEnv = GetSelectedExtent((*it), srid, onlyVisibles);
104  else
105  finalEnv.Union(GetSelectedExtent((*it), srid, onlyVisibles));
106 
107  ++it;
108  }
109 
110  return finalEnv;
111 }
112 
114 {
115  if(onlyVisibles && layer->getVisibility() == te::map::NOT_VISIBLE)
116  return te::gm::Envelope();
117 
118  te::gm::Envelope finalEnv;
119 
120  bool isFirst = true;
121 
122  if(!layer->hasChildren())
123  {
124  std::unique_ptr<te::da::DataSetType> dt(layer->getSchema());
125 
126  const te::da::ObjectIdSet* objSet = layer->getSelected();
127 
128  if(!objSet)
129  return te::gm::Envelope();
130 
131  std::unique_ptr<te::da::DataSet> ds(layer->getData(objSet));
132 
134 
135  while(ds->moveNext())
136  {
137  if (ds->isNull(geomProp->getName()))
138  continue;
139 
140  std::unique_ptr<te::gm::Geometry> geom = ds->getGeometry(geomProp->getName());
141 
142  te::gm::Envelope auxEnv(*geom->getMBR());
143 
144  if(layer->getSRID() != srid)
145  auxEnv.transform(layer->getSRID(), srid);
146 
147  if(isFirst)
148  {
149  finalEnv = auxEnv;
150  isFirst = false;
151  continue;
152  }
153 
154  finalEnv.Union(auxEnv);
155  }
156  }
157  else
158  {
159  for(std::size_t i = 0; i < layer->getChildrenCount(); ++i)
160  {
161  te::map::AbstractLayerPtr child(boost::dynamic_pointer_cast<AbstractLayer>(layer->getChild(i)));
162 
163  if(i == 0)
164  finalEnv = GetSelectedExtent(child, srid, onlyVisibles);
165  else
166  finalEnv.Union(GetSelectedExtent(child, srid, onlyVisibles));
167  }
168  }
169 
170  return finalEnv;
171 }
172 
173 void te::map::GetDashStyle(const std::string& dasharray, std::vector<double>& style)
174 {
175  std::vector<std::string> values;
176  te::common::Tokenize(dasharray, values);
177  for(std::size_t i = 0; i < values.size(); ++i)
178  style.push_back(atof(values[i].c_str()));
179 }
180 
182 {
183  if(layer == nullptr)
184  throw Exception(TE_TR("The layer is invalid!"));
185 
186 // name of referenced data set
187  std::string dsname = layer->getDataSetName();
188 
189  if(dsname.empty())
190  throw Exception(TE_TR("The data set name referenced by the layer is empty!"));
191 
192 // retrieve the associated data source
194 
195 // gets the data set type
196  std::unique_ptr<te::da::DataSetType> dstype(ds->getDataSetType(dsname));
197 
198  if(dstype.get() == nullptr)
199  throw Exception(TE_TR("Could not get the data set type!"));
200 
201 // gets the raster property
202  std::unique_ptr<te::rst::RasterProperty> rasterProperty(dynamic_cast<te::rst::RasterProperty*>(dstype->getProperties()[0]->clone()));
203 
204  if(rasterProperty.get() == nullptr)
205  throw Exception(TE_TR("Could not get the raster property!"));
206 
207  return rasterProperty.release();
208 }
209 
211 {
212  if(layer == nullptr)
213  throw Exception(TE_TR("The layer is invalid!"));
214 
215  std::unique_ptr<te::da::DataSet> dataset(layer->getData());
216 
217  if (dataset.get() == nullptr)
218  throw Exception(TE_TR("Could not get the data set reference by the layer!"));
219 
220 
221  std::size_t rpos = te::da::GetFirstPropertyPos(dataset.get(), te::dt::RASTER_TYPE);
222 
223  dataset->moveFirst();
224 
225  std::unique_ptr<te::da::DataSetType> dsType = layer->getSchema();
226  std::unique_ptr<te::rst::Raster> raster = dataset->getRaster(rpos);
227 
228  if (raster.get() == nullptr)
229  throw Exception(TE_TR("Could not get the raster referenced by the layer!"));
230 
231  //get visual information
232  te::se::Style* style = layer->getStyle();
233 
234  if (style == nullptr || style->getRules().empty())
235  {
236  // try create an appropriate style
237  te::rst::RasterProperty* rasterProperty = te::da::GetFirstRasterProperty(dsType.get());
238 
239  style = te::se::CreateCoverageStyle(rasterProperty->getBandProperties());
240 
241  if (style == 0)
242  throw Exception(TE_TR("Could not get the raster style referenced by the layer!"));
243 
244  layer->setStyle(style);
245  }
246 
247  // for while, consider one rule
248  const te::se::Rule* rule = style->getRule(0);
249 
250  const std::vector<te::se::Symbolizer*>& symbolizers = rule->getSymbolizers();
251 
252  if (symbolizers.empty())
253  throw Exception(TE_TR("Could not get the symbolizers referenced by the rule!"));
254 
255  // for while, consider one raster symbolizer
256  te::se::RasterSymbolizer* rasterSymbolizer = dynamic_cast<te::se::RasterSymbolizer*>(symbolizers[0]);
257 
258  if (rasterSymbolizer == nullptr)
259  throw Exception(TE_TR("Could not get the raster symbolizers referenced by the style!"));
260 
261  if (rasterSymbolizer->getNoDataValue())
262  {
263  double noDataValue = te::se::GetDouble(rasterSymbolizer->getNoDataValue());
264 
265  for (std::size_t t = 0; t < raster->getNumberOfBands(); ++t)
266  {
267  te::rst::BandProperty* bp = raster->getBand(t)->getProperty();
268  bp->m_noDataValue = noDataValue;
269  }
270  }
271 
272 //set srid information
273  raster->getGrid()->setSRID(layer->getSRID());
274 
275  return raster.release();
276 }
277 
278 void te::map::GetVisibleLayers(const te::map::AbstractLayerPtr& layer, std::list<te::map::AbstractLayerPtr>& visibleLayers)
279 {
280  te::map::Visibility visibility = layer->getVisibility();
281 
282  if(visibility == te::map::NOT_VISIBLE)
283  return;
284 
285  if(visibility == te::map::VISIBLE && layer->isValid())
286  visibleLayers.push_back(layer);
287 
288  for(std::size_t i = 0; i < layer->getChildrenCount(); ++i)
289  {
290  te::map::AbstractLayerPtr child(boost::dynamic_pointer_cast<AbstractLayer>(layer->getChild(i)));
291 
292  GetVisibleLayers(child, visibleLayers);
293  }
294 }
295 
296 void te::map::GetVisibleLayers(const std::list<te::map::AbstractLayerPtr>& layers, std::list<te::map::AbstractLayerPtr>& visibleLayers)
297 {
298  for(std::list<te::map::AbstractLayerPtr>::const_iterator it = layers.begin(); it != layers.end(); ++it)
299  GetVisibleLayers(*it, visibleLayers);
300 }
301 
302 te::gm::Envelope te::map::GetExtent(const std::list<te::map::AbstractLayerPtr>& layers, int srid, bool onlyVisibles)
303 {
305 
306  for(std::list<te::map::AbstractLayerPtr>::const_iterator it = layers.begin(); it != layers.end(); ++it)
307  e.Union(GetExtent(*it, srid, onlyVisibles));
308 
309  return e;
310 }
311 
312 te::gm::Envelope te::map::GetExtent(const te::map::AbstractLayerPtr& layer, int srid, bool onlyVisibles)
313 {
314  if(onlyVisibles && layer->getVisibility() == te::map::NOT_VISIBLE)
315  return te::gm::Envelope();
316 
317  te::gm::Envelope e = layer->getExtent();
318 
319  if((layer->getSRID() != TE_UNKNOWN_SRS) && (srid != TE_UNKNOWN_SRS))
320  e.transform(layer->getSRID(), srid);
321 
322  for(std::size_t i = 0; i < layer->getChildrenCount(); ++i)
323  {
324  te::map::AbstractLayerPtr child(boost::dynamic_pointer_cast<AbstractLayer>(layer->getChild(i)));
325  e.Union(GetExtent(child, srid, onlyVisibles));
326  }
327 
328  return e;
329 }
330 
332 {
333  assert(dataset);
334 
335  if(!dataset->moveNext())
336  throw Exception(TE_TR("Could not copy the data set to memory!"));
337 
338  return new te::mem::DataSet(*dataset);
339 }
340 
342  Canvas* canvas, const te::gm::Envelope& bbox, int bboxSRID,
343  int srid, te::se::FeatureTypeStyle* style)
344 {
345  assert(type);
346  assert(type->hasGeom());
347  assert(canvas);
348  assert(bbox.isValid());
349  assert(style);
350 
351  const std::string& datasetName = type->getName();
352  assert(!datasetName.empty());
353 
354 // for while, default geometry. TODO: need a visitor to get which properties the style references
355  te::gm::GeometryProperty* geometryProperty = te::da::GetFirstGeomProperty(type);
356 
357 // create a canvas configurer
358  te::map::CanvasConfigurer cc(canvas);
359 
360 // number of rules defined on feature type style
361  std::size_t nRules = style->getRules().size();
362 
363  for(std::size_t i = 0; i < nRules; ++i) // for each <Rule>
364  {
365 // the current rule
366  const te::se::Rule* rule = style->getRule(i);
367  assert(rule);
368 
369 // TODO: should be verified the MinScaleDenominator and MaxScaleDenominator. Where will we put the current scale information? Method parameter?
370 
371 // gets the rule filter
372  const te::fe::Filter* filter = rule->getFilter();
373 
374 // let's retrieve the correct dataset
375  std::unique_ptr<te::da::DataSet> dataset;
376  if(!filter)
377  {
378 // there isn't a Filter expression. Gets the dataset using only box restriction...
379  dataset = ds->getDataSet(datasetName, geometryProperty->getName(), &bbox, te::gm::INTERSECTS);
380  }
381  else
382  {
383 // get an enconder
384  te::map::QueryEncoder queryConverter;
385 
386 // convert the Filter expression to a TerraLib Expression!
387  te::da::Expression* exp = queryConverter.getExpression(filter);
388  if(exp == nullptr)
389  throw Exception(TE_TR("Could not convert the OGC Filter expression to TerraLib expression!"));
390 
391 /* 1) Creating te::da::Where object with this expression + box restriction */
392 
393 // the box restriction
394  te::da::LiteralEnvelope* lenv = new te::da::LiteralEnvelope(bbox, srid);
395  te::da::PropertyName* geometryPropertyName = new te::da::PropertyName(geometryProperty->getName());
396  te::da::ST_Intersects* intersects = new te::da::ST_Intersects(geometryPropertyName, lenv);
397 
398 // combining the expressions (Filter expression + box restriction)
399  te::da::And* finalRestriction = new te::da::And(exp, intersects);
400 
401  te::da::Where* wh = new te::da::Where(exp);
402  wh->setExp(finalRestriction);
403 
404 // fields
405  te::da::Fields* all = new te::da::Fields;
406  all->push_back(new te::da::Field("*"));
407 
408 // from
409  te::da::FromItem* fi = new te::da::DataSetName(datasetName);
410  te::da::From* from = new te::da::From;
411  from->push_back(fi);
412 
413 // build the Select
414  te::da::Select select(all, from, wh);
415 
416 /* 2) Calling the datasource query method to get the correct restricted dataset. */
417  dataset = ds->query(select);
418  }
419 
420  if(dataset.get() == nullptr)
421  throw Exception((boost::format(TE_TR("Could not retrieve the data set %1%.")) % datasetName).str());
422 
423  if(dataset->moveNext() == false)
424  continue;
425 
426 // get the set of symbolizers defined on current rule
427  const std::vector<te::se::Symbolizer*>& symbolizers = rule->getSymbolizers();
428  std::size_t nSymbolizers = symbolizers.size();
429 
430 // build task message; e.g. ("Drawing the dataset Countries. Rule 1 of 3.")
431  std::string message = TE_TR("Drawing the dataset");
432  message += " " + datasetName + ". ";
433  message += TE_TR("Rule");
434  message += " " + boost::lexical_cast<std::string>(i + 1) + " " + TE_TR("of") + " ";
435  message += boost::lexical_cast<std::string>(nRules) + ".";
436 
437 // create a draw task
439  //task.setTotalSteps(nSymbolizers * dataset->size()); // Removed! The te::da::DataSet size() method would be too costly to compute.
440 
441  for(std::size_t j = 0; j < nSymbolizers; ++j) // for each <Symbolizer>
442  {
443 // the current symbolizer
444  te::se::Symbolizer* symb = symbolizers[j];
445 
446 // let's config de canvas based on the current symbolizer
447  cc.config(symb);
448 
449 // for while, first geometry. TODO: get which property the symbolizer references
450  std::size_t gpos = te::da::GetFirstPropertyPos(dataset.get(), te::dt::GEOMETRY_TYPE);
451 
452 // let's draw! for each data set geometry...
453  DrawGeometries(dataset.get(), gpos, canvas, bboxSRID, srid, &task);
454 
455 // prepare to draw the other symbolizer
456  dataset->moveFirst();
457 
458  } // end for each <Symbolizer>
459 
460  } // end for each <Rule>
461 }
462 
463 void te::map::DrawGeometries(te::da::DataSet* dataset, const std::size_t& gpos, Canvas* canvas, int fromSRID, int toSRID, te::common::TaskProgress* task)
464 {
465  assert(dataset);
466  assert(canvas);
467 
468 // verify if is necessary convert the data set geometries to the given srid
469  bool needRemap = false;
470  if((fromSRID != TE_UNKNOWN_SRS) && (toSRID != TE_UNKNOWN_SRS) && (fromSRID != toSRID))
471  needRemap = true;
472 
473  do
474  {
475  if(task)
476  {
477  if(!task->isActive())
478  return;
479 
480  // update the draw task
481  task->pulse();
482  }
483 
484  std::unique_ptr<te::gm::Geometry> geom;
485  try
486  {
487  geom = dataset->getGeometry(gpos);
488  if(geom.get() == nullptr)
489  continue;
490  }
491  catch(std::exception& /*e*/)
492  {
493  continue;
494  }
495 
496 // if necessary, geometry remap
497  if(needRemap)
498  {
499  geom->setSRID(fromSRID);
500  geom->transform(toSRID);
501  }
502 
503  canvas->draw(geom.get());
504 
505  }while(dataset->moveNext()); // next geometry!
506 }
507 
509  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)
510 {
511  assert(type);
512  assert(type->hasRaster());
513  assert(canvas);
514  assert(bbox.isValid());
515  assert(visibleArea.isValid());
516  assert(style);
517 
518  const std::string& datasetName = type->getName();
519  assert(!datasetName.empty());
520 
521 // for while, first raster property
523 
524 // retrieve the data set
525  std::unique_ptr<te::da::DataSet> dataset(ds->getDataSet(datasetName, rasterProperty->getName(), &bbox, te::gm::INTERSECTS));
526  if(dataset.get() == nullptr)
527  throw Exception((boost::format(TE_TR("Could not retrieve the data set %1%.")) % datasetName).str());
528 
529 // retrieve the raster
530  std::size_t rpos = te::da::GetFirstPropertyPos(dataset.get(), te::dt::RASTER_TYPE);
531  std::unique_ptr<te::rst::Raster> raster(dataset->getRaster(rpos));
532  if(dataset.get() == nullptr)
533  throw Exception((boost::format(TE_TR("Could not retrieve the raster from the data set %1%.")) % datasetName).str());
534 
535  DrawRaster(raster.get(), canvas, bbox, bboxSRID, visibleArea, srid, style, rc, scale, cancel);
536 }
537 
538 void te::map::DrawRaster(te::rst::Raster* raster, Canvas* canvas, const te::gm::Envelope& /*bbox*/, int bboxSRID,
539  const te::gm::Envelope& visibleArea, int srid, te::se::CoverageStyle* style, te::map::RasterContrast* rc, const double& scale, bool* cancel)
540 {
541  // for while, consider one rule
542  const te::se::Rule* rule = style->getRule(0);
543 
544  if (!(scale >= rule->getMinScaleDenominator() && scale < rule->getMaxScaleDenominator()))
545  {
546  return;
547  }
548 
549 // build the grid canvas. i.e. a grid with canvas dimensions and requested mbr
550  te::gm::Envelope* gmbr = new te::gm::Envelope(visibleArea);
551  std::unique_ptr<te::rst::Grid> gridCanvas(new te::rst::Grid(static_cast<unsigned int>(canvas->getWidth()), static_cast<unsigned int>(canvas->getHeight()), gmbr, srid));
552 
553 // compute the best level
554  te::gm::Envelope* visibleAreaRasterProj = new te::gm::Envelope(visibleArea);
555  visibleAreaRasterProj->transform(srid, bboxSRID);
556 
557  double resx = visibleAreaRasterProj->getWidth() / static_cast<double>(canvas->getWidth());
558  double resy = visibleAreaRasterProj->getHeight() / static_cast<double>(canvas->getHeight());
559 
560  double rx = resx / raster->getResolutionX();
561  double ry = resy / raster->getResolutionY();
562 
563  double factor = std::min(rx, ry);
564  factor = std::max(factor, 1.0);
565 
566  std::size_t level = static_cast<std::size_t>(std::log(factor) / std::log(2.0));
567 
568 // get the raster overview
569  te::rst::Raster* overview = raster;
570  bool needDelete = false;
571  std::size_t numberOfLevels = raster->getMultiResLevelsCount();
572  if(level != 0 && numberOfLevels != 0) // need overview? has overview?
573  {
574  if(numberOfLevels >= level)
575  overview = raster->getMultiResLevel(static_cast<unsigned int>(level - 1));
576  else
577  overview = raster->getMultiResLevel(static_cast<unsigned int>(numberOfLevels - 1));
578 
579  assert(overview);
580 
581  //adjust raster overview parameters
582 
583  if (raster->getNumberOfBands() == overview->getNumberOfBands())
584  {
585  for (std::size_t t = 0; t < raster->getNumberOfBands(); ++t)
586  {
587  te::rst::BandProperty* bp = raster->getBand(t)->getProperty();
588  te::rst::BandProperty* bpOverView = overview->getBand(t)->getProperty();
589  bpOverView->m_noDataValue = bp->m_noDataValue;
590  }
591  }
592 
593  overview->getGrid()->setSRID(raster->getSRID());
594 
595  needDelete = true;
596  }
597 
598 // create a raster transform
599  RasterTransform rasterTransform(overview, nullptr);
600 
601 //check band data type
602  if(raster->getBandDataType(0) != te::dt::UCHAR_TYPE)
603  {
604  // raster min / max values
605  for (int b = 0; b < static_cast<int>(raster->getNumberOfBands()); b++)
606  {
609  const std::complex<double>* cmin = rsMin->at(b).m_minVal;
610  const std::complex<double>* cmax = rsMax->at(b).m_maxVal;
611  double min = cmin->real();
612  double max = cmax->real();
613 
614  rasterTransform.setLinearTransfParameters(min, max, 0, 255, b);
615  }
616  }
617  else
618  {
619  rasterTransform.setLinearTransfParameters(0, 255, 0, 255);
620  }
621 
622  const std::vector<te::se::Symbolizer*>& symbolizers = rule->getSymbolizers();
623  assert(!symbolizers.empty());
624 
625 // for while, consider one raster symbolizer
626  te::se::RasterSymbolizer* rasterSymbolizer = dynamic_cast<te::se::RasterSymbolizer*>(symbolizers[0]);
627  assert(rasterSymbolizer);
628 
629 // configure the raster transformation based on the raster symbolizer
630  RasterTransformConfigurer rtc(rasterSymbolizer, &rasterTransform);
631  rtc.configure();
632 
633  if (rc)
634  {
635  int type = rc->getType();
636 
637  std::vector<double> gain;
638  std::vector<double> offset1;
639  std::vector<double> offset2;
640  std::vector<double> min;
641  std::vector<double> max;
642  rc->getValues(gain, offset1, offset2, min, max);
643 
644  rasterTransform.setContrastType(static_cast<te::map::RasterTransform::ContrastType>(type));
645  rasterTransform.setContrastGainsAndOffsets(gain, offset1, offset2);
646  }
647 
648 // verify if is necessary convert the raster to the given srid
649  bool needRemap = false;
650  if((bboxSRID != TE_UNKNOWN_SRS) && (srid != TE_UNKNOWN_SRS) && (bboxSRID != srid))
651  needRemap = true;
652 
653 // build task message; e.g. ("Drawing the raster cbers_sao_jose_dos_campos.")
654  std::string message = TE_TR("Drawing raster");
655  const std::string& rasterName = raster->getName();
656  !rasterName.empty() ? message += " " + raster->getName() + ". " : message += ".";
657 
658 // create the draw task
659  te::common::TaskProgress task(message, te::common::TaskProgress::DRAW, static_cast<int>(gridCanvas->getNumberOfRows()));
660 
661 // create a RGBA array that will be drawn in the canvas. i.e. This array is the result of the render process.
662  //te::color::RGBAColor** rgba = new te::color::RGBAColor*[gridCanvas->getNumberOfRows()];
663 
664 // create a RGBA array that will be drawn in the canvas. i.e. This array represents a row of the render process.
666  te::color::RGBAColor* columns = new te::color::RGBAColor[gridCanvas->getNumberOfColumns()];
667  row[0] = columns;
668 
669 // create a SRS converter
670  std::unique_ptr<te::srs::Converter> converter(new te::srs::Converter());
671 
672  if(needRemap)
673  {
674  converter->setSourceSRID(srid);
675  converter->setTargetSRID(bboxSRID);
676  }
677 
678 // fill the result RGBA array
679  for(unsigned int r = 0; r < gridCanvas->getNumberOfRows(); ++r)
680  {
681  for(unsigned int c = 0; c < gridCanvas->getNumberOfColumns(); ++c)
682  {
683  te::gm::Coord2D inputGeo = gridCanvas->gridToGeo(c, r);
684 
685  if(needRemap)
686  converter->convert(inputGeo.x, inputGeo.y, inputGeo.x, inputGeo.y);
687 
688  te::gm::Coord2D outputGrid = overview->getGrid()->geoToGrid(inputGeo.x, inputGeo.y);
689 
690 // TODO: round or truncate?
691  int x = te::rst::Round(outputGrid.x);
692  int y = te::rst::Round(outputGrid.y);
693 
694  te::color::RGBAColor color(0, 0, 0, 0);
695 
696  if((x >= 0 && x < static_cast<int>(overview->getNumberOfColumns())) &&
697  (y >= 0 && y < static_cast<int>(overview->getNumberOfRows())))
698  color = rasterTransform.apply(x, y);
699 
700  columns[c] = color;
701  }
702 
703  //rgba[r] = columns;
704 
705  if(!task.isActive())
706  {
707 // draw the part of result
708  //canvas->drawImage(0, 0, rgba, canvas->getWidth(), r + 1);
709  canvas->drawImage(0, static_cast<int>(r), row, canvas->getWidth(), 1);
710 
711 // free memory
712  //te::common::Free(rgba, r + 1);
713  te::common::Free(row, 1);
714 
715  *cancel = true;
716 
717  return;
718  }
719 
720  if (cancel != nullptr && (*cancel))
721  return;
722 
723  canvas->drawImage(0, static_cast<int>(r), row, canvas->getWidth(), 1);
724 
725  task.pulse();
726  }
727 
728  if(needDelete)
729  delete overview;
730 
731 // put the result in the canvas
732  //canvas->drawImage(0, 0, rgba, canvas->getWidth(), canvas->getHeight());
733 
734 // free memory
735  //te::common::Free(rgba, gridCanvas->getNumberOfRows());
736  te::common::Free(row, 1);
737 
738 // image outline
739  if(rasterSymbolizer->getImageOutline() == nullptr)
740  return;
741 
742 // get the symbolizer that will be used to draw the image outline
743  te::se::Symbolizer* outlineSymbolizer = rasterSymbolizer->getImageOutline()->getSymbolizer();
744  if(outlineSymbolizer == nullptr)
745  return;
746 
747 // create a canvas configurer
748  te::map::CanvasConfigurer cc(canvas);
749  cc.config(outlineSymbolizer);
750 
751 // creates the image outline
752  std::unique_ptr<te::gm::Geometry> geom(te::gm::GetGeomFromEnvelope(raster->getExtent(), bboxSRID));
753  if(needRemap)
754  {
755  geom->setSRID(bboxSRID);
756  geom->transform(srid);
757  }
758 
759  canvas->draw(geom.get());
760 }
761 
762 te::rst::Raster* te::map::GetExtentRaster(te::rst::Raster* raster, int w, int h, const te::gm::Envelope& /*bbox*/, int bboxSRID,
763  const te::gm::Envelope& visibleArea, int srid)
764 {
765  std::vector<te::rst::BandProperty*> bprops;
766 
767  for(size_t t = 0; t < raster->getNumberOfBands(); ++t)
768  {
769  te::rst::Band* band = raster->getBand(t);
770 
771  te::rst::BandProperty* bp = new te::rst::BandProperty(t, band->getProperty()->getType(), "");
772 
773  bprops.push_back(bp);
774  }
775 
776 // build the grid canvas. i.e. a grid with canvas dimensions and requested mbr
777  te::gm::Envelope* gmbr = new te::gm::Envelope(visibleArea);
778  te::rst::Grid* gridCanvas = new te::rst::Grid(static_cast<unsigned int>(w), static_cast<unsigned int>(h), gmbr, srid);
779 
780 //build output raster
781  te::rst::Raster* rasterOut = te::rst::RasterFactory::make("MEM", gridCanvas, bprops, std::map<std::string, std::string>());
782 
783 // verify if is necessary convert the raster to the given srid
784  bool needRemap = false;
785  if((bboxSRID != TE_UNKNOWN_SRS) && (srid != TE_UNKNOWN_SRS) && (bboxSRID != srid))
786  needRemap = true;
787 
788 // create a SRS converter
789  std::unique_ptr<te::srs::Converter> converter(new te::srs::Converter());
790 
791  if(needRemap)
792  {
793  converter->setSourceSRID(srid);
794  converter->setTargetSRID(bboxSRID);
795  }
796 
797 // fill the result RGBA array
798  for(unsigned int r = 0; r < gridCanvas->getNumberOfRows(); ++r)
799  {
800  for(unsigned int c = 0; c < gridCanvas->getNumberOfColumns(); ++c)
801  {
802  te::gm::Coord2D inputGeo = gridCanvas->gridToGeo(c, r);
803 
804  if(needRemap)
805  converter->convert(inputGeo.x, inputGeo.y, inputGeo.x, inputGeo.y);
806 
807  te::gm::Coord2D outputGrid = raster->getGrid()->geoToGrid(inputGeo.x, inputGeo.y);
808 
809 // TODO: round or truncate?
810  int x = te::rst::Round(outputGrid.x);
811  int y = te::rst::Round(outputGrid.y);
812 
813  if((x >= 0 && x < static_cast<int>(raster->getNumberOfColumns())) &&
814  (y >= 0 && y < static_cast<int>(raster->getNumberOfRows())))
815  {
816  std::vector<double> values;
817  raster->getValues(static_cast<unsigned int>(x), static_cast<unsigned int>(y), values);
818  rasterOut->setValues(c, r, values);
819  }
820  }
821  }
822 
823  return rasterOut;
824 }
825 
827 {
828  assert(layer.get());
829 
830  std::unique_ptr<te::map::LayerSchema> schema(layer->getSchema());
831 
832  te::gm::GeometryProperty* geometryProperty = te::da::GetFirstGeomProperty(schema.get());
833  assert(geometryProperty);
834 
835  te::gm::GeomType gtype = geometryProperty->getGeometryType();
836 
837  switch(gtype)
838  {
844  break;
845 
846  default:
847  return gtype;
848  }
849 
850  // Here, tries fetch a geometry and retrieve its type
851 
852  std::unique_ptr<te::da::DataSet> dataset(layer->getData());
853  assert(dataset.get());
854 
855  dataset->moveNext();
856 
857  std::size_t gpos = te::da::GetFirstPropertyPos(dataset.get(), te::dt::GEOMETRY_TYPE);
858 
859  std::unique_ptr<te::gm::Geometry> g(dataset->getGeometry(gpos));
860  assert(g.get());
861 
862  return g->getGeomTypeId();
863 }
864 
866 {
867  te::gm::Envelope worldBoxPlanar = worldBox;
868 
869  // Checks if is Planar Geographic
870  std::string authName = "EPSG"; // Now: So far it is the only one supported by TerraLib 5. Future: Review this line!
871  te::srs::SpatialReferenceSystemManager::getInstance().isGeographic(static_cast<unsigned int>(srid), authName);
872  te::common::UnitOfMeasurePtr unitPtr = te::srs::SpatialReferenceSystemManager::getInstance().getUnit(static_cast<unsigned int>(srid), authName);
873 
874  if(!unitPtr)
875  return worldBoxPlanar;
876 
877  std::string unitPtrStr = unitPtr->getName();
878  unitPtrStr = te::common::Convert2UCase(unitPtrStr);
879 
880  if(unitPtrStr.compare("DEGREE") == 0)
881  {
882  int zone = CalculatePlanarZone(worldBox);
883  std::string proj4 = GetUTMProj4FromZone(zone);
884 
885  // Get the id of the projection of destination
886  std::pair<std::string, unsigned int> projPlanar = te::srs::SpatialReferenceSystemManager::getInstance().getIdFromP4Txt(proj4);
887 
888  // Remapping
889  worldBoxPlanar.transform(srid, static_cast<int>(projPlanar.second));
890  }
891 
892  return worldBoxPlanar;
893 }
894 
896 {
897  double longitude = latLongBox.getCenter().x;
898  int meridiano = static_cast<int>(longitude / 6);
899  meridiano = meridiano * 6;
900 
901  meridiano = abs(meridiano) + 3;
902 
903  double long0 = -meridiano * TeCDR;
904 
905  // TeUTM T4
906  int zone = (static_cast<int>((long0*TeCRD+183.0)/6.0));
907 
908  return zone;
909 }
910 
911 std::string te::map::GetUTMProj4FromZone( int zone )
912 {
913  /*
914  PROJ4
915  +proj Projection name
916  +datum Datum name
917  +lat_0 Latitude of origin
918  +lon_0 Central meridian
919  +x_0 False easting
920  +y_0 False northing
921  +lat_1 Latitude of first standard parallel
922  +lat_2 Latitude of second standard parallel
923  +units meters, US survey feet, etc.
924  +lat_ts Latitude of true scale
925  +south Denotes southern hemisphere UTM zone
926  +no_defs Don't use the /usr/share/proj/proj_def.dat defaults file
927  */
928 
929  std::stringstream szone;
930  szone << zone;
931 
932  std::string proj4 = "+proj=utm";
933  proj4+= " +zone="+ szone.str();
934  proj4+= " +south"; // pode ser +north?
935  proj4+= " +ellps=aust_SA";
936  proj4+= " +towgs84=-57,1,-41,0,0,0,0";
937  proj4+= " +units=m";
938  proj4+= " +no_defs ";
939 
940  return proj4;
941 }
942 
944 {
945  boost::uuids::basic_random_generator<boost::mt19937> gen;
946  boost::uuids::uuid u = gen();
947  std::string id = boost::uuids::to_string(u);
948 
949  layer->setId(id);
950  layer->setTitle(refLayer->getTitle());
951  layer->setExtent(refLayer->getExtent());
952  layer->setSRID(refLayer->getSRID());
953  layer->setVisibility(refLayer->getVisibility());
954 
955  te::se::Style* style = refLayer->getStyle();
956  layer->setStyle(style ? style->clone() : nullptr);
957 
958  te::se::Style* selectionStyle = refLayer->getSelectionStyle();
959  layer->setSelectionStyle(selectionStyle ? selectionStyle->clone() : nullptr);
960 
961  te::map::Grouping* grouping = refLayer->getGrouping();
962  layer->setGrouping(grouping ? grouping->clone() : nullptr);
963 
964  te::map::Chart* chart = refLayer->getChart();
965  layer->setChart(chart ? chart->clone() : nullptr);
966 
967  te::map::RasterContrast* rasterContrast = refLayer->getRasterContrast();
968  layer->setRasterContrast(rasterContrast ? new te::map::RasterContrast(*rasterContrast) : nullptr);
969 
970  layer->setGeomPropertytName(refLayer->getGeomPropertyName());
971  layer->setCompositionMode(refLayer->getCompositionMode());
972  layer->setDataSetName(refLayer->getDataSetName());
973  layer->setDataSourceId(refLayer->getDataSourceId());
974  layer->setEncoding(refLayer->getEncoding());
975 }
virtual std::unique_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
Chart * clone()
Definition: Chart.cpp:76
unsigned int getNumberOfRows() const
Returns the grid number of rows.
virtual void setValues(unsigned int c, unsigned int r, const std::vector< double > &values)
Sets the imaginary attribute values in all complex bands of a cell.
void setContrastType(const ContrastType &newType)
Set the current contrast type.
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
TEDATAACCESSEXPORT te::rst::RasterProperty * GetFirstRasterProperty(const DataSetType *dt)
unsigned int band
Geometric property.
virtual void setDataSourceId(const std::string &id)
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
A Raster Transform is a class that defines functions to transform a styled raster.
An abstract class that models a source of data in a query.
Definition: FromItem.h:50
The Field class can be used to model an expression that takes part of the output items of a SELECT...
double y
y-coordinate.
Definition: Coord2D.h:114
TEMAPEXPORT void CopyAbstractLayerInfo(const te::map::AbstractLayer *refLayer, te::map::AbstractLayer *layer)
Make a copy of refLayer abstract attributes to layer. Creating new id.
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
Definition: Style.h:65
Spatial intersects operator.
Definition: ST_Intersects.h:46
An exception class for the MapTools module.
This is the base class for layers.
Definition: AbstractLayer.h:77
virtual const te::gm::Envelope & getExtent() const
It returns the Layer extent (or minimum bounding box).
A class that models the name of a dataset used in a From clause.
Definition: DataSetName.h:43
boost::shared_ptr< DataSource > DataSourcePtr
virtual unsigned int getMultiResLevelsCount() const =0
Returns the current number of multi-resolution pyramid levels.
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
virtual Style * clone() const =0
It creates a new copy of this object.
virtual const std::string & getTitle() const
It returns the layer title.
bool hasGeom() const
It returns true if the DataSetType has at least one geometry property; otherwise, it returns false...
Definition: DataSetType.h:655
A raster band description.
Definition: BandProperty.h:61
double x
x-coordinate.
Definition: Coord2D.h:113
TEMAPEXPORT std::string GetUTMProj4FromZone(int zone)
Returns proj4 string with UTM projection in the specified zone (Only working for south).
virtual te::se::Style * getSelectionStyle() const
It returns the selection Style associated to the layer.
virtual void setRasterContrast(te::map::RasterContrast *contrast)
It sets the raster contrast associated to the Layer.
TEMAPEXPORT te::gm::Envelope GetExtent(const std::list< te::map::AbstractLayerPtr > &layers, int srid, bool onlyVisibles)
It calculates the extent of the given layers in the given SRID.
A class that models the name of any property of an object.
Base exception class for plugin module.
A class that models the description of a dataset.
Definition: DataSetType.h:72
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
A Symbolizer describes how a feature is to appear on a map.
Definition: Symbolizer.h:80
void setDataSetName(const std::string &name)
const double & getMinScaleDenominator() const
Definition: Rule.cpp:123
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...
Definition: CoverageStyle.h:45
void setCompositionMode(te::map::CompositionMode mode)
It sets the composition mode.
void setContrastGainsAndOffsets(const std::vector< double > &contrastGains, const std::vector< double > &contrastOffsets1, const std::vector< double > &contrastOffsets2)
Set gain and offset parameters to be used by the CONTRAST_TRANSF method.
void configure()
Configure Transformation.
virtual void getValues(unsigned int c, unsigned int r, std::vector< double > &values) const
Returns the imaginary attribute values in all complex bands of a cell.
TESEEXPORT Style * CreateCoverageStyle(const std::vector< te::rst::BandProperty * > &properties)
Try creates an appropriate coverage style based on given band properties.
virtual void setGrouping(te::map::Grouping *grouping)
It sets the Grouping associated to the Layer.
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:53
TEMAPEXPORT te::gm::GeomType GetGeomType(const te::map::AbstractLayerPtr &layer)
It gets the geometry type of the given layer.
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
Definition: StringUtils.h:168
te::da::Expression * getExpression(const te::fe::Filter *f)
It converts the OGC Filter Expression to a TerraLib Expression.
TESEEXPORT double GetDouble(const te::se::ParameterValue *param)
It gets the parameter value as a double.
virtual Visibility getVisibility() const
It returns the layer visibility.
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
static te::dt::Date ds(2010, 01, 01)
const te::map::RasterTransform::ContrastType getType() const
It gets the contrast type.
A layer with reference to a dataset.
double m_noDataValue
Value to indicate elements where there is no data, default is std::numeric_limits<double>::max().
Definition: BandProperty.h:136
const te::fe::Filter * getFilter() const
Definition: Rule.cpp:97
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
TEMAPEXPORT void DrawGeometries(te::da::DataSetType *type, te::da::DataSourcePtr ds, Canvas *canvas, const te::gm::Envelope &bbox, int bboxSRID, int srid, te::se::FeatureTypeStyle *style)
It draws the data set geometries in the given canvas using the informed SRID and style.
virtual void setTitle(const std::string &title)
It sets the layer title.
bool isActive() const
Verify if the task is active.
Raster property.
Boolean logic operator: AND.
void Union(const Envelope &rhs)
It updates the envelop with coordinates of another envelope.
void geoToGrid(const double &x, const double &y, double &col, double &row) const
Get the grid point associated to a spatial location.
This is an abstract class that models a query expression.
virtual te::map::Chart * getChart() const
It returns the Chart associated to the Layer.
te::core::EncodingType getEncoding() const
It returns the encoding type.
void setLinearTransfParameters(double vmin, double vmax, double rmin, double rmax)
Set parameters of linear transformation.
te::map::CompositionMode getCompositionMode() const
It returns the composition mode.
Rule * getRule(std::size_t i) const
Definition: Style.cpp:105
virtual void setGeomPropertytName(const std::string &name)
const std::vector< Rule * > & getRules() const
Definition: Style.cpp:94
TEMAPEXPORT te::gm::Envelope GetSelectedExtent(const std::list< te::map::AbstractLayerPtr > layers, int srid, bool onlyVisibles)
It calculates the extent of selected objects of the given layers in the given SRID.
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
TEMAPEXPORT te::da::DataSet * DataSet2Memory(te::da::DataSet *dataset)
It creates a new In-Memory dataset with the items from the given dataset.
int b
Definition: TsRtree.cpp:32
This class contains the parameters needed for grouping the values of a Property.
Definition: Grouping.h:57
Coord2D getCenter() const
It returns the rectangle&#39;s center coordinate.
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
It tokenizes a given string with a delimiter of your own choice.
Definition: StringUtils.h:221
void Free(std::vector< T * > *v)
This function can be applied to a pointer to a vector of pointers.
Definition: STLUtils.h:131
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)
TEMAPEXPORT void GetDashStyle(const std::string &dasharray, std::vector< double > &style)
Converts a dasharray pattern coded by a string to a vector of double.
virtual void setChart(te::map::Chart *chart)
It sets the Chart associated to the Layer.
This class represents the informations needed to build map charts.
Definition: Chart.h:51
static RasterSummaryManager & getInstance()
It returns a reference to the singleton instance.
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...
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:55
An abstract class for raster data strucutures.
unsigned int getNumberOfRows() const
Returns the raster number of rows.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
virtual te::se::Style * getStyle() const
It returns the Style associated to the layer.
bool hasRaster() const
It returns true if the DataSetType has at least one raster property; otherwise, it returns false...
Definition: DataSetType.h:660
BandProperty * getProperty()
Returns the band property.
virtual std::unique_ptr< LayerSchema > getSchema() const =0
It returns the layer schema.
void DataSet()
TERASTEREXPORT int Round(double val)
Round a double value to a integer value.
static te::dt::TimeDuration dt(20, 30, 50, 11)
virtual int getHeight() const =0
It returns the canvas height.
virtual void setVisibility(Visibility v)
It sets the layer visibility.
virtual int getBandDataType(std::size_t i) const =0
Returns the data type in a particular band (or dimension).
unsigned int getNumberOfColumns() const
Returns the grid number of columns.
double getResolutionX() const
Returns the raster horizontal (x-axis) resolution.
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
Definition: Fields.h:37
A visitor that converts a OGC Filter Expression to TerraLib Expression.
Definition: QueryEncoder.h:53
boost::ptr_vector< BandSummary > RasterSummary
RasterSummary is just a typedef of a boost::ptr_vector.
Definition: RasterSummary.h:44
A class that can be used to model a filter expression that can be applied to a query.
Definition: Where.h:47
void setExp(Expression *exp)
Sets the expression.
Definition: Where.cpp:63
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
The RasterSymbolizer describes how to render raster/matrix-coverage data (e.g., satellite photos...
virtual void drawImage(char *src, std::size_t size, ImageType t)=0
It draws the src image over the canvas.
virtual void setExtent(const te::gm::Envelope &mbr)
It sets the Layer extent (or minimum bounding box).
TEMAPEXPORT te::rst::RasterProperty * GetRasterProperty(AbstractLayer *layer)
It gets the raster property referenced by the given data set layer.
A raster band description.
std::unique_ptr< te::gm::Envelope > GetExtent(te::da::DataSet *dset, te::qt::widgets::Promoter *p, const int &rowPosition)
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
A filter is any valid predicate expression.
Definition: fe/Filter.h:55
virtual Raster * getMultiResLevel(const unsigned int level) const =0
Returns the required level of a multi-resolution pyramid or NULL if that level does not exists...
This class represents the informations needed to build map charts.
Grid * getGrid()
It returns the raster grid.
virtual void setSelectionStyle(te::se::Style *style)
It sets the selection Style associated to the layer.
Utility functions for the data access module.
void setEncoding(te::core::EncodingType et)
It set the encoding type.
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
const std::vector< Symbolizer * > & getSymbolizers() const
Definition: Rule.cpp:158
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
Definition: From.h:37
A Converter is responsible for the conversion of coordinates between different Coordinate Systems (CS...
Definition: Converter.h:53
virtual te::map::RasterContrast * getRasterContrast() const
It returns the raster contrast associated to the Layer.
void apply(double icol, double ilin, double ocol, double olin)
This class contains the parameters needed to apply dynamic contrast over a raster.
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.
boost::shared_ptr< UnitOfMeasure > UnitOfMeasurePtr
int getSRID() const
Returns the raster spatial reference system identifier.
const std::string & getName() const
Returns the raster name.
This class contains the parameters needed to apply dynamic contrast over a raster.
const std::string & getDataSetName() const
A Rule is used to attach property/scale conditions to and group the individual symbols used for rende...
Definition: Rule.h:76
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.
virtual void setSRID(int srid)
It sets the Spatial Reference System ID associated to the Layer.
virtual te::map::Grouping * getGrouping() const
It returns the Grouping associated to the Layer.
A Raster Transform configurer generates a Raster Transform given a RasterSymbolzier.
static Raster * make()
It creates and returns an empty raster with default raster driver.
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.
Definition: RGBAColor.h:57
TEMAPEXPORT te::rst::Raster * GetExtentRaster(te::rst::Raster *raster, int w, int h, const te::gm::Envelope &bbox, int bboxSRID, const te::gm::Envelope &visibleArea, int srid)
A class that models a literal for Envelope values.
void gridToGeo(const double &col, const double &row, double &x, double &y) const
Get the spatial location of a grid point.
double getResolutionY() const
Returns the raster vertical (y-axis) resolution.
A Raster Transform configurer generates a Raster Transform given a RasterSymbolzier.
TEMAPEXPORT int CalculatePlanarZone(te::gm::Envelope latLongBox)
Calculates the UTM zone from a Geographic envelope.
virtual const std::string & getGeomPropertyName() const
const double & getMaxScaleDenominator() const
Definition: Rule.cpp:133
#define TeCRD
Conversion factor: radians to degrees.
Grouping * clone()
Definition: Grouping.cpp:55
virtual int getSRID() const
It returns the Spatial Reference System ID associated to the Layer.
int getType() const
It returns the data type of the elements in the band.
Definition: BandProperty.h:113
A Raster Transform is a class that defines functions to transform a styled raster.
This class contains the parameters needed for grouping the values of a Property.
void setSRID(int srid)
Just sets the grid spatial reference system identifier.
std::vector< te::rst::BandProperty * > & getBandProperties()
Returns a reference to the list of bands definitions.
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
void getValues(std::vector< double > &gain, std::vector< double > &offset1, std::vector< double > &offset2, std::vector< double > &min, std::vector< double > &max)
It get the contrast transformation values.
void config(const te::se::Symbolizer *symbolizer)
It configs the canvas based on given symbolizer.
Visibility
Each layer can have three states of visibility.
Calculate the min value.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
A rectified grid is the spatial support for raster data.
Definition: raster/Grid.h:68
ParameterValue * getNoDataValue() const
#define TeCDR
Conversion factor: degrees to radians.
Calculate the max value.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
virtual void draw(const te::gm::Geometry *geom)=0
It draws the geometry on canvas.
virtual void setId(const std::string &id)
It sets the layer id.
virtual const std::string & getDataSourceId() const
bool isValid() const
It tells if the rectangle is valid or not.
virtual int getWidth() const =0
It returns the canvas width.
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
TEMAPEXPORT te::gm::Envelope GetWorldBoxInPlanar(const te::gm::Envelope &worldBox, int srid)
It gets the requested envelope on a UTM planar projection.
A Symbology Enconding visitor that configures a given canvas based on symbolizers elements...
TEMAPEXPORT void GetVisibleLayers(const std::list< te::map::AbstractLayerPtr > &layers, std::list< te::map::AbstractLayerPtr > &visibleLayers)
It gets the visible layers of the given layer list.
const std::string & getName() const
It returns the property name.
Definition: Property.h:127
A Symbology Enconding visitor that configures a given canvas based on symbolizers elements...