QGIS API Documentation  2.10.1-Pisa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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( QgsWKBTypes::Type type, double x = 0.0, double y = 0.0, double z = 0.0, double m = 0.0 );
34 
35  bool operator==( const QgsPointV2& pt ) const;
36  bool operator!=( const QgsPointV2& pt ) const;
37 
38  virtual QgsAbstractGeometryV2* clone() const override;
39  void clear() override;
40 
41  double x() const { return mX; }
42  double y() const { return mY; }
43  double z() const { return mZ; }
44  double m() const { return mM; }
45 
46  void setX( double x ) { mX = x; }
47  void setY( double y ) { mY = y; }
48  void setZ( double z ) { mZ = z; }
49  void setM( double m ) { mM = m; }
50 
51  virtual QString geometryType() const override { return "Point"; }
52 
53  //implementation of inherited methods
54  virtual int dimension() const override { return 0; }
55 
56 
57  virtual bool fromWkb( const unsigned char* wkb ) override;
58  virtual bool fromWkt( const QString& wkt ) override;
59 
60  int wkbSize() const override;
61  unsigned char* asWkb( int& binarySize ) const override;
62  QString asWkt( int precision = 17 ) const override;
63  QDomElement asGML2( QDomDocument& doc, int precision = 17, const QString& ns = "gml" ) const override;
64  QDomElement asGML3( QDomDocument& doc, int precision = 17, const QString& ns = "gml" ) const override;
65  QString asJSON( int precision = 17 ) const override;
66 
67  virtual QgsRectangle calculateBoundingBox() const override { return QgsRectangle( mX, mY, mX, mY );}
68 
69  void draw( QPainter& p ) const override;
70  void transform( const QgsCoordinateTransform& ct ) override;
71  void transform( const QTransform& t ) override;
72 
73  virtual void coordinateSequence( QList< QList< QList< QgsPointV2 > > >& coord ) const override;
74 
75  //low-level editing
76  virtual bool insertVertex( const QgsVertexId& position, const QgsPointV2& vertex ) override { Q_UNUSED( position ); Q_UNUSED( vertex ); return false; }
77  virtual bool moveVertex( const QgsVertexId& position, const QgsPointV2& newPos ) override;
78  virtual bool deleteVertex( const QgsVertexId& position ) override { Q_UNUSED( position ); return false; }
79 
80  double closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const override;
81  bool nextVertex( QgsVertexId& id, QgsPointV2& vertex ) const override;
82 
83  private:
84  double mX;
85  double mY;
86  double mZ;
87  double mM;
88 };
89 
90 #endif // QGSPOINTV2_H
A rectangle specified with double values.
Definition: qgsrectangle.h:35
void setZ(double z)
Definition: qgspointv2.h:48
double x() const
Definition: qgspointv2.h:41
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 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:54
Abstract base class for all geometries.
void setX(double x)
Definition: qgspointv2.h:46
virtual int wkbSize() const =0
Returns the size of the WKB representation of the geometry.
void setY(double y)
Definition: qgspointv2.h:47
double y() const
Definition: qgspointv2.h:42
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:51
Utility class for identifying a unique vertex within a geometry.
double z() const
Definition: qgspointv2.h:43
void setM(double m)
Definition: qgspointv2.h:49
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 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.
virtual void transform(const QgsCoordinateTransform &ct)=0
Transforms the geometry using a coordinate transform.
virtual bool insertVertex(const QgsVertexId &position, const QgsPointV2 &vertex) override
Inserts a vertex into the geometry.
Definition: qgspointv2.h:76
virtual QgsRectangle calculateBoundingBox() const override
Calculates the minimal bounding box for the geometry.
Definition: qgspointv2.h:67
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:44
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 bool deleteVertex(const QgsVertexId &position) override
Deletes a vertex within the geometry.
Definition: qgspointv2.h:78