QGIS API Documentation  2.12.0-Lyon
qgspointv2.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgspointv2.h
3  --------------
4  begin : September 2014
5  copyright : (C) 2014 by Marco Hugentobler
6  email : marco at sourcepole dot ch
7  ***************************************************************************/
8
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17
18 #ifndef QGSPOINTV2_H
19 #define QGSPOINTV2_H
20
21 #include "qgsabstractgeometryv2.h"
22
29 class CORE_EXPORT QgsPointV2: public QgsAbstractGeometryV2
30 {
31  public:
32  QgsPointV2( double x = 0.0, double y = 0.0 );
33  QgsPointV2( const QgsPoint& p );
34  QgsPointV2( QgsWKBTypes::Type type, double x = 0.0, double y = 0.0, double z = 0.0, double m = 0.0 );
35
36  bool operator==( const QgsPointV2& pt ) const;
37  bool operator!=( const QgsPointV2& pt ) const;
38
39  virtual QgsPointV2* clone() const override;
40  void clear() override;
41
42  double x() const { return mX; }
43  double y() const { return mY; }
44  double z() const { return mZ; }
45  double m() const { return mM; }
46
47  void setX( double x ) { mX = x; }
48  void setY( double y ) { mY = y; }
49  void setZ( double z ) { mZ = z; }
50  void setM( double m ) { mM = m; }
51
52  virtual QString geometryType() const override { return "Point"; }
53
54  //implementation of inherited methods
55  virtual int dimension() const override { return 0; }
56
57
58  virtual bool fromWkb( const unsigned char* wkb ) override;
59  virtual bool fromWkt( const QString& wkt ) override;
60
61  int wkbSize() const override;
62  unsigned char* asWkb( int& binarySize ) const override;
63  QString asWkt( int precision = 17 ) const override;
64  QDomElement asGML2( QDomDocument& doc, int precision = 17, const QString& ns = "gml" ) const override;
65  QDomElement asGML3( QDomDocument& doc, int precision = 17, const QString& ns = "gml" ) const override;
66  QString asJSON( int precision = 17 ) const override;
67
68  virtual QgsRectangle calculateBoundingBox() const override { return QgsRectangle( mX, mY, mX, mY );}
69
70  void draw( QPainter& p ) const override;
71
77  void transform( const QTransform& t ) override;
78
79  virtual void coordinateSequence( QList< QList< QList< QgsPointV2 > > >& coord ) const override;
80
81  //low-level editing
82  virtual bool insertVertex( const QgsVertexId& position, const QgsPointV2& vertex ) override { Q_UNUSED( position ); Q_UNUSED( vertex ); return false; }
83  virtual bool moveVertex( const QgsVertexId& position, const QgsPointV2& newPos ) override;
84  virtual bool deleteVertex( const QgsVertexId& position ) override { Q_UNUSED( position ); return false; }
85
86  double closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const override;
87  bool nextVertex( QgsVertexId& id, QgsPointV2& vertex ) const override;
88
92  double vertexAngle( const QgsVertexId& vertex ) const override { Q_UNUSED( vertex ); return 0.0; }
93
94  virtual int vertexCount( int /*part*/ = 0, int /*ring*/ = 0 ) const override { return 1; }
95  virtual int ringCount( int /*part*/ = 0 ) const override { return 1; }
96  virtual int partCount() const override { return 1; }
97  virtual QgsPointV2 vertexAt( const QgsVertexId& /*id*/ ) const override { return *this; }
98
99  virtual bool addZValue( double zValue = 0 ) override;
100  virtual bool addMValue( double mValue = 0 ) override;
101
102  private:
103  double mX;
104  double mY;
105  double mZ;
106  double mM;
107 };
108
109 #endif // QGSPOINTV2_H
A rectangle specified with double values.
Definition: qgsrectangle.h:35
virtual int ringCount(int=0) const override
Definition: qgspointv2.h:95
void setZ(double z)
Definition: qgspointv2.h:49
double x() const
Definition: qgspointv2.h:42
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
virtual bool moveVertex(const QgsVertexId &position, const QgsPointV2 &newPos)=0
Moves a vertex within the geometry.
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
virtual QgsPointV2 vertexAt(const QgsVertexId &) const override
Returns the point corresponding to a specified vertex id.
Definition: qgspointv2.h:97
virtual QString asJSON(int precision=17) const =0
Returns a GeoJSON representation of the geometry.
virtual int dimension() const override
Returns the inherent dimension of the geometry.
Definition: qgspointv2.h:55
Abstract base class for all geometries.
TransformDirection
Enum used to indicate the direction (forward or inverse) of the transform.
void setX(double x)
Definition: qgspointv2.h:47
virtual int wkbSize() const =0
Returns the size of the WKB representation of the geometry.
void setY(double y)
Definition: qgspointv2.h:48
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
double y() const
Definition: qgspointv2.h:43
virtual void clear()=0
Clears the geometry, ie reset it to a null geometry.
virtual QString geometryType() const override
Returns a unique string representing the geometry type.
Definition: qgspointv2.h:52
Utility class for identifying a unique vertex within a geometry.
double z() const
Definition: qgspointv2.h:44
void setM(double m)
Definition: qgspointv2.h:50
virtual bool fromWkb(const unsigned char *wkb)=0
Sets the geometry from a WKB string.
Point geometry type.
Definition: qgspointv2.h:29
virtual unsigned char * asWkb(int &binarySize) const =0
Returns a WKB representation of the geometry.
virtual void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform)=0
Transforms the geometry using a coordinate transform.
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
virtual QDomElement asGML3(QDomDocument &doc, int precision=17, const QString &ns="gml") const =0
Returns a GML3 representation of the geometry.
virtual bool nextVertex(QgsVertexId &id, QgsPointV2 &vertex) const =0
Returns next vertex id and coordinates.
virtual bool fromWkt(const QString &wkt)=0
Sets the geometry from a WKT string.
A class to represent a point.
Definition: qgspoint.h:63
virtual bool insertVertex(const QgsVertexId &position, const QgsPointV2 &vertex) override
Inserts a vertex into the geometry.
Definition: qgspointv2.h:82
virtual QgsRectangle calculateBoundingBox() const override
Calculates the minimal bounding box for the geometry.
Definition: qgspointv2.h:68
virtual void coordinateSequence(QList< QList< QList< QgsPointV2 > > > &coord) const =0
Retrieves the sequence of geometries, rings and nodes.
Class for doing transforms between two map coordinate systems.
virtual QString asWkt(int precision=17) const =0
Returns a WKT representation of the geometry.
double m() const
Definition: qgspointv2.h:45
virtual void draw(QPainter &p) const =0
Draws the geometry using the specified QPainter.
double ANALYSIS_EXPORT leftOf(Point3D *thepoint, Point3D *p1, Point3D *p2)
Returns whether 'thepoint' is left or right of the line from 'p1' to 'p2'.
virtual QDomElement asGML2(QDomDocument &doc, int precision=17, const QString &ns="gml") const =0
Returns a GML2 representation of the geometry.
virtual QgsAbstractGeometryV2 * clone() const =0
Clones the geometry by performing a deep copy.
virtual double closestSegment(const QgsPointV2 &pt, QgsPointV2 &segmentPt, QgsVertexId &vertexAfter, bool *leftOf, double epsilon) const =0
Searches for the closest segment of the geometry to a given point.
virtual int vertexCount(int=0, int=0) const override
Definition: qgspointv2.h:94
virtual bool deleteVertex(const QgsVertexId &position) override
Deletes a vertex within the geometry.
Definition: qgspointv2.h:84
virtual int partCount() const override
Definition: qgspointv2.h:96
double vertexAngle(const QgsVertexId &vertex) const override
Angle undefined.
Definition: qgspointv2.h:92