QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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  , mGraph( std::make_unique< QgsGraph >() )
29 {
30 }
31 
33 
34 void QgsGraphBuilder::addVertex( int, const QgsPointXY &pt )
35 {
36  mGraph->addVertex( pt );
37 }
38 
39 void QgsGraphBuilder::addEdge( int pt1id, const QgsPointXY &, int pt2id, const QgsPointXY &, const QVector< QVariant > &prop )
40 {
41  mGraph->addEdge( pt1id, pt2id, prop );
42 }
43 
45 {
46  return *mGraph;
47 }
48 
50 {
51  QgsGraph *res = mGraph.release();
52 
53  // create a new graph in case this builder is used for additional work
54  mGraph = std::make_unique< QgsGraph >();
55 
56  return res;
57 }
qgsgraph.h
QgsGraph
Mathematical graph representation.
Definition: qgsgraph.h:142
qgsgraphbuilder.h
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsGraphBuilder::QgsGraphBuilder
QgsGraphBuilder(const QgsCoordinateReferenceSystem &crs, bool otfEnabled=true, double topologyTolerance=0.0, const QString &ellipsoidID="WGS84")
Default constructor.
Definition: qgsgraphbuilder.cpp:26
QgsGraphBuilder::addEdge
void addEdge(int pt1id, const QgsPointXY &pt1, int pt2id, const QgsPointXY &pt2, const QVector< QVariant > &prop) override
Add edge to the graph.
Definition: qgsgraphbuilder.cpp:39
QgsGraphBuilderInterface
Determine interface for creating a graph. Contains the settings of the graph. QgsGraphBuilder and Qgs...
Definition: qgsgraphbuilderinterface.h:40
QgsGraphBuilder::~QgsGraphBuilder
~QgsGraphBuilder() override
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:58
qgsgeometry.h
QgsGraphBuilder::takeGraph
QgsGraph * takeGraph()
Takes the generated graph from the builder, resetting the builder back to its initial state ready for...
Definition: qgsgraphbuilder.cpp:49
QgsGraphBuilder::graph
QgsGraph graph() const
Returns the generated QgsGraph.
Definition: qgsgraphbuilder.cpp:44
QgsGraphBuilder::addVertex
void addVertex(int id, const QgsPointXY &pt) override
Add vertex to the graph.
Definition: qgsgraphbuilder.cpp:34