QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
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 <QObject>
22#include <QMap>
23#include <QString>
24
25#include "qgis_core.h"
26#include "qgis_sip.h"
27#include "qgis.h"
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
42class CORE_EXPORT QgsWkbTypes
43{
44 Q_GADGET
45 public:
46
55 {
56 switch ( type )
57 {
64
68
72
76
80
84
88
92
96
100
104
108
112
114 // case MultiTriangle:
116
118 // case MultiTriangleZ:
120
122 // case MultiTriangleM:
124
126 // case MultiTriangleZM:
128
131
134
137
140
144
148
152
156
160
164
168
172
175
179
183
187
188 }
190 }
191
202 {
203 switch ( type )
204 {
207
208 // until we support TIN types, use multipolygon
211
214
217
220
223
226
229
232
236
240
244
248
252
256
260
264
268
272
276
280
285
290
295
300
304
308
312
316
319
323
327
331 }
333 }
334
335
349 {
350 switch ( geometryType( type ) )
351 {
352 case Qgis::GeometryType::Point:
353 case Qgis::GeometryType::Unknown:
354 case Qgis::GeometryType::Null:
355 return type;
356
357 case Qgis::GeometryType::Line:
358 case Qgis::GeometryType::Polygon:
359 return multiType( type );
360 }
362 }
363
379 {
380 switch ( type )
381 {
388
391
394
397
400
403
406
409
412
415
418
421
424
429
433
439
444
449
453
458
462
466
470
475
480
484
488
492
496
499
503 }
505 }
506
520 {
521 switch ( type )
522 {
523
527
531
535
539
542
545
548
551
554
557
560
563
566
569
572
575
616 return type;
617
618 }
620 }
621
630 {
631 switch ( type )
632 {
635
642
649
656
662
669
676
683
689
695
701
707
713
719
722
723 }
725 }
726
728 static Qgis::WkbType zmType( Qgis::WkbType type, bool hasZ, bool hasM ) SIP_HOLDGIL
729 {
730 type = flatType( type );
731 if ( hasZ )
732 type = static_cast<Qgis::WkbType>( static_cast<quint32>( type ) + 1000 );
733 if ( hasM )
734 type = static_cast<Qgis::WkbType>( static_cast<quint32>( type ) + 2000 );
735 return type;
736 }
737
742 static Qgis::WkbType parseType( const QString &wktStr );
743
750 {
751 return ( type != Qgis::WkbType::Unknown && !isMultiType( type ) );
752 }
753
760 {
761 switch ( type )
762 {
796 return false;
797
798 default:
799 return true;
800
801 }
802 }
803
809 {
810 switch ( flatType( type ) )
811 {
817 return true;
818
819 default:
820 return false;
821 }
822 }
823
832 {
833 const Qgis::GeometryType gtype = geometryType( type );
834 switch ( gtype )
835 {
836 case Qgis::GeometryType::Line:
837 return 1;
838 case Qgis::GeometryType::Polygon:
839 return 2;
840 default: //point, no geometry, unknown geometry
841 return 0;
842 }
843 }
844
853 {
854 if ( type == Qgis::WkbType::Unknown || type == Qgis::WkbType::NoGeometry )
855 return 0;
856
857 return 2 + hasZ( type ) + hasM( type );
858 }
859
866 {
867 switch ( type )
868 {
874 return Qgis::GeometryType::Unknown;
875
886 return Qgis::GeometryType::Point;
887
910 return Qgis::GeometryType::Line;
911
934 return Qgis::GeometryType::Polygon;
935
937 return Qgis::GeometryType::Null;
938 }
939
940 return Qgis::GeometryType::Unknown;
941 }
942
946 static QString displayString( Qgis::WkbType type ) SIP_HOLDGIL;
947
953 static QString translatedDisplayString( Qgis::WkbType type ) SIP_HOLDGIL;
954
969 static QString geometryDisplayString( Qgis::GeometryType type ) SIP_HOLDGIL;
970
977 static bool hasZ( Qgis::WkbType type ) SIP_HOLDGIL
978 {
979 switch ( type )
980 {
1013 return true;
1014
1015 default:
1016 return false;
1017
1018 }
1019 }
1020
1027 static bool hasM( Qgis::WkbType type ) SIP_HOLDGIL
1028 {
1029 switch ( type )
1030 {
1057 return true;
1058
1059 default:
1060 return false;
1061
1062 }
1063 }
1064
1074 {
1075 if ( hasZ( type ) )
1076 return type;
1077 else if ( type == Qgis::WkbType::Unknown )
1079 else if ( type == Qgis::WkbType::NoGeometry )
1081
1082 //upgrade with z dimension
1083 const Qgis::WkbType flat = flatType( type );
1084 if ( hasM( type ) )
1085 return static_cast< Qgis::WkbType >( static_cast< quint32>( flat ) + 3000 );
1086 else
1087 return static_cast<Qgis::WkbType >( static_cast< quint32>( flat ) + 1000 );
1088 }
1089
1099 {
1100 if ( hasM( type ) )
1101 return type;
1102 else if ( type == Qgis::WkbType::Unknown )
1104 else if ( type == Qgis::WkbType::NoGeometry )
1106 else if ( type == Qgis::WkbType::Point25D )
1108 else if ( type == Qgis::WkbType::LineString25D )
1110 else if ( type == Qgis::WkbType::Polygon25D )
1112 else if ( type == Qgis::WkbType::MultiPoint25D )
1114 else if ( type == Qgis::WkbType::MultiLineString25D )
1116 else if ( type == Qgis::WkbType::MultiPolygon25D )
1118
1119 //upgrade with m dimension
1120 const Qgis::WkbType flat = flatType( type );
1121 if ( hasZ( type ) )
1122 return static_cast< Qgis::WkbType >( static_cast< quint32 >( flat ) + 3000 );
1123 else
1124 return static_cast< Qgis::WkbType >( static_cast< quint32 >( flat ) + 2000 );
1125 }
1126
1135 {
1136 if ( !hasZ( type ) )
1137 return type;
1138
1139 Qgis::WkbType returnType = flatType( type );
1140 if ( hasM( type ) )
1141 returnType = addM( returnType );
1142 return returnType;
1143 }
1144
1153 {
1154 if ( !hasM( type ) )
1155 return type;
1156
1157 Qgis::WkbType returnType = flatType( type );
1158 if ( hasZ( type ) )
1159 returnType = addZ( returnType );
1160 return returnType;
1161 }
1162
1169 {
1170 const Qgis::WkbType flat = flatType( type );
1171
1172 if ( static_cast< quint32 >( flat ) >= static_cast< quint32>( Qgis::WkbType::Point ) && static_cast< quint32 >( flat ) <= static_cast< quint32>( Qgis::WkbType::MultiPolygon ) )
1173 return static_cast< Qgis::WkbType >( static_cast< quint32 >( flat ) + 0x80000000U );
1174 else if ( type == Qgis::WkbType::NoGeometry )
1176 else
1178 }
1179
1180};
1181
1182#endif // QGSWKBTYPES_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition: qgis.h:228
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition: qgis.h:155
@ LineString25D
LineString25D.
@ MultiSurfaceM
MultiSurfaceM.
@ MultiLineStringZM
MultiLineStringZM.
@ MultiPointZM
MultiPointZM.
@ MultiPointZ
MultiPointZ.
@ CompoundCurve
CompoundCurve.
@ MultiPolygonZM
MultiPolygonZM.
@ LineStringM
LineStringM.
@ LineString
LineString.
@ MultiLineStringM
MultiLineStringM.
@ MultiPolygon25D
MultiPolygon25D.
@ MultiPointM
MultiPointM.
@ MultiPoint
MultiPoint.
@ LineStringZM
LineStringZM.
@ GeometryCollectionZM
GeometryCollectionZM.
@ TriangleZ
TriangleZ.
@ Polygon
Polygon.
@ CompoundCurveZM
CompoundCurveZM.
@ CompoundCurveM
CompoundCurveM.
@ MultiLineString25D
MultiLineString25D.
@ MultiPolygon
MultiPolygon.
@ GeometryCollectionZ
GeometryCollectionZ.
@ GeometryCollectionM
GeometryCollectionM.
@ CircularStringZM
CircularStringZM.
@ Triangle
Triangle.
@ PolygonM
PolygonM.
@ NoGeometry
No geometry.
@ MultiSurfaceZ
MultiSurfaceZ.
@ CurvePolygonZM
CurvePolygonZM.
@ MultiLineString
MultiLineString.
@ MultiPolygonM
MultiPolygonM.
@ MultiCurveZM
MultiCurveZM.
@ MultiSurfaceZM
MultiSurfaceZM.
@ PolygonZM
PolygonZM.
@ MultiPoint25D
MultiPoint25D.
@ Unknown
Unknown.
@ PointM
PointM.
@ CurvePolygonM
CurvePolygonM.
@ CircularString
CircularString.
@ PointZ
PointZ.
@ TriangleZM
TriangleZM.
@ MultiLineStringZ
MultiLineStringZ.
@ GeometryCollection
GeometryCollection.
@ MultiPolygonZ
MultiPolygonZ.
@ CurvePolygonZ
CurvePolygonZ.
@ MultiCurve
MultiCurve.
@ CompoundCurveZ
CompoundCurveZ.
@ MultiCurveZ
MultiCurveZ.
@ MultiCurveM
MultiCurveM.
@ CircularStringM
CircularStringM.
@ CurvePolygon
CurvePolygon.
@ Point25D
Point25D.
@ PointZM
PointZM.
@ TriangleM
TriangleM.
@ CircularStringZ
CircularStringZ.
@ LineStringZ
LineStringZ.
@ MultiSurface
MultiSurface.
@ PolygonZ
PolygonZ.
@ Polygon25D
Polygon25D.
Handles storage of information regarding WKB types and their properties.
Definition: qgswkbtypes.h:43
static Qgis::WkbType linearType(Qgis::WkbType type) SIP_HOLDGIL
Returns the linear type for a WKB type.
Definition: qgswkbtypes.h:519
static Qgis::WkbType to25D(Qgis::WkbType type) SIP_HOLDGIL
Will convert the 25D version of the flat type if supported or Unknown if not supported.
Definition: qgswkbtypes.h:1168
static Qgis::WkbType addZ(Qgis::WkbType type) SIP_HOLDGIL
Adds the z dimension to a WKB type and returns the new type.
Definition: qgswkbtypes.h:1073
static Qgis::GeometryType geometryType(Qgis::WkbType type) SIP_HOLDGIL
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
Definition: qgswkbtypes.h:865
static bool isSingleType(Qgis::WkbType type) SIP_HOLDGIL
Returns true if the WKB type is a single type.
Definition: qgswkbtypes.h:749
static Qgis::WkbType addM(Qgis::WkbType type) SIP_HOLDGIL
Adds the m dimension to a WKB type and returns the new type.
Definition: qgswkbtypes.h:1098
static bool isMultiType(Qgis::WkbType type) SIP_HOLDGIL
Returns true if the WKB type is a multi type.
Definition: qgswkbtypes.h:759
static Qgis::WkbType parseType(const QString &wktStr)
Attempts to extract the WKB type from a WKT string.
static bool hasZ(Qgis::WkbType type) SIP_HOLDGIL
Tests whether a WKB type contains the z-dimension.
Definition: qgswkbtypes.h:977
static Qgis::WkbType singleType(Qgis::WkbType type) SIP_HOLDGIL
Returns the single type for a WKB type.
Definition: qgswkbtypes.h:54
static bool isCurvedType(Qgis::WkbType type) SIP_HOLDGIL
Returns true if the WKB type is a curved type or can contain curved geometries.
Definition: qgswkbtypes.h:808
static Qgis::WkbType dropZ(Qgis::WkbType type) SIP_HOLDGIL
Drops the z dimension (if present) for a WKB type and returns the new type.
Definition: qgswkbtypes.h:1134
static Qgis::WkbType curveType(Qgis::WkbType type) SIP_HOLDGIL
Returns the curve type for a WKB type.
Definition: qgswkbtypes.h:378
static Qgis::WkbType dropM(Qgis::WkbType type) SIP_HOLDGIL
Drops the m dimension (if present) for a WKB type and returns the new type.
Definition: qgswkbtypes.h:1152
static Qgis::WkbType multiType(Qgis::WkbType type) SIP_HOLDGIL
Returns the multi type for a WKB type.
Definition: qgswkbtypes.h:201
static int wkbDimensions(Qgis::WkbType type) SIP_HOLDGIL
Returns the inherent dimension of the geometry type as an integer.
Definition: qgswkbtypes.h:831
static bool hasM(Qgis::WkbType type) SIP_HOLDGIL
Tests whether a WKB type contains m values.
Definition: qgswkbtypes.h:1027
static int coordDimensions(Qgis::WkbType type) SIP_HOLDGIL
Returns the coordinate dimension of the geometry type as an integer.
Definition: qgswkbtypes.h:852
static Qgis::WkbType flatType(Qgis::WkbType type) SIP_HOLDGIL
Returns the flat type for a WKB type.
Definition: qgswkbtypes.h:629
static Qgis::WkbType zmType(Qgis::WkbType type, bool hasZ, bool hasM) SIP_HOLDGIL
Returns the modified input geometry type according to hasZ / hasM.
Definition: qgswkbtypes.h:728
static Qgis::WkbType promoteNonPointTypesToMulti(Qgis::WkbType type) SIP_HOLDGIL
Promotes a WKB geometry type to its multi-type equivalent, with the exception of point geometry types...
Definition: qgswkbtypes.h:348
#define SIP_HOLDGIL
Definition: qgis_sip.h:166