QueryLayerRenderer.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/QueryLayerRenderer.cpp
22 
23  \brief It renders the objects associated to a query layer.
24 */
25 
26 // TerraLib
27 #include "../color/RGBAColor.h"
28 #include "../common/progress/TaskProgress.h"
29 #include "../common/Globals.h"
30 #include "../common/STLUtils.h"
31 #include "../common/StringUtils.h"
32 #include "../core/translator/Translator.h"
33 #include "../dataaccess/dataset/DataSet.h"
34 #include "../dataaccess/dataset/DataSetType.h"
35 #include "../dataaccess/query/And.h"
36 #include "../dataaccess/query/EqualTo.h"
37 #include "../dataaccess/query/GreaterThanOrEqualTo.h"
38 #include "../dataaccess/query/LessThanOrEqualTo.h"
39 #include "../dataaccess/query/LiteralDouble.h"
40 #include "../dataaccess/query/LiteralEnvelope.h"
41 #include "../dataaccess/query/LiteralString.h"
42 #include "../dataaccess/query/PropertyName.h"
43 #include "../dataaccess/query/ST_Intersects.h"
44 #include "../dataaccess/utils/Utils.h"
45 #include "../fe/Filter.h"
46 #include "../fe/Utils.h"
47 #include "../geometry/Coord2D.h"
48 #include "../geometry/Envelope.h"
49 #include "../geometry/GeometryProperty.h"
50 #include "../geometry/MultiPolygon.h"
51 #include "../geometry/Polygon.h"
52 #include "../raster/Raster.h"
53 #include "../raster/RasterProperty.h"
54 #include "../se/FeatureTypeStyle.h"
55 #include "../se/CoverageStyle.h"
56 #include "../se/Rule.h"
57 #include "../se/Utils.h"
58 #include "../srs/Config.h"
59 #include "AbstractLayer.h"
60 #include "QueryLayerRenderer.h"
61 #include "Canvas.h"
62 #include "CanvasConfigurer.h"
63 #include "Chart.h"
64 #include "ChartRendererManager.h"
65 #include "Exception.h"
66 #include "Grouping.h"
67 #include "QueryEncoder.h"
68 #include "Utils.h"
69 #include "QueryLayer.h"
70 #include "../dataaccess/query/OrderBy.h"
71 #include "../dataaccess/query/OrderByItem.h"
72 #include "../dataaccess/query/Select.h"
73 
74 // Boost
75 #include <boost/format.hpp>
76 #include <boost/lexical_cast.hpp>
77 #include <boost/math/special_functions/round.hpp>
78 
79 // STL
80 #include <cassert>
81 #include <cstdlib>
82 #include <memory>
83 #include <utility>
84 
86  : m_index(0)
87 {
88 }
89 
91 
93  Canvas* canvas,
94  const te::gm::Envelope& bbox,
95  int srid,
96  const double& scale, bool* cancel)
97 {
98  if(!bbox.isValid())
99  throw Exception(TE_TR("The requested box is invalid!"));
100 
101  assert(layer);
102  assert(canvas);
103 
104  // Check if layer extent intersects the drawing area and so compute bounding box intersection
105  te::gm::Envelope reprojectedBBOX(bbox);
106 
107  if((layer->getSRID() != TE_UNKNOWN_SRS) && (srid != TE_UNKNOWN_SRS))
108  {
109  reprojectedBBOX.transform(srid, layer->getSRID());
110 
111  if(!reprojectedBBOX.isValid())
112  throw Exception(TE_TR("The reprojected box is invalid!"));
113  }
114  else if(layer->getSRID() != srid)
115  {
116  throw Exception(TE_TR("The layer or map don't have a valid SRID!"));
117  }
118 
119  if(!reprojectedBBOX.intersects(layer->getExtent()))
120  return;
121 
122  // Adjust internal renderer transformer
123  m_transformer.setTransformationParameters(bbox.m_llx, bbox.m_lly, bbox.m_urx, bbox.m_ury, canvas->getWidth(), canvas->getHeight());
124 
125  canvas->setWindow(bbox.m_llx, bbox.m_lly, bbox.m_urx, bbox.m_ury);
126 
127  // Resets internal renderer state
128  reset();
129 
130  te::gm::Envelope ibbox = reprojectedBBOX.intersection(layer->getExtent());
131 
132  assert(ibbox.isValid());
133 
134  // Gets the layer schema
135  std::unique_ptr<LayerSchema> schema(layer->getSchema());
136  assert(schema.get());
137 
138  // Gets the name of the referenced spatial property
139  std::string spatialPropertyName = layer->getGeomPropertyName();
140 
141  if(schema->hasGeom())
142  {
143  te::gm::GeometryProperty* geometryProperty = nullptr;
144 
145  if(spatialPropertyName.empty())
146  geometryProperty = te::da::GetFirstGeomProperty(schema.get());
147  else
148  geometryProperty = dynamic_cast<te::gm::GeometryProperty*>(schema->getProperty(spatialPropertyName));
149 
150  assert(geometryProperty);
151 
152  // If the AbstractLayer has a grouping, do not consider the style.
153  Grouping* grouping = layer->getGrouping();
154  if(grouping && grouping->isVisible())
155  {
156  drawLayerGroupingMem(layer, geometryProperty->getName(), canvas, ibbox, srid);
157  return;
158  }
159 
160  // Gets the layer style
161  te::se::Style* style = layer->getStyle();
162  if(style == nullptr)
163  {
164  // Try create an appropriate style. i.e. a FeatureTypeStyle
165  style = te::se::CreateFeatureTypeStyle(geometryProperty->getGeometryType());
166 
167  if(style == nullptr)
168  throw Exception((boost::format(TE_TR("Could not create a default feature type style to the layer %1%.")) % layer->getTitle()).str());
169 
170  layer->setStyle(style);
171  }
172 
173  // Should I render this style?
174  te::se::FeatureTypeStyle* fts = dynamic_cast<te::se::FeatureTypeStyle*>(style);
175  if(fts == nullptr)
176  throw Exception(TE_TR("The layer style is not a Feature Type Style!"));
177 
178  drawLayerGeometries(layer, geometryProperty->getName(), fts, canvas, ibbox, srid);
179  }
180  else if(schema->hasRaster())
181  {
182  te::rst::RasterProperty* rasterProperty = nullptr;
183 
184  if(spatialPropertyName.empty())
185  rasterProperty = te::da::GetFirstRasterProperty(schema.get());
186  else
187  rasterProperty = dynamic_cast<te::rst::RasterProperty*>(schema->getProperty(spatialPropertyName));
188 
189  assert(rasterProperty);
190 
191  // Get the layer style
192  te::se::Style* style = layer->getStyle();
193  if(style == nullptr)
194  {
195  // Try create an appropriate style. i.e. a CoverageStyle
196  style = te::se::CreateCoverageStyle(rasterProperty->getBandProperties());
197 
198  if(style == nullptr)
199  throw Exception((boost::format(TE_TR("Could not create a default coverage style to the layer %1%.")) % layer->getTitle()).str());
200 
201  layer->setStyle(style);
202  }
203 
204  // Should I render this style?
205  te::se::CoverageStyle* cs = dynamic_cast<te::se::CoverageStyle*>(style);
206  if(cs == nullptr)
207  throw Exception(TE_TR("The layer style is not a Coverage Style!"));
208 
209  // Retrieves the data
210  std::unique_ptr<te::da::DataSet> dataset = layer->getData(rasterProperty->getName(), &ibbox, te::gm::INTERSECTS);
211 
212  if(dataset.get() == nullptr)
213  throw Exception((boost::format(TE_TR("Could not retrieve the data set from the layer %1%.")) % layer->getTitle()).str());
214 
215  // Retrieves the raster
216  std::unique_ptr<te::rst::Raster> raster(dataset->getRaster(rasterProperty->getName()));
217  if(dataset.get() == nullptr)
218  throw Exception((boost::format(TE_TR("Could not retrieve the raster from the layer %1%.")) % layer->getTitle()).str());
219 
220  // Let's draw!
221  DrawRaster(raster.get(), canvas, ibbox, layer->getSRID(), bbox, srid, cs, layer->getRasterContrast(), scale, cancel);
222  }
223  else
224  {
225  throw Exception(TE_TR("The layer don't have a geometry or raster property!"));
226  }
227 }
228 
230  const std::string& geomPropertyName,
232  Canvas* canvas,
233  const te::gm::Envelope& bbox,
234  int srid)
235 {
236  assert(!geomPropertyName.empty());
237  m_oid.clear();
238  te::map::QueryLayer* qlayer = nullptr;
239  te::da::Select* select = nullptr;
240 
241  bool linked = te::da::HasLinkedTable(layer->getSchema().get());
242  if(linked)
243  {
244  // make sorting by object id
245  qlayer = dynamic_cast<te::map::QueryLayer*>(layer);
246  select = dynamic_cast<te::da::Select*>(qlayer->getQuery()->clone());
247  te::da::Select* selectaux = dynamic_cast<te::da::Select*>(select->clone());
248  te::da::OrderBy* orderBy = new te::da::OrderBy;
249 
250  std::unique_ptr<te::da::DataSetType> schema = layer->getSchema();
251  std::vector<te::dt::Property*> props = schema->getPrimaryKey()->getProperties();
252  size_t pksize = 0;
253  while(++pksize < props.size())
254  {
255  m_oid.push_back(props[pksize-1]->getName());
256  if(props[pksize-1]->getDatasetName() != props[pksize]->getDatasetName())
257  break;
258  }
259 
260  for(size_t i = 0; i < pksize; ++i)
261  orderBy->push_back(new te::da::OrderByItem(m_oid[i]));
262 
263  selectaux->setOrderBy(orderBy);
264  qlayer->setQuery(selectaux);
265  }
266 
267  // Creates a canvas configurer
268  CanvasConfigurer cc(canvas);
269 
270  // Number of rules defined on feature type style
271  std::size_t nRules = style->getRules().size();
272 
273  for(std::size_t i = 0; i < nRules; ++i) // for each <Rule>
274  {
275  // The current rule
276  te::se::Rule* rule = style->getRule(i);
277  assert(rule);
278 
279  // TODO: Should be verified the MinScaleDenominator and MaxScaleDenominator. Where will we put the current scale information? Method parameter?
280 
281  // Gets the rule filter
282  const te::fe::Filter* filter = rule->getFilter();
283 
284  // Let's retrieve the correct dataset
285  std::unique_ptr<te::da::DataSet> dataset;
286 
287  if(!filter)
288  {
289  try
290  {
291  // There isn't a Filter expression. Gets the data using only extent spatial restriction...
292  dataset = layer->getData(geomPropertyName, &bbox, te::gm::INTERSECTS);
293  if(linked)
294  qlayer->setQuery(select);
295  }
296  catch(std::exception& /*e*/)
297  {
298  continue; // TODO: deal the exceptions!
299  }
300  }
301  else
302  {
303  try
304  {
305  // Gets an enconder
306  te::map::QueryEncoder filter2Query;
307 
308  // Converts the Filter expression to a TerraLib Expression!
309  te::da::Expression* exp = filter2Query.getExpression(filter);
310  if(exp == nullptr)
311  throw Exception(TE_TR("Could not convert the OGC Filter expression to TerraLib expression!"));
312 
313  /* 1) Creating the final restriction. i.e. Filter expression + extent spatial restriction */
314 
315  // The extent spatial restriction
316  te::da::LiteralEnvelope* lenv = new te::da::LiteralEnvelope(bbox, layer->getSRID());
317  te::da::PropertyName* geometryPropertyName = new te::da::PropertyName(geomPropertyName);
318  te::da::ST_Intersects* intersects = new te::da::ST_Intersects(geometryPropertyName, lenv);
319 
320  // Combining the expressions (Filter expression + extent spatial restriction)
321  te::da::And* restriction = new te::da::And(exp, intersects);
322 
323  /* 2) Calling the layer query method to get the correct restricted data. */
324  dataset = layer->getData(restriction);
325  if(linked)
326  qlayer->setQuery(select);
327  }
328  catch(std::exception& /*e*/)
329  {
330  continue; // TODO: deal the exceptions!
331  }
332  }
333 
334  if(dataset.get() == nullptr)
335  throw Exception((boost::format(TE_TR("Could not retrieve the data set from the layer %1%.")) % layer->getTitle()).str());
336 
337  if(dataset->moveNext() == false)
338  continue;
339 
340  // Gets the set of symbolizers defined on current rule
341  const std::vector<te::se::Symbolizer*>& symbolizers = rule->getSymbolizers();
342 
343  // Builds task message; e.g. ("Drawing the layer Countries. Rule 1 of 3.")
344  std::string message = TE_TR("Drawing the layer");
345  message += " " + layer->getTitle() + ". ";
346  message += TE_TR("Rule");
347  message += " " + boost::lexical_cast<std::string>(i + 1) + " " + TE_TR("of") + " ";
348  message += boost::lexical_cast<std::string>(nRules) + ".";
349 
350  // Creates a draw task
352  //task.setTotalSteps(symbolizers.size() * dataset->size()); // Removed! The te::da::DataSet size() method would be too costly to compute.
353 
354  // For while, first geometry property. TODO: get which geometry property the symbolizer references
355  std::size_t gpos = te::da::GetPropertyPos(dataset.get(), geomPropertyName);
356 
357  if(symbolizers.empty())
358  {
359  // The current rule do not have a symbolizer. Try creates a default based on first geometry of dataset.
360  std::unique_ptr<te::gm::Geometry> g(dataset->getGeometry(gpos));
361  assert(g.get());
362 
363  te::se::Symbolizer* symbolizer = te::se::CreateSymbolizer(g->getGeomTypeId());
364  assert(symbolizer);
365 
366  rule->push_back(symbolizer);
367 
368  dataset->moveFirst();
369  }
370 
371  std::size_t nSymbolizers = symbolizers.size();
372 
373  for(std::size_t j = 0; j < nSymbolizers; ++j) // for each <Symbolizer>
374  {
375  // The current symbolizer
376  te::se::Symbolizer* symb = symbolizers[j];
377 
378  // Let's config the canvas based on the current symbolizer
379  cc.config(symb);
380 
381  // Let's draw! for each data set geometry...
382  if(j != nSymbolizers - 1)
383  drawDatSetGeometries(dataset.get(), gpos, canvas, layer->getSRID(), srid, nullptr, &task);
384  else
385  drawDatSetGeometries(dataset.get(), gpos, canvas, layer->getSRID(), srid, layer->getChart(), &task); // Here, produces the chart if exists
386 
387  // Prepares to draw the other symbolizer
388  dataset->moveFirst();
389 
390  } // end for each <Symbolizer>
391 
392  } // end for each <Rule>
393 }
394 
396  AbstractLayer* /*layer*/, const std::string& /*geomPropertyName*/,
397  Canvas* /*canvas*/, const te::gm::Envelope& /*bbox*/, int /*srid*/)
398 {
399 
400 }
401 
403  const std::string& geomPropertyName,
404  Canvas* canvas,
405  const te::gm::Envelope& bbox,
406  int srid)
407 {
408  assert(!geomPropertyName.empty());
409 
410  if (te::da::HasLinkedTable(layer->getSchema().get()) && (layer->getGrouping()->getSummary() != "NONE"))
411  {
412  drawLayerLinkedGroupingMem(layer, geomPropertyName, canvas, bbox, srid);
413  return;
414  }
415 
416  // Creates a canvas configurer
417  te::map::CanvasConfigurer cc(canvas);
418 
419  // The layer grouping
420  Grouping* grouping = layer->getGrouping();
421 
422  // The referenced property name
423  std::string propertyName = grouping->getPropertyName();
424  assert(!propertyName.empty());
425 
426  // The grouping type
427  GroupingType type = grouping->getType();
428 
429  // The grouping precision
430  const std::size_t& precision = grouping->getPrecision();
431 
432  // The rule items
433  std::vector<te::se::Rule*> layerRules = layer->getStyle()->getRules();
434 
435  // case UNIQUE_VALUE: for each rule, builds a map [item value] -> [rule]
436  std::map<std::string, te::se::Rule*> uniqueRuleMap;
437 
438  // case (NOT) UNIQUE_VALUE: for each rule, builds a map [(lower, upper)] -> [rule]
439  std::map<std::pair< double, double>, te::se::Rule* > othersRuleMap;
440 
441  for (std::size_t i = 0; i < layerRules.size(); ++i)
442  {
443  // The current group item
444  te::se::Rule* ruleItem = layerRules[i];
445 
446  if (type == UNIQUE_VALUE)
447  {
448  std::string uniqueValue;
449 
450  te::fe::GetFilterUniqueValue(ruleItem->getFilter(), uniqueValue);
451 
452  uniqueRuleMap[uniqueValue] = ruleItem;
453  }
454  else
455  {
456  std::string lowerLimitStr;
457  std::string upperLimitStr;
458 
459  te::fe::GetFilterStepValues(ruleItem->getFilter(), lowerLimitStr, upperLimitStr);
460 
461  double lowerLimit = atof(lowerLimitStr.c_str());
462  double upperLimit = atof(upperLimitStr.c_str());
463  std::pair<double, double> range(lowerLimit, upperLimit);
464 
465  othersRuleMap[range] = ruleItem;
466  }
467  }
468 
469  // Builds the task message; e.g. ("Drawing the grouping of layer Countries.")
470  std::string message = TE_TR("Drawing the grouping of layer");
471  message += " " + layer->getTitle() + ".";
472 
473  // Creates the draw task
475 
476  std::unique_ptr<te::da::DataSet> dataset;
477  try
478  {
479  dataset = layer->getData(geomPropertyName, &bbox, te::gm::INTERSECTS);
480  }
481  catch(std::exception& /*e*/)
482  {
483  return; // TODO: deal the exceptions!
484  }
485 
486  if(dataset.get() == nullptr)
487  throw Exception((boost::format(TE_TR("Could not retrieve the data set from the layer %1%.")) % layer->getTitle()).str());
488 
489  if(dataset->moveNext() == false)
490  return;
491 
492  // Gets the first geometry property
493  std::size_t gpos = te::da::GetPropertyPos(dataset.get(), geomPropertyName);
494 
495  // Gets the property position
496  std::unique_ptr<te::map::LayerSchema> dt(layer->getSchema());
497  std::size_t propertyPos = te::da::GetPropertyPos(dt.get(), propertyName);
498 
499  // Verifies if is necessary convert the data set geometries to the given srid
500  bool needRemap = false;
501  if((layer->getSRID() != TE_UNKNOWN_SRS) && (srid != TE_UNKNOWN_SRS) && (layer->getSRID() != srid))
502  needRemap = true;
503 
504  // The layer chart
505  Chart* chart = layer->getChart();
506 
507  do
508  {
509  te::se::Rule* rule = nullptr;
510 
511  // Finds the current data set item on group map
512  std::string value;
513 
514  if (dataset->isNull(propertyPos))
516  else
517  value = dataset->getAsString(propertyPos, static_cast<int>(precision));
518 
519  if (type == UNIQUE_VALUE)
520  {
521  std::map<std::string, te::se::Rule*>::const_iterator it = uniqueRuleMap.find(value);
522  if (it == uniqueRuleMap.end())
523  continue;
524 
525  rule = it->second;
526  }
527  else
528  {
529  double dvalue = atof(value.c_str());
530  std::map<std::pair< double, double>, te::se::Rule*>::const_iterator it;
531  for (it = othersRuleMap.begin(); it != othersRuleMap.end(); ++it)
532  {
533  if (dvalue >= it->first.first && dvalue < it->first.second)
534  break;
535  }
536 
537  if (it != othersRuleMap.end())
538  rule = it->second;
539 
540  //check if a rule was found for current value
541  if (!rule)
542  continue;
543  }
544 
545  std::unique_ptr<te::gm::Geometry> geom;
546  try
547  {
548  geom = dataset->getGeometry(gpos);
549  if(geom.get() == nullptr)
550  continue;
551  }
552  catch(std::exception& /*e*/)
553  {
554  continue;
555  }
556 
557  std::vector<te::se::Symbolizer*> symbolizers = rule->getSymbolizers();
558 
559  // Gets the set of symbolizers defined on group item
560  std::size_t nSymbolizers = symbolizers.size();
561 
562  for(std::size_t j = 0; j < nSymbolizers; ++j) // for each <Symbolizer>
563  {
564  // The current symbolizer
565  te::se::Symbolizer* symb = symbolizers[j];
566 
567  // Let's config the canvas based on the current symbolizer
568  cc.config(symb);
569 
570  // If necessary, geometry remap
571  if(needRemap)
572  {
573  geom->setSRID(layer->getSRID());
574  geom->transform(srid);
575  }
576 
577  canvas->draw(geom.get());
578 
579  if(chart && j == nSymbolizers - 1)
580  buildChart(chart, dataset.get(), geom.get());
581  }
582 
583  } while(dataset->moveNext());
584 
585  // Let's draw the generated charts
586  for(std::size_t i = 0; i < m_chartCoordinates.size(); ++i)
587  {
588  canvas->drawImage(static_cast<int>(m_chartCoordinates[i].x),
589  static_cast<int>(m_chartCoordinates[i].y),
590  m_chartImages[i],
591  static_cast<int>(chart->getWidth()),
592  static_cast<int>(chart->getHeight()));
593 
595  }
596 }
597 
599  const std::string& geomPropertyName,
600  Canvas* canvas,
601  const te::gm::Envelope& bbox,
602  int srid)
603 {
604  assert(!geomPropertyName.empty());
605 
606  m_oid.clear();
607 
608  te::map::QueryLayer* qlayer = dynamic_cast<te::map::QueryLayer*>(layer);
609  te::da::Select* select = dynamic_cast<te::da::Select*>(qlayer->getQuery()->clone());
610 
611  std::unique_ptr<te::da::DataSetType> schema = layer->getSchema();
612  std::vector<te::dt::Property*> props = schema->getPrimaryKey()->getProperties();
613  size_t pksize = 0;
614  while(++pksize < props.size())
615  {
616  m_oid.push_back(props[pksize-1]->getName());
617  if(props[pksize-1]->getDatasetName() != props[pksize]->getDatasetName())
618  break;
619  }
620 
621  te::da::OrderBy* orderBy = new te::da::OrderBy;
622  for(size_t i = 0; i < pksize; ++i)
623  orderBy->push_back(new te::da::OrderByItem(m_oid[i]));
624 
625  te::da::Select* selectaux = dynamic_cast<te::da::Select*>(select->clone());
626  selectaux->setOrderBy(orderBy);
627  qlayer->setQuery(selectaux);
628 
629  // Creates a canvas configurer
630  te::map::CanvasConfigurer cc(canvas);
631 
632  // The layer grouping
633  Grouping* grouping = layer->getGrouping();
634 
635  // The referenced property name
636  std::string propertyName = grouping->getPropertyName();
637  assert(!propertyName.empty());
638 
639  // The grouping type
640  GroupingType type = grouping->getType();
641 
642  // The grouping precision
643  const std::size_t& precision = grouping->getPrecision();
644 
645  // The grouping sumarization
646  const std::string gfunction = grouping->getSummary();
647 
648  // The rule items
649  std::vector<te::se::Rule*> layerRules = layer->getStyle()->getRules();
650 
651  // case UNIQUE_VALUE: for each rule, builds a map [item value] -> [rule]
652  std::map<std::string, te::se::Rule*> uniqueRuleMap;
653 
654  // case (NOT) UNIQUE_VALUE: for each rule, builds a map [(lower, upper)] -> [rule]
655  std::map<std::pair< double, double>, te::se::Rule* > othersRuleMap;
656 
657  for (std::size_t i = 0; i < layerRules.size(); ++i)
658  {
659  // The current group item
660  te::se::Rule* ruleItem = layerRules[i];
661 
662  if (type == UNIQUE_VALUE)
663  {
664  std::string uniqueValue;
665 
666  te::fe::GetFilterUniqueValue(ruleItem->getFilter(), uniqueValue);
667 
668  uniqueRuleMap[uniqueValue] = ruleItem;
669  }
670  else
671  {
672  std::string lowerLimitStr;
673  std::string upperLimitStr;
674 
675  te::fe::GetFilterStepValues(ruleItem->getFilter(), lowerLimitStr, upperLimitStr);
676 
677  double lowerLimit = atof(lowerLimitStr.c_str());
678  double upperLimit = atof(upperLimitStr.c_str());
679  std::pair<double, double> range(lowerLimit, upperLimit);
680 
681  othersRuleMap[range] = ruleItem;
682  }
683  }
684 
685  // Builds the task message; e.g. ("Drawing the grouping of layer Countries.")
686  std::string message = TE_TR("Drawing the grouping of layer");
687  message += " " + layer->getTitle() + ".";
688 
689  // Creates the draw task
691 
692  std::unique_ptr<te::da::DataSet> dataset;
693  try
694  {
695  dataset = layer->getData(geomPropertyName, &bbox, te::gm::INTERSECTS);
696  qlayer->setQuery(select);
697  }
698  catch(std::exception& /*e*/)
699  {
700  return; // TODO: deal the exceptions!
701  }
702 
703  if(dataset.get() == nullptr)
704  throw Exception((boost::format(TE_TR("Could not retrieve the data set from the layer %1%.")) % layer->getTitle()).str());
705 
706  if(dataset->moveNext() == false)
707  return;
708 
709  // Gets the first geometry property
710  std::size_t gpos = te::da::GetPropertyPos(dataset.get(), geomPropertyName);
711 
712  // Gets the property position
713  std::unique_ptr<te::map::LayerSchema> dt(layer->getSchema());
714  std::size_t propertyPos = te::da::GetPropertyPos(dt.get(), propertyName);
715  size_t ptype = dataset->getPropertyDataType(te::da::GetPropertyPos(dataset.get(), propertyName));
716 
717  // Verifies if is necessary convert the data set geometries to the given srid
718  bool needRemap = false;
719  if((layer->getSRID() != TE_UNKNOWN_SRS) && (srid != TE_UNKNOWN_SRS) && (layer->getSRID() != srid))
720  needRemap = true;
721 
722  std::vector<std::string> pkdata(pksize), pkdataaux(pksize);
723  std::vector<double> values;
724  double value;
725  std::vector<std::string> svalues;
726  std::string svalue;
727 
728  // The layer chart
729  Chart* chart = layer->getChart();
730 
731  // The chart sumarization
732  std::string cfunction;
733  std::map<std::string, std::vector<double> > chartValues;
734  std::map<std::string, double> chartValue;
735  bool hasGroupNullValue = false;
736  bool hasGroupNullValueAux = false;
737  bool hasChartNullValue = false;
738  bool hasChartNullValueAux = false;
739  size_t csize = 0;
740  if(chart)
741  {
742  cfunction = chart->getSummary();
743  csize = chart->getProperties().size();
744  std::vector<size_t> propPos;
745  for(std::size_t i = 0; i < csize; ++i)
746  {
747  std::vector<double> v;
748  chartValues[chart->getProperties()[i]] = v;
749  propPos.push_back(te::da::GetPropertyPos(dataset.get(), chart->getProperties()[i]));
750  }
751  chart->setPropertiesPos(propPos);
752  }
753 
754  te::gm::Geometry *geom = nullptr, *geomaux = nullptr;
755  do
756  {
757  try
758  {
759  if(geomaux == nullptr)
760  geomaux = dataset->getGeometry(gpos).release();
761  if(geomaux == nullptr)
762  continue;
763  }
764  catch(std::exception& /*e*/)
765  {
766  continue;
767  }
768 
769  std::vector<te::se::Symbolizer*> symbolizers;
770 
771  // Finds the current data set item on group map
772  size_t i;
773  for(i = 0; i < pksize; ++i)
774  pkdata[i] = dataset->getAsString(m_oid[i]);
775 
776  for(i = 0; i < pksize; ++i)
777  {
778  if(dataset->isAtBegin())
779  pkdataaux[i] = dataset->getAsString(m_oid[i]);
780  else
781  {
782  if(pkdata[i] != pkdataaux[i])
783  {
784  pkdataaux = pkdata;
785  break;
786  }
787  }
788  }
789  if(i == pksize) // it is the same object
790  {
791  // read value
792  if(hasGroupNullValue == false && dataset->isNull(propertyPos) == false)
793  {
794  if(type == UNIQUE_VALUE)
795  {
796  if(ptype == te::dt::STRING_TYPE)
797  svalues.push_back(dataset->getAsString(propertyPos, static_cast<int>(precision)));
798  else
799  values.push_back(te::da::GetValueAsDouble(dataset.get(), propertyPos));
800  }
801  else
802  values.push_back(te::da::GetValueAsDouble(dataset.get(), propertyPos));
803  }
804  else
805  hasGroupNullValue = true;
806 
807  if(hasChartNullValue == false)
808  {
809  for(std::size_t i = 0; i < csize; ++i)
810  {
811  if(dataset->isNull(chart->getProperties()[i]))
812  {
813  hasChartNullValue = true;
814  break;
815  }
816  }
817  if(hasChartNullValue == false)
818  {
819  for(std::size_t i = 0; i < csize; ++i)
820  chartValues[chart->getProperties()[i]].push_back(te::da::GetValueAsDouble(dataset.get(), chart->getPropertiesPos()[i]));
821  }
822  }
823 
824  // read other values
825  continue;
826  }
827  else // it is other object
828  {
829  delete geom;
830  geom = geomaux;
831 
832  te::se::Rule* rule = nullptr;
833 
834  // sumarize value
835  // computing a value according to the required summarization
836  // get symbolizers
837  if(hasGroupNullValue == false)
838  {
839  if(type == UNIQUE_VALUE)
840  {
841  if(ptype == te::dt::STRING_TYPE)
842  {
843  value = te::da::GetSummarizedValue(values, gfunction);
844  value = te::da::Round(value, precision);
845  svalue = boost::lexical_cast<std::string>(value);
846  }
847  else
848  svalue = te::da::GetSummarizedValue(svalues, gfunction);
849 
850  std::map<std::string, te::se::Rule*>::const_iterator it = uniqueRuleMap.find(svalue);
851  if (it == uniqueRuleMap.end())
852  continue;
853 
854  rule = it->second;
855  }
856  else
857  {
858  value = te::da::GetSummarizedValue(values, gfunction);
859  value = te::da::Round(value, precision);
860 
861  std::map<std::pair< double, double>, te::se::Rule*>::const_iterator it;
862  for (it = othersRuleMap.begin(); it != othersRuleMap.end(); ++it)
863  {
864  if(value >= it->first.first && value <= it->first.second)
865  break;
866  }
867 
868  if (it != othersRuleMap.end())
869  rule = it->second;
870 
871  //check if a rule was found for current value
872  if (!rule)
873  continue;
874  }
875  }
876  else
877  {
878  te::se::Style* style = layer->getStyle();
879  if(style)
880  {
881  if(!style->getRules().empty())
882  {
883  te::se::Rule* rule = style->getRule(0);
884 
885  symbolizers = rule->getSymbolizers();
886  }
887  }
888  }
889 
890  if(hasChartNullValue == false)
891  {
892  for(std::size_t i = 0; i < csize; ++i)
893  chartValue[chart->getProperties()[i]] = te::da::GetSummarizedValue(chartValues[chart->getProperties()[i]], cfunction);
894  }
895 
896  // store the values of the other object (for next loop).
897  try
898  {
899  geomaux = dataset->getGeometry(gpos).release();
900  }
901  catch(std::exception& /*e*/)
902  {
903  geomaux = nullptr;
904  continue;
905  }
906 
907  for(std::size_t i = 0; i < csize; ++i)
908  chartValues[chart->getProperties()[i]].clear();
909  values.clear();
910  svalues.clear();
911 
912  if(dataset->isNull(propertyPos) == false)
913  {
914  if(type == UNIQUE_VALUE)
915  {
916  if(ptype == te::dt::STRING_TYPE)
917  svalues.push_back(dataset->getAsString(propertyPos, static_cast<int>(precision)));
918  else
919  values.push_back(te::da::GetValueAsDouble(dataset.get(), propertyPos));
920  }
921  else
922  values.push_back(te::da::GetValueAsDouble(dataset.get(), propertyPos));
923  }
924  else
925  hasGroupNullValueAux = true;
926 
927  for(std::size_t i = 0; i < csize; ++i)
928  {
929  if(dataset->isNull(chart->getProperties()[i]))
930  {
931  hasChartNullValueAux = true;
932  break;
933  }
934  }
935  if(hasChartNullValueAux == false)
936  {
937  for(std::size_t i = 0; i < csize; ++i)
938  chartValues[chart->getProperties()[i]].push_back(te::da::GetValueAsDouble(dataset.get(), chart->getPropertiesPos()[i]));
939  }
940  }
941 
942  // Gets the set of symbolizers defined on group item
943  std::size_t nSymbolizers = symbolizers.size();
944 
945  for(std::size_t j = 0; j < nSymbolizers; ++j) // for each <Symbolizer>
946  {
947  // The current symbolizer
948  te::se::Symbolizer* symb = symbolizers[j];
949 
950  // Let's config the canvas based on the current symbolizer
951  cc.config(symb);
952 
953  // If necessary, geometry remap
954  if(needRemap)
955  {
956  geom->setSRID(layer->getSRID());
957  geom->transform(srid);
958  }
959 
960  canvas->draw(geom);
961 
962  if(chart && hasChartNullValue == false && j == nSymbolizers - 1)
963  buildChart(chart, chartValue, geom);
964  }
965 
966  hasChartNullValue = hasChartNullValueAux;
967  hasGroupNullValue = hasGroupNullValueAux;
968  hasChartNullValueAux = false;
969  hasGroupNullValueAux = false;
970  } while(dataset->moveNext());
971 
972  delete geom;
973  geom = geomaux;
974 
975  if(hasChartNullValue == false)
976  {
977  for(std::size_t i = 0; i < csize; ++i)
978  {
979  chartValue[chart->getProperties()[i]] = te::da::GetSummarizedValue(chartValues[chart->getProperties()[i]], cfunction);
980  }
981  }
982 
983  // Let's draw the generated charts
984  for(std::size_t i = 0; i < m_chartCoordinates.size(); ++i)
985  {
986  canvas->drawImage(static_cast<int>(m_chartCoordinates[i].x),
987  static_cast<int>(m_chartCoordinates[i].y),
988  m_chartImages[i],
989  static_cast<int>(chart->getWidth()),
990  static_cast<int>(chart->getHeight()));
991 
993  }
994 }
995 
996 void te::map::QueryLayerRenderer::drawDatSetGeometries(te::da::DataSet* dataset, const std::size_t& gpos, Canvas* canvas,
997  int fromSRID, int toSRID,
998  Chart* chart, te::common::TaskProgress* task)
999 {
1000  assert(dataset);
1001  assert(canvas);
1002 
1003  std::string s;
1004  size_t pksize = m_oid.size();
1005  std::vector<std::string> pkdata(pksize), pkdataaux(pksize);
1006 
1007  // Verify if is necessary convert the data set geometries to the given srid
1008  bool needRemap = false;
1009  if((fromSRID != TE_UNKNOWN_SRS) && (toSRID != TE_UNKNOWN_SRS) && (fromSRID != toSRID))
1010  needRemap = true;
1011 
1012  // The chart sumarization
1013  std::string cfunction;
1014  std::map<std::string, std::vector<double> > chartValues;
1015  std::map<std::string, double> chartValue;
1016  bool hasChartNullValue = false;
1017  bool hasChartNullValueAux = false;
1018  size_t csize = 0;
1019  if(chart)
1020  {
1021  cfunction = chart->getSummary();
1022  csize = chart->getProperties().size();
1023  std::vector<size_t> propPos;
1024  for(std::size_t i = 0; i < csize; ++i)
1025  {
1026  std::vector<double> v;
1027  chartValues[chart->getProperties()[i]] = v;
1028  propPos.push_back(te::da::GetPropertyPos(dataset, chart->getProperties()[i]));
1029  }
1030  chart->setPropertiesPos(propPos);
1031  }
1032 
1033  te::gm::Geometry *geom = nullptr, *geomaux = nullptr;
1034  do
1035  {
1036  try
1037  {
1038  if(geomaux == nullptr)
1039  geomaux = dataset->getGeometry(gpos).release();
1040  if(geomaux == nullptr)
1041  continue;
1042  }
1043  catch(std::exception& /*e*/)
1044  {
1045  continue;
1046  }
1047 
1048  if(pksize) // if linked
1049  {
1050  // it is linked. Remove redundancies.
1051  size_t i;
1052  for (i = 0; i < pksize; ++i)
1053  {
1054  pkdata[i] = dataset->getAsString(m_oid[i]);
1055  }
1056 
1057  for(i = 0; i < pksize; ++i)
1058  {
1059  if(dataset->isAtBegin())
1060  pkdataaux[i] = dataset->getAsString(m_oid[i]);
1061  else
1062  {
1063  if(pkdata[i] != pkdataaux[i])
1064  {
1065  pkdataaux = pkdata;
1066  break;
1067  }
1068  }
1069  }
1070  if(i == pksize) // it is the same object
1071  {
1072  if(hasChartNullValue == false)
1073  {
1074  // read value chart value
1075  for(std::size_t i = 0; i < csize; ++i)
1076  {
1077  if(dataset->isNull(chart->getProperties()[i]) == false)
1078  chartValues[chart->getProperties()[i]].push_back(te::da::GetValueAsDouble(dataset, chart->getPropertiesPos()[i]));
1079  else
1080  {
1081  hasChartNullValue = true;
1082  break;
1083  }
1084  }
1085  }
1086  // read other values
1087  continue;
1088  }
1089  else // it is other object
1090  {
1091  // sumarize chart value according to the required summarization
1092  if(hasChartNullValue == false)
1093  {
1094  for(std::size_t i = 0; i < csize; ++i)
1095  chartValue[chart->getProperties()[i]] = te::da::GetSummarizedValue(chartValues[chart->getProperties()[i]], cfunction);
1096  }
1097 
1098  // prepare the next loop
1099  for(std::size_t i = 0; i < csize; ++i)
1100  chartValues[chart->getProperties()[i]].clear();
1101 
1102  hasChartNullValueAux = false;
1103  for(std::size_t i = 0; i < csize; ++i)
1104  {
1105  if(dataset->isNull(chart->getProperties()[i]))
1106  {
1107  hasChartNullValueAux = true;
1108  break;
1109  }
1110  }
1111  if(hasChartNullValueAux == false)
1112  {
1113  for(std::size_t i = 0; i < csize; ++i)
1114  chartValues[chart->getProperties()[i]].push_back(te::da::GetValueAsDouble(dataset, chart->getPropertiesPos()[i]));
1115  }
1116  }
1117  }
1118  else // if not linked
1119  {
1120  // read chart value
1121  for(std::size_t i = 0; i < csize; ++i)
1122  {
1123  if(dataset->isNull(chart->getProperties()[i]) == false)
1124  chartValue[chart->getProperties()[i]] = te::da::GetValueAsDouble(dataset, chart->getPropertiesPos()[i]);
1125  else
1126  {
1127  chartValue.clear();
1128  hasChartNullValue = true;
1129  break;
1130  }
1131  }
1132  }
1133 
1134  delete geom;
1135  geom = geomaux;
1136 
1137  // store the values of the other object (for next loop).
1138  try
1139  {
1140  geomaux = dataset->getGeometry(gpos).release();
1141  }
1142  catch(std::exception& /*e*/)
1143  {
1144  geomaux = nullptr;
1145  continue;
1146  }
1147 
1148  if(task)
1149  {
1150  if(!task->isActive())
1151  return;
1152 
1153  // update the draw task
1154  task->pulse();
1155  }
1156 
1157  // If necessary, geometry remap
1158  if(needRemap)
1159  {
1160  geom->setSRID(fromSRID);
1161  geom->transform(toSRID);
1162  }
1163 
1164  canvas->draw(geom);
1165 
1166  if(chart && hasChartNullValue == false)
1167  buildChart(chart, chartValue, geom);
1168 
1169  hasChartNullValue = hasChartNullValueAux;
1170  hasChartNullValueAux = false;
1171 
1172  } while(dataset->moveNext()); // next geometry!
1173 
1174  delete geom;
1175  geom = geomaux;
1176 
1177  if(needRemap)
1178  {
1179  geom->setSRID(fromSRID);
1180  geom->transform(toSRID);
1181  }
1182 
1183  canvas->draw(geom);
1184  if(chart && hasChartNullValue == false)
1185  {
1186  if(chartValues.empty() == false)
1187  {
1188  for(std::size_t i = 0; i < csize; ++i)
1189  {
1190  chartValue[chart->getProperties()[i]] = te::da::GetSummarizedValue(chartValues[chart->getProperties()[i]], cfunction);
1191  }
1192  }
1193  buildChart(chart, chartValue, geom);
1194  }
1195  delete geom;
1196 
1197  // Let's draw the generated charts
1198  for(std::size_t i = 0; i < m_chartCoordinates.size(); ++i)
1199  {
1200  canvas->drawImage(static_cast<int>(m_chartCoordinates[i].x),
1201  static_cast<int>(m_chartCoordinates[i].y),
1202  m_chartImages[i],
1203  static_cast<unsigned int>(chart->getWidth()),
1204  static_cast<unsigned int>(chart->getHeight()));
1205 
1207  }
1208 }
1209 
1210 void te::map::QueryLayerRenderer::buildChart(const Chart* chart, const std::map<std::string, double>& chartValue, te::gm::Geometry* geom)
1211 {
1212  if(!chart->isVisible())
1213  return;
1214 
1215  // World coordinates
1216  const te::gm::Envelope* e = geom->getMBR();
1217  std::unique_ptr<te::gm::Coord2D> worldCoord(new te::gm::Coord2D(e->getCenter().x, e->getCenter().y));
1218 
1219  // Try finds the geometry centroid
1220  if(geom->getGeomTypeId() == te::gm::PolygonType)
1221  {
1222  te::gm::Polygon* p = dynamic_cast<te::gm::Polygon*>(geom);
1223  worldCoord.reset(p->getCentroidCoord());
1224  }
1225  else if (geom->getGeomTypeId() == te::gm::MultiPolygonType)
1226  {
1227  te::gm::MultiPolygon* mp = dynamic_cast<te::gm::MultiPolygon*>(geom);
1228  worldCoord.reset(mp->getCentroidCoord());
1229  }
1230 
1231  // Device coordinates
1232  double dx = 0.0; double dy = 0.0;
1233  m_transformer.world2Device(worldCoord->x, worldCoord->y, dx, dy);
1234 
1235  double dw = dx + chart->getWidth();
1236  double dh = dy + chart->getHeight();
1237 
1238  // Builds the chart envelope
1239  te::gm::Envelope chartEnvelope(dx, dy, dw, dh);
1240 
1241  if(chart->getAvoidConflicts())
1242  {
1243  // Search on rtree
1244  std::vector<std::size_t> report;
1245  m_rtree.search(chartEnvelope, report);
1246 
1247  if(!report.empty())
1248  return;
1249 
1250  // Here, no intersections considering the current chart envelope
1251  m_rtree.insert(chartEnvelope, ++m_index);
1252  }
1253 
1254  // Stores the chart coordinate
1255  m_chartCoordinates.push_back(te::gm::Coord2D(dx, dy));
1256 
1257  // Builds the chart image
1258  std::size_t width = 0;
1259  te::color::RGBAColor** rgba = ChartRendererManager::getInstance().render(chart, chartValue, width);
1260  m_chartImages.push_back(rgba);
1261 }
1262 
1264 {
1265  if(!chart->isVisible())
1266  return;
1267 
1268  // World coordinates
1269  const te::gm::Envelope* e = geom->getMBR();
1270  std::unique_ptr<te::gm::Coord2D> worldCoord(new te::gm::Coord2D(e->getCenter().x, e->getCenter().y));
1271 
1272  // Try finds the geometry centroid
1273  if (geom->getGeomTypeId() == te::gm::PolygonType)
1274  {
1275  te::gm::Polygon* p = dynamic_cast<te::gm::Polygon*>(geom);
1276  worldCoord.reset(p->getCentroidCoord());
1277  }
1278  else if (geom->getGeomTypeId() == te::gm::MultiPolygonType)
1279  {
1280  te::gm::MultiPolygon* mp = dynamic_cast<te::gm::MultiPolygon*>(geom);
1281  worldCoord.reset(mp->getCentroidCoord());
1282  }
1283 
1284  // Device coordinates
1285  double dx = 0.0; double dy = 0.0;
1286  m_transformer.world2Device(worldCoord->x, worldCoord->y, dx, dy);
1287 
1288  double dw = dx + chart->getWidth();
1289  double dh = dy + chart->getHeight();
1290 
1291  // Builds the chart envelope
1292  te::gm::Envelope chartEnvelope(dx, dy, dw, dh);
1293 
1294  if(chart->getAvoidConflicts())
1295  {
1296  // Search on rtree
1297  std::vector<std::size_t> report;
1298  m_rtree.search(chartEnvelope, report);
1299 
1300  if(!report.empty())
1301  return;
1302 
1303  // Here, no intersections considering the current chart envelope
1304  m_rtree.insert(chartEnvelope, ++m_index);
1305  }
1306 
1307  // Stores the chart coordinate
1308  m_chartCoordinates.push_back(te::gm::Coord2D(dx, dy));
1309 
1310  // Builds the chart image
1311  std::size_t width = 0;
1312  te::color::RGBAColor** rgba = ChartRendererManager::getInstance().render(chart, dataset, width);
1313  m_chartImages.push_back(rgba);
1314 }
1315 
1317 {
1318  m_index = 0;
1319  m_chartCoordinates.clear();
1320  m_chartImages.clear();
1321 }
virtual std::unique_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
TEDATAACCESSEXPORT te::rst::RasterProperty * GetFirstRasterProperty(const DataSetType *dt)
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:50
const std::vector< std::string > & getProperties() const
Definition: Chart.cpp:97
Geometric property.
if(WIN32) add_definitions(-D_SCL_SECURE_NO_WARNINGS-DTEWCSDLL) endif() file(GLOB TERRALIB_SRC_FILES $
double y
y-coordinate.
Definition: Coord2D.h:114
bool intersects(const Envelope &rhs) const
It returns true if the envelopes "spatially intersects".
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).
std::string getSummary() const
It gets the grouping summary. It is used only in case 1 to n.
Definition: Chart.cpp:211
TESEEXPORT Symbolizer * CreateSymbolizer(const te::gm::GeomType &geomType)
Try creates an appropriate symbolizer based on given geometry type.
std::vector< std::string > m_oid
static te::dt::Date dx(2010, 12, 31)
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
virtual const std::string & getTitle() const
It returns the layer title.
double x
x-coordinate.
Definition: Coord2D.h:113
TEDATAACCESSEXPORT bool HasLinkedTable(te::da::DataSetType *type)
It checks if the datasettype has a linked table.
A class that models the name of any property of an object.
Base exception class for plugin module.
const size_t getPrecision() const
It gets the precision used for the property values.
Definition: Grouping.cpp:99
A Symbolizer describes how a feature is to appear on a map.
Definition: Symbolizer.h:80
GeomType getGeomTypeId() const _NOEXCEPT_OP(true)
It returns the geometry subclass type identifier.
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
This is the base class for Layers.
std::string getPropertyName() const
It gets the property name whose values will be grouped.
Definition: Grouping.cpp:67
TESEEXPORT Style * CreateCoverageStyle(const std::vector< te::rst::BandProperty * > &properties)
Try creates an appropriate coverage style based on given band properties.
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...
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:53
TEDATAACCESSEXPORT std::size_t GetPropertyPos(const DataSet *dataset, const std::string &name)
virtual bool isAtBegin() const =0
It tells if the dataset internal pointer is on the first element of the collection or not...
This is a singleton for managing chart renderer instance available in the system. ...
double m_urx
Upper right corner x-coordinate.
boost::ptr_vector< OrderByItem > OrderBy
A class that can be used to model an ORDER BY clause.
Definition: OrderBy.h:37
te::da::Expression * getExpression(const te::fe::Filter *f)
It converts the OGC Filter Expression to a TerraLib Expression.
A layer resulting from a query.
Definition: QueryLayer.h:50
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
TEDATAACCESSEXPORT double GetValueAsDouble(const te::da::DataSet *ds, const size_t pos)
It gets the value as double.
std::vector< te::color::RGBAColor ** > m_chartImages
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
void push_back(Symbolizer *s)
Definition: Rule.cpp:138
It renders the objects associated to a query layer.
bool isActive() const
Verify if the task is active.
Raster property.
Boolean logic operator: AND.
This is an abstract class that models a query expression.
virtual te::map::Chart * getChart() const
It returns the Chart associated to the Layer.
TESEEXPORT Style * CreateFeatureTypeStyle(const te::gm::GeomType &geomType)
Try creates an appropriate feature type style based on given geometry type.
Rule * getRule(std::size_t i) const
Definition: Style.cpp:105
const std::vector< Rule * > & getRules() const
Definition: Style.cpp:94
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
~QueryLayerRenderer()
Destructor.
This class contains the parameters needed for grouping the values of a Property.
Definition: Grouping.h:57
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&#39;s center coordinate.
void Free(std::vector< T * > *v)
This function can be applied to a pointer to a vector of pointers.
Definition: STLUtils.h:131
TEFEEXPORT void GetFilterStepValues(const te::fe::Filter *filter, std::string &valueMin, std::string &valueMax)
void drawLayerGeometries(AbstractLayer *layer, const std::string &geomPropertyName, te::se::FeatureTypeStyle *style, Canvas *canvas, const te::gm::Envelope &bbox, int srid)
It draws the abstract layer in the given canvas using the SRS informed.
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)
double m_llx
Lower left corner x-coordinate.
void drawDatSetGeometries(te::da::DataSet *dataset, const std::size_t &gpos, Canvas *canvas, int fromSRID, int toSRID, Chart *chart, te::common::TaskProgress *task=0)
It draws the data set geometries in the given canvas using the informed SRS.
This class represents the informations needed to build map charts.
Definition: Chart.h:51
static T & getInstance()
It returns a reference to the singleton instance.
Definition: Singleton.h:126
void buildChart(const Chart *chart, te::da::DataSet *dataset, te::gm::Geometry *geom)
const Envelope * getMBR() const _NOEXCEPT_OP(true)
It returns the minimum bounding rectangle for the geometry in an internal representation.
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...
void drawLayerGrouping(AbstractLayer *layer, const std::string &geomPropertyName, Canvas *canvas, const te::gm::Envelope &bbox, int srid)
It draws the grouping of the abstract layer in the given canvas using the SRS informed.
virtual te::se::Style * getStyle() const
It returns the Style associated to the layer.
virtual std::unique_ptr< LayerSchema > getSchema() const =0
It returns the layer schema.
std::size_t getHeight() const
Definition: Chart.cpp:146
bool isVisible() const
It gets the chart visibility.
Definition: Chart.cpp:191
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
static te::dt::TimeDuration dt(20, 30, 50, 11)
virtual int getHeight() const =0
It returns the canvas height.
te::sam::rtree::Index< std::size_t, 8 > m_rtree
A visitor that converts a OGC Filter Expression to TerraLib Expression.
Definition: QueryEncoder.h:53
TEDATAACCESSEXPORT double GetSummarizedValue(std::vector< double > &values, const std::string &summary)
It gets the summarized value.
te::gm::Polygon * p
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
virtual std::string getAsString(std::size_t i, int precision=0) const
Method for retrieving a data value as a string plain representation.
virtual void drawImage(char *src, std::size_t size, ImageType t)=0
It draws the src image over the canvas.
te::da::Select * getQuery() const
Definition: QueryLayer.cpp:363
A filter is any valid predicate expression.
Definition: fe/Filter.h:55
Query * clone() const
It creates a new copy of this query.
Definition: Select.cpp:276
int search(const te::gm::Envelope &mbr, std::vector< DATATYPE > &report) const
Range search query.
This class represents the informations needed to build map charts.
Utility functions for the data access module.
void setOrderBy(OrderBy *o)
It sets the list of expressions used to sort the output result.
Definition: Select.cpp:829
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
TEDATAACCESSEXPORT double Round(const double &value, const size_t &precision)
It gets the round value.
const std::vector< Symbolizer * > & getSymbolizers() const
Definition: Rule.cpp:158
double m_lly
Lower left corner y-coordinate.
void setPropertiesPos(const std::vector< size_t > &propPos)
Definition: Chart.cpp:107
virtual te::map::RasterContrast * getRasterContrast() const
It returns the raster contrast associated to the 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.
bool isVisible() const
It gets the grouping visibility.
Definition: Grouping.cpp:129
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
void draw(AbstractLayer *layer, Canvas *canvas, const te::gm::Envelope &bbox, int srid, const double &scale, bool *cancel)
It draws the layer geographic objects in the given canvas using the SRS informed. ...
GroupingType
The grouping type associated to the layer.
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.
void insert(const te::gm::Envelope &mbr, const DATATYPE &data)
It inserts an item into the tree.
const std::vector< size_t > & getPropertiesPos() const
Definition: Chart.cpp:102
virtual te::map::Grouping * getGrouping() const
It returns the Grouping associated to the Layer.
double m_ury
Upper right corner y-coordinate.
void setQuery(te::da::Select *s)
Definition: QueryLayer.cpp:390
std::string getSummary() const
It gets the grouping summary. It is used only in case 1 to n.
Definition: Grouping.cpp:139
Coord2D * getCentroidCoord() const
It returns the mathematical centroid for this surface as a coordinate.
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
virtual void setSRID(int srid) _NOEXCEPT_OP(true)=0
It sets the Spatial Reference System ID of the geometry and all its parts if it is a GeometryCollecti...
const GroupingType getType() const
It gets the grouping type.
Definition: Grouping.cpp:89
bool getAvoidConflicts() const
Definition: Chart.cpp:206
A layer resulting from a query.
A class that models a literal for Envelope values.
virtual const std::string & getGeomPropertyName() const
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
virtual int getSRID() const
It returns the Spatial Reference System ID associated to the Layer.
void world2Device(double &wx, double &wy) const
It transforms the coordinate wx and wy from world coordinates to device (canvas) coordinates without ...
This class contains the parameters needed for grouping the values of a Property.
std::vector< te::rst::BandProperty * > & getBandProperties()
Returns a reference to the list of bands definitions.
WorldDeviceTransformer m_transformer
void config(const te::se::Symbolizer *symbolizer)
It configs the canvas based on given symbolizer.
Envelope intersection(const Envelope &rhs) const
It returns an envelope that represents the point set intersection with another envelope.
void drawLayerGroupingMem(AbstractLayer *layer, const std::string &geomPropertyName, Canvas *canvas, const te::gm::Envelope &bbox, int srid)
It draws the grouping of the abstract layer in the given canvas using the SRS informed.
A class that can be used in an ORDER BY clause to sort the items of a resulting query.
Definition: OrderByItem.h:53
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
std::vector< te::gm::Coord2D > m_chartCoordinates
virtual void transform(int srid) _NOEXCEPT_OP(false)=0
It converts the coordinate values of the geometry to the new spatial reference system.
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.
bool isValid() const
It tells if the rectangle is valid or not.
virtual int getWidth() const =0
It returns the canvas width.
Coord2D * getCentroidCoord() const
std::size_t getWidth() const
Definition: Chart.cpp:156
A Symbology Enconding visitor that configures a given canvas based on symbolizers elements...
static const std::string sm_nanStr
Not a number string value.
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...
void drawLayerLinkedGroupingMem(AbstractLayer *layer, const std::string &geomPropertyName, Canvas *canvas, const te::gm::Envelope &bbox, int srid)
TEFEEXPORT void GetFilterUniqueValue(const te::fe::Filter *filter, std::string &value)