QGIS API Documentation  3.0.2-Girona (307d082)
qgsgraphbuilderinterface.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgraphbuilderinterface.h
3  --------------------------------------
4  Date : 2010-10-22
5  Copyright : (C) 2010 by Yakushev Sergey
6  Email : YakushevS <at> list.ru
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 #ifndef QGSGRAPHBUILDERINTERFACE_H
17 #define QGSGRAPHBUILDERINTERFACE_H
18 
19 #include <QVector>
20 #include <QVariant>
21 
22 #include "qgspoint.h"
23 #include "qgsproject.h"
25 #include "qgsdistancearea.h"
26 #include "qgis_analysis.h"
27 
28 #ifdef SIP_RUN
29 % ModuleHeaderCode
30 #include <qgsgraphbuilder.h>
31 % End
32 #endif
33 
40 class ANALYSIS_EXPORT QgsGraphBuilderInterface
41 {
42 
43 #ifdef SIP_RUN
45  if ( dynamic_cast< QgsGraphBuilder * >( sipCpp ) != NULL )
46  sipType = sipType_QgsGraphBuilder;
47  else
48  sipType = NULL;
49  SIP_END
50 #endif
51 
52  public:
53 
61  QgsGraphBuilderInterface( const QgsCoordinateReferenceSystem &crs, bool ctfEnabled = true, double topologyTolerance = 0.0, const QString &ellipsoidID = "WGS84" )
62  : mCrs( crs )
63  , mCtfEnabled( ctfEnabled )
64  , mTopologyTolerance( topologyTolerance )
65  {
66  mDa.setSourceCrs( mCrs, QgsProject::instance()->transformContext() );
67  mDa.setEllipsoid( ellipsoidID );
68  }
69 
70  virtual ~QgsGraphBuilderInterface() = default;
71 
74  {
75  return mCrs;
76  }
77 
80  {
81  return mCtfEnabled;
82  }
83 
86  {
87  return mTopologyTolerance;
88  }
89 
92  {
93  return &mDa;
94  }
95 
102  virtual void addVertex( int id, const QgsPointXY &pt )
103  {
104  Q_UNUSED( id );
105  Q_UNUSED( pt );
106  }
107 
117  virtual void addEdge( int pt1id, const QgsPointXY &pt1, int pt2id, const QgsPointXY &pt2, const QVector< QVariant > &strategies )
118  {
119  Q_UNUSED( pt1id );
120  Q_UNUSED( pt1 );
121  Q_UNUSED( pt2id );
122  Q_UNUSED( pt2 );
123  Q_UNUSED( strategies );
124  }
125 
126  private:
128 
129  QgsDistanceArea mDa;
130 
131  bool mCtfEnabled;
132 
133  double mTopologyTolerance;
134 
135 };
136 
137 // clazy:excludeall=qstring-allocations
138 
139 #endif // QGSGRAPHBUILDERINTERFACE_H
bool coordinateTransformationEnabled()
Returns coordinate transformation enabled.
A class to represent a 2D point.
Definition: qgspointxy.h:43
Determine interface for creating a graph.
virtual void addEdge(int pt1id, const QgsPointXY &pt1, int pt2id, const QgsPointXY &pt2, const QVector< QVariant > &strategies)
Add edge to the graph.
#define SIP_END
Definition: qgis_sip.h:175
QgsGraphBuilderInterface(const QgsCoordinateReferenceSystem &crs, bool ctfEnabled=true, double topologyTolerance=0.0, const QString &ellipsoidID="WGS84")
Default constructor.
A general purpose distance and area calculator, capable of performing ellipsoid based calculations...
virtual void addVertex(int id, const QgsPointXY &pt)
Add vertex to the graph.
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:383
This class represents a coordinate reference system (CRS).
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:165
double topologyTolerance()
Returns topology tolerance.
QgsCoordinateReferenceSystem destinationCrs() const
Returns destinaltion CRS.
QgsDistanceArea * distanceArea()
Returns measurement tool.