Skip to content

Commit d360150

Browse files
authored
Merge pull request #7171 from 3nids/sip_python_repr
create Python __repr__ methods for QgsPoint and QgsPointXY
2 parents 2aa2ef4 + ff1988f commit d360150

37 files changed

+358
-12
lines changed

python/core/auto_generated/geometry/qgscircle.sip.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ Returns true if the circle contains the ``point``.
253253
virtual QString toString( int pointPrecision = 17, int radiusPrecision = 17, int azimuthPrecision = 2 ) const;
254254

255255

256+
SIP_PYOBJECT __repr__();
257+
%MethodCode
258+
QString str = QStringLiteral( "<QgsCircle: %1>" ).arg( sipCpp->toString() );
259+
sipRes = PyUnicode_FromString( str.toUtf8().data() );
260+
%End
256261
};
257262

258263
/************************************************************************

python/core/auto_generated/geometry/qgscircularstring.sip.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ Sets the circular string's points
162162
virtual QgsCircularString *createEmptyWithSameType() const /Factory/;
163163

164164

165+
SIP_PYOBJECT __repr__();
166+
%MethodCode
167+
QString str = QStringLiteral( "<QgsCircularString: %1>" ).arg( sipCpp->asWkt() );
168+
sipRes = PyUnicode_FromString( str.toUtf8().data() );
169+
%End
170+
165171
protected:
166172

167173
virtual QgsRectangle calculateBoundingBox() const;

python/core/auto_generated/geometry/qgscompoundcurve.sip.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ Appends first point if not already closed.
166166
virtual QgsCompoundCurve *createEmptyWithSameType() const /Factory/;
167167

168168

169+
SIP_PYOBJECT __repr__();
170+
%MethodCode
171+
QString str = QStringLiteral( "<QgsCompoundCurve: %1>" ).arg( sipCpp->asWkt() );
172+
sipRes = PyUnicode_FromString( str.toUtf8().data() );
173+
%End
174+
169175
protected:
170176

171177
virtual QgsRectangle calculateBoundingBox() const;

python/core/auto_generated/geometry/qgscurvepolygon.sip.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ Returns approximate rotation angle for a vertex. Usually average angle between a
216216
virtual QgsCurvePolygon *createEmptyWithSameType() const /Factory/;
217217

218218

219+
SIP_PYOBJECT __repr__();
220+
%MethodCode
221+
QString str = QStringLiteral( "<QgsCurvePolygon: %1>" ).arg( sipCpp->asWkt() );
222+
sipRes = PyUnicode_FromString( str.toUtf8().data() );
223+
%End
224+
219225
protected:
220226

221227
virtual int childCount() const;

python/core/auto_generated/geometry/qgsellipse.sip.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,12 @@ returns a string representation of the ellipse.
248248
Members will be truncated to the specified precision.
249249
%End
250250

251+
SIP_PYOBJECT __repr__();
252+
%MethodCode
253+
QString str = QStringLiteral( "<QgsEllipse: %1>" ).arg( sipCpp->toString() );
254+
sipRes = PyUnicode_FromString( str.toUtf8().data() );
255+
%End
256+
251257
protected:
252258

253259
};

python/core/auto_generated/geometry/qgsgeometry.sip.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,12 @@ Exports the geometry to WKT
12901290
precision parameter added in QGIS 2.4
12911291
%End
12921292

1293+
SIP_PYOBJECT __repr__();
1294+
%MethodCode
1295+
QString str = QStringLiteral( "<QgsGeometry: %1>" ).arg( sipCpp->asWkt() );
1296+
sipRes = PyUnicode_FromString( str.toUtf8().data() );
1297+
%End
1298+
12931299
QString asJson( int precision = 17 ) const;
12941300
%Docstring
12951301
Exports the geometry to a GeoJSON string.

python/core/auto_generated/geometry/qgslinestring.sip.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,12 @@ of the curve.
317317
virtual QgsLineString *createEmptyWithSameType() const /Factory/;
318318

319319

320+
SIP_PYOBJECT __repr__();
321+
%MethodCode
322+
QString str = QStringLiteral( "<QgsLineString: %1>" ).arg( sipCpp->asWkt() );
323+
sipRes = PyUnicode_FromString( str.toUtf8().data() );
324+
%End
325+
320326
protected:
321327

322328
virtual QgsRectangle calculateBoundingBox() const;

python/core/auto_generated/geometry/qgsmulticurve.sip.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ Returns a copy of the multi curve, where each component curve has had its line d
5656
virtual QgsMultiCurve *createEmptyWithSameType() const /Factory/;
5757

5858

59+
SIP_PYOBJECT __repr__();
60+
%MethodCode
61+
QString str = QStringLiteral( "<QgsMulitCurve: %1>" ).arg( sipCpp->asWkt() );
62+
sipRes = PyUnicode_FromString( str.toUtf8().data() );
63+
%End
5964

6065
};
6166

python/core/auto_generated/geometry/qgsmultilinestring.sip.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ Returns the geometry converted to the more generic curve type :py:class:`QgsMult
5353
virtual QgsMultiLineString *createEmptyWithSameType() const /Factory/;
5454

5555

56+
SIP_PYOBJECT __repr__();
57+
%MethodCode
58+
QString str = QStringLiteral( "<QgsMultiLineString: %1>" ).arg( sipCpp->asWkt() );
59+
sipRes = PyUnicode_FromString( str.toUtf8().data() );
60+
%End
61+
5662
protected:
5763

5864
virtual bool wktOmitChildType() const;

python/core/auto_generated/geometry/qgsmultipoint.sip.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ Multi point geometry collection.
5555
virtual QgsMultiPoint *createEmptyWithSameType() const /Factory/;
5656

5757

58+
SIP_PYOBJECT __repr__();
59+
%MethodCode
60+
QString str = QStringLiteral( "<QgsMultiPoint: %1>" ).arg( sipCpp->asWkt() );
61+
sipRes = PyUnicode_FromString( str.toUtf8().data() );
62+
%End
63+
5864
protected:
5965

6066
virtual bool wktOmitChildType() const;

0 commit comments

Comments
 (0)