#include <qgsgeometryanalyzer.h>
Public Member Functions | |
bool | simplify (QgsVectorLayer *layer, const QString &shapefileName, double tolerance, bool onlySelectedFeatures=false, QProgressDialog *p=0) |
Simplify vector layer using (a modified) Douglas-Peucker algorithm and write it to a new shape file. | |
bool | centroids (QgsVectorLayer *layer, const QString &shapefileName, bool onlySelectedFeatures=false, QProgressDialog *p=0) |
Calculate the true centroids, or 'center of mass' for a vector layer and write it to a new shape file. | |
bool | extent (QgsVectorLayer *layer, const QString &shapefileName, bool onlySelectedFeatures=false, QProgressDialog *p=0) |
Create a polygon based on the extent of all (selected) features and write it to a new shape file. | |
bool | buffer (QgsVectorLayer *layer, const QString &shapefileName, double bufferDistance, bool onlySelectedFeatures=false, bool dissolve=false, int bufferDistanceField=-1, QProgressDialog *p=0) |
Create buffers for a vector layer and write it to a new shape file. | |
bool | convexHull (QgsVectorLayer *layer, const QString &shapefileName, bool onlySelectedFeatures=false, int uniqueIdField=-1, QProgressDialog *p=0) |
Create convex hull(s) of a vector layer and write it to a new shape file. | |
bool | dissolve (QgsVectorLayer *layer, const QString &shapefileName, bool onlySelectedFeatures=false, int uniqueIdField=-1, QProgressDialog *p=0) |
Dissolve a vector layer and write it to a new shape file. | |
Private Member Functions | |
QList< double > | simpleMeasure (QgsGeometry *geometry) |
double | perimeterMeasure (QgsGeometry *geometry, QgsDistanceArea &measure) |
void | simplifyFeature (QgsFeature &f, QgsVectorFileWriter *vfw, double tolerance) |
Helper function to simplify an individual feature. | |
void | centroidFeature (QgsFeature &f, QgsVectorFileWriter *vfw) |
Helper function to get the cetroid of an individual feature. | |
void | bufferFeature (QgsFeature &f, int nProcessedFeatures, QgsVectorFileWriter *vfw, bool dissolve, QgsGeometry **dissolveGeometry, double bufferDistance, int bufferDistanceField) |
Helper function to buffer an individual feature. | |
void | convexFeature (QgsFeature &f, int nProcessedFeatures, QgsGeometry **dissolveGeometry) |
Helper function to get the convex hull of feature(s). | |
void | dissolveFeature (QgsFeature &f, int nProcessedFeatures, QgsGeometry **dissolveGeometry) |
Helper function to dissolve feature(s). |
Definition at line 37 of file qgsgeometryanalyzer.h.
bool QgsGeometryAnalyzer::simplify | ( | QgsVectorLayer * | layer, | |
const QString & | shapefileName, | |||
double | tolerance, | |||
bool | onlySelectedFeatures = false , |
|||
QProgressDialog * | p = 0 | |||
) |
Simplify vector layer using (a modified) Douglas-Peucker algorithm and write it to a new shape file.
layer | input vector layer | |
shapefileName | path to the output shp | |
tolerance | (level of simplification) | |
onlySelectedFeatures | if true, only selected features are considered, else all the features | |
p | progress dialog (or 0 if no progress dialog is to be shown) |
Definition at line 31 of file qgsgeometryanalyzer.cpp.
References QgsVectorLayer::dataProvider(), QgsVectorDataProvider::encoding(), QgsVectorLayer::featureAtId(), QgsVectorLayer::featureCount(), QgsVectorDataProvider::fields(), QgsVectorDataProvider::geometryType(), QgsVectorLayer::nextFeature(), QgsVectorLayer::pendingAllAttributesList(), QgsVectorLayer::select(), QgsVectorLayer::selectedFeaturesIds(), simplifyFeature(), and QgsMapLayer::srs().
bool QgsGeometryAnalyzer::centroids | ( | QgsVectorLayer * | layer, | |
const QString & | shapefileName, | |||
bool | onlySelectedFeatures = false , |
|||
QProgressDialog * | p = 0 | |||
) |
Calculate the true centroids, or 'center of mass' for a vector layer and write it to a new shape file.
layer | input vector layer | |
shapefileName | path to the output shp | |
onlySelectedFeatures | if true, only selected features are considered, else all the features | |
p | progress dialog (or 0 if no progress dialog is to be shown) |
Definition at line 145 of file qgsgeometryanalyzer.cpp.
References centroidFeature(), QgsVectorLayer::dataProvider(), QgsVectorDataProvider::encoding(), QgsVectorLayer::featureAtId(), QgsVectorLayer::featureCount(), QgsVectorDataProvider::fields(), QgsVectorLayer::nextFeature(), QgsVectorLayer::pendingAllAttributesList(), QgsVectorLayer::select(), QgsVectorLayer::selectedFeaturesIds(), QgsMapLayer::srs(), and QGis::WKBPoint.
bool QgsGeometryAnalyzer::extent | ( | QgsVectorLayer * | layer, | |
const QString & | shapefileName, | |||
bool | onlySelectedFeatures = false , |
|||
QProgressDialog * | p = 0 | |||
) |
Create a polygon based on the extent of all (selected) features and write it to a new shape file.
layer | input vector layer | |
shapefileName | path to the output shp | |
onlySelectedFeatures | if true, only selected features are considered, else all the features | |
p | progress dialog (or 0 if no progress dialog is to be shown) |
Definition at line 259 of file qgsgeometryanalyzer.cpp.
References QgsVectorLayer::boundingBoxOfSelected(), QgsVectorLayer::dataProvider(), QgsVectorDataProvider::encoding(), QgsMapLayer::extent(), QgsGeometry::fromRect(), QgsFeature::setAttributeMap(), QgsFeature::setGeometry(), QgsMapLayer::srs(), QGis::WKBPolygon, and QgsRectangle::xMinimum().
bool QgsGeometryAnalyzer::buffer | ( | QgsVectorLayer * | layer, | |
const QString & | shapefileName, | |||
double | bufferDistance, | |||
bool | onlySelectedFeatures = false , |
|||
bool | dissolve = false , |
|||
int | bufferDistanceField = -1 , |
|||
QProgressDialog * | p = 0 | |||
) |
Create buffers for a vector layer and write it to a new shape file.
layer | input vector layer | |
shapefileName | path to the output shp | |
bufferDistance | distance for buffering (if no buffer field is specified) | |
onlySelectedFeatures | if true, only selected features are considered, else all the features | |
dissolve | if true, merge all the buffers to a big multipolygon | |
bufferDistanceField | index of the attribute field that contains the buffer distance (or -1 if all features have the same buffer distance) | |
p | progress dialog (or 0 if no progress dialog is to be shown) |
Definition at line 747 of file qgsgeometryanalyzer.cpp.
References bufferFeature(), QgsVectorLayer::dataProvider(), dissolveFeature(), QgsVectorDataProvider::encoding(), QgsVectorLayer::featureAtId(), QgsVectorLayer::featureCount(), QgsVectorDataProvider::fields(), QgsVectorLayer::nextFeature(), QgsVectorLayer::pendingAllAttributesList(), QgsDebugMsg, QgsVectorLayer::select(), QgsVectorLayer::selectedFeaturesIds(), QgsFeature::setGeometry(), QgsMapLayer::srs(), QGis::WKBMultiPolygon, and QGis::WKBPolygon.
bool QgsGeometryAnalyzer::convexHull | ( | QgsVectorLayer * | layer, | |
const QString & | shapefileName, | |||
bool | onlySelectedFeatures = false , |
|||
int | uniqueIdField = -1 , |
|||
QProgressDialog * | p = 0 | |||
) |
Create convex hull(s) of a vector layer and write it to a new shape file.
layer | input vector layer | |
shapefileName | path to the output shp | |
onlySelectedFeatures | if true, only selected features are considered, else all the features | |
uniqueIdField | index of the attribute field that contains the unique convex hull id (or -1 if all features have the same buffer distance) | |
p | progress dialog (or 0 if no progress dialog is to be shown) |
Definition at line 380 of file qgsgeometryanalyzer.cpp.
References convexFeature(), QgsGeometry::convexHull(), QgsVectorLayer::dataProvider(), dissolveFeature(), QgsVectorDataProvider::encoding(), QgsVectorLayer::featureAtId(), QgsVectorLayer::featureCount(), QgsVectorLayer::nextFeature(), QgsVectorLayer::pendingAllAttributesList(), QgsDebugMsg, QgsVectorLayer::select(), QgsVectorLayer::selectedFeaturesIds(), QgsFeature::setAttributeMap(), QgsFeature::setGeometry(), simpleMeasure(), QgsMapLayer::srs(), and QGis::WKBPolygon.
bool QgsGeometryAnalyzer::dissolve | ( | QgsVectorLayer * | layer, | |
const QString & | shapefileName, | |||
bool | onlySelectedFeatures = false , |
|||
int | uniqueIdField = -1 , |
|||
QProgressDialog * | p = 0 | |||
) |
Dissolve a vector layer and write it to a new shape file.
layer | input vector layer | |
shapefileName | path to the output shp | |
onlySelectedFeatures | if true, only selected features are considered, else all the features | |
uniqueIdField | index of the attribute field that contains the unique id to dissolve on (or -1 if all features should be dissolved together) | |
p | progress dialog (or 0 if no progress dialog is to be shown) |
Definition at line 590 of file qgsgeometryanalyzer.cpp.
References QgsVectorLayer::dataProvider(), dissolveFeature(), QgsVectorDataProvider::encoding(), QgsVectorLayer::featureAtId(), QgsVectorLayer::featureCount(), QgsVectorDataProvider::fields(), QgsVectorDataProvider::geometryType(), QgsVectorLayer::nextFeature(), QgsVectorLayer::pendingAllAttributesList(), QgsVectorLayer::select(), QgsVectorLayer::selectedFeaturesIds(), QgsFeature::setAttributeMap(), QgsFeature::setGeometry(), and QgsMapLayer::srs().
QList< double > QgsGeometryAnalyzer::simpleMeasure | ( | QgsGeometry * | geometry | ) | [private] |
Definition at line 329 of file qgsgeometryanalyzer.cpp.
References QgsGeometry::asPoint(), QgsDistanceArea::measure(), perimeterMeasure(), QGis::Polygon, QgsGeometry::type(), QGis::WKBPoint, QgsGeometry::wkbType(), QgsPoint::x(), and QgsPoint::y().
Referenced by convexHull().
double QgsGeometryAnalyzer::perimeterMeasure | ( | QgsGeometry * | geometry, | |
QgsDistanceArea & | measure | |||
) | [private] |
Definition at line 352 of file qgsgeometryanalyzer.cpp.
References QgsGeometry::asMultiPolygon(), QgsGeometry::asPolygon(), QgsGeometry::fromPolyline(), QgsGeometry::isMultipart(), and QgsDistanceArea::measure().
Referenced by simpleMeasure().
void QgsGeometryAnalyzer::simplifyFeature | ( | QgsFeature & | f, | |
QgsVectorFileWriter * | vfw, | |||
double | tolerance | |||
) | [private] |
Helper function to simplify an individual feature.
Definition at line 122 of file qgsgeometryanalyzer.cpp.
References QgsVectorFileWriter::addFeature(), QgsFeature::attributeMap(), QgsFeature::geometry(), QgsFeature::setAttributeMap(), QgsFeature::setGeometry(), and QgsGeometry::simplify().
Referenced by simplify().
void QgsGeometryAnalyzer::centroidFeature | ( | QgsFeature & | f, | |
QgsVectorFileWriter * | vfw | |||
) | [private] |
Helper function to get the cetroid of an individual feature.
Definition at line 236 of file qgsgeometryanalyzer.cpp.
References QgsVectorFileWriter::addFeature(), QgsFeature::attributeMap(), QgsGeometry::centroid(), QgsFeature::geometry(), QgsFeature::setAttributeMap(), and QgsFeature::setGeometry().
Referenced by centroids().
void QgsGeometryAnalyzer::bufferFeature | ( | QgsFeature & | f, | |
int | nProcessedFeatures, | |||
QgsVectorFileWriter * | vfw, | |||
bool | dissolve, | |||
QgsGeometry ** | dissolveGeometry, | |||
double | bufferDistance, | |||
int | bufferDistanceField | |||
) | [private] |
Helper function to buffer an individual feature.
Definition at line 854 of file qgsgeometryanalyzer.cpp.
References QgsVectorFileWriter::addFeature(), QgsFeature::attributeMap(), QgsGeometry::buffer(), QgsGeometry::combine(), QgsFeature::geometry(), QgsFeature::setAttributeMap(), and QgsFeature::setGeometry().
Referenced by buffer().
void QgsGeometryAnalyzer::convexFeature | ( | QgsFeature & | f, | |
int | nProcessedFeatures, | |||
QgsGeometry ** | dissolveGeometry | |||
) | [private] |
Helper function to get the convex hull of feature(s).
Definition at line 564 of file qgsgeometryanalyzer.cpp.
References QgsGeometry::combine(), QgsGeometry::convexHull(), and QgsFeature::geometry().
Referenced by convexHull().
void QgsGeometryAnalyzer::dissolveFeature | ( | QgsFeature & | f, | |
int | nProcessedFeatures, | |||
QgsGeometry ** | dissolveGeometry | |||
) | [private] |
Helper function to dissolve feature(s).
Definition at line 724 of file qgsgeometryanalyzer.cpp.
References QgsGeometry::asWkb(), QgsGeometry::combine(), QgsFeature::geometry(), and QgsGeometry::wkbSize().
Referenced by buffer(), convexHull(), and dissolve().