QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
QgsTransectSample Class Reference

A class for the creation of transect sample lines based on a set of strata polygons and baselines. More...

#include <qgstransectsample.h>

Collaboration diagram for QgsTransectSample:
Collaboration graph
[legend]

Public Types

enum  DistanceUnits { Meters, StrataUnits }

Public Member Functions

 QgsTransectSample (QgsVectorLayer *strataLayer, QString strataIdAttribute, QString minDistanceAttribute, QString nPointsAttribute, DistanceUnits minDistUnits, QgsVectorLayer *baselineLayer, bool shareBaseline, QString baselineStrataId, const QString &outputPointLayer, const QString &outputLineLayer, const QString &usedBaselineLayer, double minTransectLength=0.0)
 ~QgsTransectSample ()
int createSample (QProgressDialog *pd)

Private Member Functions

 QgsTransectSample ()
QgsGeometryfindBaselineGeometry (QVariant strataId)

Static Private Member Functions

static bool otherTransectWithinDistance (QgsGeometry *geom, double minDistLayerUnit, double minDistance, QgsSpatialIndex &sIndex, const QMap< QgsFeatureId, QgsGeometry * > &lineFeatureMap, QgsDistanceArea &da)
 Returns true if another transect is within the specified minimum distance.
static bool closestSegmentPoints (QgsGeometry &g1, QgsGeometry &g2, double &dist, QgsPoint &pt1, QgsPoint &pt2)
 Finds the closest points between two line segments.
static QgsGeometryclosestMultilineElement (const QgsPoint &pt, QgsGeometry *multiLine)
 Returns a copy of the multiline element closest to a point (caller takes ownership)
static QgsGeometryclipBufferLine (QgsGeometry *stratumGeom, QgsGeometry *clippedBaseline, double tolerance)
 Returns clipped buffer line.

Private Attributes

QgsVectorLayermStrataLayer
QString mStrataIdAttribute
QString mMinDistanceAttribute
QString mNPointsAttribute
QgsVectorLayermBaselineLayer
bool mShareBaseline
QString mBaselineStrataId
QString mOutputPointLayer
QString mOutputLineLayer
QString mUsedBaselineLayer
DistanceUnits mMinDistanceUnits
double mMinTransectLength

Detailed Description

A class for the creation of transect sample lines based on a set of strata polygons and baselines.

Definition at line 16 of file qgstransectsample.h.

Member Enumeration Documentation

Enumerator:
Meters 
StrataUnits 

Definition at line 20 of file qgstransectsample.h.

Constructor & Destructor Documentation

QgsTransectSample::QgsTransectSample ( QgsVectorLayer strataLayer,
QString  strataIdAttribute,
QString  minDistanceAttribute,
QString  nPointsAttribute,
DistanceUnits  minDistUnits,
QgsVectorLayer baselineLayer,
bool  shareBaseline,
QString  baselineStrataId,
const QString &  outputPointLayer,
const QString &  outputLineLayer,
const QString &  usedBaselineLayer,
double  minTransectLength = 0.0 
)

Definition at line 15 of file qgstransectsample.cpp.

QgsTransectSample::~QgsTransectSample ( )

Definition at line 28 of file qgstransectsample.cpp.

QgsTransectSample::QgsTransectSample ( )
private

Definition at line 24 of file qgstransectsample.cpp.

Member Function Documentation

QgsGeometry * QgsTransectSample::clipBufferLine ( QgsGeometry stratumGeom,
QgsGeometry clippedBaseline,
double  tolerance 
)
staticprivate

Returns clipped buffer line.

Iteratively applies reduced tolerances if the result is not a single line

Parameters
stratumGeomstratum polygon
clippedBaselinebase line geometry clipped to the stratum
tolerancebuffer distance (in layer units)
Returns
clipped buffer line or 0 in case of error

Definition at line 538 of file qgstransectsample.cpp.

References QgsGeometry::asMultiPolygon(), QgsGeometry::asPolygon(), QgsGeometry::buffer(), QgsGeometry::fromMultiPolyline(), QgsGeometry::fromPolygon(), QgsGeometry::intersection(), QgsGeometry::intersects(), QgsGeometry::isMultipart(), QGis::Line, size, QgsGeometry::type(), QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QgsGeometry::wkbType(), and QGis::WKBUnknown.

Referenced by createSample().

QgsGeometry * QgsTransectSample::closestMultilineElement ( const QgsPoint pt,
QgsGeometry multiLine 
)
staticprivate

Returns a copy of the multiline element closest to a point (caller takes ownership)

Definition at line 503 of file qgstransectsample.cpp.

References QgsGeometry::asMultiPolyline(), QgsGeometry::distance(), QgsGeometry::fromPoint(), QgsGeometry::fromPolyline(), QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, and QgsGeometry::wkbType().

Referenced by createSample().

bool QgsTransectSample::closestSegmentPoints ( QgsGeometry g1,
QgsGeometry g2,
double &  dist,
QgsPoint pt1,
QgsPoint pt2 
)
staticprivate

Finds the closest points between two line segments.

Parameters
g1first input geometry. Must be a linestring with two vertices
g2second input geometry. Must be a linestring with two vertices
distout: distance between the segments
pt1out: closest point on first geometry
pt2out: closest point on secont geometry
Returns
true in case of success

