本文整理汇总了C++中QgsMultiPolyline::append方法的典型用法代码示例。如果您正苦于以下问题:C++ QgsMultiPolyline::append方法的具体用法?C++ QgsMultiPolyline::append怎么用?C++ QgsMultiPolyline::append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QgsMultiPolyline
的用法示例。
在下文中一共展示了QgsMultiPolyline::append方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
QgsGeometry *QgsRubberBand::asGeometry()
{
QgsGeometry *geom = NULL;
switch ( mGeometryType )
{
case QGis::Polygon:
{
QgsPolygon polygon;
QList< QList<QgsPoint> >::const_iterator it = mPoints.constBegin();
for ( ; it != mPoints.constEnd(); ++it )
{
polygon.append( getPolyline( *it ) );
}
geom = QgsGeometry::fromPolygon( polygon );
break;
}
case QGis::Point:
{
QgsMultiPoint multiPoint;
QList< QList<QgsPoint> >::const_iterator it = mPoints.constBegin();
for ( ; it != mPoints.constEnd(); ++it )
{
multiPoint += getPolyline( *it );
}
geom = QgsGeometry::fromMultiPoint( multiPoint );
break;
}
case QGis::Line:
default:
{
if ( mPoints.size() > 0 )
{
if ( mPoints.size() > 1 )
{
QgsMultiPolyline multiPolyline;
QList< QList<QgsPoint> >::const_iterator it = mPoints.constBegin();
for ( ; it != mPoints.constEnd(); ++it )
{
multiPolyline.append( getPolyline( *it ) );
}
geom = QgsGeometry::fromMultiPolyline( multiPolyline );
}
else
{
geom = QgsGeometry::fromPolyline( getPolyline( mPoints[0] ) );
}
}
break;
}
}
return geom;
}
示例2: clipBufferLine
QgsGeometry* QgsTransectSample::clipBufferLine( const QgsGeometry& stratumGeom, QgsGeometry* clippedBaseline, double tolerance )
{
if ( !stratumGeom || !clippedBaseline || clippedBaseline->wkbType() == QgsWkbTypes::Unknown )
{
return nullptr;
}
QgsGeometry usedBaseline = *clippedBaseline;
if ( mBaselineSimplificationTolerance >= 0 )
{
//int verticesBefore = usedBaseline->asMultiPolyline().count();
usedBaseline = clippedBaseline->simplify( mBaselineSimplificationTolerance );
if ( usedBaseline.isEmpty() )
{
return nullptr;
}
//int verticesAfter = usedBaseline->asMultiPolyline().count();
//debug: write to file
/*QgsVectorFileWriter debugWriter( "/tmp/debug.shp", "utf-8", QgsFields(), QgsWkbTypes::LineString, &( mStrataLayer->crs() ) );
QgsFeature debugFeature; debugFeature.setGeometry( usedBaseline );
debugWriter.addFeature( debugFeature );*/
}
double currentBufferDist = tolerance;
int maxLoops = 10;
for ( int i = 0; i < maxLoops; ++i )
{
//loop with tolerance: create buffer, convert buffer to line, clip line by stratum, test if result is (single) line
QgsGeometry clipBaselineBuffer = usedBaseline.buffer( currentBufferDist, 8 );
if ( clipBaselineBuffer.isEmpty() )
{
continue;
}
//it is also possible that clipBaselineBuffer is a multipolygon
QgsGeometry bufferLine; //buffer line or multiline
QgsGeometry bufferLineClipped;
QgsMultiPolyline mpl;
if ( clipBaselineBuffer.isMultipart() )
{
QgsMultiPolygon bufferMultiPolygon = clipBaselineBuffer.asMultiPolygon();
if ( bufferMultiPolygon.size() < 1 )
{
continue;
}
for ( int j = 0; j < bufferMultiPolygon.size(); ++j )
{
int size = bufferMultiPolygon.at( j ).size();
for ( int k = 0; k < size; ++k )
{
mpl.append( bufferMultiPolygon.at( j ).at( k ) );
}
}
bufferLine = QgsGeometry::fromMultiPolyline( mpl );
}
else
{
QgsPolygon bufferPolygon = clipBaselineBuffer.asPolygon();
if ( bufferPolygon.size() < 1 )
{
continue;
}
int size = bufferPolygon.size();
mpl.reserve( size );
for ( int j = 0; j < size; ++j )
{
mpl.append( bufferPolygon[j] );
}
bufferLine = QgsGeometry::fromMultiPolyline( mpl );
}
bufferLineClipped = bufferLine.intersection( stratumGeom );
if ( bufferLineClipped.isEmpty() && bufferLineClipped.type() == QgsWkbTypes::LineGeometry )
{
//if stratumGeom is a multipolygon, bufferLineClipped must intersect each part
bool bufferLineClippedIntersectsStratum = true;
if ( stratumGeom.wkbType() == QgsWkbTypes::MultiPolygon || stratumGeom.wkbType() == QgsWkbTypes::MultiPolygon25D )
{
QVector<QgsPolygon> multiPoly = stratumGeom.asMultiPolygon();
QVector<QgsPolygon>::const_iterator multiIt = multiPoly.constBegin();
for ( ; multiIt != multiPoly.constEnd(); ++multiIt )
{
QgsGeometry poly = QgsGeometry::fromPolygon( *multiIt );
if ( !poly.intersects( bufferLineClipped ) )
{
bufferLineClippedIntersectsStratum = false;
break;
}
}
}
if ( bufferLineClippedIntersectsStratum )
{
return new QgsGeometry( bufferLineClipped );
}
}
//.........这里部分代码省略.........
示例3: clipBufferLine
QgsGeometry* QgsTransectSample::clipBufferLine( QgsGeometry* stratumGeom, QgsGeometry* clippedBaseline, double tolerance )
{
if ( !stratumGeom || !clippedBaseline || clippedBaseline->wkbType() == QGis::WKBUnknown )
{
return 0;
}
double currentBufferDist = tolerance;
int maxLoops = 10;
for ( int i = 0; i < maxLoops; ++i )
{
//loop with tolerance: create buffer, convert buffer to line, clip line by stratum, test if result is (single) line
QgsGeometry* clipBaselineBuffer = clippedBaseline->buffer( currentBufferDist, 8 );
if ( !clipBaselineBuffer )
{
delete clipBaselineBuffer;
continue;
}
//it is also possible that clipBaselineBuffer is a multipolygon
QgsGeometry* bufferLine = 0; //buffer line or multiline
QgsGeometry* bufferLineClipped = 0;
QgsMultiPolyline mpl;
if ( clipBaselineBuffer->isMultipart() )
{
QgsMultiPolygon bufferMultiPolygon = clipBaselineBuffer->asMultiPolygon();
if ( bufferMultiPolygon.size() < 1 )
{
delete clipBaselineBuffer;
continue;
}
for ( int j = 0; j < bufferMultiPolygon.size(); ++j )
{
int size = bufferMultiPolygon.at( j ).size();
for ( int k = 0; k < size; ++k )
{
mpl.append( bufferMultiPolygon.at( j ).at( k ) );
}
}
bufferLine = QgsGeometry::fromMultiPolyline( mpl );
}
else
{
QgsPolygon bufferPolygon = clipBaselineBuffer->asPolygon();
if ( bufferPolygon.size() < 1 )
{
delete clipBaselineBuffer;
continue;
}
int size = bufferPolygon.size();
for ( int j = 0; j < size; ++j )
{
mpl.append( bufferPolygon[j] );
}
bufferLine = QgsGeometry::fromMultiPolyline( mpl );
}
bufferLineClipped = bufferLine->intersection( stratumGeom );
if ( bufferLineClipped && bufferLineClipped->type() == QGis::Line )
{
//if stratumGeom is a multipolygon, bufferLineClipped must intersect each part
bool bufferLineClippedIntersectsStratum = true;
if ( stratumGeom->wkbType() == QGis::WKBMultiPolygon || stratumGeom->wkbType() == QGis::WKBMultiPolygon25D )
{
QVector<QgsPolygon> multiPoly = stratumGeom->asMultiPolygon();
QVector<QgsPolygon>::const_iterator multiIt = multiPoly.constBegin();
for ( ; multiIt != multiPoly.constEnd(); ++multiIt )
{
QgsGeometry* poly = QgsGeometry::fromPolygon( *multiIt );
if ( !poly->intersects( bufferLineClipped ) )
{
bufferLineClippedIntersectsStratum = false;
delete poly;
break;
}
delete poly;
}
}
if ( bufferLineClippedIntersectsStratum )
{
return bufferLineClipped;
}
}
delete bufferLineClipped; delete clipBaselineBuffer; delete bufferLine;
currentBufferDist /= 2;
}
return 0; //no solution found even with reduced tolerances
}