11 mOutputLayer( outputLayer ), mNumberOfPointsAttribute( nPointsAttribute ), mMinDistanceAttribute( minDistAttribute ), mNCreatedPoints( 0 )
61 mt_srand( QTime::currentTime().msec() );
64 double minDistance = 0;
97 QMap< QgsFeatureId, QgsPoint > pointMapForFeature;
100 int maxIterations = nPoints * 200;
106 while ( nIterations < maxIterations && points < nPoints )
136 if ( minDistance <= 0 )
142 if ( neighborList.isEmpty() )
147 QMap< QgsFeatureId, QgsPoint >::const_iterator it = pointMap.find( neighborList[0] );
148 if ( it == pointMap.constEnd() )
154 if ( neighborPt.
sqrDist( pt ) < ( minDistance * minDistance ) )
QgsFeatureId id() const
Get the feature id for this feature.
Wrapper for iterator of features from vector data provider or vector layer.
QgsVectorLayer * mInputLayer
Layer id of input polygon/multipolygon layer.
A rectangle specified with double values.
bool isEmpty() const
test if rectangle is empty.
int createRandomPoints(QProgressDialog *pd)
Starts calculation of random points.
QString mMinDistanceAttribute
Attribute containing minimum distance between sample points (or -1 if no min.
bool checkMinDistance(QgsPoint &pt, QgsSpatialIndex &index, double minDistance, QMap< QgsFeatureId, QgsPoint > &pointMap)
void addSamplePoints(QgsFeature &inputFeature, QgsVectorFileWriter &writer, int nPoints, double minDistance)
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
QgsGeometry * geometry() const
Get the geometry object associated with this feature.
static bool deleteShapeFile(QString theFileName)
Delete a shapefile (and its accompanying shx / dbf / prf)
Container of fields for a vector layer.
bool setAttribute(int field, const QVariant &attr)
Set an attribute by id.
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...
double sqrDist(double x, double y) const
Returns the squared distance between this point and x,y.
void setGeometry(const QgsGeometry &geom)
Set this feature's geometry from another QgsGeometry object (deep copy)
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QList< QgsFeatureId > nearestNeighbor(QgsPoint point, int neighbors) const
returns nearest neighbors (their count is specified by second parameter)
void mt_srand(unsigned value)
bool addFeature(QgsFeature &feature, QgsFeatureRendererV2 *renderer=0, QGis::UnitType outputUnit=QGis::Meters)
add feature to the currently opened shapefile
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Append a field. The field must have unique name, otherwise it is rejected (returns false) ...
QGis::GeometryType geometryType() const
Returns point, line or polygon.
Encapsulate a field in an attribute table or data source.
A class to represent a point geometry.
static QgsGeometry * fromPoint(const QgsPoint &point)
construct geometry from a point
QgsRectangle boundingBox()
Returns the bounding box of this feature.
bool insertFeature(const QgsFeature &f)
add feature to index
WriterError hasError()
checks whether there were any errors in constructor
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QgsFeatureId mNCreatedPoints
QString mOutputLayer
Output path of result layer.
bool within(const QgsGeometry *geometry) const
Test for if geometry is within another (uses GEOS)
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
bool nextFeature(QgsFeature &f)
double width() const
Width of the rectangle.
Represents a vector layer which manages a vector based data sets.
double xMinimum() const
Get the x minimum value (left side of rectangle)
QString mNumberOfPointsAttribute
Attribute containing number of points per feature.
double height() const
Height of the rectangle.