Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add repr for QgsTileXYZ
  • Loading branch information
nyalldawson committed May 9, 2023
1 parent 1b4a59f commit 35e3d49
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python/core/auto_generated/qgstiles.sip.in
Expand Up @@ -47,9 +47,17 @@ Returns tile's zoom level (Z)
Returns tile coordinates in a formatted string
%End


SIP_PYOBJECT __repr__();
%MethodCode
const QString str = QStringLiteral( "<QgsTileXYZ: %1, %2, %3>" ).arg( sipCpp->column() ).arg( sipCpp->row() ).arg( sipCpp->zoomLevel() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

};



class QgsTileRange
{
%Docstring(signature="appended")
Expand Down
8 changes: 8 additions & 0 deletions src/core/qgstiles.h
Expand Up @@ -53,6 +53,14 @@ class CORE_EXPORT QgsTileXYZ
//! Returns tile coordinates in a formatted string
QString toString() const { return QStringLiteral( "X=%1 Y=%2 Z=%3" ).arg( mColumn ).arg( mRow ).arg( mZoomLevel ); }

#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
const QString str = QStringLiteral( "<QgsTileXYZ: %1, %2, %3>" ).arg( sipCpp->column() ).arg( sipCpp->row() ).arg( sipCpp->zoomLevel() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif

private:
int mColumn = -1;
int mRow = -1;
Expand Down
4 changes: 4 additions & 0 deletions tests/src/python/test_qgstiles.py
Expand Up @@ -37,6 +37,10 @@ def testQgsTileXYZ(self):
self.assertEqual(tile.row(), 2)
self.assertEqual(tile.zoomLevel(), 3)

def testQgsTileXYZRepr(self):
tile = QgsTileXYZ(1, 2, 3)
self.assertEqual(str(tile), '<QgsTileXYZ: 1, 2, 3>')

def testQgsTileRange(self):
range = QgsTileRange(1, 2, 3, 4)
self.assertEqual(range.startColumn(), 1)
Expand Down

0 comments on commit 35e3d49

Please sign in to comment.