QGIS API Documentation 3.99.0-Master (c22de0620c0)
Loading...
Searching...
No Matches
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
16#include "qgsgraphbuilder.h"
17
18#include "qgsgraph.h"
19
20QgsGraphBuilder::QgsGraphBuilder( const QgsCoordinateReferenceSystem &crs, bool otfEnabled, double topologyTolerance, const QString &ellipsoidID )
21 : QgsGraphBuilderInterface( crs, otfEnabled, topologyTolerance, ellipsoidID )
22 , mGraph( std::make_unique<QgsGraph>() )
23{
24}
25
27
29{
30 return mGraph->addVertex( pt );
31}
32
33void QgsGraphBuilder::addEdge( int pt1id, const QgsPointXY &, int pt2id, const QgsPointXY &, const QVector<QVariant> &prop )
34{
35 mGraph->addEdge( pt1id, pt2id, prop );
36}
37
39{
40 return *mGraph;
41}
42
43std::unique_ptr< QgsGraph > QgsGraphBuilder::takeGraph()
44{
45 std::unique_ptr< QgsGraph > res = std::move( mGraph );
46
47 // create a new graph in case this builder is used for additional work
48 mGraph = std::make_unique<QgsGraph>();
49
50 return res;
51}
Represents a coordinate reference system (CRS).
QgsGraphBuilderInterface(const QgsCoordinateReferenceSystem &crs, bool ctfEnabled=true, double topologyTolerance=0.0, const QString &ellipsoidID="WGS84")
Default constructor.
double topologyTolerance() const
Returns topology tolerance.
~QgsGraphBuilder() override
QgsGraphBuilder(const QgsCoordinateReferenceSystem &crs, bool otfEnabled=true, double topologyTolerance=0.0, const QString &ellipsoidID="WGS84")
Default constructor.
int 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.
std::unique_ptr< QgsGraph > takeGraph()
Takes the generated graph from the builder, resetting the builder back to its initial state ready for...
Mathematical graph representation.
Definition qgsgraph.h:131
Represents a 2D point.
Definition qgspointxy.h:62