本文整理汇总了C++中QgsPointV2函数的典型用法代码示例。如果您正苦于以下问题:C++ QgsPointV2函数的具体用法?C++ QgsPointV2怎么用?C++ QgsPointV2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QgsPointV2函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: numPoints
QgsRectangle QgsCircularString::calculateBoundingBox() const
{
QgsRectangle bbox;
int nPoints = numPoints();
for ( int i = 0; i < ( nPoints - 2 ) ; i += 2 )
{
if ( i == 0 )
{
bbox = segmentBoundingBox( QgsPointV2( mX[i], mY[i] ), QgsPointV2( mX[i + 1], mY[i + 1] ), QgsPointV2( mX[i + 2], mY[i + 2] ) );
}
else
{
QgsRectangle segmentBox = segmentBoundingBox( QgsPointV2( mX[i], mY[i] ), QgsPointV2( mX[i + 1], mY[i + 1] ), QgsPointV2( mX[i + 2], mY[i + 2] ) );
bbox.combineExtentWith( segmentBox );
}
}
if ( nPoints > 0 && nPoints % 2 == 0 )
{
if ( nPoints == 2 )
{
bbox.combineExtentWith( mX[ 0 ], mY[ 0 ] );
}
bbox.combineExtentWith( mX[ nPoints - 1 ], mY[ nPoints - 1 ] );
}
return bbox;
}
开发者ID:cayetanobv,项目名称:QGIS,代码行数:27,代码来源:qgscircularstring.cpp
示例2: toMapCoordinates
void QgsMapToolAddCircularString::activate()
{
if ( mParentTool )
{
mParentTool->deleteTempRubberBand();
if ( mPoints.isEmpty() )
{
// if the parent tool has a curve, use its last point as the first point in this curve
const QgsCompoundCurveV2* compoundCurve = mParentTool->captureCurve();
if ( compoundCurve && compoundCurve->nCurves() > 0 )
{
const QgsCurveV2* curve = compoundCurve->curveAt( compoundCurve->nCurves() - 1 );
if ( curve )
{
//mParentTool->captureCurve() is in layer coordinates, but we need map coordinates
QgsPointV2 endPointLayerCoord = curve->endPoint();
QgsPoint mapPoint = toMapCoordinates( mCanvas->currentLayer(), QgsPoint( endPointLayerCoord.x(), endPointLayerCoord.y() ) );
mPoints.append( QgsPointV2( mapPoint ) );
if ( !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand(( mode() == CapturePolygon ) ? Qgis::Polygon : Qgis::Line, true );
mTempRubberBand->show();
}
QgsCircularStringV2* c = new QgsCircularStringV2();
QgsPointSequenceV2 rubberBandPoints = mPoints;
rubberBandPoints.append( QgsPointV2( mapPoint ) );
c->setPoints( rubberBandPoints );
mTempRubberBand->setGeometry( c );
}
}
}
}
QgsMapToolCapture::activate();
}
开发者ID:Zakui,项目名称:QGIS,代码行数:34,代码来源:qgsmaptooladdcircularstring.cpp
示例3: QgsLineString
void TestQgsGeometryUtils::testDistanceToVertex()
{
//test with linestring
QgsLineString* outerRing1 = new QgsLineString();
outerRing1->setPoints( QList<QgsPointV2>() << QgsPointV2( 1, 1 ) << QgsPointV2( 1, 2 ) << QgsPointV2( 2, 2 ) << QgsPointV2( 2, 1 ) << QgsPointV2( 1, 1 ) );
QCOMPARE( QgsGeometryUtils::distanceToVertex( *outerRing1, QgsVertexId( 0, 0, 0 ) ), 0.0 );
QCOMPARE( QgsGeometryUtils::distanceToVertex( *outerRing1, QgsVertexId( 0, 0, 1 ) ), 1.0 );
QCOMPARE( QgsGeometryUtils::distanceToVertex( *outerRing1, QgsVertexId( 0, 0, 2 ) ), 2.0 );
QCOMPARE( QgsGeometryUtils::distanceToVertex( *outerRing1, QgsVertexId( 0, 0, 3 ) ), 3.0 );
QCOMPARE( QgsGeometryUtils::distanceToVertex( *outerRing1, QgsVertexId( 0, 0, 4 ) ), 4.0 );
QCOMPARE( QgsGeometryUtils::distanceToVertex( *outerRing1, QgsVertexId( 0, 0, 5 ) ), -1.0 );
QCOMPARE( QgsGeometryUtils::distanceToVertex( *outerRing1, QgsVertexId( 0, 1, 1 ) ), -1.0 );
//test with polygon
QgsPolygonV2 polygon1;
polygon1.setExteriorRing( outerRing1 );
QCOMPARE( QgsGeometryUtils::distanceToVertex( polygon1, QgsVertexId( 0, 0, 0 ) ), 0.0 );
QCOMPARE( QgsGeometryUtils::distanceToVertex( polygon1, QgsVertexId( 0, 0, 1 ) ), 1.0 );
QCOMPARE( QgsGeometryUtils::distanceToVertex( polygon1, QgsVertexId( 0, 0, 2 ) ), 2.0 );
QCOMPARE( QgsGeometryUtils::distanceToVertex( polygon1, QgsVertexId( 0, 0, 3 ) ), 3.0 );
QCOMPARE( QgsGeometryUtils::distanceToVertex( polygon1, QgsVertexId( 0, 0, 4 ) ), 4.0 );
QCOMPARE( QgsGeometryUtils::distanceToVertex( polygon1, QgsVertexId( 0, 0, 5 ) ), -1.0 );
QCOMPARE( QgsGeometryUtils::distanceToVertex( polygon1, QgsVertexId( 0, 1, 1 ) ), -1.0 );
//test with point
QgsPointV2 point( 1, 2 );
QCOMPARE( QgsGeometryUtils::distanceToVertex( point, QgsVertexId( 0, 0, 0 ) ), 0.0 );
QCOMPARE( QgsGeometryUtils::distanceToVertex( point, QgsVertexId( 0, 0, 1 ) ), -1.0 );
}
开发者ID:Gustry,项目名称:QGIS,代码行数:29,代码来源:testqgsgeometryutils.cpp
示例4: QgsPointV2
void QgsMapToolCircularStringRadius::recalculateTempRubberBand( const QgsPoint& mousePosition )
{
QList<QgsPointV2> rubberBandPoints;
if ( !( mPoints.size() % 2 ) )
{
//recalculate midpoint on circle segment
QgsPointV2 midPoint;
if ( !QgsGeometryUtils::segmentMidPoint( mPoints.at( mPoints.size() - 2 ), mTemporaryEndPoint, midPoint, mRadius,
QgsPointV2( mousePosition ) ) )
{
return;
}
mPoints.replace( mPoints.size() - 1, midPoint );
rubberBandPoints.append( mPoints.at( mPoints.size() - 2 ) );
rubberBandPoints.append( mPoints.last() );
rubberBandPoints.append( mTemporaryEndPoint );
}
else
{
rubberBandPoints.append( mPoints.last() );
rubberBandPoints.append( QgsPointV2( mousePosition ) );
}
QgsCircularStringV2* cString = new QgsCircularStringV2();
cString->setPoints( rubberBandPoints );
delete mTempRubberBand;
mTempRubberBand = createGeometryRubberBand(( mode() == CapturePolygon ) ? QGis::Polygon : QGis::Line, true );
mTempRubberBand->setGeometry( cString );
mTempRubberBand->show();
}
开发者ID:Naisha634,项目名称:QGIS,代码行数:29,代码来源:qgsmaptoolcircularstringradius.cpp
示例5: QgsPointV2
void QgsCircularString::insertVertexBetween( int after, int before, int pointOnCircle )
{
double xAfter = mX.at( after );
double yAfter = mY.at( after );
double xBefore = mX.at( before );
double yBefore = mY.at( before );
double xOnCircle = mX.at( pointOnCircle );
double yOnCircle = mY.at( pointOnCircle );
double radius, centerX, centerY;
QgsGeometryUtils::circleCenterRadius( QgsPointV2( xAfter, yAfter ), QgsPointV2( xBefore, yBefore ), QgsPointV2( xOnCircle, yOnCircle ), radius, centerX, centerY );
double x = ( xAfter + xBefore ) / 2.0;
double y = ( yAfter + yBefore ) / 2.0;
QgsPointV2 newVertex = QgsGeometryUtils::pointOnLineWithDistance( QgsPointV2( centerX, centerY ), QgsPointV2( x, y ), radius );
mX.insert( before, newVertex.x() );
mY.insert( before, newVertex.y() );
if ( is3D() )
{
mZ.insert( before, ( mZ[after] + mZ[before] ) / 2.0 );
}
if ( isMeasure() )
{
mM.insert( before, ( mM[after] + mM[before] ) / 2.0 );
}
clearCache();
}
开发者ID:cayetanobv,项目名称:QGIS,代码行数:29,代码来源:qgscircularstring.cpp
示例6: circleCenterRadius
double QgsGeometryUtils::circleLength( double x1, double y1, double x2, double y2, double x3, double y3 )
{
double centerX, centerY, radius;
circleCenterRadius( QgsPointV2( x1, y1 ), QgsPointV2( x2, y2 ), QgsPointV2( x3, y3 ), radius, centerX, centerY );
double length = M_PI / 180.0 * radius * sweepAngle( centerX, centerY, x1, y1, x2, y2, x3, y3 );
if ( length < 0 )
{
length = -length;
}
return length;
}
开发者ID:spatialthoughts,项目名称:QGIS,代码行数:11,代码来源:qgsgeometryutils.cpp
示例7: QgsMapToolAddCircularString
QgsMapToolCircularStringRadius::QgsMapToolCircularStringRadius( QgsMapToolCapture* parentTool, QgsMapCanvas* canvas, CaptureMode mode )
: QgsMapToolAddCircularString( parentTool, canvas, mode ),
mTemporaryEndPoint( QgsPointV2() ),
mRadius( 0.0 ),
mRadiusSpinBox( nullptr )
{
}
开发者ID:Naisha634,项目名称:QGIS,代码行数:8,代码来源:qgsmaptoolcircularstringradius.cpp
示例8: vertexCount
QgsPointV2 QgsAbstractGeometryV2::centroid() const
{
// http://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon
// Pick the first ring of first part for the moment
int n = vertexCount( 0, 0 );
if ( n == 1 )
{
return vertexAt( QgsVertexId( 0, 0, 0 ) );
}
double A = 0.;
double Cx = 0.;
double Cy = 0.;
int i = 0, j = 1;
if ( vertexAt( QgsVertexId( 0, 0, 0 ) ) != vertexAt( QgsVertexId( 0, 0, n - 1 ) ) )
{
i = n - 1;
j = 0;
}
for ( ; j < n; i = j++ )
{
QgsPointV2 vi = vertexAt( QgsVertexId( 0, 0, i ) );
QgsPointV2 vj = vertexAt( QgsVertexId( 0, 0, j ) );
double d = vi.x() * vj.y() - vj.x() * vi.y();
A += d;
Cx += ( vi.x() + vj.x() ) * d;
Cy += ( vi.y() + vj.y() ) * d;
}
if ( A < 1E-12 )
{
Cx = Cy = 0.;
for ( int i = 0; i < n - 1; ++i )
{
QgsPointV2 vi = vertexAt( QgsVertexId( 0, 0, i ) );
Cx += vi.x();
Cy += vi.y();
}
return QgsPointV2( Cx / ( n - 1 ), Cy / ( n - 1 ) );
}
else
{
return QgsPointV2( Cx / ( 3. * A ), Cy / ( 3. * A ) );
}
}
开发者ID:nicanor-b,项目名称:QGIS,代码行数:46,代码来源:qgsabstractgeometryv2.cpp
示例9: QgsPointV2
QgsPointV2 QgsLineStringV2::endPoint() const
{
if ( numPoints() < 1 )
{
return QgsPointV2();
}
return pointN( numPoints() - 1 );
}
开发者ID:saberraz,项目名称:QGIS,代码行数:8,代码来源:qgslinestringv2.cpp
示例10: p
bool QgsNodeEditorModel::setData( const QModelIndex& index, const QVariant& value, int role )
{
if ( !index.isValid() || role != Qt::EditRole )
{
return false;
}
if ( index.row() >= mSelectedFeature->vertexMap().count() )
{
return false;
}
double x = ( index.column() == 0 ? value.toDouble() : mSelectedFeature->vertexMap().at( index.row() )->point().x() );
double y = ( index.column() == 1 ? value.toDouble() : mSelectedFeature->vertexMap().at( index.row() )->point().y() );
if ( index.column() == mRCol ) // radius modified
{
if ( index.row() == 0 || index.row() >= mSelectedFeature->vertexMap().count() - 1 )
return false;
double r = value.toDouble();
double x1 = mSelectedFeature->vertexMap().at( index.row() - 1 )->point().x();
double y1 = mSelectedFeature->vertexMap().at( index.row() - 1 )->point().y();
double x2 = x;
double y2 = y;
double x3 = mSelectedFeature->vertexMap().at( index.row() + 1 )->point().x();
double y3 = mSelectedFeature->vertexMap().at( index.row() + 1 )->point().y();
QgsPointV2 result;
if ( QgsGeometryUtils::segmentMidPoint( QgsPointV2( x1, y1 ), QgsPointV2( x3, y3 ), result, r, QgsPointV2( x2, y2 ) ) )
{
x = result.x();
y = result.y();
}
}
double z = ( index.column() == mZCol ? value.toDouble() : mSelectedFeature->vertexMap().at( index.row() )->point().z() );
double m = ( index.column() == mMCol ? value.toDouble() : mSelectedFeature->vertexMap().at( index.row() )->point().m() );
QgsPointV2 p( QgsWkbTypes::PointZM, x, y, z, m );
mLayer->beginEditCommand( QObject::tr( "Moved vertices" ) );
mLayer->moveVertex( p, mSelectedFeature->featureId(), index.row() );
mLayer->endEditCommand();
mLayer->triggerRepaint();
return false;
}
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:45,代码来源:qgsnodeeditor.cpp
示例11: QgsPointV2
int QgsVectorLayerEditUtils::addPart( const QList<QgsPoint> &points, QgsFeatureId featureId )
{
QgsPointSequenceV2 l;
for ( QList<QgsPoint>::const_iterator it = points.constBegin(); it != points.constEnd(); ++it )
{
l << QgsPointV2( *it );
}
return addPart( l, featureId );
}
开发者ID:Zakui,项目名称:QGIS,代码行数:9,代码来源:qgsvectorlayereditutils.cpp
示例12: QFETCH
void TestQgsGeometryUtils::testCircleCenterRadius()
{
QFETCH( double, x1 );
QFETCH( double, y1 );
QFETCH( double, x2 );
QFETCH( double, y2 );
QFETCH( double, x3 );
QFETCH( double, y3 );
QFETCH( double, expectedRadius );
QFETCH( double, expectedCenterX );
QFETCH( double, expectedCenterY );
double radius, centerX, centerY;
QgsGeometryUtils::circleCenterRadius( QgsPointV2( x1, y1 ), QgsPointV2( x2, y2 ), QgsPointV2( x3, y3 ), radius, centerX, centerY );
QVERIFY( qgsDoubleNear( expectedRadius, radius ) );
QVERIFY( qgsDoubleNear( expectedCenterX, centerX ) );
QVERIFY( qgsDoubleNear( expectedCenterY, centerY ) );
}
开发者ID:Gustry,项目名称:QGIS,代码行数:18,代码来源:testqgsgeometryutils.cpp
示例13: QgsCircularStringV2
void QgsMapToolAddCircularString::updateCenterPointRubberBand( const QgsPointV2& pt )
{
if ( !mShowCenterPointRubberBand || !mCenterPointRubberBand || mPoints.size() < 2 )
{
return;
}
if (( mPoints.size() ) % 2 != 0 )
{
return;
}
//create circular string
QgsCircularStringV2* cs = new QgsCircularStringV2();
QList< QgsPointV2 > csPoints;
csPoints.append( mPoints.at( mPoints.size() - 2 ) );
csPoints.append( mPoints.at( mPoints.size() - 1 ) );
csPoints.append( pt );
cs->setPoints( csPoints );
double centerX, centerY;
double radius;
QgsGeometryUtils::circleCenterRadius( csPoints.at( 0 ), csPoints.at( 1 ), csPoints.at( 2 ), radius, centerX, centerY );
QgsLineStringV2* segment1 = new QgsLineStringV2();
segment1->addVertex( QgsPointV2( centerX, centerY ) );
segment1->addVertex( csPoints.at( 0 ) );
QgsLineStringV2* segment2 = new QgsLineStringV2();
segment2->addVertex( csPoints.at( 2 ) );
segment2->addVertex( QgsPointV2( centerX, centerY ) );
QgsCompoundCurveV2* cc = new QgsCompoundCurveV2();
cc->addCurve( segment1 );
cc->addCurve( cs );
cc->addCurve( segment2 );
QgsCurvePolygonV2* cp = new QgsCurvePolygonV2();
cp->setExteriorRing( cc );
mCenterPointRubberBand->setGeometry( cp );
mCenterPointRubberBand->show();
}
开发者ID:chhao91,项目名称:QGIS,代码行数:42,代码来源:qgsmaptooladdcircularstring.cpp
示例14: midPoint
bool QgsGeometryUtils::segmentMidPoint( const QgsPointV2& p1, const QgsPointV2& p2, QgsPointV2& result, double radius, const QgsPointV2& mousePos )
{
QgsPointV2 midPoint(( p1.x() + p2.x() ) / 2.0, ( p1.y() + p2.y() ) / 2.0 );
double midDist = sqrt( sqrDistance2D( p1, midPoint ) );
if ( radius < midDist )
{
return false;
}
double centerMidDist = sqrt( radius * radius - midDist * midDist );
double dist = radius - centerMidDist;
double midDx = midPoint.x() - p1.x();
double midDy = midPoint.y() - p1.y();
//get the four possible midpoints
QList<QgsPointV2> possibleMidPoints;
possibleMidPoints.append( pointOnLineWithDistance( midPoint, QgsPointV2( midPoint.x() - midDy, midPoint.y() + midDx ), dist ) );
possibleMidPoints.append( pointOnLineWithDistance( midPoint, QgsPointV2( midPoint.x() - midDy, midPoint.y() + midDx ), 2 * radius - dist ) );
possibleMidPoints.append( pointOnLineWithDistance( midPoint, QgsPointV2( midPoint.x() + midDy, midPoint.y() - midDx ), dist ) );
possibleMidPoints.append( pointOnLineWithDistance( midPoint, QgsPointV2( midPoint.x() + midDy, midPoint.y() - midDx ), 2 * radius - dist ) );
//take the closest one
double minDist = std::numeric_limits<double>::max();
int minDistIndex = -1;
for ( int i = 0; i < possibleMidPoints.size(); ++i )
{
double currentDist = sqrDistance2D( mousePos, possibleMidPoints.at( i ) );
if ( currentDist < minDist )
{
minDistIndex = i;
minDist = currentDist;
}
}
if ( minDistIndex == -1 )
{
return false;
}
result = possibleMidPoints.at( minDistIndex );
return true;
}
开发者ID:spatialthoughts,项目名称:QGIS,代码行数:42,代码来源:qgsgeometryutils.cpp
示例15: QgsLineStringV2
int QgsVectorLayerEditUtils::addRing( const QList<QgsPoint>& ring, const QgsFeatureIds& targetFeatureIds, QgsFeatureId* modifiedFeatureId )
{
QgsLineStringV2* ringLine = new QgsLineStringV2();
QList< QgsPointV2 > ringPoints;
QList<QgsPoint>::const_iterator ringIt = ring.constBegin();
for ( ; ringIt != ring.constEnd(); ++ringIt )
{
ringPoints.append( QgsPointV2( ringIt->x(), ringIt->y() ) );
}
ringLine->setPoints( ringPoints );
return addRing( ringLine, targetFeatureIds, modifiedFeatureId );
}
开发者ID:rotulet,项目名称:QGIS,代码行数:12,代码来源:qgsvectorlayereditutils.cpp
示例16: lengths
QgsPointV2 QgsTriangle::inscribedCenter() const
{
QVector<double> l = lengths();
double x = ( l.at( 0 ) * vertexAt( 2 ).x() +
l.at( 1 ) * vertexAt( 0 ).x() +
l.at( 2 ) * vertexAt( 1 ).x() ) / perimeter();
double y = ( l.at( 0 ) * vertexAt( 2 ).y() +
l.at( 1 ) * vertexAt( 0 ).y() +
l.at( 2 ) * vertexAt( 1 ).y() ) / perimeter();
return QgsPointV2( x, y );
}
开发者ID:cayetanobv,项目名称:QGIS,代码行数:13,代码来源:qgstriangle.cpp
示例17: QgsLineStringV2
QgsLineStringV2* QgsGeometryImport::linestringFromPolyline( const QgsPolyline& polyline )
{
QgsLineStringV2* line = new QgsLineStringV2();
QList<QgsPointV2> points;
QgsPolyline::const_iterator it = polyline.constBegin();
for ( ; it != polyline.constEnd(); ++it )
{
points.append( QgsPointV2( it->x(), it->y() ) );
}
line->setPoints( points );
return line;
}
开发者ID:Br1ndavoine,项目名称:QGIS,代码行数:13,代码来源:qgsgeometryimport.cpp
示例18: QgsPointV2
bool QgsSnapIndex::SegmentSnapItem::getProjection( const QgsPointV2 &p, QgsPointV2 &pProj )
{
const QgsPointV2& s1 = idxFrom->point();
const QgsPointV2& s2 = idxTo->point();
double nx = s2.y() - s1.y();
double ny = -( s2.x() - s1.x() );
double t = ( p.x() * ny - p.y() * nx - s1.x() * ny + s1.y() * nx ) / (( s2.x() - s1.x() ) * ny - ( s2.y() - s1.y() ) * nx );
if ( t < 0. || t > 1. )
{
return false;
}
pProj = QgsPointV2( s1.x() + ( s2.x() - s1.x() ) * t, s1.y() + ( s2.y() - s1.y() ) * t );
return true;
}
开发者ID:rhurlin,项目名称:QGIS,代码行数:14,代码来源:qgssnapindex.cpp
示例19: sqrt
QgsPointV2 QgsGeometryUtils::pointOnLineWithDistance( const QgsPointV2& startPoint, const QgsPointV2& directionPoint, double distance )
{
double dx = directionPoint.x() - startPoint.x();
double dy = directionPoint.y() - startPoint.y();
double length = sqrt( dx * dx + dy * dy );
if ( qgsDoubleNear( length, 0.0 ) )
{
return startPoint;
}
double scaleFactor = distance / length;
return QgsPointV2( startPoint.x() + dx * scaleFactor, startPoint.y() + dy * scaleFactor );
}
开发者ID:spatialthoughts,项目名称:QGIS,代码行数:14,代码来源:qgsgeometryutils.cpp
注:本文中的QgsPointV2函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论