sipify QgsPoint

This commit is contained in:
raymondnijssen 2017-04-30 21:23:57 +02:00 committed by Denis Rouzaud
parent bb3a41883d
commit b82c9b8917
3 changed files with 291 additions and 132 deletions

View File

@ -65,7 +65,6 @@ core/qgspallabeling.sip
core/qgspathresolver.sip core/qgspathresolver.sip
core/qgspluginlayer.sip core/qgspluginlayer.sip
core/qgspluginlayerregistry.sip core/qgspluginlayerregistry.sip
core/qgspoint.sip
core/qgspointlocator.sip core/qgspointlocator.sip
core/qgsproject.sip core/qgsproject.sip
core/qgsprojectbadlayerhandler.sip core/qgsprojectbadlayerhandler.sip

View File

@ -1,222 +1,343 @@
/** \ingroup core /************************************************************************
* A class to represent a point. * This file has been generated automatically from *
* Currently no Z axis / 2.5D support is implemented. * *
*/ * src/core/qgspoint.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsPoint class QgsPoint
{ {
%Docstring
%TypeHeaderCode A class to represent a point.
#include <qgspoint.h> For Z and M support prefer QgsPointV2.
#include <QString>
%End %End
%TypeHeaderCode
#include "qgspoint.h"
%End
public: public:
/// Default constructor
QgsPoint(); QgsPoint();
/** Create a point from another point */ QgsPoint( const QgsPoint &p );
QgsPoint( const QgsPoint& p ); %Docstring
Create a point from another point
%End
/** Create a point from x,y coordinates
* @param x x coordinate
* @param y y coordinate
*/
QgsPoint( double x, double y ); QgsPoint( double x, double y );
%Docstring
Create a point from x,y coordinates
\param x x coordinate
\param y y coordinate
%End
/** Create a point from a QPointF
* @param point QPointF source
* @note added in QGIS 2.7
*/
QgsPoint( QPointF point ); QgsPoint( QPointF point );
%Docstring
Create a point from a QPointF
\param point QPointF source
.. versionadded:: 2.7
%End
/** Create a point from a QPoint
* @param point QPoint source
* @note added in QGIS 2.7
*/
QgsPoint( QPoint point ); QgsPoint( QPoint point );
%Docstring
Create a point from a QPoint
\param point QPoint source
.. versionadded:: 2.7
%End
QgsPoint( const QgsPointV2 &point );
%Docstring
Create a new point.
Z and M values will be dropped.
.. versionadded:: 3.0
%End
~QgsPoint(); ~QgsPoint();
/** Sets the x value of the point
* @param x x coordinate
*/
void setX( double x ); void setX( double x );
%Docstring
Sets the x value of the point
\param x x coordinate
%End
/** Sets the y value of the point
* @param y y coordinate
*/
void setY( double y ); void setY( double y );
%Docstring
Sets the y value of the point
\param y y coordinate
%End
/** Sets the x and y value of the point */
void set( double x, double y ); void set( double x, double y );
%Docstring
Sets the x and y value of the point
%End
/** Get the x value of the point
* @return x coordinate
*/
double x() const; double x() const;
%Docstring
Get the x value of the point
:return: x coordinate
:rtype: float
%End
/** Get the y value of the point
* @return y coordinate
*/
double y() const; double y() const;
%Docstring
Get the y value of the point
:return: y coordinate
:rtype: float
%End
/** Converts a point to a QPointF
* @returns QPointF with same x and y values
* @note added in QGIS 2.7
*/
QPointF toQPointF() const; QPointF toQPointF() const;
%Docstring
Converts a point to a QPointF
:return: QPointF with same x and y values
.. versionadded:: 2.7
:rtype: QPointF
%End
//! String representation of the point (x,y)
QString toString() const; QString toString() const;
%Docstring
String representation of the point (x,y)
:rtype: str
%End
//! As above but with precision for string representation of a point
QString toString( int precision ) const; QString toString( int precision ) const;
%Docstring
As above but with precision for string representation of a point
:rtype: str
%End
/** Return a string representation as degrees minutes seconds.
* Its up to the calling function to ensure that this point can
* be meaningfully represented in this form.
* @param precision number of decimal points to use for seconds
* @param useSuffix set to true to include a direction suffix (e.g., 'N'),
* set to false to use a "-" prefix for west and south coordinates
* @param padded set to true to force minutes and seconds to use two decimals,
* e.g., '05' instead of '5'.
*/
QString toDegreesMinutesSeconds( int precision, const bool useSuffix = true, const bool padded = false ) const; QString toDegreesMinutesSeconds( int precision, const bool useSuffix = true, const bool padded = false ) const;
%Docstring
Return a string representation as degrees minutes seconds.
Its up to the calling function to ensure that this point can
be meaningfully represented in this form.
\param precision number of decimal points to use for seconds
\param useSuffix set to true to include a direction suffix (e.g., 'N'),
set to false to use a "-" prefix for west and south coordinates
\param padded set to true to force minutes and seconds to use two decimals,
e.g., '05' instead of '5'.
:rtype: str
%End
/** Return a string representation as degrees minutes.
* Its up to the calling function to ensure that this point can
* be meaningfully represented in this form.
* @param precision number of decimal points to use for minutes
* @param useSuffix set to true to include a direction suffix (e.g., 'N'),
* set to false to use a "-" prefix for west and south coordinates
* @param padded set to true to force minutes to use two decimals,
* e.g., '05' instead of '5'.
*/
QString toDegreesMinutes( int precision, const bool useSuffix = true, const bool padded = false ) const; QString toDegreesMinutes( int precision, const bool useSuffix = true, const bool padded = false ) const;
%Docstring
Return a string representation as degrees minutes.
Its up to the calling function to ensure that this point can
be meaningfully represented in this form.
\param precision number of decimal points to use for minutes
\param useSuffix set to true to include a direction suffix (e.g., 'N'),
set to false to use a "-" prefix for west and south coordinates
\param padded set to true to force minutes to use two decimals,
e.g., '05' instead of '5'.
:rtype: str
%End
/** Return the well known text representation for the point.
* The wkt is created without an SRID.
* @return Well known text in the form POINT(x y)
*/
QString wellKnownText() const; QString wellKnownText() const;
%Docstring
Return the well known text representation for the point.
The wkt is created without an SRID.
:return: Well known text in the form POINT(x y)
:rtype: str
%End
/** Returns the squared distance between this point a specified x, y coordinate.
* @see distance()
*/
double sqrDist( double x, double y ) const; double sqrDist( double x, double y ) const;
%Docstring
Returns the squared distance between this point a specified x, y coordinate.
.. seealso:: distance()
:rtype: float
%End
/** Returns the squared distance between this point another point. double sqrDist( const QgsPoint &other ) const;
* @see distance() %Docstring
*/ Returns the squared distance between this point another point.
double sqrDist( const QgsPoint& other ) const; .. seealso:: distance()
:rtype: float
%End
/** Returns the distance between this point and a specified x, y coordinate.
* @param x x-coordniate
* @param y y-coordinate
* @see sqrDist()
* @note added in QGIS 2.16
*/
double distance( double x, double y ) const; double distance( double x, double y ) const;
%Docstring
Returns the distance between this point and a specified x, y coordinate.
\param x x-coordniate
\param y y-coordinate
.. seealso:: sqrDist()
.. versionadded:: 2.16
:rtype: float
%End
/** Returns the distance between this point and another point. double distance( const QgsPoint &other ) const;
* @param other other point %Docstring
* @see sqrDist() Returns the distance between this point and another point.
* @note added in QGIS 2.16 \param other other point
*/ .. seealso:: sqrDist()
double distance( const QgsPoint& other ) const; .. versionadded:: 2.16
:rtype: float
%End
/** Returns the minimum distance between this point and a segment */ double sqrDistToSegment( double x1, double y1, double x2, double y2, QgsPoint &minDistPoint /Out/, double epsilon = DEFAULT_SEGMENT_EPSILON ) const;
double sqrDistToSegment( double x1, double y1, double x2, double y2, QgsPoint& minDistPoint /Out/, double epsilon = DEFAULT_SEGMENT_EPSILON ) const; %Docstring
Returns the minimum distance between this point and a segment
:rtype: float
%End
/** Calculates azimuth between this point and other one (clockwise in degree, starting from north) */ double azimuth( const QgsPoint &other ) const;
double azimuth( const QgsPoint& other ) const; %Docstring
Calculates azimuth between this point and other one (clockwise in degree, starting from north)
:rtype: float
%End
/** Returns a new point which corresponds to this point projected by a specified distance
* in a specified bearing.
* @param distance distance to project
* @param bearing angle to project in, clockwise in degrees starting from north
* @note added in QGIS 2.16
*/
QgsPoint project( double distance, double bearing ) const; QgsPoint project( double distance, double bearing ) const;
%Docstring
Returns a new point which corresponds to this point projected by a specified distance
in a specified bearing.
\param distance distance to project
\param bearing angle to project in, clockwise in degrees starting from north
.. versionadded:: 2.16
:rtype: QgsPoint
%End
/** Compares this point with another point with a fuzzy tolerance
* @param other point to compare with
* @param epsilon maximum difference for coordinates between the points
* @returns true if points are equal within specified tolerance
* @note added in QGIS 2.9
*/
bool compare( const QgsPoint &other, double epsilon = 4 * DBL_EPSILON ) const; bool compare( const QgsPoint &other, double epsilon = 4 * DBL_EPSILON ) const;
%Docstring
Compares this point with another point with a fuzzy tolerance
\param other point to compare with
\param epsilon maximum difference for coordinates between the points
:return: true if points are equal within specified tolerance
.. versionadded:: 2.9
:rtype: bool
%End
//! equality operator
bool operator==( const QgsPoint &other ); bool operator==( const QgsPoint &other );
%Docstring
equality operator
:rtype: bool
%End
//! Inequality operator
bool operator!=( const QgsPoint &other ) const; bool operator!=( const QgsPoint &other ) const;
%Docstring
Inequality operator
:rtype: bool
%End
//! Multiply x and y by the given value
void multiply( double scalar ); void multiply( double scalar );
%Docstring
Multiply x and y by the given value
%End
//! Test if this point is on the segment defined by points a, b int onSegment( const QgsPoint &a, const QgsPoint &b ) const;
//! @return 0 if this point is not on the open ray through a and b, %Docstring
//! 1 if point is on open ray a, 2 if point is within line segment, 3 if point is on open ray b.
//! 3 if point is on open ray b. :rtype: int
int onSegment( const QgsPoint& a, const QgsPoint& b ) const; %End
//! Calculates the vector obtained by subtracting a point from this point
QgsVector operator-( const QgsPoint& p ) const;
//! Adds a vector to this point in place QgsVector operator-( const QgsPoint &p ) const;
%Docstring
Calculates the vector obtained by subtracting a point from this point
:rtype: QgsVector
%End
QgsPoint &operator+=( QgsVector v ); QgsPoint &operator+=( QgsVector v );
%Docstring
Adds a vector to this point in place
:rtype: QgsPoint
%End
//! Subtracts a vector from this point in place
QgsPoint &operator-=( QgsVector v ); QgsPoint &operator-=( QgsVector v );
%Docstring
Subtracts a vector from this point in place
:rtype: QgsPoint
%End
//! Adds a vector to this point
QgsPoint operator+( QgsVector v ) const; QgsPoint operator+( QgsVector v ) const;
%Docstring
Adds a vector to this point
:rtype: QgsPoint
%End
//! Subtracts a vector from this point
QgsPoint operator-( QgsVector v ) const; QgsPoint operator-( QgsVector v ) const;
%Docstring
Subtracts a vector from this point
:rtype: QgsPoint
%End
//! Multiplies the coordinates in this point by a scalar quantity
QgsPoint operator*( double scalar ) const; QgsPoint operator*( double scalar ) const;
%Docstring
Multiplies the coordinates in this point by a scalar quantity
:rtype: QgsPoint
%End
//! Divides the coordinates in this point by a scalar quantity
QgsPoint operator/( double scalar ) const; QgsPoint operator/( double scalar ) const;
%Docstring
Divides the coordinates in this point by a scalar quantity
:rtype: QgsPoint
%End
//! Multiplies the coordinates in this point by a scalar quantity in place
QgsPoint &operator*=( double scalar ); QgsPoint &operator*=( double scalar );
%Docstring
Multiplies the coordinates in this point by a scalar quantity in place
:rtype: QgsPoint
%End
//! Divides the coordinates in this point by a scalar quantity in place
QgsPoint &operator/=( double scalar ); QgsPoint &operator/=( double scalar );
%Docstring
Divides the coordinates in this point by a scalar quantity in place
:rtype: QgsPoint
%End
private:
SIP_PYOBJECT __repr__(); SIP_PYOBJECT __repr__();
%MethodCode %MethodCode
QString str = "(" + QString::number(sipCpp->x()) + "," + QString::number(sipCpp->y()) + ")"; QString str = "(" + QString::number( sipCpp->x() ) + "," + QString::number( sipCpp->y() ) + ")";
//QString str("(%f,%f)").arg(sipCpp->x()).arg(sipCpp->y()); //QString str("(%f,%f)").arg(sipCpp->x()).arg(sipCpp->y());
sipRes = PyUnicode_FromString( str.toUtf8().data() ); sipRes = PyUnicode_FromString( str.toUtf8().data() );
%End %End
int __len__(); int __len__();
%Docstring
:rtype: int
%End
%MethodCode %MethodCode
sipRes = 2; sipRes = 2;
%End %End
SIP_PYOBJECT __getitem__(int); SIP_PYOBJECT __getitem__( int );
%MethodCode %MethodCode
if (a0 == 0) { if ( a0 == 0 )
sipRes = Py_BuildValue("d",sipCpp->x()); {
} else if (a0 == 1) { sipRes = Py_BuildValue( "d", sipCpp->x() );
sipRes = Py_BuildValue("d",sipCpp->y()); }
} else { else if ( a0 == 1 )
QString msg = QString("Bad index: %1").arg(a0); {
PyErr_SetString(PyExc_IndexError, msg.toAscii().constData()); sipRes = Py_BuildValue( "d", sipCpp->y() );
}
else
{
QString msg = QString( "Bad index: %1" ).arg( a0 );
PyErr_SetString( PyExc_IndexError, msg.toAscii().constData() );
} }
%End %End
long __hash__() const; long __hash__() const;
%Docstring
:rtype: long
%End
%MethodCode %MethodCode
sipRes = qHash( *sipCpp ); sipRes = qHash( *sipCpp );
%End %End
}; // class QgsPoint }; // class QgsPoint
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgspoint.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/

View File

@ -195,7 +195,7 @@ class CORE_EXPORT QgsPoint
double distance( const QgsPoint &other ) const; double distance( const QgsPoint &other ) const;
//! Returns the minimum distance between this point and a segment //! Returns the minimum distance between this point and a segment
double sqrDistToSegment( double x1, double y1, double x2, double y2, QgsPoint &minDistPoint, double epsilon = DEFAULT_SEGMENT_EPSILON ) const; double sqrDistToSegment( double x1, double y1, double x2, double y2, QgsPoint &minDistPoint SIP_OUT, double epsilon = DEFAULT_SEGMENT_EPSILON ) const;
//! Calculates azimuth between this point and other one (clockwise in degree, starting from north) //! Calculates azimuth between this point and other one (clockwise in degree, starting from north)
double azimuth( const QgsPoint &other ) const; double azimuth( const QgsPoint &other ) const;
@ -271,8 +271,45 @@ class CORE_EXPORT QgsPoint
friend uint qHash( const QgsPoint &pnt ); friend uint qHash( const QgsPoint &pnt );
#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
QString str = "(" + QString::number( sipCpp->x() ) + "," + QString::number( sipCpp->y() ) + ")";
//QString str("(%f,%f)").arg(sipCpp->x()).arg(sipCpp->y());
sipRes = PyUnicode_FromString( str.toUtf8().data() );
% End
int __len__();
% MethodCode
sipRes = 2;
% End
SIP_PYOBJECT __getitem__( int );
% MethodCode
if ( a0 == 0 )
{
sipRes = Py_BuildValue( "d", sipCpp->x() );
}
else if ( a0 == 1 )
{
sipRes = Py_BuildValue( "d", sipCpp->y() );
}
else
{
QString msg = QString( "Bad index: %1" ).arg( a0 );
PyErr_SetString( PyExc_IndexError, msg.toAscii().constData() );
}
% End
long __hash__() const;
% MethodCode
sipRes = qHash( *sipCpp );
% End
#endif
}; // class QgsPoint }; // class QgsPoint
#ifndef SIP_RUN
inline bool operator==( const QgsPoint &p1, const QgsPoint &p2 ) inline bool operator==( const QgsPoint &p1, const QgsPoint &p2 )
{ {
@ -298,4 +335,6 @@ inline uint qHash( const QgsPoint &p )
return hash; return hash;
} }
#endif
#endif //QGSPOINT_H #endif //QGSPOINT_H