Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #7171 from 3nids/sip_python_repr
create Python __repr__ methods for QgsPoint and QgsPointXY
- Loading branch information
|
@@ -253,6 +253,11 @@ Returns true if the circle contains the ``point``. |
|
|
virtual QString toString( int pointPrecision = 17, int radiusPrecision = 17, int azimuthPrecision = 2 ) const; |
|
|
|
|
|
|
|
|
SIP_PYOBJECT __repr__(); |
|
|
%MethodCode |
|
|
QString str = QStringLiteral( "<QgsCircle: %1>" ).arg( sipCpp->toString() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
%End |
|
|
}; |
|
|
|
|
|
/************************************************************************ |
|
|
|
@@ -162,6 +162,12 @@ Sets the circular string's points |
|
|
virtual QgsCircularString *createEmptyWithSameType() const /Factory/; |
|
|
|
|
|
|
|
|
SIP_PYOBJECT __repr__(); |
|
|
%MethodCode |
|
|
QString str = QStringLiteral( "<QgsCircularString: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
%End |
|
|
|
|
|
protected: |
|
|
|
|
|
virtual QgsRectangle calculateBoundingBox() const; |
|
|
|
@@ -166,6 +166,12 @@ Appends first point if not already closed. |
|
|
virtual QgsCompoundCurve *createEmptyWithSameType() const /Factory/; |
|
|
|
|
|
|
|
|
SIP_PYOBJECT __repr__(); |
|
|
%MethodCode |
|
|
QString str = QStringLiteral( "<QgsCompoundCurve: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
%End |
|
|
|
|
|
protected: |
|
|
|
|
|
virtual QgsRectangle calculateBoundingBox() const; |
|
|
|
@@ -216,6 +216,12 @@ Returns approximate rotation angle for a vertex. Usually average angle between a |
|
|
virtual QgsCurvePolygon *createEmptyWithSameType() const /Factory/; |
|
|
|
|
|
|
|
|
SIP_PYOBJECT __repr__(); |
|
|
%MethodCode |
|
|
QString str = QStringLiteral( "<QgsCurvePolygon: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
%End |
|
|
|
|
|
protected: |
|
|
|
|
|
virtual int childCount() const; |
|
|
|
@@ -248,6 +248,12 @@ returns a string representation of the ellipse. |
|
|
Members will be truncated to the specified precision. |
|
|
%End |
|
|
|
|
|
SIP_PYOBJECT __repr__(); |
|
|
%MethodCode |
|
|
QString str = QStringLiteral( "<QgsEllipse: %1>" ).arg( sipCpp->toString() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
%End |
|
|
|
|
|
protected: |
|
|
|
|
|
}; |
|
|
|
@@ -1290,6 +1290,12 @@ Exports the geometry to WKT |
|
|
precision parameter added in QGIS 2.4 |
|
|
%End |
|
|
|
|
|
SIP_PYOBJECT __repr__(); |
|
|
%MethodCode |
|
|
QString str = QStringLiteral( "<QgsGeometry: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
%End |
|
|
|
|
|
QString asJson( int precision = 17 ) const; |
|
|
%Docstring |
|
|
Exports the geometry to a GeoJSON string. |
|
|
|
@@ -317,6 +317,12 @@ of the curve. |
|
|
virtual QgsLineString *createEmptyWithSameType() const /Factory/; |
|
|
|
|
|
|
|
|
SIP_PYOBJECT __repr__(); |
|
|
%MethodCode |
|
|
QString str = QStringLiteral( "<QgsLineString: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
%End |
|
|
|
|
|
protected: |
|
|
|
|
|
virtual QgsRectangle calculateBoundingBox() const; |
|
|
|
@@ -56,6 +56,11 @@ Returns a copy of the multi curve, where each component curve has had its line d |
|
|
virtual QgsMultiCurve *createEmptyWithSameType() const /Factory/; |
|
|
|
|
|
|
|
|
SIP_PYOBJECT __repr__(); |
|
|
%MethodCode |
|
|
QString str = QStringLiteral( "<QgsMulitCurve: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
%End |
|
|
|
|
|
}; |
|
|
|
|
|
|
@@ -53,6 +53,12 @@ Returns the geometry converted to the more generic curve type :py:class:`QgsMult |
|
|
virtual QgsMultiLineString *createEmptyWithSameType() const /Factory/; |
|
|
|
|
|
|
|
|
SIP_PYOBJECT __repr__(); |
|
|
%MethodCode |
|
|
QString str = QStringLiteral( "<QgsMultiLineString: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
%End |
|
|
|
|
|
protected: |
|
|
|
|
|
virtual bool wktOmitChildType() const; |
|
|
|
@@ -55,6 +55,12 @@ Multi point geometry collection. |
|
|
virtual QgsMultiPoint *createEmptyWithSameType() const /Factory/; |
|
|
|
|
|
|
|
|
SIP_PYOBJECT __repr__(); |
|
|
%MethodCode |
|
|
QString str = QStringLiteral( "<QgsMultiPoint: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
%End |
|
|
|
|
|
protected: |
|
|
|
|
|
virtual bool wktOmitChildType() const; |
|
|
|
@@ -54,6 +54,12 @@ Returns the geometry converted to the more generic curve type :py:class:`QgsMult |
|
|
virtual QgsMultiPolygon *createEmptyWithSameType() const /Factory/; |
|
|
|
|
|
|
|
|
SIP_PYOBJECT __repr__(); |
|
|
%MethodCode |
|
|
QString str = QStringLiteral( "<QgsMultiPolygon: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
%End |
|
|
|
|
|
protected: |
|
|
|
|
|
virtual bool wktOmitChildType() const; |
|
|
|
@@ -426,6 +426,12 @@ Angle undefined. Always returns 0.0 |
|
|
virtual QgsPoint *createEmptyWithSameType() const /Factory/; |
|
|
|
|
|
|
|
|
SIP_PYOBJECT __repr__(); |
|
|
%MethodCode |
|
|
QString str = QStringLiteral( "<QgsPoint: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
%End |
|
|
|
|
|
protected: |
|
|
|
|
|
virtual int childCount() const; |
|
|
|
@@ -65,6 +65,12 @@ negative if the point lies outside the polygon. |
|
|
virtual QgsPolygon *createEmptyWithSameType() const /Factory/; |
|
|
|
|
|
|
|
|
SIP_PYOBJECT __repr__(); |
|
|
%MethodCode |
|
|
QString str = QStringLiteral( "<QgsPolygon: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
%End |
|
|
|
|
|
protected: |
|
|
|
|
|
|
|
|
|
@@ -322,6 +322,12 @@ Converts the rectangle to a 3D box, with the specified |
|
|
|
|
|
operator QVariant() const; |
|
|
|
|
|
SIP_PYOBJECT __repr__(); |
|
|
%MethodCode |
|
|
QString str = QStringLiteral( "<QgsRectangle: %1>" ).arg( sipCpp->asWktCoordinates() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
%End |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
@@ -230,8 +230,7 @@ Multiply x and y by the given value |
|
|
|
|
|
SIP_PYOBJECT __repr__(); |
|
|
%MethodCode |
|
|
QString str = "(" + QString::number( sipCpp->x() ) + "," + QString::number( sipCpp->y() ) + ")"; |
|
|
//QString str("(%f,%f)").arg(sipCpp->x()).arg(sipCpp->y()); |
|
|
QString str = QStringLiteral( "<QgsPointXY: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
%End |
|
|
|
|
|
|
@@ -694,7 +694,7 @@ sub detect_non_method_member{ |
|
|
} |
|
|
|
|
|
# SIP_SKIP |
|
|
if ( $LINE =~ m/SIP_SKIP|SIP_PYTHON_OPERATOR_/ ){ |
|
|
if ( $LINE =~ m/SIP_SKIP|SIP_PYTHON_SPECIAL_/ ){ |
|
|
dbg_info('SIP SKIP!'); |
|
|
# if multiline definition, remove previous lines |
|
|
if ( $MULTILINE_DEFINITION != MULTILINE_NO){ |
|
@@ -711,9 +711,18 @@ sub detect_non_method_member{ |
|
|
detect_and_remove_following_body_or_initializerlist(); |
|
|
# line skipped, go to next iteration |
|
|
|
|
|
if ($LINE =~ m/SIP_PYTHON_OPERATOR_(\w+)\(\s*(\w+)\s*\)/ ){ |
|
|
my $pyop = "${ACTUAL_CLASS}.__" . lc($1) . "__ = lambda self: self.$2()"; |
|
|
dbg_info("PYTHON OPERATOR $pyop"); |
|
|
if ($LINE =~ m/SIP_PYTHON_SPECIAL_(\w+)\(\s*(".*"|\w+)\s*\)/ ){ |
|
|
my $method_or_code = $2; |
|
|
dbg_info("PYTHON SPECIAL method or code: $method_or_code"); |
|
|
my $pyop = "${ACTUAL_CLASS}.__" . lc($1) . "__ = lambda self: "; |
|
|
if ( $method_or_code =~ m/^"(.*)"$/ ){ |
|
|
$pyop .= $1; |
|
|
} |
|
|
else |
|
|
{ |
|
|
$pyop .= "self.${method_or_code}()"; |
|
|
} |
|
|
dbg_info("PYTHON SPECIAL $pyop"); |
|
|
if ($python_output ne ''){ |
|
|
push @OUTPUT_PYTHON, "$pyop\n"; |
|
|
} |
|
|
|
@@ -39,6 +39,16 @@ count=0 |
|
|
|
|
|
modules=(core gui analysis server) |
|
|
for module in "${modules[@]}"; do |
|
|
|
|
|
# clean auto_additions and auto_generated folders |
|
|
rm -rf python/${module}/auto_additions/*.py |
|
|
rm -rf python/${module}/auto_generated/*.py |
|
|
# put back __init__.py |
|
|
echo '""" |
|
|
This folder is completed using sipify.pl script |
|
|
It is not aimed to be manually edited |
|
|
"""' > python/${module}/auto_additions/__init__.py |
|
|
|
|
|
while read -r sipfile; do |
|
|
echo "$sipfile.in" |
|
|
header=$(${GP}sed -E 's@(.*)\.sip@src/\1.h@; s@auto_generated/@@' <<< $sipfile) |
|
|
|
@@ -247,6 +247,13 @@ class CORE_EXPORT QgsCircle : public QgsEllipse |
|
|
|
|
|
QString toString( int pointPrecision = 17, int radiusPrecision = 17, int azimuthPrecision = 2 ) const override; |
|
|
|
|
|
#ifdef SIP_RUN |
|
|
SIP_PYOBJECT __repr__(); |
|
|
% MethodCode |
|
|
QString str = QStringLiteral( "<QgsCircle: %1>" ).arg( sipCpp->toString() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
% End |
|
|
#endif |
|
|
}; |
|
|
|
|
|
#endif // QGSCIRCLE_H |
|
@@ -146,6 +146,14 @@ class CORE_EXPORT QgsCircularString: public QgsCurve |
|
|
|
|
|
QgsCircularString *createEmptyWithSameType() const override SIP_FACTORY; |
|
|
|
|
|
#ifdef SIP_RUN |
|
|
SIP_PYOBJECT __repr__(); |
|
|
% MethodCode |
|
|
QString str = QStringLiteral( "<QgsCircularString: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
% End |
|
|
#endif |
|
|
|
|
|
protected: |
|
|
|
|
|
QgsRectangle calculateBoundingBox() const override; |
|
|
|
@@ -146,6 +146,14 @@ class CORE_EXPORT QgsCompoundCurve: public QgsCurve |
|
|
|
|
|
QgsCompoundCurve *createEmptyWithSameType() const override SIP_FACTORY; |
|
|
|
|
|
#ifdef SIP_RUN |
|
|
SIP_PYOBJECT __repr__(); |
|
|
% MethodCode |
|
|
QString str = QStringLiteral( "<QgsCompoundCurve: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
% End |
|
|
#endif |
|
|
|
|
|
protected: |
|
|
|
|
|
QgsRectangle calculateBoundingBox() const override; |
|
|
|
@@ -204,6 +204,14 @@ class CORE_EXPORT QgsCurvePolygon: public QgsSurface |
|
|
|
|
|
QgsCurvePolygon *createEmptyWithSameType() const override SIP_FACTORY; |
|
|
|
|
|
#ifdef SIP_RUN |
|
|
SIP_PYOBJECT __repr__(); |
|
|
% MethodCode |
|
|
QString str = QStringLiteral( "<QgsCurvePolygon: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
% End |
|
|
#endif |
|
|
|
|
|
protected: |
|
|
|
|
|
int childCount() const override; |
|
|
|
@@ -240,6 +240,14 @@ class CORE_EXPORT QgsEllipse |
|
|
*/ |
|
|
virtual QString toString( int pointPrecision = 17, int axisPrecision = 17, int azimuthPrecision = 2 ) const; |
|
|
|
|
|
#ifdef SIP_RUN |
|
|
SIP_PYOBJECT __repr__(); |
|
|
% MethodCode |
|
|
QString str = QStringLiteral( "<QgsEllipse: %1>" ).arg( sipCpp->toString() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
% End |
|
|
#endif |
|
|
|
|
|
protected: |
|
|
QgsPoint mCenter; |
|
|
double mSemiMajorAxis = 0.0; |
|
|
|
@@ -1248,6 +1248,14 @@ class CORE_EXPORT QgsGeometry |
|
|
*/ |
|
|
QString asWkt( int precision = 17 ) const; |
|
|
|
|
|
#ifdef SIP_RUN |
|
|
SIP_PYOBJECT __repr__(); |
|
|
% MethodCode |
|
|
QString str = QStringLiteral( "<QgsGeometry: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
% End |
|
|
#endif |
|
|
|
|
|
/** |
|
|
* Exports the geometry to a GeoJSON string. |
|
|
*/ |
|
|
|
@@ -346,6 +346,14 @@ class CORE_EXPORT QgsLineString: public QgsCurve |
|
|
|
|
|
QgsLineString *createEmptyWithSameType() const override SIP_FACTORY; |
|
|
|
|
|
#ifdef SIP_RUN |
|
|
SIP_PYOBJECT __repr__(); |
|
|
% MethodCode |
|
|
QString str = QStringLiteral( "<QgsLineString: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
% End |
|
|
#endif |
|
|
|
|
|
protected: |
|
|
|
|
|
QgsRectangle calculateBoundingBox() const override; |
|
|
|
@@ -73,6 +73,13 @@ class CORE_EXPORT QgsMultiCurve: public QgsGeometryCollection |
|
|
|
|
|
QgsMultiCurve *createEmptyWithSameType() const override SIP_FACTORY; |
|
|
|
|
|
#ifdef SIP_RUN |
|
|
SIP_PYOBJECT __repr__(); |
|
|
% MethodCode |
|
|
QString str = QStringLiteral( "<QgsMulitCurve: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
% End |
|
|
#endif |
|
|
|
|
|
}; |
|
|
|
|
|
|
@@ -65,6 +65,14 @@ class CORE_EXPORT QgsMultiLineString: public QgsMultiCurve |
|
|
|
|
|
QgsMultiLineString *createEmptyWithSameType() const override SIP_FACTORY; |
|
|
|
|
|
#ifdef SIP_RUN |
|
|
SIP_PYOBJECT __repr__(); |
|
|
% MethodCode |
|
|
QString str = QStringLiteral( "<QgsMultiLineString: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
% End |
|
|
#endif |
|
|
|
|
|
protected: |
|
|
|
|
|
bool wktOmitChildType() const override; |
|
|
|
@@ -66,6 +66,14 @@ class CORE_EXPORT QgsMultiPoint: public QgsGeometryCollection |
|
|
|
|
|
QgsMultiPoint *createEmptyWithSameType() const override SIP_FACTORY; |
|
|
|
|
|
#ifdef SIP_RUN |
|
|
SIP_PYOBJECT __repr__(); |
|
|
% MethodCode |
|
|
QString str = QStringLiteral( "<QgsMultiPoint: %1>" ).arg( sipCpp->asWkt() ); |
|
|
sipRes = PyUnicode_FromString( str.toUtf8().data() ); |
|
|
% End |
|
|
#endif |
|
|
|
|
|
protected: |
|
|
|
|
|
bool wktOmitChildType() const override; |
|
|
Oops, something went wrong.