QGIS API Documentation  2.15.0-Master (5f66276)
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 
29 class ANALYSIS_EXPORT QgsPointSample
30 {
31  public:
32  QgsPointSample( QgsVectorLayer* inputLayer, const QString& outputLayer, const QString& nPointsAttribute, const QString& minDistAttribute = QString() );
33 
36  int createRandomPoints( QProgressDialog* pd );
37 
38  private:
39 
40  QgsPointSample(); //default constructor is forbidden
41  void addSamplePoints( QgsFeature& inputFeature, QgsVectorFileWriter& writer, int nPoints, double minDistance );
42  bool checkMinDistance( QgsPoint& pt, QgsSpatialIndex& index, double minDistance, QMap< QgsFeatureId, QgsPoint >& pointMap );
43 
45  QgsVectorLayer* mInputLayer;
47  QString mOutputLayer;
49  QString mNumberOfPointsAttribute;
51  QString mMinDistanceAttribute;
52  QgsFeatureId mNCreatedPoints; //helper to find free ids
53 };
54 
55 #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: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.