21 #include "qgis_core.h"
41 Q_PROPERTY(
double x READ x WRITE setX )
42 Q_PROPERTY(
double y READ y WRITE setY )
43 Q_PROPERTY(
double z READ z WRITE setZ )
44 Q_PROPERTY(
double m READ m WRITE setM )
75 QgsPoint(
double x = std::numeric_limits<double>::quiet_NaN(),
double y = std::numeric_limits<double>::quiet_NaN(),
double z = std::numeric_limits<double>::quiet_NaN(),
double m = std::numeric_limits<double>::quiet_NaN(),
QgsWkbTypes::Type wkbType =
QgsWkbTypes::Unknown );
77 QgsPoint( SIP_PYOBJECT x = Py_None, SIP_PYOBJECT y = Py_None, SIP_PYOBJECT z = Py_None, SIP_PYOBJECT m = Py_None, SIP_PYOBJECT wkbType = Py_None ) [(
double x = 0.0,
double y = 0.0,
double z = 0.0,
double m = 0.0,
QgsWkbTypes::Type wkbType =
QgsWkbTypes::Unknown )];
79 if ( sipCanConvertToType( a0, sipType_QgsPointXY, SIP_NOT_NONE ) && a1 == Py_None && a2 == Py_None && a3 == Py_None && a4 == Py_None )
84 QgsPointXY *p =
reinterpret_cast<QgsPointXY *
>( sipConvertToType( a0, sipType_QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
87 sipReleaseType( p, sipType_QgsPointXY, state );
91 sipCpp =
new sipQgsPoint(
QgsPoint( *p ) );
94 else if ( sipCanConvertToType( a0, sipType_QPointF, SIP_NOT_NONE ) && a1 == Py_None && a2 == Py_None && a3 == Py_None && a4 == Py_None )
99 QPointF *p =
reinterpret_cast<QPointF *
>( sipConvertToType( a0, sipType_QPointF, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
102 sipReleaseType( p, sipType_QPointF, state );
106 sipCpp =
new sipQgsPoint(
QgsPoint( *p ) );
110 ( a0 == Py_None || PyFloat_AsDouble( a0 ) != -1.0 || !PyErr_Occurred() ) &&
111 ( a1 == Py_None || PyFloat_AsDouble( a1 ) != -1.0 || !PyErr_Occurred() ) &&
112 ( a2 == Py_None || PyFloat_AsDouble( a2 ) != -1.0 || !PyErr_Occurred() ) &&
113 ( a3 == Py_None || PyFloat_AsDouble( a3 ) != -1.0 || !PyErr_Occurred() ) &&
114 ( a4 == Py_None || sipCanConvertToEnum( a4, sipType_QgsWkbTypes_Type ) ) )
116 double x = a0 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a0 );
117 double y = a1 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a1 );
118 double z = a2 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a2 );
119 double m = a3 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a3 );
121 sipCpp =
new sipQgsPoint(
QgsPoint( x, y, z, m, wkbType ) );
125 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"Invalid type in constructor arguments." ).toUtf8().constData() );
146 explicit QgsPoint(
QgsWkbTypes::Type wkbType,
double x = std::numeric_limits<double>::quiet_NaN(),
double y = std::numeric_limits<double>::quiet_NaN(),
double z = std::numeric_limits<double>::quiet_NaN(),
double m = std::numeric_limits<double>::quiet_NaN() )
SIP_SKIP;
150 const QgsPoint *pt = qgsgeometry_cast< const QgsPoint * >( &other );
159 const bool nan1X = std::isnan( mX );
160 const bool nan2X = std::isnan( pt->
x() );
161 if ( nan1X != nan2X )
166 const bool nan1Y = std::isnan( mY );
167 const bool nan2Y = std::isnan( pt->
y() );
168 if ( nan1Y != nan2Y )
175 const bool nan1Z = std::isnan( mZ );
176 const bool nan2Z = std::isnan( pt->
z() );
177 if ( nan1Z != nan2Z )
185 const bool nan1M = std::isnan( mM );
186 const bool nan2M = std::isnan( pt->
m() );
187 if ( nan1M != nan2M )
206 double x()
const {
return mX; }
213 double y()
const {
return mY; }
220 double z()
const {
return mZ; }
227 double m()
const {
return mM; }
270 void setX(
double x )
281 void setY(
double y )
294 void setZ(
double z )
309 void setM(
double m )
321 QPointF toQPointF()
const
323 return QPointF( mX, mY );
333 double distance(
double x,
double y )
const
335 return std::sqrt( ( mX - x ) * ( mX - x ) + ( mY - y ) * ( mY - y ) );
344 double distance(
const QgsPoint &other )
const
346 return std::sqrt( ( mX - other.
x() ) * ( mX - other.
x() ) + ( mY - other.
y() ) * ( mY - other.
y() ) );
356 double distanceSquared(
double x,
double y )
const
358 return ( mX - x ) * ( mX - x ) + ( mY - y ) * ( mY - y );
368 double distanceSquared(
const QgsPoint &other )
const
370 return ( mX - other.
x() ) * ( mX - other.
x() ) + ( mY - other.
y() ) * ( mY - other.
y() );
380 double distance3D(
double x,
double y,
double z )
const;
388 double distance3D(
const QgsPoint &other )
const;
397 double distanceSquared3D(
double x,
double y,
double z )
const;
406 double distanceSquared3D(
const QgsPoint &other )
const;
412 double azimuth(
const QgsPoint &other )
const;
419 double inclination(
const QgsPoint &other )
const;
451 QgsPoint project(
double distance,
double azimuth,
double inclination = 90.0 )
const;
489 QgsPoint *snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0 ) const override
SIP_FACTORY;
490 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false ) override;
491 void clear() override;
493 bool fromWkt( const QString &wkt ) override;
495 QString asWkt(
int precision = 17 ) const override;
499 QString asKml(
int precision = 17 ) const override;
500 void draw( QPainter &p ) const override;
502 void transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
double mTranslate = 0.0,
double mScale = 1.0 ) override;
504 int nCoordinates() const override;
505 int vertexNumberFromVertexId(
QgsVertexId id ) const override;
507 bool isValid( QString &error
SIP_OUT,
int flags = 0 ) const override;
512 bool deleteVertex(
QgsVertexId position ) override;
522 double vertexAngle(
QgsVertexId vertex ) const override;
524 int vertexCount(
int = 0,
int = 0 ) const override;
525 int ringCount(
int = 0 ) const override;
526 int partCount() const override;
529 double segmentLength(
QgsVertexId startVertex ) const override;
531 bool addZValue(
double zValue = 0 ) override;
532 bool addMValue(
double mValue = 0 ) override;
533 bool dropZValue() override;
534 bool dropMValue() override;
535 void swapXy() override;
553 return static_cast<const QgsPoint *
>( geom );
561 SIP_PYOBJECT __repr__();
563 QString str = QStringLiteral(
"<QgsPoint: %1>" ).arg( sipCpp->asWkt() );
564 sipRes = PyUnicode_FromString( str.toUtf8().constData() );