Definition at line 381 of file qgstransectsample.cpp.

References QgsGeometry::asPolyline(), qgsDoubleNear(), QgsPoint::setX(), QgsPoint::setY(), QgsPoint::sqrDist(), QgsPoint::sqrDistToSegment(), QGis::WKBLineString, QGis::WKBLineString25D, QgsGeometry::wkbType(), QgsPoint::x(), and QgsPoint::y().

Referenced by otherTransectWithinDistance().

int QgsTransectSample::createSample ( QProgressDialog *  pd)

Definition at line 32 of file qgstransectsample.cpp.

References QgsVectorFileWriter::addFeature(), QgsFields::append(), QgsGeometry::asPoint(), QgsFeature::attribute(), QgsDistanceArea::bearing(), clipBufferLine(), closestMultilineElement(), QgsGeometry::closestSegmentWithContext(), QgsMapLayer::crs(), QGis::DecimalDegrees, QgsGeometry::distance(), QgsCoordinateReferenceSystem::EpsgCrsId, QgsVectorLayer::featureCount(), QgsFields::field(), findBaselineGeometry(), QgsGeometry::fromPolyline(), QgsFeature::geometry(), QgsFeature::geometryAndOwnership(), QgsVectorLayer::getFeatures(), QgsVectorFileWriter::hasError(), QgsSpatialIndex::insertFeature(), QgsGeometry::interpolate(), QgsGeometry::intersection(), QgsMapLayer::isValid(), QgsGeometry::length(), M_PI, QgsCoordinateReferenceSystem::mapUnits(), mBaselineLayer, MD_RAND_MAX, QgsDistanceArea::measure(), Meters, mMinDistanceAttribute, mMinDistanceUnits, mMinTransectLength, mNPointsAttribute, mOutputLineLayer, mOutputPointLayer, mStrataIdAttribute, mStrataLayer, mt_rand(), mt_srand(), mUsedBaselineLayer, QgsFeatureIterator::nextFeature(), QgsVectorFileWriter::NoError, otherTransectWithinDistance(), QgsVectorLayer::pendingFields(), QgsFeature::setAttribute(), QgsDistanceArea::setEllipsoidalMode(), QgsFeature::setGeometry(), QgsDistanceArea::setSourceCrs(), QgsFeatureRequest::setSubsetOfAttributes(), QgsCoordinateReferenceSystem::srsid(), QgsField::type(), QGis::WKBLineString, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBPoint, QgsGeometry::wkbType(), QGis::WKBUnknown, QgsPoint::x(), and QgsPoint::y().

QgsGeometry * QgsTransectSample::findBaselineGeometry ( QVariant  strataId)
private
bool QgsTransectSample::otherTransectWithinDistance ( QgsGeometry geom,
double  minDistLayerUnit,
double  minDistance,
QgsSpatialIndex sIndex,
const QMap< QgsFeatureId, QgsGeometry * > &  lineFeatureMap,
QgsDistanceArea da 
)
staticprivate

Returns true if another transect is within the specified minimum distance.

Definition at line 342 of file qgstransectsample.cpp.

References QgsGeometry::boundingBox(), QgsGeometry::buffer(), closestSegmentPoints(), QgsSpatialIndex::intersects(), and QgsDistanceArea::measureLine().

Referenced by createSample().

Member Data Documentation

QgsVectorLayer* QgsTransectSample::mBaselineLayer
private

Definition at line 47 of file qgstransectsample.h.

Referenced by createSample(), and findBaselineGeometry().

QString QgsTransectSample::mBaselineStrataId
private

Definition at line 49 of file qgstransectsample.h.

Referenced by findBaselineGeometry().

QString QgsTransectSample::mMinDistanceAttribute
private

Definition at line 44 of file qgstransectsample.h.

Referenced by createSample().

DistanceUnits QgsTransectSample::mMinDistanceUnits
private

Definition at line 55 of file qgstransectsample.h.

Referenced by createSample().

double QgsTransectSample::mMinTransectLength
private

Definition at line 57 of file qgstransectsample.h.

Referenced by createSample().

QString QgsTransectSample::mNPointsAttribute
private

Definition at line 45 of file qgstransectsample.h.

Referenced by createSample().

QString QgsTransectSample::mOutputLineLayer
private

Definition at line 52 of file qgstransectsample.h.

Referenced by createSample().

QString QgsTransectSample::mOutputPointLayer
private

Definition at line 51 of file qgstransectsample.h.

Referenced by createSample().

bool QgsTransectSample::mShareBaseline
private

Definition at line 48 of file qgstransectsample.h.

Referenced by findBaselineGeometry().

QString QgsTransectSample::mStrataIdAttribute
private

Definition at line 43 of file qgstransectsample.h.

Referenced by createSample().

QgsVectorLayer* QgsTransectSample::mStrataLayer
private

Definition at line 42 of file qgstransectsample.h.

Referenced by createSample().

QString QgsTransectSample::mUsedBaselineLayer
private

Definition at line 53 of file qgstransectsample.h.

Referenced by createSample().


The documentation for this class was generated from the following files: