QGIS API Documentation  2.99.0-Master (314842d)
qgspointsample.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgspointsample.h
3  ---------------------
4  begin : July 2013
5  copyright : (C) 2013 by Marco Hugentobler
6  email : marco dot hugentobler at sourcepole dot ch
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 #ifndef QGSPOINTSAMPLE_H
16 #define QGSPOINTSAMPLE_H
17 
18 #include "qgsfeature.h"
19 #include <QString>
20 #include "qgis_analysis.h"
21 
22 class QgsFeature;
23 class QgsPoint;
24 class QgsSpatialIndex;
26 class QgsVectorLayer;
27 class QProgressDialog;
28 
31 class ANALYSIS_EXPORT QgsPointSample
32 {
33  public:
34  QgsPointSample( QgsVectorLayer *inputLayer, const QString &outputLayer, const QString &nPointsAttribute, const QString &minDistAttribute = QString() );
35 
38  int createRandomPoints( QProgressDialog *pd );
39 
40  private:
41 
42  QgsPointSample(); //default constructor is forbidden
43  void addSamplePoints( QgsFeature &inputFeature, QgsVectorFileWriter &writer, int nPoints, double minDistance );
44  bool checkMinDistance( QgsPoint &pt, QgsSpatialIndex &index, double minDistance, QMap< QgsFeatureId, QgsPoint > &pointMap );
45 
47  QgsVectorLayer *mInputLayer = nullptr;
49  QString mOutputLayer;
51  QString mNumberOfPointsAttribute;
53  QString mMinDistanceAttribute;
54  QgsFeatureId mNCreatedPoints; //helper to find free ids
55 };
56 
57 #endif // QGSPOINTSAMPLE_H
static unsigned index
A convenience class for writing vector files to disk.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:136
Creates random points in polygons / multipolygons.
A class to represent a point.
Definition: qgspoint.h:37
qint64 QgsFeatureId
Definition: qgsfeature.h:33
Represents a vector layer which manages a vector based data sets.