本文整理汇总了C++中QgsPoint函数的典型用法代码示例。如果您正苦于以下问题:C++ QgsPoint函数的具体用法?C++ QgsPoint怎么用?C++ QgsPoint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QgsPoint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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
示例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;
}
示例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;
}
}
示例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 )
示例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 ) );
}
示例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;
}
示例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 );
}
示例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.;
}
示例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 )
示例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;
}
}
示例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;
}
示例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 );
}
示例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 );
}
示例15: QgsPoint
QgsPoint QgsLineString::startPoint() const
{
if ( numPoints() < 1 )
{
return QgsPoint();
}
return pointN( 0 );
}