QGIS API Documentation
2.2.0-Valmiera
|
Creates random points in polygons / multipolygons. More...
#include <qgspointsample.h>
Public Member Functions | |
QgsPointSample (QgsVectorLayer *inputLayer, const QString &outputLayer, QString nPointsAttribute, QString minDistAttribute=QString()) | |
~QgsPointSample () | |
int | createRandomPoints (QProgressDialog *pd) |
Starts calculation of random points. |
Private Member Functions | |
QgsPointSample () | |
void | addSamplePoints (QgsFeature &inputFeature, QgsVectorFileWriter &writer, int nPoints, double minDistance) |
bool | checkMinDistance (QgsPoint &pt, QgsSpatialIndex &index, double minDistance, QMap< QgsFeatureId, QgsPoint > &pointMap) |
Private Attributes | |
QgsVectorLayer * | mInputLayer |
Layer id of input polygon/multipolygon layer. | |
QString | mOutputLayer |
Output path of result layer. | |
QString | mNumberOfPointsAttribute |
Attribute containing number of points per feature. | |
QString | mMinDistanceAttribute |
Attribute containing minimum distance between sample points (or -1 if no min. | |
QgsFeatureId | mNCreatedPoints |
Creates random points in polygons / multipolygons.
Definition at line 15 of file qgspointsample.h.
QgsPointSample::QgsPointSample | ( | QgsVectorLayer * | inputLayer, |
const QString & | outputLayer, | ||
QString | nPointsAttribute, | ||
QString | minDistAttribute = QString() |
||
) |
Definition at line 10 of file qgspointsample.cpp.
QgsPointSample::~QgsPointSample | ( | ) |
Definition at line 19 of file qgspointsample.cpp.
|
private |
Definition at line 15 of file qgspointsample.cpp.
|
private |
Definition at line 82 of file qgspointsample.cpp.
References QgsVectorFileWriter::addFeature(), QgsGeometry::boundingBox(), checkMinDistance(), QgsGeometry::fromPoint(), QgsFeature::geometry(), QgsRectangle::height(), QgsFeature::id(), QgsSpatialIndex::insertFeature(), QgsRectangle::isEmpty(), MD_RAND_MAX, mNCreatedPoints, mt_rand(), QgsFeature::setAttribute(), QgsFeature::setGeometry(), QgsRectangle::width(), QgsGeometry::within(), QgsRectangle::xMinimum(), and QgsRectangle::yMinimum().
Referenced by createRandomPoints().
|
private |
Definition at line 134 of file qgspointsample.cpp.
References QgsSpatialIndex::nearestNeighbor(), and QgsPoint::sqrDist().
Referenced by addSamplePoints().
int QgsPointSample::createRandomPoints | ( | QProgressDialog * | pd | ) |
Starts calculation of random points.
Definition at line 23 of file qgspointsample.cpp.
References addSamplePoints(), QgsFields::append(), QgsFeature::attribute(), QgsMapLayer::crs(), QgsVectorFileWriter::deleteShapeFile(), QgsVectorLayer::geometryType(), QgsVectorLayer::getFeatures(), QgsVectorFileWriter::hasError(), mInputLayer, mMinDistanceAttribute, mNCreatedPoints, mNumberOfPointsAttribute, mOutputLayer, mt_srand(), QgsFeatureIterator::nextFeature(), QgsVectorFileWriter::NoError, QgsVectorLayer::pendingFields(), QGis::Polygon, and QGis::WKBPoint.
|
private |
Layer id of input polygon/multipolygon layer.
Definition at line 32 of file qgspointsample.h.
Referenced by createRandomPoints().
|
private |
Attribute containing minimum distance between sample points (or -1 if no min.
distance constraint)
Definition at line 38 of file qgspointsample.h.
Referenced by createRandomPoints().
|
private |
Definition at line 39 of file qgspointsample.h.
Referenced by addSamplePoints(), and createRandomPoints().
|
private |
Attribute containing number of points per feature.
Definition at line 36 of file qgspointsample.h.
Referenced by createRandomPoints().
|
private |
Output path of result layer.
Definition at line 34 of file qgspointsample.h.
Referenced by createRandomPoints().