BoxLoaderStrategy.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 BoxLoaderStrategy.cpp
22 
23  \brief This class implements the main functions necessary to
24  save and load the graph data and metadata information
25  using as strategy a bounding box to create a region
26  that defines a group of elements.
27 */
28 
29 // Terralib Includes
30 #include "../../core/translator/Translator.h"
31 #include "../../common/StringUtils.h"
32 #include "../../dataaccess/dataset/DataSet.h"
33 #include "../../dataaccess/dataset/DataSetType.h"
34 #include "../../dataaccess/datasource/DataSource.h"
35 #include "../../dataaccess/query_h.h"
36 #include "../../datatype/AbstractData.h"
37 #include "../../geometry/Envelope.h"
38 #include "../../geometry/Point.h"
39 #include "../core/AbstractGraph.h"
40 #include "../core/Edge.h"
41 #include "../core/EdgeProperty.h"
42 #include "../core/GraphCache.h"
43 #include "../core/GraphData.h"
44 #include "../core/GraphMetadata.h"
45 #include "../core/Vertex.h"
46 #include "../core/VertexProperty.h"
47 #include "../Config.h"
48 #include "../Globals.h"
49 #include "../Exception.h"
50 #include "BoxLoaderStrategy.h"
51 
52 
54 {
55 }
56 
58 
60 {
61  if(m_graphMetadata == nullptr || m_graphMetadata->getDataSource() == nullptr || g == nullptr)
62  {
63  throw Exception(TE_TR(""));
64  }
65 
66  Vertex* vAux = nullptr;
67 
69  {
70  vAux = loadVertexAttrs(vertexId);
71  }
73  {
74  vAux = loadVertex(vertexId);
75  }
76 
77  if(vAux == nullptr)
78  {
79  throw Exception(TE_TR("Vertex Id not found."));
80  }
81 
82  //ONLY WORKS FOR te::graph::Edge_List
84  {
85  throw Exception(TE_TR("TO DO"));
86  }
87 
88  //get the tables names
89  std::string vertexAttrTable = m_graphMetadata->getVertexTableName();
90  std::string edgeAttrTable = m_graphMetadata->getEdgeTableName();
91 
92  //get the vertex coord
93  te::gm::Point* point = nullptr;
94  std::string geometryAttrName;
95 
96  for(int i = 0; i < m_graphMetadata->getVertexPropertySize(); ++i)
97  {
99  {
100  geometryAttrName = m_graphMetadata->getVertexProperty(i)->getName();
101 
102  point = dynamic_cast<te::gm::Point*>(vAux->getAttributes()[i]);
103 
104  break;
105  }
106  }
107 
108  assert(point);
109 
110  //calculate box
111  te::gm::Envelope* envelope = calculateBox(point, vertexAttrTable);
112 
113  //get all id's from vertex and edges that is inside that box
114 
115  //filds
116  te::da::Fields* all = new te::da::Fields;
117  all->push_back(new te::da::Field("*"));
118 
119  //from
120  te::da::From* from = new te::da::From;
121 
122  te::da::FromItem* fi = new te::da::DataSetName(vertexAttrTable, "vertex");
123  from->push_back(fi);
124 
125  te::da::FromItem* fiEdge = new te::da::DataSetName(edgeAttrTable, "edge");
126  from->push_back(fiEdge);
127 
128  std::string vertexFrom = "edge.";
130 
131  std::string vertexTo = "edge.";
133 
134  std::string vId = "vertex.";
136 
137  //where
138  te::da::Field* fvf = new te::da::Field(vertexFrom);
139  te::da::Field* fv1id = new te::da::Field(vId);
140  te::da::Expression* exp1 = new te::da::EqualTo(fv1id->getExpression(), fvf->getExpression());
141 
142  te::da::Field* fvt = new te::da::Field(vertexTo);
143  te::da::Field* fv2id = new te::da::Field(vId);
144  te::da::Expression* exp2 = new te::da::EqualTo(fv2id->getExpression(), fvt->getExpression());
145 
146  te::da::Or* ora = new te::da::Or(exp1, exp2);
147 
148 
149  std::string vEttr = "vertex." + geometryAttrName;
150 
151  int srid = point->getSRID();
152  te::da::LiteralEnvelope* lenv = new te::da::LiteralEnvelope(*envelope, srid);
153  te::da::Field* fvattr = new te::da::Field(vEttr);
154  te::da::ST_Intersects* intersects = new te::da::ST_Intersects(fvattr->getExpression(), lenv);
155 
156  te::da::And* andd = new te::da::And(intersects, ora);
157 
158  te::da::Where* wh = new te::da::Where(andd);
159 
160  //select
161  te::da::Select select(all, from, wh);
162 
163  //query
164  std::unique_ptr<te::da::DataSet> dataset = m_graphMetadata->getDataSource()->query(select);
165 
166  std::unique_ptr<te::da::DataSetType> vertexDsType = m_graphMetadata->getDataSource()->getDataSetType(vertexAttrTable);
167 
168  int vertexProperties = static_cast<int>(vertexDsType->getProperties().size());
169 
170  std::string graphType = g->getMetadata()->getType();
171 
172  te::graph::Vertex* v = nullptr;
173 
174  int currentId = -1;
175 
176  //list of all attributes: edge table + vertex table + vertex table
177  while(dataset->moveNext())
178  {
179  int vId = dataset->getInt32(0); //first item is the vertex id
180  int eId = dataset->getInt32(vertexProperties); //first after vertexProperties item is the edge id
181  int vFrom = dataset->getInt32(vertexProperties + 1); //second after vertexPropertie item is the vertex from id
182 // int vTo = dataset->getInt32(vertexProperties + 2); //third after vertexPropertie item is the vertex to id
183 
184  if(currentId != vId)
185  {
186  //verify if its already in cache
187  if(gc->checkCacheByVertexId(vId) == nullptr)
188  {
189  v = new te::graph::Vertex(vId, false);
190 
191  v->setAttributeVecSize(vertexProperties - 1);
192 
193  for(int i = 1; i < vertexProperties; ++i)
194  {
195  v->addAttribute(i - 1, dataset->getValue(i).release());
196  }
197 
198  g->add(v);
199  }
200 
201  currentId = vId;
202  }
203 
204  if(v)
205  {
207  {
208  if(vId == vFrom)
209  v->getSuccessors().insert(eId);
210  else
211  v->getPredecessors().insert(eId);
212  }
213 
214  //TODO for other graph types
215  }
216  }
217 
218  delete vAux;
219  delete envelope;
220 }
221 
222 
224 {
225  if(m_graphMetadata == nullptr || m_graphMetadata->getDataSource() == nullptr || g == nullptr)
226  {
227  throw Exception(TE_TR(""));
228  }
229 
230  Edge* e = nullptr;
231 
233  {
234  e = loadEdge(edgeId);
235  }
237  {
238  e = loadEdgeAttrs(edgeId);
239  }
240 
241  if(e == nullptr)
242  {
243  throw Exception(TE_TR("Edge Id not found."));
244  }
245 
246  Vertex* vAux = nullptr;
247 
248  int vAuxId = e->getIdFrom();
249 
251  {
252  vAux = loadVertexAttrs(vAuxId);
253  }
255  {
256  vAux = loadVertex(vAuxId);
257  }
258 
259  if(vAux == nullptr)
260  {
261  throw Exception(TE_TR("Vertex Id not found."));
262  }
263 
264  delete e;
265 
266  //ONLY WORKS FOR te::graph::Edge_List
268  {
269  throw Exception(TE_TR("TO DO"));
270  }
271 
272  //get the tables names
273  std::string vertexAttrTable = m_graphMetadata->getVertexTableName();
274  std::string edgeAttrTable = m_graphMetadata->getEdgeTableName();
275 
276  //get the vertex coord
277  te::gm::Point* point = nullptr;
278  std::string geometryAttrName;
279 
280  for(int i = 0; i < m_graphMetadata->getVertexPropertySize(); ++i)
281  {
283  {
284  geometryAttrName = m_graphMetadata->getVertexProperty(i)->getName();
285 
286  point = dynamic_cast<te::gm::Point*>(vAux->getAttributes()[i]);
287 
288  break;
289  }
290  }
291 
292  assert(point);
293 
294  //calculate box
295  te::gm::Envelope* envelope = calculateBox(point, vertexAttrTable);
296 
297  //get all id's from vertex and edges that is inside that box
298 
299  //filds
300  te::da::Fields* all = new te::da::Fields;
301  all->push_back(new te::da::Field("*"));
302 
303  //from
304  te::da::From* from = new te::da::From;
305 
306  te::da::FromItem* fi = new te::da::DataSetName(vertexAttrTable, "vertex");
307  from->push_back(fi);
308 
309  te::da::FromItem* fiEdge = new te::da::DataSetName(edgeAttrTable, "edge");
310  from->push_back(fiEdge);
311 
312  std::string vertexFrom = "edge.";
314 
315  std::string vertexTo = "edge.";
317 
318  std::string vId = "vertex.";
320 
321  //where
322  te::da::Field* fvf = new te::da::Field(vertexFrom);
323  te::da::Field* fv1id = new te::da::Field(vId);
324  te::da::Expression* exp1 = new te::da::EqualTo(fv1id->getExpression(), fvf->getExpression());
325 
326  te::da::Field* fvt = new te::da::Field(vertexTo);
327  te::da::Field* fv2id = new te::da::Field(vId);
328  te::da::Expression* exp2 = new te::da::EqualTo(fv2id->getExpression(), fvt->getExpression());
329 
330  te::da::Or* ora = new te::da::Or(exp1, exp2);
331 
332 
333  std::string vEttr = "vertex." + geometryAttrName;
334 
335  int srid = point->getSRID();
336  te::da::LiteralEnvelope* lenv = new te::da::LiteralEnvelope(*envelope, srid);
337  te::da::Field* fvattr = new te::da::Field(vEttr);
338  te::da::ST_Intersects* intersects = new te::da::ST_Intersects(fvattr->getExpression(), lenv);
339 
340  te::da::And* andd = new te::da::And(intersects, ora);
341 
342  te::da::Where* wh = new te::da::Where(andd);
343 
344  //select
345  te::da::Select select(all, from, wh);
346 
347  //query
348  std::unique_ptr<te::da::DataSet> dataset = m_graphMetadata->getDataSource()->query(select);
349 
350  std::unique_ptr<te::da::DataSetType> vertexDsType = m_graphMetadata->getDataSource()->getDataSetType(vertexAttrTable);
351  std::unique_ptr<te::da::DataSetType> edgeDsType = m_graphMetadata->getDataSource()->getDataSetType(edgeAttrTable);
352 
353  int vertexProperties = static_cast<int>(vertexDsType->getProperties().size());
354  int edgeProperties = static_cast<int>(edgeDsType->getProperties().size());
355 
356  std::string graphType = g->getMetadata()->getType();
357 
358  int currentId = -1;
359 
360  //list of all attributes: edge table + vertex table + vertex table
361  while(dataset->moveNext())
362  {
363  int eId = dataset->getInt32(vertexProperties); //first after vertexProperties item is the edge id
364  int vFrom = dataset->getInt32(vertexProperties + 1); //second after vertexPropertie item is the vertex from id
365  int vTo = dataset->getInt32(vertexProperties + 2); //third after vertexPropertie item is the vertex to id
366 
367  if(currentId != eId)
368  {
369  //verify if its already in cache
370  if(gc->checkCacheByEdgeId(eId) == nullptr)
371  {
372  te::graph::Edge* e = new te::graph::Edge(eId, vFrom, vTo, false);
373 
374  e->setAttributeVecSize(edgeProperties - 3);
375 
376  for(int i = 3; i < edgeProperties; ++i)
377  {
378  e->addAttribute(i - 3, dataset->getValue(i + vertexProperties).release());
379  };
380 
381  g->add(e);
382  }
383 
384  currentId = eId;
385  }
386  }
387 
388  delete vAux;
389  delete envelope;
390 }
391 
393  te::gm::Point* p, std::string /*tableName*/)
394 {
396 
397  double h = e->getHeight() / (100. / getMetadata()->m_boxPercentSize);
398  double w = e->getWidth() / (100. / getMetadata()->m_boxPercentSize);
399 
400  te::gm::Envelope* env = new te::gm::Envelope();
401 
402  //env->m_llx = p->getX();
403  //env->m_urx = p->getX() + w;
404  //env->m_lly = p->getY() - h;
405  //env->m_ury = p->getY();
406 
407  env->m_llx = p->getX() - ( w / 2.);
408  env->m_urx = p->getX() + ( w / 2.);
409  env->m_lly = p->getY() - ( h / 2.);
410  env->m_ury = p->getY() + ( h / 2.);
411 
412  return env;
413 }
414 
415 
416 /*
417 void te::graph::BoxLoaderStrategy::loadDataByVertexId(int vertexId, te::graph::AbstractGraph* g, te::graph::GraphCache* gc)
418 {
419  if(m_graphMetadata == 0 || m_graphMetadata->getDataSource() == 0 || g == 0)
420  {
421  throw Exception(TE_TR(""));
422  }
423 
424  Vertex* vAux = 0;
425 
426  if(m_graphMetadata->getStorageMode() == te::graph::Edge_List)
427  {
428  vAux = loadVertexAttrs(vertexId);
429  }
430  else if(m_graphMetadata->getStorageMode() == te::graph::Vertex_List)
431  {
432  vAux = loadVertex(vertexId);
433  }
434 
435  if(vAux == 0)
436  {
437  throw Exception(TE_TR("Vertex Id not found."));
438  }
439 
440  //ONLY WORKS FOR te::graph::Edge_List
441  if(m_graphMetadata->getStorageMode() == te::graph::Vertex_List)
442  {
443  throw Exception(TE_TR("TO DO"));
444  }
445 
446  //get the tables names
447  std::string edgeTable = m_graphMetadata->getEdgeTableName();
448  std::string vertexAttrTalbe = m_graphMetadata->getVertexTableName();
449 
450  //get the vertex coord
451  te::gm::Point* point = 0;
452  std::string geometryAttrName = "";
453 
454  for(int i = 0; i < m_graphMetadata->getVertexPropertySize(); ++i)
455  {
456  if(m_graphMetadata->getVertexProperty(i)->getType() == te::dt::GEOMETRY_TYPE)
457  {
458  geometryAttrName = m_graphMetadata->getVertexProperty(i)->getName();
459 
460  point = dynamic_cast<te::gm::Point*>(vAux->getAttributes()[i]);
461 
462  break;
463  }
464  }
465 
466  assert(point);
467 
468  //calculate box
469  te::gm::Envelope* envelope = calculateBox(point, vertexAttrTalbe);
470 
471  //get all id's from vertex and edges that is inside that box
472 
473  //filds
474  te::da::Fields* all = new te::da::Fields;
475  all->push_back(new te::da::Field("*"));
476 
477  //from
478  te::da::From* from = new te::da::From;
479 
480  te::da::FromItem* fi1 = new te::da::DataSetName(edgeTable, "edges");
481  from->push_back(fi1);
482  te::da::FromItem* fi2 = new te::da::DataSetName(vertexAttrTalbe, "v1");
483  from->push_back(fi2);
484  te::da::FromItem* fi3 = new te::da::DataSetName(vertexAttrTalbe, "v2");
485  from->push_back(fi3);
486 
487 
488  std::string vertexFrom = "edges.";
489  vertexFrom += Globals::sm_tableEdgeModelAttrVFrom;
490 
491  std::string vertexTo = "edges.";
492  vertexTo += Globals::sm_tableEdgeModelAttrVTo;
493 
494  std::string v1Id = "v1.";
495  v1Id += Globals::sm_tableVertexModelAttrId;
496 
497  std::string v2Id = "v2.";
498  v2Id += Globals::sm_tableVertexModelAttrId;
499 
500  //where
501  te::da::Field* fvf = new te::da::Field(vertexFrom);
502  te::da::Field* fv1id = new te::da::Field(v1Id);
503  te::da::Expression* exp1 = new te::da::EqualTo(fvf->getExpression(), fv1id->getExpression());
504 
505  te::da::Field* fvt = new te::da::Field(vertexTo);
506  te::da::Field* fv2id = new te::da::Field(v2Id);
507  te::da::Expression* exp2 = new te::da::EqualTo(fvt->getExpression(), fv2id->getExpression());
508 
509  te::da::And* and = new te::da::And(exp1, exp2);
510 
511 
512  std::string v1Attr = "v1." + geometryAttrName;
513  std::string v2Attr = "v2." + geometryAttrName;
514 
515  int srid = point->getSRID();
516  te::da::LiteralEnvelope* lenv1 = new te::da::LiteralEnvelope(*envelope, srid);
517  te::da::LiteralEnvelope* lenv2 = new te::da::LiteralEnvelope(*envelope, srid);
518  te::da::Field* fv1attr = new te::da::Field(v1Attr);
519  te::da::Field* fv2attr = new te::da::Field(v2Attr);
520  te::da::ST_Intersects* intersects1 = new te::da::ST_Intersects(fv1attr->getExpression(), lenv1);
521  te::da::ST_Intersects* intersects2 = new te::da::ST_Intersects(fv2attr->getExpression(), lenv2);
522  te::da::Or* or = new te::da::Or(intersects1, intersects2);
523 
524  te::da::And* andd = new te::da::And(and, or);
525 
526  te::da::Where* wh = new te::da::Where(andd);
527 
528  //select
529  te::da::Select select(all, from, wh);
530 
531  //query
532  te::da::DataSourceTransactor* transactor = m_graphMetadata->getDataSource()->getTransactor();
533 
534  if(!transactor)
535  {
536  throw Exception(TE_TR("Error getting Transactor."));
537  }
538 
539  te::da::DataSourceCatalogLoader* catalog = transactor->getCatalogLoader();
540 
541  te::da::DataSet* dataset = transactor->query(select);
542  te::da::DataSetType* edgeDsType = catalog->getDataSetType(edgeTable);
543  te::da::DataSetType* vertexDsType = catalog->getDataSetType(vertexAttrTalbe);
544 
545  int edgeProperties = edgeDsType->getProperties().size();
546  int vertexProperties = vertexDsType->getProperties().size();
547 
548  //list of all attributes: edge table + vertex table + vertex table
549  while(dataset->moveNext())
550  {
551  int edgeId = dataset->getInt32(0); //first item is the edge id
552  int vFromId = dataset->getInt32(1); //second item is the vertefFrom id
553  int vToId = dataset->getInt32(2); //third item is the verteTo id
554 
555  //verify if its already in cache
556  if(gc->checkCacheByEdgeId(edgeId) == 0)
557  {
558  te::graph::Edge* e = new te::graph::Edge(edgeId, vFromId, vToId, false);
559 
560  e->setAttributeVecSize(edgeDsType->getProperties().size() - 3);
561 
562  for(size_t i = 3; i < edgeDsType->getProperties().size(); ++i)
563  {
564  e->addAttribute(i - 3, dataset->getValue(i));
565  };
566 
567  g->add(e);
568  }
569 
570  if(gc->checkCacheByVertexId(vFromId) == false)
571  {
572  te::graph::Vertex* v = new te::graph::Vertex(vFromId, false);
573 
574  v->setAttributeVecSize(vertexDsType->getProperties().size() - 1);
575 
576  for(size_t i = 1; i < vertexDsType->getProperties().size(); ++i)
577  {
578  v->addAttribute(i - 1, dataset->getValue(i + edgeProperties));
579  }
580 
581  g->add(v);
582  }
583 
584  if(gc->checkCacheByVertexId(vToId) == false)
585  {
586  te::graph::Vertex* v = new te::graph::Vertex(vToId, false);
587 
588  v->setAttributeVecSize(vertexDsType->getProperties().size() - 1);
589 
590  for(size_t i = 1; i < vertexDsType->getProperties().size(); ++i)
591  {
592  v->addAttribute(i - 1, dataset->getValue(i + edgeProperties + vertexProperties));
593  }
594 
595  g->add(v);
596  }
597  }
598 
599  delete vAux;
600  delete envelope;
601  delete dataset;
602  delete catalog;
603  delete transactor;
604 }
605 
606 
607 void te::graph::BoxLoaderStrategy::loadDataByEdgeId(int edgeId, te::graph::AbstractGraph* g, te::graph::GraphCache* gc)
608 {
609  if(m_graphMetadata == 0 || m_graphMetadata->getDataSource() == 0 || g == 0)
610  {
611  throw Exception(TE_TR(""));
612  }
613 
614  Edge* e = 0;
615 
616  if(m_graphMetadata->getStorageMode() == te::graph::Edge_List)
617  {
618  e = loadEdge(edgeId);
619  }
620  else if(m_graphMetadata->getStorageMode() == te::graph::Vertex_List)
621  {
622  e = loadEdgeAttrs(edgeId);
623  }
624 
625  if(e == 0)
626  {
627  throw Exception(TE_TR("Edge Id not found."));
628  }
629 
630  int vId = e->getIdFrom();
631 
632  delete e;
633 
634  loadDataByVertexId(vId, g, gc);
635 }
636 */
te::da::DataSource * getDataSource()
It returns the data source associated with this graph.
void setAttributeVecSize(int size)
This function is used to set the number of attributes associated with the vertex elements.
Definition: Vertex.cpp:79
te::graph::GraphMetadata * getMetadata()
It returns a pointer to a class that describes the graph metadata.
void setAttributeVecSize(int size)
This function is used to set the number of attributes associated with the edge elements.
Definition: Edge.cpp:86
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...
static const std::string sm_tableVertexModelAttrId
Attribute id.
virtual te::dt::Property * getVertexProperty(int idx)
Get a vertex property given a index.
Spatial intersects operator.
Definition: ST_Intersects.h:46
te::graph::GraphMetadata * m_graphMetadata
Graph metadata attribute.
A class that models the name of a dataset used in a From clause.
Definition: DataSetName.h:43
virtual int getVertexPropertySize()
Used to verify the number of properties associated to vertex elements.
Base exception class for plugin module.
Expression * getExpression() const
It returns the expression set for an output select query.
std::set< int > & getPredecessors()
Returns the Predecessors vector.
Definition: Vertex.cpp:101
double m_urx
Upper right corner x-coordinate.
double getWidth() const
It returns the envelope width.
BoxLoaderStrategy(te::graph::GraphMetadata *metadata)
Default constructor.
virtual void loadDataByEdgeId(int edgeId, te::graph::AbstractGraph *g, te::graph::GraphCache *gc=0)
Functio used to load a group of edges elements given a base element.
std::vector< te::dt::AbstractData * > & getAttributes()
It returns the vector of attributes associated with this element.
Definition: Vertex.cpp:74
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
GraphData * checkCacheByVertexId(int id)
This functions check in cache if the vertex element with a given id was alredy in memory...
Definition: GraphCache.cpp:246
virtual te::gm::Envelope * getEnvelope()
Used to get the bounding box of the geometry elements associated with this graph. ...
virtual void add(Vertex *v)=0
Add a new vertex element to a graph.
Boolean logic operator: AND.
This is an abstract class that models a query expression.
From the point of view of graph theory, vertices are treated as featureless and indivisible objects...
Definition: Vertex.h:68
virtual std::unique_ptr< DataSet > query(const Select &q, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It executes a query that may return some data using a generic query. This method always returns a dis...
te::gm::GeometryCollection * gc
virtual te::graph::GraphMetadata * getMetadata()=0
Function used to access the graph metadata.
Class used to define the edge struct of a graph. Its compose with a identifier, the vertex origin and...
Definition: Edge.h:58
int getSRID() const _NOEXCEPT_OP(true)
It returns the Spatial Reference System ID associated to this geometric object.
double m_llx
Lower left corner x-coordinate.
const double & getY() const
It returns the Point y-coordinate value.
Definition: Point.h:152
A point with x and y coordinate values.
Definition: Point.h:50
double m_boxPercentSize
Attribute used to box percent size used in loader strategy.
An Envelope defines a 2D rectangular region.
Abstract class used to define the main functions of graph struct. All graph implementations must used...
Definition: AbstractGraph.h:55
This class implements the main functions necessary to save and load the graph data and metadata infor...
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
Definition: Fields.h:37
A class that can be used to model a filter expression that can be applied to a query.
Definition: Where.h:47
te::gm::Polygon * p
Vertex * loadVertexAttrs(int id)
Function used to load one vertex given a ID.
Edge * loadEdgeAttrs(int id)
Function used to load one edge given a ID.
This class define the main functions necessary to save and load the graph data and metadata informati...
std::set< int > & getSuccessors()
Returns the Successors vector.
Definition: Vertex.cpp:106
int getIdFrom()
It returns the vertex origin identification.
Definition: Edge.cpp:71
Edge * loadEdge(int id)
Function used to load one edge given a ID.
virtual std::unique_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
Definition: From.h:37
double m_lly
Lower left corner y-coordinate.
Class used to manager the graph data elements. This class uses a cache policy to control the elements...
Definition: GraphCache.h:60
virtual ~BoxLoaderStrategy()
Default destructor.
GraphData * checkCacheByEdgeId(int id)
This functions check in cache if the edge element with a given id was alredy in memory.
Definition: GraphCache.cpp:270
int getType() const
It returns the property data type.
Definition: Property.h:161
#define TE_GRAPH_FACTORY_GRAPH_TYPE_BIDIRECTIONALGRAPH
double m_ury
Upper right corner y-coordinate.
std::string getEdgeTableName()
It returns the edge table name that contains the vertex elements in data source.
It models the comparison operator.
Definition: EqualTo.h:46
A class that models a literal for Envelope values.
std::string getVertexTableName()
It returns the vertex table name that contains the vertex elements in data source.
virtual void loadDataByVertexId(int vertexId, te::graph::AbstractGraph *g, te::graph::GraphCache *gc=0)
Functio used to load a group of vertex elements given a base element.
std::string getType()
It returns the graph type (defined in Enums file)
void addAttribute(int idx, te::dt::AbstractData *ad)
Add a new attribute to this element.
Definition: Vertex.cpp:84
GraphStorageMode getStorageMode()
It returns the the graph storage mode (defined in Enums file)
static const std::string sm_tableEdgeModelAttrVFrom
Attribute Vertex From.
Vertex * loadVertex(int id)
Function used to load one vertex given a ID.
void addAttribute(int idx, te::dt::AbstractData *ad)
Add a new attribute to this element.
Definition: Edge.cpp:91
te::gm::Envelope * calculateBox(te::gm::Point *p, std::string tableName)
Generate a box with p as center. The new box will have n% of the total graph height and n% of total g...
double getHeight() const
It returns the envelope height.
static const std::string sm_tableEdgeModelAttrVTo
Attribute Vertex To.
const double & getX() const
It returns the Point x-coordinate value.
Definition: Point.h:138
Class used to define the graph metadata informations.
Definition: GraphMetadata.h:56
const std::string & getName() const
It returns the property name.
Definition: Property.h:127