QGIS API Documentation 4.1.0-Master (31622b25bb0)
Loading...
Searching...
No Matches
qgsvertexid.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvertexid.h
3 -------------------------------------------------------------------
4Date : 04 Sept 2014
5Copyright : (C) 2014 by Marco Hugentobler
6email : marco.hugentobler at sourcepole dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSVERTEXID_H
17#define QGSVERTEXID_H
18
19#include "qgis.h"
20#include "qgis_core.h"
21
22#include <QHash>
23#include <QString>
24
25using namespace Qt::StringLiterals;
26
28
34struct CORE_EXPORT QgsVertexId
35{
36 // clang-format off
40 explicit QgsVertexId( int _part = -1, int _ring = -1, int _vertex = -1, Qgis::VertexType _type = Qgis::VertexType::Segment ) SIP_HOLDGIL
41 // clang-format on
42: part( _part )
43 , ring( _ring )
44 , vertex( _vertex )
45 , type( _type )
46 {}
47
51 bool isValid() const SIP_HOLDGIL { return part >= 0 && ring >= 0 && vertex >= 0; }
52
54 {
55 return part == other.part && ring == other.ring && vertex == other.vertex;
56 }
58 {
59 return part != other.part || ring != other.ring || vertex != other.vertex;
60 }
61
66 {
67 return part >= 0 && o.part == part;
68 }
69
75 {
76 return partEqual( o ) && ( ring >= 0 && o.ring == ring );
77 }
78
84 {
85 return ringEqual( o ) && ( vertex >= 0 && o.vertex == vertex );
86 }
87
91 bool isValid( const QgsAbstractGeometry *geom ) const SIP_HOLDGIL;
92
94 int part = -1;
95
97 int ring = -1;
98
100 int vertex = -1;
101
104
105#ifdef SIP_RUN
106// clang-format off
107 SIP_PYOBJECT __repr__();
108 % MethodCode
109 QString str = u"<QgsVertexId: %1,%2,%3 %4>"_s.arg( sipCpp->part ).arg( sipCpp->ring ).arg( sipCpp->vertex ).arg( qgsEnumValueToKey( sipCpp->type ) );
110 sipRes = PyUnicode_FromString( str.toUtf8().data() );
111 % End
112// clang-format on
113#endif
114
115};
116
117#ifndef SIP_RUN
118inline size_t qHash( QgsVertexId id, size_t seed = 0 ) noexcept
119{
120 return qHashMulti( seed, id.part, id.ring, id.vertex );
121}
122#endif
123
124#endif //QGSVERTEXID_H
VertexType
Types of vertex.
Definition qgis.h:3246
@ Segment
The actual start or end point of a segment.
Definition qgis.h:3247
Abstract base class for all geometries.
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
Definition qgis.h:7404
#define SIP_HOLDGIL
Definition qgis_sip.h:178
size_t qHash(QgsVertexId id, size_t seed=0) noexcept
Utility class for identifying a unique vertex within a geometry.
Definition qgsvertexid.h:35
int vertex
Vertex number.
bool isValid() const
Returns true if the vertex id is valid.
Definition qgsvertexid.h:51
int part
Part number.
Definition qgsvertexid.h:94
bool vertexEqual(QgsVertexId o) const
Returns true if this vertex ID corresponds to the same vertex as another vertex ID (i....
Definition qgsvertexid.h:83
bool operator==(QgsVertexId other) const
Definition qgsvertexid.h:53
bool operator!=(QgsVertexId other) const
Definition qgsvertexid.h:57
Qgis::VertexType type
Vertex type.
int ring
Ring number.
Definition qgsvertexid.h:97
bool ringEqual(QgsVertexId o) const
Returns true if this vertex ID belongs to the same ring as another vertex ID (i.e.
Definition qgsvertexid.h:74
QgsVertexId(int _part=-1, int _ring=-1, int _vertex=-1, Qgis::VertexType _type=Qgis::VertexType::Segment)
Constructor for QgsVertexId.
Definition qgsvertexid.h:40
bool partEqual(QgsVertexId o) const
Returns true if this vertex ID belongs to the same part as another vertex ID.
Definition qgsvertexid.h:65