Skip to content
Permalink
Browse files

Drop z dimension in case of circle from tangential points

  • Loading branch information
pblottiere committed Feb 16, 2018
1 parent 35d0f57 commit cd4d9d0b0d2f8c01c78aef18f071d07de7adb907
@@ -43,7 +43,7 @@ QgsMapToolCircle2TangentsPoint::~QgsMapToolCircle2TangentsPoint()
void QgsMapToolCircle2TangentsPoint::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
{

QgsPoint mapPoint = fromPointXY( e->mapPoint() );
QgsPoint mapPoint( e->mapPoint() );
EdgesOnlyFilter filter;
QgsPointLocator::Match match = mCanvas->snappingUtils()->snapToMap( mapPoint, &filter );

@@ -56,8 +56,8 @@ void QgsMapToolCircle2TangentsPoint::cadCanvasReleaseEvent( QgsMapMouseEvent *e
if ( match.isValid() )
{
match.edgePoints( p1, p2 );
mPoints.append( fromPointXY( p1 ) );
mPoints.append( fromPointXY( p2 ) );
mPoints.append( QgsPoint( p1 ) );
mPoints.append( QgsPoint( p2 ) );
}
}
if ( mPoints.size() == 4 )
@@ -100,7 +100,7 @@ void QgsMapToolCircle2TangentsPoint::cadCanvasReleaseEvent( QgsMapMouseEvent *e

void QgsMapToolCircle2TangentsPoint::cadCanvasMoveEvent( QgsMapMouseEvent *e )
{
QgsPoint mapPoint = fromPointXY( e->mapPoint() );
QgsPoint mapPoint( e->mapPoint() );
EdgesOnlyFilter filter;
QgsPointLocator::Match match = mCanvas->snappingUtils()->snapToMap( mapPoint, &filter );

@@ -123,8 +123,8 @@ void QgsMapToolCircle2TangentsPoint::cadCanvasMoveEvent( QgsMapMouseEvent *e )
match.edgePoints( p1, p2 );
std::unique_ptr<QgsLineString> line( new QgsLineString() );

line->addVertex( fromPointXY( p1 ) );
line->addVertex( fromPointXY( p2 ) );
line->addVertex( QgsPoint( p1 ) );
line->addVertex( QgsPoint( p2 ) );

mTempRubberBand->setGeometry( line.release() );
mTempRubberBand->show();
@@ -202,6 +202,21 @@ QgsCircle QgsCircle::from3Tangents( const QgsPoint &pt1_tg1, const QgsPoint &pt2
if ( !isIntersect )
return QgsCircle();

if ( p1.is3D() )
{
p1.convertTo( QgsWkbTypes::dropZ( p1.wkbType() ) );
}

if ( p2.is3D() )
{
p2.convertTo( QgsWkbTypes::dropZ( p2.wkbType() ) );
}

if ( p3.is3D() )
{
p3.convertTo( QgsWkbTypes::dropZ( p3.wkbType() ) );
}

return QgsTriangle( p1, p2, p3 ).inscribedCircle();
}

@@ -7031,6 +7031,11 @@ void TestQgsGeometry::circle()
QVERIFY( circ_tgt.isEmpty() );
circ_tgt = QgsCircle().from3Tangents( QgsPoint( 5, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 1, 0 ), QgsPoint( 1, 5 ) );
QVERIFY( circ_tgt.isEmpty() );

// check that Z dimension is ignored in case of using tangents
QgsCircle circ_tgt_z = QgsCircle().from3Tangents( QgsPoint( 0, 0, 333 ), QgsPoint( 0, 1, 1 ), QgsPoint( 2, 0, 2 ), QgsPoint( 3, 0, 3 ), QgsPoint( 5, 0, 4 ), QgsPoint( 0, 5, 5 ) );
QCOMPARE( circ_tgt_z.center().is3D(), false );

// minimalCircleFrom3points
QgsCircle minCircle3Points = QgsCircle().minimalCircleFrom3Points( QgsPoint( 0, 5 ), QgsPoint( 0, -5 ), QgsPoint( 1, 2 ) );
QGSCOMPARENEARPOINT( minCircle3Points.center(), QgsPoint( 0, 0 ), 0.0001 );

0 comments on commit cd4d9d0

Please sign in to comment.
You can’t perform that action at this time.