Skip to content

Commit cd4d9d0

Browse files
committedFeb 16, 2018
Drop z dimension in case of circle from tangential points
1 parent 35d0f57 commit cd4d9d0

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed
 

‎src/app/qgsmaptoolcircle2tangentspoint.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ QgsMapToolCircle2TangentsPoint::~QgsMapToolCircle2TangentsPoint()
4343
void QgsMapToolCircle2TangentsPoint::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
4444
{
4545

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

@@ -56,8 +56,8 @@ void QgsMapToolCircle2TangentsPoint::cadCanvasReleaseEvent( QgsMapMouseEvent *e
5656
if ( match.isValid() )
5757
{
5858
match.edgePoints( p1, p2 );
59-
mPoints.append( fromPointXY( p1 ) );
60-
mPoints.append( fromPointXY( p2 ) );
59+
mPoints.append( QgsPoint( p1 ) );
60+
mPoints.append( QgsPoint( p2 ) );
6161
}
6262
}
6363
if ( mPoints.size() == 4 )
@@ -100,7 +100,7 @@ void QgsMapToolCircle2TangentsPoint::cadCanvasReleaseEvent( QgsMapMouseEvent *e
100100

101101
void QgsMapToolCircle2TangentsPoint::cadCanvasMoveEvent( QgsMapMouseEvent *e )
102102
{
103-
QgsPoint mapPoint = fromPointXY( e->mapPoint() );
103+
QgsPoint mapPoint( e->mapPoint() );
104104
EdgesOnlyFilter filter;
105105
QgsPointLocator::Match match = mCanvas->snappingUtils()->snapToMap( mapPoint, &filter );
106106

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

126-
line->addVertex( fromPointXY( p1 ) );
127-
line->addVertex( fromPointXY( p2 ) );
126+
line->addVertex( QgsPoint( p1 ) );
127+
line->addVertex( QgsPoint( p2 ) );
128128

129129
mTempRubberBand->setGeometry( line.release() );
130130
mTempRubberBand->show();

‎src/core/geometry/qgscircle.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,21 @@ QgsCircle QgsCircle::from3Tangents( const QgsPoint &pt1_tg1, const QgsPoint &pt2
202202
if ( !isIntersect )
203203
return QgsCircle();
204204

205+
if ( p1.is3D() )
206+
{
207+
p1.convertTo( QgsWkbTypes::dropZ( p1.wkbType() ) );
208+
}
209+
210+
if ( p2.is3D() )
211+
{
212+
p2.convertTo( QgsWkbTypes::dropZ( p2.wkbType() ) );
213+
}
214+
215+
if ( p3.is3D() )
216+
{
217+
p3.convertTo( QgsWkbTypes::dropZ( p3.wkbType() ) );
218+
}
219+
205220
return QgsTriangle( p1, p2, p3 ).inscribedCircle();
206221
}
207222

‎tests/src/core/testqgsgeometry.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7031,6 +7031,11 @@ void TestQgsGeometry::circle()
70317031
QVERIFY( circ_tgt.isEmpty() );
70327032
circ_tgt = QgsCircle().from3Tangents( QgsPoint( 5, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 1, 0 ), QgsPoint( 1, 5 ) );
70337033
QVERIFY( circ_tgt.isEmpty() );
7034+
7035+
// check that Z dimension is ignored in case of using tangents
7036+
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 ) );
7037+
QCOMPARE( circ_tgt_z.center().is3D(), false );
7038+
70347039
// minimalCircleFrom3points
70357040
QgsCircle minCircle3Points = QgsCircle().minimalCircleFrom3Points( QgsPoint( 0, 5 ), QgsPoint( 0, -5 ), QgsPoint( 1, 2 ) );
70367041
QGSCOMPARENEARPOINT( minCircle3Points.center(), QgsPoint( 0, 0 ), 0.0001 );

0 commit comments

Comments
 (0)