QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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 "qgsgeometry.h"
25 
26 QgsGraphBuilder::QgsGraphBuilder( const QgsCoordinateReferenceSystem &crs, bool otfEnabled, double topologyTolerance, const QString &ellipsoidID )
27  : QgsGraphBuilderInterface( crs, otfEnabled, topologyTolerance, ellipsoidID )
28 {
29  mGraph = new QgsGraph();
30 }
31 
33 {
34  delete mGraph;
35 }
36 
37 void QgsGraphBuilder::addVertex( int, const QgsPointXY &pt )
38 {
39  mGraph->addVertex( pt );
40 }
41 
42 void QgsGraphBuilder::addEdge( int pt1id, const QgsPointXY &, int pt2id, const QgsPointXY &, const QVector< QVariant > &prop )
43 {
44  mGraph->addEdge( pt1id, pt2id, prop );
45 }
46 
48 {
49  QgsGraph *res = mGraph;
50  mGraph = nullptr;
51  return res;
52 }
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.
const QgsCoordinateReferenceSystem & crs
~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