QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
qgswkbtypes.h
Go to the documentation of this file.
1/***************************************************************************
2 qgswkbtypes.h
3 -----------------------
4 begin : January 2015
5 copyright : (C) 2015 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 QGSWKBTYPES_H
19#define QGSWKBTYPES_H
20
21#include "qgis.h"
22#include "qgis_core.h"
23#include "qgis_sip.h"
24
25#include <QMap>
26#include <QObject>
27#include <QString>
28
29/***************************************************************************
30 * This class is considered CRITICAL and any change MUST be accompanied with
31 * full unit tests in testqgsstatisticalsummary.cpp.
32 * See details in QEP #17
33 ****************************************************************************/
34
40
41class CORE_EXPORT QgsWkbTypes
42{
43 Q_GADGET
44 public:
53 {
54 switch ( type )
55 {
62
66
70
74
78
82
86
90
94
98
102
106
110
113
116
119
122
125
128
131
134
137
140
143
146
150
154
158
162
166
170
174
178
181
184
187
190
192 return Qgis::WkbType::TIN;
193
195 return Qgis::WkbType::TINZ;
196
198 return Qgis::WkbType::TINM;
199
202
205
209
213
217 }
219 }
220
231 {
232 switch ( type )
233 {
236
239
242
245
248
251
254
257
260
264
268
272
276
280
284
288
292
298
304
310
316
322
328
334
340
344
348
352
356
359
363
367
371 }
373 }
374
375
389 {
390 switch ( geometryType( type ) )
391 {
395 return type;
396
399 return multiType( type );
400 }
402 }
403
419 {
420 switch ( type )
421 {
428
431
434
437
440
443
446
449
452
455
458
461
464
470
474
481
486
492
496
502
506
510
516
521
528
532
538
542
548
551
555 }
557 }
558
572 {
573 switch ( type )
574 {
579
584
589
594
597
600
603
606
609
612
615
618
621
624
627
630
679 return type;
680 }
682 }
683
692 {
693 switch ( type )
694 {
697
704
711
718
724
731
738
745
751
757
763
769
775
781
787
793
798 return Qgis::WkbType::TIN;
799
802 }
804 }
805
808 {
809 type = flatType( type );
810 if ( hasZ )
811 type = static_cast<Qgis::WkbType>( static_cast<quint32>( type ) + 1000 );
812 if ( hasM )
813 type = static_cast<Qgis::WkbType>( static_cast<quint32>( type ) + 2000 );
814 return type;
815 }
816
821 static Qgis::WkbType parseType( const QString &wktStr );
822
828 Q_INVOKABLE static bool isSingleType( Qgis::WkbType type ) SIP_HOLDGIL
829 {
830 return ( type != Qgis::WkbType::Unknown && !isMultiType( type ) );
831 }
832
838 Q_INVOKABLE static bool isMultiType( Qgis::WkbType type ) SIP_HOLDGIL
839 {
840 switch ( type )
841 {
887 return false;
888
889 default:
890 return true;
891 }
892 }
893
897 Q_INVOKABLE static bool isCurvedType( Qgis::WkbType type ) SIP_HOLDGIL
898 {
899 switch ( flatType( type ) )
900 {
907 return true;
908
909 default:
910 return false;
911 }
912 }
913
920 Q_INVOKABLE static bool isNurbsType( Qgis::WkbType type ) SIP_HOLDGIL
921 {
922 return flatType( type ) == Qgis::WkbType::NurbsCurve;
923 }
924
933 {
934 const Qgis::GeometryType gtype = geometryType( type );
935 switch ( gtype )
936 {
938 return 1;
940 return 2;
941 default: //point, no geometry, unknown geometry
942 return 0;
943 }
944 }
945
952 Q_INVOKABLE static int coordDimensions( Qgis::WkbType type ) SIP_HOLDGIL
953 {
954 if ( type == Qgis::WkbType::Unknown || type == Qgis::WkbType::NoGeometry )
955 return 0;
956
957 return 2 + hasZ( type ) + hasM( type );
958 }
959
966 {
967 switch ( type )
968 {
975
987
1015
1033 case Qgis::WkbType::TIN:
1047
1050 }
1051
1053 }
1054
1058 Q_INVOKABLE static QString displayString( Qgis::WkbType type ) SIP_HOLDGIL;
1059
1065 Q_INVOKABLE static QString translatedDisplayString( Qgis::WkbType type ) SIP_HOLDGIL;
1066
1080 Q_INVOKABLE static QString geometryDisplayString( Qgis::GeometryType type ) SIP_HOLDGIL;
1081
1088 Q_INVOKABLE static bool hasZ( Qgis::WkbType type ) SIP_HOLDGIL
1089 {
1090 switch ( type )
1091 {
1130 return true;
1131
1132 default:
1133 return false;
1134 }
1135 }
1136
1185
1194 {
1195 if ( hasZ( type ) )
1196 return type;
1197 else if ( type == Qgis::WkbType::Unknown )
1199 else if ( type == Qgis::WkbType::NoGeometry )
1201
1202 //upgrade with z dimension
1203 const Qgis::WkbType flat = flatType( type );
1204 if ( hasM( type ) )
1205 return static_cast< Qgis::WkbType >( static_cast< quint32>( flat ) + 3000 );
1206 else
1207 return static_cast<Qgis::WkbType >( static_cast< quint32>( flat ) + 1000 );
1208 }
1209
1218 {
1219 if ( hasM( type ) )
1220 return type;
1221 else if ( type == Qgis::WkbType::Unknown )
1223 else if ( type == Qgis::WkbType::NoGeometry )
1225 else if ( type == Qgis::WkbType::Point25D )
1227 else if ( type == Qgis::WkbType::LineString25D )
1229 else if ( type == Qgis::WkbType::Polygon25D )
1231 else if ( type == Qgis::WkbType::MultiPoint25D )
1233 else if ( type == Qgis::WkbType::MultiLineString25D )
1235 else if ( type == Qgis::WkbType::MultiPolygon25D )
1237
1238 //upgrade with m dimension
1239 const Qgis::WkbType flat = flatType( type );
1240 if ( hasZ( type ) )
1241 return static_cast< Qgis::WkbType >( static_cast< quint32 >( flat ) + 3000 );
1242 else
1243 return static_cast< Qgis::WkbType >( static_cast< quint32 >( flat ) + 2000 );
1244 }
1245
1253 {
1254 if ( !hasZ( type ) )
1255 return type;
1256
1257 Qgis::WkbType returnType = flatType( type );
1258 if ( hasM( type ) )
1259 returnType = addM( returnType );
1260 return returnType;
1261 }
1262
1270 {
1271 if ( !hasM( type ) )
1272 return type;
1273
1274 Qgis::WkbType returnType = flatType( type );
1275 if ( hasZ( type ) )
1276 returnType = addZ( returnType );
1277 return returnType;
1278 }
1279
1286 {
1287 const Qgis::WkbType flat = flatType( type );
1288
1289 if ( static_cast< quint32 >( flat ) >= static_cast< quint32>( Qgis::WkbType::Point ) && static_cast< quint32 >( flat ) <= static_cast< quint32>( Qgis::WkbType::MultiPolygon ) )
1290 return static_cast< Qgis::WkbType >( static_cast< quint32 >( flat ) + 0x80000000U );
1291 else if ( type == Qgis::WkbType::NoGeometry )
1293 else
1295 }
1296};
1297
1298#endif // QGSWKBTYPES_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:365
@ Point
Points.
Definition qgis.h:366
@ Line
Lines.
Definition qgis.h:367
@ Polygon
Polygons.
Definition qgis.h:368
@ Unknown
Unknown types.
Definition qgis.h:369
@ Null
No geometry.
Definition qgis.h:370
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:280
@ LineString25D
LineString25D.
Definition qgis.h:348
@ MultiSurfaceM
MultiSurfaceM.
Definition qgis.h:327
@ PolyhedralSurfaceM
PolyhedralSurfaceM.
Definition qgis.h:328
@ MultiLineStringZM
MultiLineStringZM.
Definition qgis.h:335
@ MultiPointZM
MultiPointZM.
Definition qgis.h:334
@ MultiPointZ
MultiPointZ.
Definition qgis.h:303
@ CompoundCurve
CompoundCurve.
Definition qgis.h:291
@ MultiPolygonZM
MultiPolygonZM.
Definition qgis.h:336
@ LineStringM
LineStringM.
Definition qgis.h:316
@ Point
Point.
Definition qgis.h:282
@ LineString
LineString.
Definition qgis.h:283
@ MultiLineStringM
MultiLineStringM.
Definition qgis.h:320
@ NurbsCurveM
NurbsCurveM.
Definition qgis.h:330
@ TIN
TIN.
Definition qgis.h:296
@ MultiPolygon25D
MultiPolygon25D.
Definition qgis.h:352
@ MultiPointM
MultiPointM.
Definition qgis.h:319
@ MultiPoint
MultiPoint.
Definition qgis.h:286
@ LineStringZM
LineStringZM.
Definition qgis.h:332
@ GeometryCollectionZM
GeometryCollectionZM.
Definition qgis.h:337
@ TriangleZ
TriangleZ.
Definition qgis.h:302
@ Polygon
Polygon.
Definition qgis.h:284
@ CompoundCurveZM
CompoundCurveZM.
Definition qgis.h:339
@ CompoundCurveM
CompoundCurveM.
Definition qgis.h:324
@ MultiLineString25D
MultiLineString25D.
Definition qgis.h:351
@ MultiPolygon
MultiPolygon.
Definition qgis.h:288
@ GeometryCollectionZ
GeometryCollectionZ.
Definition qgis.h:306
@ GeometryCollectionM
GeometryCollectionM.
Definition qgis.h:322
@ CircularStringZM
CircularStringZM.
Definition qgis.h:338
@ Triangle
Triangle.
Definition qgis.h:285
@ NurbsCurve
NurbsCurve.
Definition qgis.h:297
@ PolygonM
PolygonM.
Definition qgis.h:317
@ NoGeometry
No geometry.
Definition qgis.h:298
@ MultiSurfaceZ
MultiSurfaceZ.
Definition qgis.h:311
@ CurvePolygonZM
CurvePolygonZM.
Definition qgis.h:340
@ TINZ
TINZ.
Definition qgis.h:313
@ MultiLineString
MultiLineString.
Definition qgis.h:287
@ MultiPolygonM
MultiPolygonM.
Definition qgis.h:321
@ MultiCurveZM
MultiCurveZM.
Definition qgis.h:341
@ MultiSurfaceZM
MultiSurfaceZM.
Definition qgis.h:342
@ PolygonZM
PolygonZM.
Definition qgis.h:333
@ MultiPoint25D
MultiPoint25D.
Definition qgis.h:350
@ Unknown
Unknown.
Definition qgis.h:281
@ NurbsCurveZ
NurbsCurveZ.
Definition qgis.h:314
@ PointM
PointM.
Definition qgis.h:315
@ CurvePolygonM
CurvePolygonM.
Definition qgis.h:325
@ NurbsCurveZM
NurbsCurveZM.
Definition qgis.h:346
@ CircularString
CircularString.
Definition qgis.h:290
@ TINZM
TINZM.
Definition qgis.h:344
@ PointZ
PointZ.
Definition qgis.h:299
@ TriangleZM
TriangleZM.
Definition qgis.h:345
@ MultiLineStringZ
MultiLineStringZ.
Definition qgis.h:304
@ GeometryCollection
GeometryCollection.
Definition qgis.h:289
@ PolyhedralSurfaceZM
PolyhedralSurfaceM.
Definition qgis.h:343
@ MultiPolygonZ
MultiPolygonZ.
Definition qgis.h:305
@ CurvePolygonZ
CurvePolygonZ.
Definition qgis.h:309
@ MultiCurve
MultiCurve.
Definition qgis.h:293
@ CompoundCurveZ
CompoundCurveZ.
Definition qgis.h:308
@ MultiCurveZ
MultiCurveZ.
Definition qgis.h:310
@ MultiCurveM
MultiCurveM.
Definition qgis.h:326
@ PolyhedralSurfaceZ
PolyhedralSurfaceZ.
Definition qgis.h:312
@ CircularStringM
CircularStringM.
Definition qgis.h:323
@ CurvePolygon
CurvePolygon.
Definition qgis.h:292
@ Point25D
Point25D.
Definition qgis.h:347
@ TINM
TINM.
Definition qgis.h:329
@ PointZM
PointZM.
Definition qgis.h:331
@ TriangleM
TriangleM.
Definition qgis.h:318
@ CircularStringZ
CircularStringZ.
Definition qgis.h:307
@ LineStringZ
LineStringZ.
Definition qgis.h:300
@ PolyhedralSurface
PolyhedralSurface.
Definition qgis.h:295
@ MultiSurface
MultiSurface.
Definition qgis.h:294
@ PolygonZ
PolygonZ.
Definition qgis.h:301
@ Polygon25D
Polygon25D.
Definition qgis.h:349
Handles storage of information regarding WKB types and their properties.
Definition qgswkbtypes.h:42
static Qgis::WkbType dropM(Qgis::WkbType type)
Drops the m dimension (if present) for a WKB type and returns the new type.
static Qgis::WkbType zmType(Qgis::WkbType type, bool hasZ, bool hasM)
Returns the modified input geometry type according to hasZ / hasM.
static Qgis::GeometryType geometryType(Qgis::WkbType type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
static int wkbDimensions(Qgis::WkbType type)
Returns the inherent dimension of the geometry type as an integer.
static Qgis::WkbType to25D(Qgis::WkbType type)
Will convert the 25D version of the flat type if supported or Unknown if not supported.
static Qgis::WkbType linearType(Qgis::WkbType type)
Returns the linear type for a WKB type.
static Qgis::WkbType dropZ(Qgis::WkbType type)
Drops the z dimension (if present) for a WKB type and returns the new type.
static Qgis::WkbType parseType(const QString &wktStr)
Attempts to extract the WKB type from a WKT string.
static Qgis::WkbType promoteNonPointTypesToMulti(Qgis::WkbType type)
Promotes a WKB geometry type to its multi-type equivalent, with the exception of point geometry types...
static Qgis::WkbType addM(Qgis::WkbType type)
Adds the m dimension to a WKB type and returns the new type.
static Qgis::WkbType addZ(Qgis::WkbType type)
Adds the z dimension to a WKB type and returns the new type.
static Q_INVOKABLE bool isSingleType(Qgis::WkbType type)
Returns true if the WKB type is a single type.
static Q_INVOKABLE bool hasZ(Qgis::WkbType type)
Tests whether a WKB type contains the z-dimension.
static Qgis::WkbType singleType(Qgis::WkbType type)
Returns the single type for a WKB type.
Definition qgswkbtypes.h:52
static Q_INVOKABLE bool hasM(Qgis::WkbType type)
Tests whether a WKB type contains m values.
static Q_INVOKABLE bool isNurbsType(Qgis::WkbType type)
Returns true if the WKB type is a NURBS curve type.
static Q_INVOKABLE bool isCurvedType(Qgis::WkbType type)
Returns true if the WKB type is a curved type or can contain curved geometries.
static Qgis::WkbType multiType(Qgis::WkbType type)
Returns the multi type for a WKB type.
static Qgis::WkbType flatType(Qgis::WkbType type)
Returns the flat type for a WKB type.
static Q_INVOKABLE bool isMultiType(Qgis::WkbType type)
Returns true if the WKB type is a multi type.
static Q_INVOKABLE int coordDimensions(Qgis::WkbType type)
Returns the coordinate dimension of the geometry type as an integer.
static Qgis::WkbType curveType(Qgis::WkbType type)
Returns the curve type for a WKB type.
#define SIP_HOLDGIL
Definition qgis_sip.h:179