Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
is2DClosed -> isClosed2D and fix a typo
  • Loading branch information
lbartoletti authored and nyalldawson committed Jun 19, 2021
1 parent f3541e7 commit 6c85256
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions python/core/auto_generated/geometry/qgscurve.sip.in
Expand Up @@ -61,10 +61,10 @@ Returns the end point of the curve.
%Docstring
Returns ``True`` if the curve is closed.

.. seealso:: :py:func:`is2DClosed`
.. seealso:: :py:func:`isClosed2D`
%End

virtual bool is2DClosed() const /HoldGIL/;
virtual bool isClosed2D() const /HoldGIL/;
%Docstring
Returns true if the curve is closed.

Expand Down
2 changes: 1 addition & 1 deletion python/core/auto_generated/geometry/qgslinestring.sip.in
Expand Up @@ -422,7 +422,7 @@ segment in the line.

virtual bool isClosed() const /HoldGIL/;

virtual bool is2DClosed() const /HoldGIL/;
virtual bool isClosed2D() const /HoldGIL/;

virtual bool boundingBoxIntersects( const QgsRectangle &rectangle ) const /HoldGIL/;

Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgscurve.cpp
Expand Up @@ -37,7 +37,7 @@ bool QgsCurve::operator!=( const QgsAbstractGeometry &other ) const
return !operator==( other );
}

bool QgsCurve::is2DClosed() const
bool QgsCurve::isClosed2D() const
{
if ( numPoints() == 0 )
return false;
Expand All @@ -51,7 +51,7 @@ bool QgsCurve::is2DClosed() const
}
bool QgsCurve::isClosed() const
{
bool closed = is2DClosed();
bool closed = isClosed2D();
if ( is3D() && closed )
{
QgsPoint start = startPoint();
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgscurve.h
Expand Up @@ -67,7 +67,7 @@ class CORE_EXPORT QgsCurve: public QgsAbstractGeometry
/**
* Returns TRUE if the curve is closed.
*
* \see is2DClosed()
* \see isClosed2D()
*/
virtual bool isClosed() const SIP_HOLDGIL;

Expand All @@ -80,7 +80,7 @@ class CORE_EXPORT QgsCurve: public QgsAbstractGeometry
*
* \since QGIS 3.20
*/
virtual bool is2DClosed() const SIP_HOLDGIL;
virtual bool isClosed2D() const SIP_HOLDGIL;

/**
* Returns TRUE if the curve is a ring.
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgslinestring.cpp
Expand Up @@ -363,7 +363,7 @@ bool QgsLineString::removeDuplicateNodes( double epsilon, bool useZValues )
return result;
}

bool QgsLineString::is2DClosed() const
bool QgsLineString::isClosed2D() const
{
if ( mX.empty() )
return false;
Expand All @@ -374,7 +374,7 @@ bool QgsLineString::is2DClosed() const

bool QgsLineString::isClosed() const
{
bool closed = is2DClosed();
bool closed = isClosed2D();

if ( is3D() && closed )
closed &= qgsDoubleNear( mZ.first(), mZ.last() ) || ( std::isnan( mZ.first() ) && std::isnan( mZ.last() ) );
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgslinestring.h
Expand Up @@ -589,7 +589,7 @@ class CORE_EXPORT QgsLineString: public QgsCurve
QgsLineString *snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const override SIP_FACTORY;
bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false ) override;
bool isClosed() const override SIP_HOLDGIL;
bool is2DClosed() const override SIP_HOLDGIL;
bool isClosed2D() const override SIP_HOLDGIL;
bool boundingBoxIntersects( const QgsRectangle &rectangle ) const override SIP_HOLDGIL;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsgeometryvalidator.cpp
Expand Up @@ -102,7 +102,7 @@ void QgsGeometryValidator::validatePolyline( int i, const QgsLineString *line, b
QgsPoint startPoint = line->startPoint();
QgsPoint endPoint = line->endPoint();
QString msg;
if ( line->is3D() && line->is2DClosed() )
if ( line->is3D() && line->isClosed2D() )
{
msg = QObject::tr( "ring %1 not closed, Z mismatch: %2 vs %3" ).arg( i ).arg( startPoint.z() ).arg( endPoint.z() );
}
Expand Down
10 changes: 5 additions & 5 deletions tests/src/core/testqgsgeometry.cpp
Expand Up @@ -1694,13 +1694,13 @@ void TestQgsGeometry::circularString()

//isClosed
QgsCircularString l11;
QVERIFY( !l11.is2DClosed() );
QVERIFY( !l11.isClosed2D() );
QVERIFY( !l11.isClosed() );
l11.setPoints( QgsPointSequence() << QgsPoint( 1, 2 )
<< QgsPoint( 11, 2 )
<< QgsPoint( 11, 22 )
<< QgsPoint( 1, 22 ) );
QVERIFY( !l11.is2DClosed() );
QVERIFY( !l11.isClosed2D() );
QVERIFY( !l11.isClosed() );
QCOMPARE( l11.numPoints(), 4 );
QCOMPARE( l11.area(), 0.0 );
Expand All @@ -1711,17 +1711,17 @@ void TestQgsGeometry::circularString()
<< QgsPoint( QgsWkbTypes::PointM, 11, 2, 0, 4 )
<< QgsPoint( QgsWkbTypes::PointM, 11, 22, 0, 5 )
<< QgsPoint( QgsWkbTypes::PointM, 1, 2, 0, 6 ) );
QVERIFY( l11.is2DClosed() );
QVERIFY( l11.isClosed2D() );
QVERIFY( l11.isClosed() );

// test with z
l11.addZValue( 123.0 );
QVERIFY( l11.is2DClosed() );
QVERIFY( l11.isClosed2D() );
QVERIFY( l11.isClosed() );
QgsPoint pEnd = l11.endPoint();
pEnd.setZ( 234.0 );
l11.moveVertex( QgsVertexId( 0, 0, l11.numPoints() - 1 ), pEnd );
QVERIFY( l11.is2DClosed() );
QVERIFY( l11.isClosed2D() );
QVERIFY( !l11.isClosed() );

//polygonf
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgsgeometryvalidator.py
Expand Up @@ -262,7 +262,7 @@ def test_ring_closed(self):
self.assertEqual(spy[0][0].where(), QgsPointXY(3, 3))
self.assertEqual(spy[0][0].what(), 'ring 2 not closed')

# not closed but 2d close
# not closed but 2d closed
g = QgsGeometry.fromWkt("POLYGONZ((1 1 0, 1 2 1, 2 2 2, 2 1 3, 1 1 4))")

validator = QgsGeometryValidator(g)
Expand Down

0 comments on commit 6c85256

Please sign in to comment.