QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
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
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
26QgsGraphBuilder::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
35{
36 mGraph->addVertex( pt );
37}
38
39void 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}
This class represents a coordinate reference system (CRS).
Determine interface for creating a graph.
~QgsGraphBuilder() override
QgsGraphBuilder(const QgsCoordinateReferenceSystem &crs, bool otfEnabled=true, double topologyTolerance=0.0, const QString &ellipsoidID="WGS84")
Default constructor.
QgsGraph * takeGraph()
Takes the generated graph from the builder, resetting the builder back to its initial state ready for...
void addVertex(int id, const QgsPointXY &pt) override
Add vertex to the graph.
QgsGraph graph() const
Returns the generated QgsGraph.
void addEdge(int pt1id, const QgsPointXY &pt1, int pt2id, const QgsPointXY &pt2, const QVector< QVariant > &prop) override
Add edge to the graph.
Mathematical graph representation.
Definition: qgsgraph.h:143
A class to represent a 2D point.
Definition: qgspointxy.h:59
const QgsCoordinateReferenceSystem & crs