QGIS API Documentation  2.99.0-Master (8ec3eaf)
qgsgraphbuilder.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgraphbuilder.cpp
3  --------------------------------------
4  Date : 2010-10-25
5  Copyright : (C) 2010 by Yakushev Sergey
6  Email : [email protected]
7 ****************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15 
21 #include "qgsgraphbuilder.h"
22 #include "qgsgraph.h"
23 
24 #include <qgsfeature.h>
25 #include <qgsgeometry.h>
26 
27 QgsGraphBuilder::QgsGraphBuilder( const QgsCoordinateReferenceSystem& crs, bool otfEnabled, double topologyTolerance, const QString& ellipsoidID )
28  : QgsGraphBuilderInterface( crs, otfEnabled, topologyTolerance, ellipsoidID )
29 {
30  mGraph = new QgsGraph();
31 }
32 
34 {
35  delete mGraph;
36 }
37 
38 void QgsGraphBuilder::addVertex( int, const QgsPoint& pt )
39 {
40  mGraph->addVertex( pt );
41 }
42 
43 void QgsGraphBuilder::addEdge( int pt1id, const QgsPoint&, int pt2id, const QgsPoint&, const QVector< QVariant >& prop )
44 {
45  mGraph->addEdge( pt1id, pt2id, prop );
46 }
47 
49 {
50  QgsGraph* res = mGraph;
51  mGraph = nullptr;
52  return res;
53 }
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 addEdge(int pt1id, const QgsPoint &pt1, int pt2id, const QgsPoint &pt2, const QVector< QVariant > &prop) override
Add edge to the graph.
QgsGraph * graph()
Returns generated QgsGraph.
int addVertex(const QgsPoint &pt)
Add a vertex to the graph.
Definition: qgsgraph.cpp:27
virtual void addVertex(int id, const QgsPoint &pt) override
Add vertex to the graph.
A class to represent a point.
Definition: qgspoint.h:142
Mathematical graph representation.
Definition: qgsgraph.h:130
int addEdge(int outVertexIdx, int inVertexIdx, const QVector< QVariant > &strategies)
Add an edge to the graph.
Definition: qgsgraph.cpp:33
This class represents a coordinate reference system (CRS).