QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsgraphbuilder.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2010 by Sergey Yakushev *
3  * yakushevs <at> list.ru *
4  * *
5  * *
6  * This program is free software; you can redistribute it and/or modify *
7  * it under the terms of the GNU General Public License as published by *
8  * the Free Software Foundation; either version 2 of the License, or *
9  * (at your option) any later version. *
10  ***************************************************************************/
11 
17 #include "qgsgraphbuilder.h"
18 #include "qgsgraph.h"
19 
20 // Qgis includes
21 #include <qgsfeature.h>
22 #include <qgsgeometry.h>
23 
24 QgsGraphBuilder::QgsGraphBuilder( const QgsCoordinateReferenceSystem& crs, bool otfEnabled, double topologyTolerance, const QString& ellipsoidID ) :
25  QgsGraphBuilderInterface( crs, otfEnabled, topologyTolerance, ellipsoidID )
26 {
27  mGraph = new QgsGraph();
28 }
29 
31 {
32  if ( mGraph != NULL )
33  delete mGraph;
34 }
35 
36 void QgsGraphBuilder::addVertex( int, const QgsPoint& pt )
37 {
38  mGraph->addVertex( pt );
39 }
40 
41 void QgsGraphBuilder::addArc( int pt1id, const QgsPoint&, int pt2id, const QgsPoint&, const QVector< QVariant >& prop )
42 {
43  mGraph->addArc( pt1id, pt2id, prop );
44 }
45 
47 {
48  QgsGraph* res = mGraph;
49  mGraph = NULL;
50  return res;
51 }
QgsGraphBuilder(const QgsCoordinateReferenceSystem &crs, bool otfEnabled=true, double topologyTolerance=0.0, const QString &ellipsoidID="WGS84")
default constructor
Determine interface for creating a graph.
virtual void addVertex(int id, const QgsPoint &pt)
add vertex
int addArc(int outVertexIdx, int inVertexIdx, const QVector< QVariant > &properties)
add edge to a graph
Definition: qgsgraph.cpp:35
QgsGraph * graph()
return QgsGraph result;
int addVertex(const QgsPoint &pt)
add vertex to a grap
Definition: qgsgraph.cpp:29
QgsGraph * mGraph
A class to represent a point geometry.
Definition: qgspoint.h:63
Mathematics graph representation.
Definition: qgsgraph.h:131
Class for storing a coordinate reference system (CRS)
virtual void addArc(int pt1id, const QgsPoint &pt1, int pt2id, const QgsPoint &pt2, const QVector< QVariant > &prop)
add arc