30 #include "../../common/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"
64 if(m_graphMetadata == 0 || m_graphMetadata->getDataSource() == 0 || g == 0)
73 vAux = loadVertexAttrs(vertexId);
77 vAux = loadVertex(vertexId);
82 throw Exception(
TR_GRAPH(
"Vertex Id not found."));
92 std::string vertexAttrTable = m_graphMetadata->getVertexTableName();
93 std::string edgeAttrTable = m_graphMetadata->getEdgeTableName();
97 std::string geometryAttrName =
"";
99 for(
int i = 0; i < m_graphMetadata->getVertexPropertySize(); ++i)
103 geometryAttrName = m_graphMetadata->getVertexProperty(i)->getName();
129 from->push_back(fiEdge);
131 std::string vertexFrom =
"edge.";
134 std::string vertexTo =
"edge.";
137 std::string vId =
"vertex.";
152 std::string vEttr =
"vertex." + geometryAttrName;
167 std::auto_ptr<te::da::DataSet> dataset = m_graphMetadata->getDataSource()->query(select);
169 std::auto_ptr<te::da::DataSetType> vertexDsType = m_graphMetadata->getDataSource()->getDataSetType(vertexAttrTable);
171 int vertexProperties = vertexDsType->getProperties().size();
180 while(dataset->moveNext())
182 int vId = dataset->getInt32(0);
183 int eId = dataset->getInt32(vertexProperties);
184 int vFrom = dataset->getInt32(vertexProperties + 1);
196 for(
int i = 1; i < vertexProperties; ++i)
228 if(m_graphMetadata == 0 || m_graphMetadata->getDataSource() == 0 || g == 0)
237 e = loadEdge(edgeId);
241 e = loadEdgeAttrs(edgeId);
246 throw Exception(
TR_GRAPH(
"Edge Id not found."));
255 vAux = loadVertexAttrs(vAuxId);
259 vAux = loadVertex(vAuxId);
264 throw Exception(
TR_GRAPH(
"Vertex Id not found."));
276 std::string vertexAttrTable = m_graphMetadata->getVertexTableName();
277 std::string edgeAttrTable = m_graphMetadata->getEdgeTableName();
281 std::string geometryAttrName =
"";
283 for(
int i = 0; i < m_graphMetadata->getVertexPropertySize(); ++i)
287 geometryAttrName = m_graphMetadata->getVertexProperty(i)->getName();
313 from->push_back(fiEdge);
315 std::string vertexFrom =
"edge.";
318 std::string vertexTo =
"edge.";
321 std::string vId =
"vertex.";
336 std::string vEttr =
"vertex." + geometryAttrName;
351 std::auto_ptr<te::da::DataSet> dataset = m_graphMetadata->getDataSource()->query(select);
353 std::auto_ptr<te::da::DataSetType> vertexDsType = m_graphMetadata->getDataSource()->getDataSetType(vertexAttrTable);
354 std::auto_ptr<te::da::DataSetType> edgeDsType = m_graphMetadata->getDataSource()->getDataSetType(edgeAttrTable);
356 int vertexProperties = vertexDsType->getProperties().size();
357 int edgeProperties = edgeDsType->getProperties().size();
364 while(dataset->moveNext())
366 int eId = dataset->getInt32(vertexProperties);
367 int vFrom = dataset->getInt32(vertexProperties + 1);
368 int vTo = dataset->getInt32(vertexProperties + 2);
379 for(
int i = 3; i < edgeProperties; ++i)
381 e->
addAttribute(i - 3, dataset->getValue(i + vertexProperties).release());
400 double h = e->
getHeight() / (100. / getMetadata()->m_boxPercentSize);
401 double w = e->
getWidth() / (100. / getMetadata()->m_boxPercentSize);
Abstract class used to define the main functions of graph struct. All graph implementations must used...
Class used to define the edge struct of a graph. Its compose with a identifier, the vertex origin and...
int getSRID() const
It returns the Spatial Reference System ID associated to this geometric object.
This class define the main functions necessary to save and load the graph data and metadata informati...
void setAttributeVecSize(int size)
This function is used to set the number of attributes associated with the edge elements.
A class that models the name of a dataset used in a From clause.
double getWidth() const
It returns the envelope width.
Expression * getExpression() const
It returns the expression set for an output select query.
void setAttributeVecSize(int size)
This function is used to set the number of attributes associated with the vertex elements.
A Select models a query to be used when retrieving data from a DataSource.
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.
Class used to manager the graph data elements. This class uses a cache policy to control the elements...
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...
Spatial intersects operator.
From the point of view of graph theory, vertices are treated as featureless and indivisible objects...
The Field class can be used to model an expression that takes part of the output items of a SELECT...
virtual te::graph::GraphMetadata * getMetadata()=0
Function used to access the graph metadata.
int getIdFrom()
It returns the vertex origin identification.
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
void addAttribute(int idx, te::dt::AbstractData *ad)
Add a new attribute to this element.
#define TR_GRAPH(message)
It marks a string in order to get translated. This is a special mark used in the Graph module of Terr...
double getHeight() const
It returns the envelope height.
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
#define TE_GRAPH_FACTORY_GRAPH_TYPE_BIDIRECTIONALGRAPH
Boolean logic operator: AND.
GraphData * checkCacheByEdgeId(int id)
This functions check in cache if the edge element with a given id was alredy in memory.
const double & getX() const
It returns the Point x-coordinate value.
void addAttribute(int idx, te::dt::AbstractData *ad)
Add a new attribute to this element.
An abstract class that models a source of data in a query.
double m_lly
Lower left corner y-coordinate.
static const std::string sm_tableEdgeModelAttrVFrom
Attribute Vertex From.
virtual ~BoxLoaderStrategy()
Default destructor.
static const std::string sm_tableVertexModelAttrId
Attribute id.
double m_ury
Upper right corner y-coordinate.
A point with x and y coordinate values.
A class that models a literal for Envelope values.
double m_urx
Upper right corner x-coordinate.
std::set< int > & getPredecessors()
Returns the Predecessors vector.
virtual void add(Vertex *v)=0
Add a new vertex element to a graph.
std::vector< te::dt::AbstractData * > & getAttributes()
It returns the vector of attributes associated with this element.
BoxLoaderStrategy(te::graph::GraphMetadata *metadata)
Default constructor.
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.
This class implements the main functions necessary to save and load the graph data and metadata infor...
This is an abstract class that models a query expression.
GraphData * checkCacheByVertexId(int id)
This functions check in cache if the vertex element with a given id was alredy in memory...
double m_llx
Lower left corner x-coordinate.
std::string getType()
It returns the graph type (defined in Enums file)
static const std::string sm_tableEdgeModelAttrVTo
Attribute Vertex To.
It models the comparison operator.
Class used to define the graph metadata informations.
const double & getY() const
It returns the Point y-coordinate value.
An Envelope defines a 2D rectangular region.
A class that can be used to model a filter expression that can be applied to a query.
std::set< int > & getSuccessors()
Returns the Successors vector.