本文整理汇总了C++中QgsPoint函数的典型用法代码示例。如果您正苦于以下问题:C++ QgsPoint函数的具体用法?C++ QgsPoint怎么用?C++ QgsPoint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QgsPoint函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: QgsPoint
int QgsGml::pointsFromCoordinateString( QList<QgsPoint>& points, const QString& coordString ) const
{
//tuples are separated by space, x/y by ','
QStringList tuples = coordString.split( mTupleSeparator, QString::SkipEmptyParts );
QStringList tuples_coordinates;
double x, y;
bool conversionSuccess;
QStringList::const_iterator tupleIterator;
for ( tupleIterator = tuples.constBegin(); tupleIterator != tuples.constEnd(); ++tupleIterator )
{
tuples_coordinates = tupleIterator->split( mCoordinateSeparator, QString::SkipEmptyParts );
if ( tuples_coordinates.size() < 2 )
{
continue;
}
x = tuples_coordinates.at( 0 ).toDouble( &conversionSuccess );
if ( !conversionSuccess )
{
continue;
}
y = tuples_coordinates.at( 1 ).toDouble( &conversionSuccess );
if ( !conversionSuccess )
{
continue;
}
points.push_back( QgsPoint( x, y ) );
}
return 0;
}
开发者ID:badcock4412,项目名称:Quantum-GIS,代码行数:30,代码来源:qgsgml.cpp
示例2: QgsVertexMarker
void QgsMapToolCapture::canvasMapMoveEvent( QgsMapMouseEvent * e )
{
bool snapped = e->isSnapped();
QgsPoint point = e->mapPoint();
if ( !snapped )
{
delete mSnappingMarker;
mSnappingMarker = 0;
}
else
{
if ( !mSnappingMarker )
{
mSnappingMarker = new QgsVertexMarker( mCanvas );
mSnappingMarker->setIconType( QgsVertexMarker::ICON_CROSS );
mSnappingMarker->setColor( Qt::magenta );
mSnappingMarker->setPenWidth( 3 );
}
mSnappingMarker->setCenter( point );
}
if ( !mTempRubberBand && mCaptureCurve.numPoints() > 0 )
{
mTempRubberBand = createRubberBand( mCaptureMode == CapturePolygon ? QGis::Polygon : QGis::Line, true );
QgsPointV2 pt = mCaptureCurve.endPoint();
mTempRubberBand->addPoint( QgsPoint( pt.x(), pt.y() ) );
mTempRubberBand->addPoint( point );
}
if ( mCaptureMode != CapturePoint && mTempRubberBand && mCapturing )
{
mTempRubberBand->movePoint( point );
}
} // mouseMoveEvent
开发者ID:redwoodxiao,项目名称:QGIS,代码行数:35,代码来源:qgsmaptoolcapture.cpp
示例3: QgsDebugMsg
int QgsGml::pointsFromPosListString( QList<QgsPoint>& points, const QString& coordString, int dimension ) const
{
// coordinates separated by spaces
QStringList coordinates = coordString.split( ' ', QString::SkipEmptyParts );
if ( coordinates.size() % dimension != 0 )
{
QgsDebugMsg( "Wrong number of coordinates" );
}
int ncoor = coordinates.size() / dimension;
for ( int i = 0; i < ncoor; i++ )
{
bool conversionSuccess;
double x = coordinates.value( i * dimension ).toDouble( &conversionSuccess );
if ( !conversionSuccess )
{
continue;
}
double y = coordinates.value( i * dimension + 1 ).toDouble( &conversionSuccess );
if ( !conversionSuccess )
{
continue;
}
points.append( QgsPoint( x, y ) );
}
return 0;
}
开发者ID:avautour,项目名称:QGIS,代码行数:28,代码来源:qgsgml.cpp
示例4: sqrt
double QgsComposerScaleBar::mapDiagonal() const
{
if ( !mComposerMap )
{
return 0.0;
}
QgsRectangle composerMapRect = mComposerMap->extent();
if ( mUnits == MapUnits )
{
return sqrt( composerMapRect.width() * composerMapRect.width() + composerMapRect.height() * composerMapRect.height() );
}
else
{
QgsDistanceArea da;
da.setProjectionsEnabled( true );
da.setSourceCrs( mComposerMap->mapRenderer()->destinationCrs().srsid() );
QSettings s;
da.setEllipsoid( s.value( "/qgis/measure/ellipsoid", "WGS84" ).toString() );
double measure = da.measureLine( QgsPoint( composerMapRect.xMinimum(), composerMapRect.yMaximum() ), QgsPoint( composerMapRect.xMaximum(), composerMapRect.yMinimum() ) );
if ( mUnits == Feet )
{
measure /= 0.3048;
}
return measure;
}
}
开发者ID:unpatioli,项目名称:Quantum-GIS,代码行数:27,代码来源:qgscomposerscalebar.cpp
示例5: QString
void RgShortestPathWidget::setFrontPoint( const QgsPoint& pt )
{
mPlugin->iface()->mapCanvas()->unsetMapTool( mFrontPointMapTool );
mFrontPointLineEdit->setText( QString( "(" ) + QString().setNum( pt.x() ) + QString( "," ) +
QString().setNum( pt.y() ) + QString( ")" ) );
mFrontPoint = pt;
double mupp = mPlugin->iface()->mapCanvas()->getCoordinateTransform()->mapUnitsPerPixel() * 2;
mrbFrontPoint->reset( QGis::Polygon );
mrbFrontPoint->addPoint( QgsPoint( pt.x() - mupp, pt.y() - mupp ), false );
mrbFrontPoint->addPoint( QgsPoint( pt.x() + mupp, pt.y() - mupp ), false );
mrbFrontPoint->addPoint( QgsPoint( pt.x() + mupp, pt.y() + mupp ), false );
mrbFrontPoint->addPoint( QgsPoint( pt.x() - mupp, pt.y() + mupp ), true );
mrbFrontPoint->show();
} //RgShortestPathWidget::setFrontPoint( const QgsPoint& pt )
开发者ID:L-Infantini,项目名称:Quantum-GIS,代码行数:16,代码来源:shortestpathwidget.cpp
示例6: testSnapModeAll
void testSnapModeAll()
{
QgsMapSettings mapSettings;
mapSettings.setOutputSize( QSize( 100, 100 ) );
mapSettings.setExtent( QgsRectangle( 0, 0, 1, 1 ) );
QVERIFY( mapSettings.hasValidSettings() );
QgsSnappingUtils u;
QgsSnappingConfig snappingConfig = u.config();
u.setMapSettings( mapSettings );
snappingConfig.setMode( QgsSnappingConfig::AllLayers );
u.setConfig( snappingConfig );
// right now there are no layers in map settings - snapping will fail
QgsPointLocator::Match m = u.snapToMap( QPoint( 100, 100 ) );
QVERIFY( !m.isValid() );
// now check with our layer
mapSettings.setLayers( QStringList() << mVL->id() );
u.setMapSettings( mapSettings );
QgsPointLocator::Match m2 = u.snapToMap( QPoint( 100, 100 ) );
QVERIFY( m2.isValid() );
QCOMPARE( m2.point(), QgsPoint( 1, 0 ) );
}
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:26,代码来源:testqgssnappingutils.cpp
示例7: QgsDebugMsg
unsigned char* QgsDistanceArea::measureLine( unsigned char* feature, double* area, bool hasZptr )
{
unsigned char *ptr = feature + 5;
unsigned int nPoints = *(( int* )ptr );
ptr = feature + 9;
QList<QgsPoint> points;
double x, y;
QgsDebugMsg( "This feature WKB has " + QString::number( nPoints ) + " points" );
// Extract the points from the WKB format into the vector
for ( unsigned int i = 0; i < nPoints; ++i )
{
x = *(( double * ) ptr );
ptr += sizeof( double );
y = *(( double * ) ptr );
ptr += sizeof( double );
if ( hasZptr )
{
// totally ignore Z value
ptr += sizeof( double );
}
points.append( QgsPoint( x, y ) );
}
*area = measureLine( points );
return ptr;
}
开发者ID:coyotte508,项目名称:Quantum-GIS,代码行数:29,代码来源:qgsdistancearea.cpp
示例8: pt2
static QgsCurve *_transform_ring_to_new_base( const QgsCurve &curve, const QgsPoint &pt0, const QMatrix4x4 *toNewBase )
{
int count = curve.numPoints();
QVector<QgsPoint> pts;
pts.reserve( count );
QgsVertexId::VertexType vt;
for ( int i = 0; i < count; ++i )
{
QgsPoint pt;
curve.pointAt( i, pt, vt );
QgsPoint pt2( QgsWkbTypes::PointZ, pt.x() - pt0.x(), pt.y() - pt0.y(), std::isnan( pt.z() ) ? 0 : pt.z() - pt0.z() );
QVector4D v( pt2.x(), pt2.y(), pt2.z(), 0 );
if ( toNewBase )
v = toNewBase->map( v );
// we also round coordinates before passing them to poly2tri triangulation in order to fix possible numerical
// stability issues. We had crashes with nearly collinear points where one of the points was off by a tiny bit (e.g. by 1e-20).
// See TestQgsTessellator::testIssue17745().
//
// A hint for a similar issue: https://github.com/greenm01/poly2tri/issues/99
//
// The collinear tests uses epsilon 1e-12. Seems rounding to 12 places you still
// can get problems with this test when points are pretty much on a straight line.
// I suggest you round to 10 decimals for stability and you can live with that
// precision.
pts << QgsPoint( QgsWkbTypes::PointZ, _round_coord( v.x() ), _round_coord( v.y() ), _round_coord( v.z() ) );
}
return new QgsLineString( pts );
}
开发者ID:lyhkop,项目名称:QGIS,代码行数:30,代码来源:qgstessellator.cpp
示例9: eval_geometry_data
void eval_geometry_data()
{
QTest::addColumn<QString>( "string" );
QTest::addColumn<void*>( "geomptr" );
QTest::addColumn<bool>( "evalError" );
QTest::addColumn<double>( "result" );
QgsPoint point( 123, 456 );
QgsPolyline line;
line << QgsPoint( 1, 1 ) << QgsPoint( 4, 2 ) << QgsPoint( 3, 1 );
QTest::newRow( "geom x" ) << "$x" << ( void* ) QgsGeometry::fromPoint( point ) << false << 123.;
QTest::newRow( "geom y" ) << "$y" << ( void* ) QgsGeometry::fromPoint( point ) << false << 456.;
QTest::newRow( "geom xat" ) << "xat(-1)" << ( void* ) QgsGeometry::fromPolyline( line ) << false << 3.;
QTest::newRow( "geom yat" ) << "yat(1)" << ( void* ) QgsGeometry::fromPolyline( line ) << false << 2.;
}
开发者ID:MERIDIAN-CHARTWARE,项目名称:QGIS-1,代码行数:16,代码来源:testqgsexpression.cpp
示例10: QStringLiteral
void RgShortestPathWidget::setFrontPoint( const QgsPoint& pt )
{
mPlugin->iface()->mapCanvas()->unsetMapTool( mFrontPointMapTool );
mFrontPointLineEdit->setText( QStringLiteral( "(%1, %2)" ).arg( QString::number( pt.x(), 'f' ),
QString::number( pt.y(), 'f' ) ) );
mFrontPoint = pt;
double mupp = mPlugin->iface()->mapCanvas()->getCoordinateTransform()->mapUnitsPerPixel() * 2;
mrbFrontPoint->reset( QgsWkbTypes::PolygonGeometry );
mrbFrontPoint->addPoint( QgsPoint( pt.x() - mupp, pt.y() - mupp ), false );
mrbFrontPoint->addPoint( QgsPoint( pt.x() + mupp, pt.y() - mupp ), false );
mrbFrontPoint->addPoint( QgsPoint( pt.x() + mupp, pt.y() + mupp ), false );
mrbFrontPoint->addPoint( QgsPoint( pt.x() - mupp, pt.y() + mupp ), true );
mrbFrontPoint->show();
} //RgShortestPathWidget::setFrontPoint( const QgsPoint& pt )
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:16,代码来源:shortestpathwidget.cpp
示例11: QgsPoint
double QgsComposerScaleBar::mapWidth() const
{
if ( !mComposerMap )
{
return 0.0;
}
QgsRectangle composerMapRect = mComposerMap->extent();
if ( mUnits == MapUnits )
{
return composerMapRect.width();
}
else
{
QgsDistanceArea da;
da.setEllipsoidalMode( mComposerMap->mapRenderer()->hasCrsTransformEnabled() );
da.setSourceCrs( mComposerMap->mapRenderer()->destinationCrs().srsid() );
da.setEllipsoid( QgsProject::instance()->readEntry( "Measure", "/Ellipsoid", "WGS84" ) );
double measure = da.measureLine( QgsPoint( composerMapRect.xMinimum(), composerMapRect.yMinimum() ), QgsPoint( composerMapRect.xMaximum(), composerMapRect.yMinimum() ) );
if ( mUnits == Feet )
{
measure /= 0.3048;
}
return measure;
}
}
开发者ID:Nald,项目名称:Quantum-GIS,代码行数:27,代码来源:qgscomposerscalebar.cpp
示例12: wkbPtr
const unsigned char* QgsDistanceArea::measureLine( const unsigned char* feature, double* area, bool hasZptr )
{
QgsConstWkbPtr wkbPtr( feature + 1 + sizeof( int ) );
int nPoints;
wkbPtr >> nPoints;
QList<QgsPoint> points;
double x, y;
QgsDebugMsg( "This feature WKB has " + QString::number( nPoints ) + " points" );
// Extract the points from the WKB format into the vector
for ( int i = 0; i < nPoints; ++i )
{
wkbPtr >> x >> y;
if ( hasZptr )
{
// totally ignore Z value
wkbPtr += sizeof( double );
}
points.append( QgsPoint( x, y ) );
}
*area = measureLine( points );
return wkbPtr;
}
开发者ID:AnAvidDeveloper,项目名称:QGIS,代码行数:26,代码来源:qgsdistancearea.cpp
示例13: QgsRubberBand
void QgsMapToolPinLabels::highlightLabel( const QgsLabelPosition& labelpos,
const QString& id,
const QColor& color )
{
QgsRectangle rect = labelpos.labelRect;
QgsRubberBand *rb = new QgsRubberBand( mCanvas, QGis::Polygon );
rb->addPoint( QgsPoint( rect.xMinimum(), rect.yMinimum() ) );
rb->addPoint( QgsPoint( rect.xMinimum(), rect.yMaximum() ) );
rb->addPoint( QgsPoint( rect.xMaximum(), rect.yMaximum() ) );
rb->addPoint( QgsPoint( rect.xMaximum(), rect.yMinimum() ) );
rb->addPoint( QgsPoint( rect.xMinimum(), rect.yMinimum() ) );
rb->setColor( color );
rb->setWidth( 0 );
rb->show();
mHighlights.insert( id, rb );
}
开发者ID:Aladar64,项目名称:QGIS,代码行数:17,代码来源:qgsmaptoolpinlabels.cpp
示例14: reset
void QgsRubberBand::setToCanvasRectangle( const QRect& rect )
{
if ( !mMapCanvas )
{
return;
}
const QgsMapToPixel* transform = mMapCanvas->getCoordinateTransform();
QgsPoint ll = transform->toMapCoordinates( rect.left(), rect.bottom() );
QgsPoint ur = transform->toMapCoordinates( rect.right(), rect.top() );
reset( QGis::Polygon );
addPoint( ll, false );
addPoint( QgsPoint( ur.x(), ll.y() ), false );
addPoint( ur, false );
addPoint( QgsPoint( ll.x(), ur.y() ), true );
}
开发者ID:Nald,项目名称:Quantum-GIS,代码行数:17,代码来源:qgsrubberband.cpp
示例15: QgsPoint
QgsPoint QgsLineString::startPoint() const
{
if ( numPoints() < 1 )
{
return QgsPoint();
}
return pointN( 0 );
}
开发者ID:dbaston,项目名称:QGIS,代码行数:8,代码来源:qgslinestring.cpp
示例16: QgsPoint
/**
* Check to see if the point is within the selection rectangle
*/
bool QgsDelimitedTextProvider::boundsCheck( double x, double y )
{
// no selection rectangle or geometry => always in the bounds
if ( mSelectionRectangle.isEmpty() || !mFetchGeom )
return true;
return mSelectionRectangle.contains( QgsPoint( x, y ) );
}
开发者ID:Nald,项目名称:Quantum-GIS,代码行数:11,代码来源:qgsdelimitedtextprovider.cpp
示例17: testNearestEdge
void testNearestEdge()
{
QgsPointLocator loc( mVL );
QgsPoint pt( 1.1, 0.5 );
QgsPointLocator::Match m = loc.nearestEdge( pt, 999 );
QVERIFY( m.isValid() );
QVERIFY( m.hasEdge() );
QCOMPARE( m.layer(), mVL );
QCOMPARE( m.featureId(), ( QgsFeatureId )1 );
QCOMPARE( m.point(), QgsPoint( 1, 0.5 ) );
QCOMPARE( m.distance(), 0.1 );
QCOMPARE( m.vertexIndex(), 1 );
QgsPoint pt1, pt2;
m.edgePoints( pt1, pt2 );
QCOMPARE( pt1, QgsPoint( 1, 0 ) );
QCOMPARE( pt2, QgsPoint( 1, 1 ) );
}
开发者ID:AM7000000,项目名称:QGIS,代码行数:17,代码来源:testqgspointlocator.cpp
示例18: QgsMapToolAddCircularString
QgsMapToolCircularStringRadius::QgsMapToolCircularStringRadius( QgsMapToolCapture *parentTool, QgsMapCanvas *canvas, CaptureMode mode )
: QgsMapToolAddCircularString( parentTool, canvas, mode )
, mTemporaryEndPoint( QgsPoint() )
, mRadius( 0.0 )
{
}
开发者ID:phborba,项目名称:QGIS,代码行数:8,代码来源:qgsmaptoolcircularstringradius.cpp
示例19: QgsPoint
QgsPoint QgsCompoundCurve::endPoint() const
{
if ( mCurves.empty() )
{
return QgsPoint();
}
return mCurves.at( mCurves.size() - 1 )->endPoint();
}
开发者ID:alexbruy,项目名称:QGIS,代码行数:8,代码来源:qgscompoundcurve.cpp
示例20: eval_geometry_method_data
void eval_geometry_method_data()
{
QTest::addColumn<QString>( "string" );
QTest::addColumn<void*>( "geomptr" );
QTest::addColumn<bool>( "evalError" );
QTest::addColumn<bool>( "needGeom" );
QTest::addColumn<void*>( "resultptr" );
QgsPolyline polygon_ring;
polygon_ring << QgsPoint( 0, 0 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 );
QgsPolygon polygon;
polygon << polygon_ring;
QgsGeometry* geom = QgsGeometry::fromPolygon( polygon );
QTest::newRow( "buffer" ) << "buffer( $geometry, 1.0, 3)" << ( void* ) geom << false << true << ( void* ) geom->buffer( 1.0, 3 );
geom = QgsGeometry::fromPolygon( polygon );
QTest::newRow( "buffer" ) << "buffer( $geometry, 2.0)" << ( void* ) geom << false << true << ( void* ) geom->buffer( 2.0, 8 );
QgsPoint point1( 10, 20 );
QgsPoint point2( 30, 20 );
QgsGeometry* pnt1 = QgsGeometry::fromPoint( point1 );
QgsGeometry* pnt2 = QgsGeometry::fromPoint( point2 );
QTest::newRow( "union" ) << "union( $geometry, geomFromWKT('" + pnt2->exportToWkt() + "') )" << ( void* ) pnt1 << false << true << ( void* ) pnt1->combine( pnt2 );
geom = QgsGeometry::fromPolygon( polygon );
QTest::newRow( "intersection" ) << "intersection( $geometry, geomFromWKT('POLYGON((0 0, 0 10, 10 0, 0 0))') )" << ( void* ) geom << false << true << ( void* ) QgsGeometry::fromWkt( "POLYGON ((0 0,5 5,10 0,0 0))" );
geom = QgsGeometry::fromPolygon( polygon );
QTest::newRow( "difference" ) << "difference( $geometry, geomFromWKT('POLYGON((0 0, 0 10, 10 0, 0 0))') )" << ( void* ) geom << false << true << ( void* ) QgsGeometry::fromWkt( "POLYGON ((5 5,10 10,10 0,5 5))" );
geom = QgsGeometry::fromPolygon( polygon );
QTest::newRow( "symDifference" ) << "symDifference( $geometry, geomFromWKT('POLYGON((0 0, 0 10, 10 0, 0 0))') )" << ( void* ) geom << false << true << ( void* ) QgsGeometry::fromWkt( "MULTIPOLYGON(((5 5,0 0,0 10,5 5)),((5 5,10 10,10 0,5 5)))" );
geom = QgsGeometry::fromPolygon( polygon );
QTest::newRow( "centroid polygon" ) << "centroid( $geometry )" << ( void* ) geom << false << true << ( void* ) geom->centroid();
geom = QgsGeometry::fromPolygon( polygon );
QTest::newRow( "centroid self intersecting polygon" ) << "centroid( geomFromWKT('POLYGON((0 0, 0 2, 2 -0.1, 2 2.1, 0 0))') )" << ( void* ) geom << false << false << ( void* ) QgsGeometry::fromWkt( "POINT (8.0 1.0)" );
geom = QgsGeometry::fromPolygon( polygon );
QTest::newRow( "centroid multi polygon" ) << "centroid( geomFromWKT('MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)),((2 0,2 1,3 1,3 0,2 0)))') )" << ( void* ) geom << false << false << ( void* ) QgsGeometry::fromWkt( "POINT (1.5 0.5)" );
geom = QgsGeometry::fromPolygon( polygon );
QTest::newRow( "convexHull simple" ) << "convexHull( $geometry )" << ( void* ) geom << false << true << ( void* ) geom->convexHull();
geom = QgsGeometry::fromPolygon( polygon );
QTest::newRow( "convexHull multi" ) << "convexHull( geomFromWKT('GEOMETRYCOLLECTION(POINT(0 1), POINT(0 0), POINT(1 0), POINT(1 1))') )" << ( void* ) geom << false << false << ( void* ) QgsGeometry::fromWkt( "POLYGON ((0 0,0 1,1 1,1 0,0 0))" );
geom = QgsGeometry::fromPolygon( polygon );
QTest::newRow( "bounds" ) << "bounds( $geometry )" << ( void* ) geom << false << true << ( void* ) QgsGeometry::fromRect( geom->boundingBox() );
}
开发者ID:AaronGaim,项目名称:QGIS,代码行数:45,代码来源:testqgsexpression.cpp
注:本文中的QgsPoint函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论