QGIS API Documentation  3.0.2-Girona (307d082)
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 QgsPointXY &pt )
39 {
40  mGraph->addVertex( pt );
41 }
42 
43 void QgsGraphBuilder::addEdge( int pt1id, const QgsPointXY &, int pt2id, const QgsPointXY &, 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.
A class to represent a 2D point.
Definition: qgspointxy.h:43
void addEdge(int pt1id, const QgsPointXY &pt1, int pt2id, const QgsPointXY &pt2, const QVector< QVariant > &prop) override
Add edge to the graph.
Determine interface for creating a graph.
~QgsGraphBuilder() override
QgsGraph * graph()
Returns generated QgsGraph.
Mathematical graph representation.
Definition: qgsgraph.h:141
int addEdge(int fromVertexIdx, int toVertexIdx, const QVector< QVariant > &strategies)
Add an edge to the graph, going from the fromVertexIdx to toVertexIdx.
Definition: qgsgraph.cpp:29
void addVertex(int id, const QgsPointXY &pt) override
Add vertex to the graph.
This class represents a coordinate reference system (CRS).
int addVertex(const QgsPointXY &pt)
Add a vertex to the graph.
Definition: qgsgraph.cpp:23