QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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  delete mGraph;
33 }
34 
35 void QgsGraphBuilder::addVertex( int, const QgsPoint& pt )
36 {
37  mGraph->addVertex( pt );
38 }
39 
40 void QgsGraphBuilder::addArc( int pt1id, const QgsPoint&, int pt2id, const QgsPoint&, const QVector< QVariant >& prop )
41 {
42  mGraph->addArc( pt1id, pt2id, prop );
43 }
44 
46 {
47  QgsGraph* res = mGraph;
48  mGraph = nullptr;
49  return res;
50 }
QgsGraphBuilder(const QgsCoordinateReferenceSystem &crs, bool otfEnabled=true, double topologyTolerance=0.0, const QString &ellipsoidID="WGS84")
default constructor
Determine interface for creating a graph.
int addArc(int outVertexIdx, int inVertexIdx, const QVector< QVariant > &properties)
add edge to a graph
Definition: qgsgraph.cpp:29
QgsGraph * graph()
return QgsGraph result;
int addVertex(const QgsPoint &pt)
add vertex to a grap
Definition: qgsgraph.cpp:23
virtual void addVertex(int id, const QgsPoint &pt) override
add vertex
A class to represent a point.
Definition: qgspoint.h:117
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) override
add arc