11 mOutputLayer( outputLayer ), mNumberOfPointsAttribute( nPointsAttribute ), mMinDistanceAttribute( minDistAttribute ), mNCreatedPoints( 0 )
15 QgsPointSample::QgsPointSample()
17 , mNCreatedPoints( 0 )
54 &( mInputLayer->
crs() ) );
66 double minDistance = 0;
74 if ( !mMinDistanceAttribute.
isEmpty() )
78 addSamplePoints( fet, writer, nPoints, minDistance );
100 int maxIterations = nPoints * 200;
106 while ( nIterations < maxIterations && points < nPoints )
112 if ( ptGeom->
within( geom ) && checkMinDistance( randPoint, sIndex, minDistance, pointMapForFeature ) )
116 f.setAttribute(
"id", mNCreatedPoints + 1 );
117 f.setAttribute(
"station_id", points + 1 );
118 f.setAttribute(
"stratum_id", inputFeature.
id() );
119 f.setGeometry( ptGeom );
122 pointMapForFeature.
insert( mNCreatedPoints, randPoint );
136 if ( minDistance <= 0 )
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.
A rectangle specified with double values.
bool isEmpty() const
test if rectangle is empty.
int createRandomPoints(QProgressDialog *pd)
Starts calculation of random points.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
QgsRectangle boundingBox() const
Returns the bounding box of this feature.
static bool deleteShapeFile(QString theFileName)
Delete a shapefile (and its accompanying shx / dbf / prf)
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
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.
QgsPointSample(QgsVectorLayer *inputLayer, const QString &outputLayer, QString nPointsAttribute, QString minDistAttribute=QString())
int toInt(bool *ok) const
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
const_iterator constEnd() const
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.
static QgsGeometry * fromPoint(const QgsPoint &point)
Creates a new geometry from a QgsPoint object.
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.
bool within(const QgsGeometry *geometry) const
Test for if geometry is within another (uses GEOS)
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
double toDouble(bool *ok) const
iterator insert(const Key &key, const T &value)
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)
iterator find(const Key &key)
double height() const
Height of the rectangle.