All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GeometricOpQuery.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008-2013 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 AggregationQuery.h
22 
23  \brief Aggregation Vector Processing functions.
24 */
25 
26 //Terralib
27 
28 #include "../common/progress/TaskProgress.h"
29 #include "../common/Logger.h"
30 #include "../common/Translator.h"
31 
32 #include "../dataaccess/dataset/DataSet.h"
33 
34 #include "../datatype/Property.h"
35 #include "../datatype/SimpleProperty.h"
36 #include "../datatype/StringProperty.h"
37 
38 #include "../dataaccess/query/Avg.h"
39 #include "../dataaccess/query/Count.h"
40 #include "../dataaccess/query/DataSetName.h"
41 #include "../dataaccess/query/Expression.h"
42 #include "../dataaccess/query/Field.h"
43 #include "../dataaccess/query/Fields.h"
44 #include "../dataaccess/query/From.h"
45 #include "../dataaccess/query/FromItem.h"
46 #include "../dataaccess/query/GroupBy.h"
47 #include "../dataaccess/query/GroupByItem.h"
48 #include "../dataaccess/query/Literal.h"
49 #include "../dataaccess/query/LiteralBool.h"
50 #include "../dataaccess/query/PropertyName.h"
51 #include "../dataaccess/query/Select.h"
52 #include "../dataaccess/query/ST_Area.h"
53 #include "../dataaccess/query/ST_Centroid.h"
54 #include "../dataaccess/query/ST_ConvexHull.h"
55 #include "../dataaccess/query/ST_Envelope.h"
56 #include "../dataaccess/query/ST_Length.h"
57 #include "../dataaccess/query/ST_Perimeter.h"
58 #include "../dataaccess/query/ST_Union.h"
59 #include "../dataaccess/query/Variance.h"
60 #include "../dataaccess/utils/Utils.h"
61 
62 #include "../geometry/Geometry.h"
63 #include "../geometry/GeometryCollection.h"
64 #include "../geometry/GeometryProperty.h"
65 #include "../geometry/Utils.h"
66 
67 #include "../memory/DataSet.h"
68 #include "../memory/DataSetItem.h"
69 
70 #include "../statistics/core/SummaryFunctions.h"
71 #include "../statistics/core/StringStatisticalSummary.h"
72 #include "../statistics/core/NumericStatisticalSummary.h"
73 
74 #include "GeometricOpQuery.h"
75 #include "Config.h"
76 #include "Exception.h"
77 #include "Utils.h"
78 
79 // STL
80 #include <map>
81 #include <math.h>
82 #include <string>
83 #include <vector>
84 
85 // BOOST
86 #include <boost/lexical_cast.hpp>
87 #include <boost/algorithm/string.hpp>
88 
90 {}
91 
93 {}
94 
96 {
97 // get the geometric operation and/or tabular operation.
98  std::vector<int> opGeom;
99  std::vector<int> opTab;
100  std::vector<te::da::DataSetType*> dsTypeVec;
101 
102  for(std::size_t i = 0; i < m_operations.size(); ++i)
103  {
104  switch(m_operations[i])
105  {
106  case te::vp::CENTROID:
107  opGeom.push_back(te::vp::CENTROID);
108  break;
109  case te::vp::CONVEX_HULL:
110  opGeom.push_back(te::vp::CONVEX_HULL);
111  break;
112  case te::vp::MBR:
113  opGeom.push_back(te::vp::MBR);
114  break;
115  case te::vp::AREA:
116  opTab.push_back(te::vp::AREA);
117  break;
118  case te::vp::LINE:
119  opTab.push_back(te::vp::LINE);
120  break;
121  case te::vp::PERIMETER:
122  opTab.push_back(te::vp::PERIMETER);
123  break;
124  default:
125  te::common::Logger::logDebug("vp", "Geometric Operation - The operation is not valid.");
126  }
127  }
128 
129  if(m_outputLayer)
130  {
131  bool hasMultiGeomColumns = false;
132  bool result = false;
133 
134  switch(m_objStrategy)
135  {
136  case te::vp::ALL_OBJ:
137  {
138  if(hasMultiGeomColumns) //Condição se o DataSource suporta mais de uma soluna geometrica...
139  {
140  dsTypeVec.push_back(te::vp::GeometricOp::GetDataSetType(te::vp::ALL_OBJ, true));
141  }
142  else
143  {
144  if(opGeom.size() > 0)
145  {
146  for(std::size_t i = 0; i < opGeom.size(); ++i)
147  dsTypeVec.push_back(te::vp::GeometricOp::GetDataSetType(te::vp::ALL_OBJ, false, opGeom[i]));
148  }
149  else
150  {
151  dsTypeVec.push_back(te::vp::GeometricOp::GetDataSetType(te::vp::ALL_OBJ, false));
152  }
153  }
154 
155  for(std::size_t dsTypePos = 0; dsTypePos < dsTypeVec.size(); ++dsTypePos)
156  {
157  m_outDsetNameVec.push_back(dsTypeVec[dsTypePos]->getName());
158 
159  std::auto_ptr<te::da::DataSetType> outDataSetType(dsTypeVec[dsTypePos]);
160  std::auto_ptr<te::mem::DataSet> outDataSet(SetAllObjects(dsTypeVec[dsTypePos], opTab, opGeom));
161  result = save(outDataSet, outDataSetType);
162  if(!result)
163  return result;
164  }
165  }
166  break;
167  case te::vp::AGGREG_OBJ:
168  {
169  if(hasMultiGeomColumns) //Condição se o DataSource suporta mais de uma coluna geometrica...
170  {
171  dsTypeVec.push_back(te::vp::GeometricOp::GetDataSetType(te::vp::AGGREG_OBJ, true));
172  }
173  else
174  {
175  if(opGeom.size() > 0)
176  {
177  for(std::size_t i = 0; i < opGeom.size(); ++i)
178  dsTypeVec.push_back(te::vp::GeometricOp::GetDataSetType(te::vp::AGGREG_OBJ, false, opGeom[i]));
179  }
180  else
181  {
182  dsTypeVec.push_back(te::vp::GeometricOp::GetDataSetType(te::vp::AGGREG_OBJ, false));
183  }
184  }
185 
186  for(std::size_t dsTypePos = 0; dsTypePos < dsTypeVec.size(); ++dsTypePos)
187  {
188  m_outDsetNameVec.push_back(dsTypeVec[dsTypePos]->getName());
189 
190  std::auto_ptr<te::da::DataSetType> outDataSetType(dsTypeVec[dsTypePos]);
191  std::auto_ptr<te::mem::DataSet> outDataSet(SetAggregObj(dsTypeVec[dsTypePos], opTab, opGeom));
192  result = save(outDataSet, outDataSetType);
193  if(!result)
194  return result;
195  }
196  }
197  break;
199  {
200  if(hasMultiGeomColumns) //Condição se o DataSource suporta mais de uma coluna geometrica...
201  {
203  }
204  else
205  {
206  if(opGeom.size() > 0)
207  {
208  for(std::size_t i = 0; i < opGeom.size(); ++i)
209  dsTypeVec.push_back(te::vp::GeometricOp::GetDataSetType(te::vp::AGGREG_BY_ATTRIBUTE, false, opGeom[i]));
210  }
211  else
212  {
214  }
215  }
216 
217  for(std::size_t dsTypePos = 0; dsTypePos < dsTypeVec.size(); ++dsTypePos)
218  {
219  m_outDsetNameVec.push_back(dsTypeVec[dsTypePos]->getName());
220 
221  std::auto_ptr<te::da::DataSetType> outDataSetType(dsTypeVec[dsTypePos]);
222  std::auto_ptr<te::mem::DataSet> outDataSet(SetAggregByAttribute(dsTypeVec[dsTypePos], opTab, opGeom));
223  result = save(outDataSet, outDataSetType);
224  if(!result)
225  return result;
226  }
227  }
228  break;
229  default:
230  te::common::Logger::logDebug("vp", "Geometric Operation - Strategy Not found!");
231  return false;
232  }
233 
234  return result;
235 
236  }
237  else
238  {
239  //Descobrir se o DataSource suporta adição de mais de uma coluna geometrica.
240  return false;
241  }
242 
243  return false;
244 }
245 
247  std::vector<int> tabVec,
248  std::vector<int> geoVec)
249 {
250  std::auto_ptr<te::mem::DataSet> outDSet(new te::mem::DataSet(dsType));
251  std::auto_ptr<te::da::DataSet> inDset = m_inDsrc->getDataSet(m_inDsetName);
252  std::size_t geom_pos = te::da::GetFirstSpatialPropertyPos(inDset.get());
253 
254  te::da::Fields* fields = new te::da::Fields;
255 
256  if(m_selectedProps.size() > 0)
257  {
258  for(std::size_t prop_pos = 0; prop_pos < m_selectedProps.size(); ++prop_pos)
259  {
260  te::da::Field* f_prop = new te::da::Field(m_selectedProps[prop_pos]);
261  fields->push_back(f_prop);
262  }
263  }
264 
265  std::string name = inDset->getPropertyName(geom_pos);
266 
267  if(tabVec.size() > 0)
268  {
269  for(std::size_t tabPos = 0; tabPos < tabVec.size(); ++tabPos)
270  {
271  te::gm::GeometryProperty* geom = te::da::GetFirstGeomProperty(m_inDsetType.get());
272 
273  te::da::Expression* ex;
274  te::da::Field* f;
275 
276  switch(tabVec[tabPos])
277  {
278  case te::vp::AREA:
279  {
280  ex = new te::da::ST_Area(te::da::PropertyName(name));
281  f = new te::da::Field(*ex, "area");
282  fields->push_back(f);
283  }
284  break;
285  case te::vp::LINE:
286  {
287  ex = new te::da::ST_Length(te::da::PropertyName(name));
288  f = new te::da::Field(*ex, "line_length");
289  fields->push_back(f);
290  }
291  break;
292  case te::vp::PERIMETER:
293  {
295  f = new te::da::Field(*ex, "perimeter");
296  fields->push_back(f);
297  }
298  break;
299  default:
300  te::common::Logger::logDebug("vp", "Geometric Operation - Invalid field to add in query.");
301  }
302  }
303  }
304 
305  if(geoVec.size() > 0)
306  {
307  for(std::size_t geoPos = 0; geoPos < geoVec.size(); ++geoPos)
308  {
309  te::da::Expression* ex_geom;
310  te::da::Field* f_geom;
311 
312  switch(geoVec[geoPos])
313  {
314  case te::vp::CONVEX_HULL:
315  {
316  std::size_t pos = dsType->getPropertyPosition("convex_hull");
317  if( pos < outDSet->getNumProperties() && pos > 0)
318  {
319  ex_geom = new te::da::ST_ConvexHull(te::da::PropertyName(name));
320  f_geom = new te::da::Field(*ex_geom, "convex_hull");
321  fields->push_back(f_geom);
322  }
323  }
324  break;
325  case te::vp::CENTROID:
326  {
327  std::size_t pos = dsType->getPropertyPosition("centroid");
328  if( pos < outDSet->getNumProperties() && pos > 0)
329  {
330  ex_geom = new te::da::ST_Centroid(te::da::PropertyName(name));
331  f_geom = new te::da::Field(*ex_geom, "centroid");
332  fields->push_back(f_geom);
333  }
334  }
335  break;
336  case te::vp::MBR:
337  {
338  std::size_t pos = dsType->getPropertyPosition("mbr");
339  if( pos < outDSet->getNumProperties() && pos > 0)
340  {
341  ex_geom = new te::da::ST_Envelope(te::da::PropertyName(name));
342  f_geom = new te::da::Field(*ex_geom, "mbr");
343  fields->push_back(f_geom);
344  }
345  }
346  break;
347  default:
348  te::common::Logger::logDebug("vp", "Geometric Operation - Invalid field to add in query.");
349  }
350  }
351  }
352  else
353  {
354  te::da::Field* f_prop = new te::da::Field(name);
355  fields->push_back(f_prop);
356  }
357 
358  te::da::FromItem* fromItem = new te::da::DataSetName(m_inDsetType->getName());
359  te::da::From* from = new te::da::From;
360  from->push_back(fromItem);
361 
362  te::da::Select select(fields, from);
363 
364  std::auto_ptr<te::da::DataSet> dsQuery = m_inDsrc->query(select);
365 
366  if (dsQuery->isEmpty())
367  return false;
368 
369  SetOutputDSet(dsQuery.get(), outDSet.get());
370 
371  return outDSet.release();
372 }
373 
375  std::vector<int> tabVec,
376  std::vector<int> geoVec)
377 {
378  std::auto_ptr<te::mem::DataSet> outDSet(new te::mem::DataSet(dsType));
379 
380  std::auto_ptr<te::da::DataSet> inDset = m_inDsrc->getDataSet(m_inDsetName);
381  std::size_t geom_pos = te::da::GetFirstSpatialPropertyPos(inDset.get());
382  std::string name = inDset->getPropertyName(geom_pos);
383 
384  te::da::Fields* fields = new te::da::Fields;
385 
386  if(tabVec.size() > 0)
387  {
388  for(std::size_t tabPos = 0; tabPos < tabVec.size(); ++tabPos)
389  {
390  te::gm::GeometryProperty* geom = te::da::GetFirstGeomProperty(m_inDsetType.get());
391 
392  te::da::Expression* ex;
393  te::da::Field* f;
394 
395  switch(tabVec[tabPos])
396  {
397  case te::vp::AREA:
398  {
400  ex = new te::da::ST_Area(*e_union);
401  f = new te::da::Field(*ex, "area");
402  fields->push_back(f);
403  }
404  break;
405  case te::vp::LINE:
406  {
408  ex = new te::da::ST_Length(*e_union);
409  f = new te::da::Field(*ex, "line_length");
410  fields->push_back(f);
411  }
412  break;
413  case te::vp::PERIMETER:
414  {
416  ex = new te::da::ST_Perimeter(*e_union);
417  f = new te::da::Field(*ex, "perimeter");
418  fields->push_back(f);
419  }
420  break;
421  default:
422  te::common::Logger::logDebug("vp", "Geometric Operation - Invalid field to add in query.");
423  }
424  }
425  }
426 
427  if(geoVec.size() > 0)
428  {
429  for(std::size_t geoPos = 0; geoPos < geoVec.size(); ++geoPos)
430  {
431  te::da::Expression* ex_geom;
432  te::da::Field* f_geom;
433 
434  switch(geoVec[geoPos])
435  {
436  case te::vp::CONVEX_HULL:
437  {
438  std::size_t pos = dsType->getPropertyPosition("convex_hull");
439  if( pos < outDSet->getNumProperties() && pos > 0)
440  {
442  ex_geom = new te::da::ST_ConvexHull(*e_union);
443  f_geom = new te::da::Field(*ex_geom, "convex_hull");
444  fields->push_back(f_geom);
445  }
446  }
447  break;
448  case te::vp::CENTROID:
449  {
450  std::size_t pos = dsType->getPropertyPosition("centroid");
451  if( pos < outDSet->getNumProperties() && pos > 0)
452  {
454  ex_geom = new te::da::ST_Centroid(*e_union);
455  f_geom = new te::da::Field(*ex_geom, "centroid");
456  fields->push_back(f_geom);
457  }
458  }
459  break;
460  case te::vp::MBR:
461  {
462  std::size_t pos = dsType->getPropertyPosition("mbr");
463  if( pos < outDSet->getNumProperties() && pos > 0)
464  {
466  ex_geom = new te::da::ST_Envelope(*e_union);
467  f_geom = new te::da::Field(*ex_geom, "mbr");
468  fields->push_back(f_geom);
469  }
470  }
471  break;
472  default:
473  te::common::Logger::logDebug("vp", "Geometric Operation - Invalid field to add in query.");
474  }
475  }
476  }
477  else
478  {
480  te::da::Field* f_prop = new te::da::Field(*e_union, name);
481  fields->push_back(f_prop);
482  }
483 
484  te::da::FromItem* fromItem = new te::da::DataSetName(m_inDsetType->getName());
485  te::da::From* from = new te::da::From;
486  from->push_back(fromItem);
487 
488  te::da::Select select(fields, from);
489 
490  std::auto_ptr<te::da::DataSet> dsQuery = m_inDsrc->query(select);
491 
492  if (dsQuery->isEmpty())
493  return false;
494 
495  SetOutputDSet(dsQuery.get(), outDSet.get());
496 
497  return outDSet.release();
498 }
499 
501  std::vector<int> tabVec,
502  std::vector<int> geoVec)
503 {
504  std::auto_ptr<te::mem::DataSet> outDSet(new te::mem::DataSet(dsType));
505  std::auto_ptr<te::da::DataSet> inDset = m_inDsrc->getDataSet(m_inDsetName);
506  std::size_t geom_pos = te::da::GetFirstSpatialPropertyPos(inDset.get());
507  std::string name = inDset->getPropertyName(geom_pos);
508 
509  te::da::Fields* fields = new te::da::Fields;
510 
511  te::da::Field* f_aggreg = new te::da::Field(m_attribute);
512  fields->push_back(f_aggreg);
513 
514  if(tabVec.size() > 0)
515  {
516  for(std::size_t tabPos = 0; tabPos < tabVec.size(); ++tabPos)
517  {
518  te::gm::GeometryProperty* geom = te::da::GetFirstGeomProperty(m_inDsetType.get());
519 
520  te::da::Expression* ex;
521  te::da::Field* f;
522 
523  switch(tabVec[tabPos])
524  {
525  case te::vp::AREA:
526  {
528  ex = new te::da::ST_Area(*e_union);
529  f = new te::da::Field(*ex, "area");
530  fields->push_back(f);
531  }
532  break;
533  case te::vp::LINE:
534  {
536  ex = new te::da::ST_Length(*e_union);
537  f = new te::da::Field(*ex, "line_length");
538  fields->push_back(f);
539  }
540  break;
541  case te::vp::PERIMETER:
542  {
544  ex = new te::da::ST_Perimeter(*e_union);
545  f = new te::da::Field(*ex, "perimeter");
546  fields->push_back(f);
547  }
548  break;
549  default:
550  te::common::Logger::logDebug("vp", "Geometric Operation - Invalid field to add in query.");
551  }
552  }
553  }
554 
555  if(geoVec.size() > 0)
556  {
557  for(std::size_t geoPos = 0; geoPos < geoVec.size(); ++geoPos)
558  {
559  te::da::Expression* ex_geom;
560  te::da::Field* f_geom;
561 
562  switch(geoVec[geoPos])
563  {
564  case te::vp::CONVEX_HULL:
565  {
566  std::size_t pos = dsType->getPropertyPosition("convex_hull");
567  if( pos < outDSet->getNumProperties() && pos > 0)
568  {
570  ex_geom = new te::da::ST_ConvexHull(*e_union);
571  f_geom = new te::da::Field(*ex_geom, "convex_hull");
572  fields->push_back(f_geom);
573  }
574  }
575  break;
576  case te::vp::CENTROID:
577  {
578  std::size_t pos = dsType->getPropertyPosition("centroid");
579  if( pos < outDSet->getNumProperties() && pos > 0)
580  {
582  ex_geom = new te::da::ST_Centroid(*e_union);
583  f_geom = new te::da::Field(*ex_geom, "centroid");
584  fields->push_back(f_geom);
585  }
586  }
587  break;
588  case te::vp::MBR:
589  {
590  std::size_t pos = dsType->getPropertyPosition("mbr");
591  if( pos < outDSet->getNumProperties() && pos > 0)
592  {
594  ex_geom = new te::da::ST_Envelope(*e_union);
595  f_geom = new te::da::Field(*ex_geom, "mbr");
596  fields->push_back(f_geom);
597  }
598  }
599  break;
600  default:
601  te::common::Logger::logDebug("vp", "Geometric Operation - Invalid field to add in query.");
602  }
603  }
604  }
605  else
606  {
608  te::da::Field* f_prop = new te::da::Field(*e_union, name);
609  fields->push_back(f_prop);
610  }
611 
612  te::da::FromItem* fromItem = new te::da::DataSetName(m_inDsetType->getName());
613  te::da::From* from = new te::da::From;
614  from->push_back(fromItem);
615 
616  te::da::Select select(fields, from);
617 
618  te::da::GroupBy* groupBy = new te::da::GroupBy();
619  te::da::GroupByItem* e_groupBy = new te::da::GroupByItem(m_attribute);
620  groupBy->push_back(e_groupBy);
621 
622  select.setGroupBy(groupBy);
623 
624  std::auto_ptr<te::da::DataSet> dsQuery = m_inDsrc->query(select);
625 
626  if (dsQuery->isEmpty())
627  return false;
628 
629  SetOutputDSet(dsQuery.get(), outDSet.get());
630 
631  return outDSet.release();
632 }
633 
635  te::mem::DataSet* outDataSet)
636 {
637  std::size_t numProps = inDataSet->getNumProperties();
638  int pk = 0;
639 
640  bool geomFlag = true;
641 
642  inDataSet->moveBeforeFirst();
643  while(inDataSet->moveNext())
644  {
645  geomFlag = true;
646 
647  te::mem::DataSetItem* dItem = new te::mem::DataSetItem(outDataSet);
648  std::size_t size = dItem->getNumProperties();
649 
650  dItem->setInt32(0, pk);
651 
652  for(std::size_t i = 0; i < numProps; ++i)
653  {
654  int type = inDataSet->getPropertyDataType(i);
655  switch(type)
656  {
657  case te::dt::INT16_TYPE:
658  dItem->setInt16(i+1, inDataSet->getInt16(i));
659  break;
660  case te::dt::INT32_TYPE:
661  dItem->setInt32(i+1, inDataSet->getInt32(i));
662  break;
663  case te::dt::INT64_TYPE:
664  dItem->setInt64(i+1, inDataSet->getInt64(i));
665  break;
666  case te::dt::DOUBLE_TYPE:
667  dItem->setDouble(i+1, inDataSet->getDouble(i));
668  break;
669  case te::dt::STRING_TYPE:
670  dItem->setString(i+1, inDataSet->getString(i));
671  break;
673  {
674  std::string inPropName = inDataSet->getPropertyName(i);
675 
676  if(inPropName == "convex_hull")
677  {
678  te::gm::Geometry* geom = inDataSet->getGeometry(i).release();
679  if(geom->isValid())
680  {
681  if(geom->getGeomTypeId() == te::gm::PolygonType)
682  dItem->setGeometry("convex_hull", geom);
683  else
684  geomFlag = false;
685  }
686  }
687  else if(inPropName == "centroid")
688  {
689  te::gm::Geometry* geom = inDataSet->getGeometry(i).release();
690  if(geom->isValid())
691  dItem->setGeometry("centroid", geom);
692  }
693  else if(inPropName == "mbr")
694  {
695  te::gm::Geometry* geom = inDataSet->getGeometry(i).release();
696  if(geom->isValid())
697  {
698  if(geom->getGeomTypeId() == te::gm::PolygonType)
699  dItem->setGeometry("mbr", geom);
700  else
701  geomFlag = false;
702  }
703  }
704  else
705  {
706  te::gm::Geometry* geom = inDataSet->getGeometry(i).release();
707 
708  switch(geom->getGeomTypeId())
709  {
710  case te::gm::PointType:
711  {
713  if(geom->isValid())
714  {
715  teGeomColl->setGeometryN(0, geom);
716  dItem->setGeometry(i+1, teGeomColl);
717  }
718  }
719  break;
721  {
723  if(geom->isValid())
724  {
725  teGeomColl->setGeometryN(0, geom);
726  dItem->setGeometry(i+1, teGeomColl);
727  }
728  }
729  break;
730  case te::gm::PolygonType:
731  {
733  if(geom->isValid())
734  {
735  teGeomColl->setGeometryN(0, geom);
736  dItem->setGeometry(i+1, teGeomColl);
737  }
738  }
739  break;
740  default:
741  {
742  dItem->setGeometry(i+1, geom);
743  }
744  break;
745  }
746  }
747  }
748  break;
749  default:
750  te::common::Logger::logDebug("vp", "Geometric Operation - Property type not found.");
751  }
752  }
753  if(geomFlag)
754  {
755  ++pk;
756  outDataSet->add(dItem);
757  }
758  }
759 }
te::da::DataSetType * GetDataSetType(te::vp::GeometricOpObjStrategy, bool MultiGeomColumns, int geomOp=-1)
int getSRID() const
It returns the Spatial Reference System ID associated to this geometric object.
Definition: Geometry.h:189
virtual boost::int16_t getInt16(std::size_t i) const =0
Method for retrieving a 16-bit integer attribute value (2 bytes long).
boost::ptr_vector< GroupByItem > GroupBy
A class that can be used to model a GROUP BY clause.
Definition: GroupBy.h:37
Geometric property.
An exception class for the Vector processing module.
void setGeometry(std::size_t i, te::gm::Geometry *value)
It sets the value of the i-th property.
Utility functions for the data access module.
A class that can be used in a GROUP BY clause.
Definition: GroupByItem.h:50
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...
Definition: Field.h:50
virtual boost::int32_t getInt32(std::size_t i) const =0
Method for retrieving a 32-bit integer attribute value (4 bytes long).
void setDouble(std::size_t i, double value)
It sets the value of the i-th property.
The geographic operation Line.
Definition: Enums.h:106
A class that models the name of a dataset used in a From clause.
Definition: DataSetName.h:43
The geographic operation Minimum Bounding Rectangle.
Definition: Enums.h:104
A class that models the name of any property of an object.
Definition: PropertyName.h:50
A class that models the description of a dataset.
Definition: DataSetType.h:72
virtual boost::int64_t getInt64(std::size_t i) const =0
Method for retrieving a 64-bit integer attribute value (8 bytes long).
void setInt16(std::size_t i, boost::int16_t value)
It sets the value of the i-th property.
std::size_t getNumProperties() const
It returns the number of properties.
Definition: DataSetItem.cpp:99
Spatial length operator.
Definition: ST_Length.h:50
virtual double getDouble(std::size_t i) const =0
Method for retrieving a double attribute value.
Spatial envelope operator.
Definition: ST_Envelope.h:50
This is an abstract class that models a query expression.
Definition: Expression.h:47
void add(DataSetItem *item)
It adds a new item to the dataset and takes its ownership.
Definition: DataSet.cpp:168
Spatial perimeter operator.
Definition: ST_Perimeter.h:50
void setInt32(std::size_t i, boost::int32_t value)
It sets the value of the i-th property.
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
Definition: DataSet.h:65
TEDATAACCESSEXPORT std::size_t GetFirstSpatialPropertyPos(const te::da::DataSet *dataset)
It returns the first dataset spatial property or NULL if none is found.
Definition: Utils.cpp:413
The geographic operation Area.
Definition: Enums.h:105
Spatial area operator.
Definition: ST_Area.h:50
Aggregate all objects.
Definition: Enums.h:118
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
Definition: Fields.h:37
Aggregate objects by attribute.
Definition: Enums.h:119
void SetOutputDSet(te::da::DataSet *inDataSet, te::mem::DataSet *outDataSet)
The geographic operation Perimeter.
Definition: Enums.h:107
virtual bool isValid() const
It tells if the geometry is well formed.
Definition: Geometry.cpp:167
GeomType getGeomTypeId() const
It returns the geometry subclass type identifier.
Definition: Geometry.h:178
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
void setGroupBy(GroupBy *g)
It sets the list of expressions used to condense the result set.
Definition: Select.cpp:957
The geographic operation Centroid.
Definition: Enums.h:103
te::mem::DataSet * SetAggregByAttribute(te::da::DataSetType *dsType, std::vector< int > tabVec, std::vector< int > geoVec)
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
virtual std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
Definition: From.h:37
Spatial centroid operator.
Definition: ST_Centroid.h:50
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
Definition: DataSetItem.h:56
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
virtual bool moveBeforeFirst()=0
It moves the internal pointer to a position before the first item in the collection.
void setGeometryN(std::size_t i, Geometry *g)
It sets the n-th geometry in this geometry collection.
The geographic operation Convex Hull.
Definition: Enums.h:102
std::size_t getPropertyPosition(const std::string &name) const
It returns the property position based on its name.
ST_Union statistical function.
Definition: ST_Union.h:46
te::mem::DataSet * SetAllObjects(te::da::DataSetType *dsType, std::vector< int > tabVec, std::vector< int > geoVec)
Configuration flags for the Terrralib Vector Processing module.
virtual std::string getString(std::size_t i) const =0
Method for retrieving a string value attribute.
void setString(std::size_t i, const std::string &value)
It sets the value of the i-th property.
void setInt64(std::size_t i, boost::int64_t value)
It sets the value of the i-th property.
It is a collection of other geometric objects.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
Definition: Utils.cpp:508
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
All objects individually.
Definition: Enums.h:117
te::mem::DataSet * SetAggregObj(te::da::DataSetType *dsType, std::vector< int > tabVec, std::vector< int > geoVec)