QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
21 class QgsFeature;
22 class QgsPoint;
23 class QgsSpatialIndex;
25 class QgsVectorLayer;
26 class QProgressDialog;
27 
30 class ANALYSIS_EXPORT QgsPointSample
31 {
32  public:
33  QgsPointSample( QgsVectorLayer* inputLayer, const QString& outputLayer, const QString& nPointsAttribute, const QString& minDistAttribute = QString() );
34 
37  int createRandomPoints( QProgressDialog* pd );
38 
39  private:
40 
41  QgsPointSample(); //default constructor is forbidden
42  void addSamplePoints( QgsFeature& inputFeature, QgsVectorFileWriter& writer, const QgsFields& outputFields, int nPoints, double minDistance );
43  bool checkMinDistance( QgsPoint& pt, QgsSpatialIndex& index, double minDistance, QMap< QgsFeatureId, QgsPoint >& pointMap );
44 
46  QgsVectorLayer* mInputLayer;
48  QString mOutputLayer;
50  QString mNumberOfPointsAttribute;
52  QString mMinDistanceAttribute;
53  QgsFeatureId mNCreatedPoints; //helper to find free ids
54 };
55 
56 #endif // QGSPOINTSAMPLE_H
static unsigned index
Container of fields for a vector layer.
Definition: qgsfield.h:252
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:187
Creates random points in polygons / multipolygons.
A class to represent a point.
Definition: qgspoint.h:117
qint64 QgsFeatureId
Definition: qgsfeature.h:31
Represents a vector layer which manages a vector based data sets.