QGIS API Documentation 3.41.0-Master (af5edcb665c)
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 <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
41class CORE_EXPORT QgsWkbTypes
42{
43 Q_GADGET
44 public:
45
54 {
55 switch ( type )
56 {
63
67
71
75
79
83
87
91
95
99
103
107
111
114
117
120
123
126
129
132
135
139
143
147
151
155
159
163
167
170
173
176
179
181 return Qgis::WkbType::TIN;
182
184 return Qgis::WkbType::TINZ;
185
187 return Qgis::WkbType::TINM;
188
191
194
198
202
206
207 }
209 }
210
221 {
222 switch ( type )
223 {
226
229
232
235
238
241
244
247
250
254
258
262
266
270
274
278
282
288
294
300
306
311
316
321
326
330
334
338
342
345
349
353
357 }
359 }
360
361
375 {
376 switch ( geometryType( type ) )
377 {
381 return type;
382
385 return multiType( type );
386 }
388 }
389
405 {
406 switch ( type )
407 {
414
417
420
423
426
429
432
435
438
441
444
447
450
455
459
465
470
475
479
484
488
492
498
503
510
514
520
524
530
533
537 }
539 }
540
554 {
555 switch ( type )
556 {
557
561
565
569
573
576
579
582
585
588
591
594
597
600
603
606
609
658 return type;
659
660 }
662 }
663
672 {
673 switch ( type )
674 {
677
684
691
698
704
711
718
725
731
737
743
749
755
761
767
772 return Qgis::WkbType::TIN;
773
776
777 }
779 }
780
782 static Qgis::WkbType zmType( Qgis::WkbType type, bool hasZ, bool hasM ) SIP_HOLDGIL
783 {
784 type = flatType( type );
785 if ( hasZ )
786 type = static_cast<Qgis::WkbType>( static_cast<quint32>( type ) + 1000 );
787 if ( hasM )
788 type = static_cast<Qgis::WkbType>( static_cast<quint32>( type ) + 2000 );
789 return type;
790 }
791
796 static Qgis::WkbType parseType( const QString &wktStr );
797
804 {
805 return ( type != Qgis::WkbType::Unknown && !isMultiType( type ) );
806 }
807
814 {
815 switch ( type )
816 {
858 return false;
859
860 default:
861 return true;
862
863 }
864 }
865
870 {
871 switch ( flatType( type ) )
872 {
878 return true;
879
880 default:
881 return false;
882 }
883 }
884
893 {
894 const Qgis::GeometryType gtype = geometryType( type );
895 switch ( gtype )
896 {
898 return 1;
900 return 2;
901 default: //point, no geometry, unknown geometry
902 return 0;
903 }
904 }
905
913 {
914 if ( type == Qgis::WkbType::Unknown || type == Qgis::WkbType::NoGeometry )
915 return 0;
916
917 return 2 + hasZ( type ) + hasM( type );
918 }
919
926 {
927 switch ( type )
928 {
935
947
971
1003
1006 }
1007
1009 }
1010
1014 static QString displayString( Qgis::WkbType type ) SIP_HOLDGIL;
1015
1021 static QString translatedDisplayString( Qgis::WkbType type ) SIP_HOLDGIL;
1022
1036 static QString geometryDisplayString( Qgis::GeometryType type ) SIP_HOLDGIL;
1037
1044 static bool hasZ( Qgis::WkbType type ) SIP_HOLDGIL
1045 {
1046 switch ( type )
1047 {
1084 return true;
1085
1086 default:
1087 return false;
1088
1089 }
1090 }
1091
1139
1148 {
1149 if ( hasZ( type ) )
1150 return type;
1151 else if ( type == Qgis::WkbType::Unknown )
1153 else if ( type == Qgis::WkbType::NoGeometry )
1155
1156 //upgrade with z dimension
1157 const Qgis::WkbType flat = flatType( type );
1158 if ( hasM( type ) )
1159 return static_cast< Qgis::WkbType >( static_cast< quint32>( flat ) + 3000 );
1160 else
1161 return static_cast<Qgis::WkbType >( static_cast< quint32>( flat ) + 1000 );
1162 }
1163
1172 {
1173 if ( hasM( type ) )
1174 return type;
1175 else if ( type == Qgis::WkbType::Unknown )
1177 else if ( type == Qgis::WkbType::NoGeometry )
1179 else if ( type == Qgis::WkbType::Point25D )
1181 else if ( type == Qgis::WkbType::LineString25D )
1183 else if ( type == Qgis::WkbType::Polygon25D )
1185 else if ( type == Qgis::WkbType::MultiPoint25D )
1187 else if ( type == Qgis::WkbType::MultiLineString25D )
1189 else if ( type == Qgis::WkbType::MultiPolygon25D )
1191
1192 //upgrade with m dimension
1193 const Qgis::WkbType flat = flatType( type );
1194 if ( hasZ( type ) )
1195 return static_cast< Qgis::WkbType >( static_cast< quint32 >( flat ) + 3000 );
1196 else
1197 return static_cast< Qgis::WkbType >( static_cast< quint32 >( flat ) + 2000 );
1198 }
1199
1207 {
1208 if ( !hasZ( type ) )
1209 return type;
1210
1211 Qgis::WkbType returnType = flatType( type );
1212 if ( hasM( type ) )
1213 returnType = addM( returnType );
1214 return returnType;
1215 }
1216
1224 {
1225 if ( !hasM( type ) )
1226 return type;
1227
1228 Qgis::WkbType returnType = flatType( type );
1229 if ( hasZ( type ) )
1230 returnType = addZ( returnType );
1231 return returnType;
1232 }
1233
1240 {
1241 const Qgis::WkbType flat = flatType( type );
1242
1243 if ( static_cast< quint32 >( flat ) >= static_cast< quint32>( Qgis::WkbType::Point ) && static_cast< quint32 >( flat ) <= static_cast< quint32>( Qgis::WkbType::MultiPolygon ) )
1244 return static_cast< Qgis::WkbType >( static_cast< quint32 >( flat ) + 0x80000000U );
1245 else if ( type == Qgis::WkbType::NoGeometry )
1247 else
1249 }
1250
1251};
1252
1253#endif // QGSWKBTYPES_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:337
@ Polygon
Polygons.
@ Unknown
Unknown types.
@ Null
No geometry.
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:256
@ LineString25D
LineString25D.
@ MultiSurfaceM
MultiSurfaceM.
@ PolyhedralSurfaceM
PolyhedralSurfaceM.
@ 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.
@ PolyhedralSurfaceZM
PolyhedralSurfaceM.
@ MultiPolygonZ
MultiPolygonZ.
@ CurvePolygonZ
CurvePolygonZ.
@ MultiCurve
MultiCurve.
@ CompoundCurveZ
CompoundCurveZ.
@ MultiCurveZ
MultiCurveZ.
@ MultiCurveM
MultiCurveM.
@ PolyhedralSurfaceZ
PolyhedralSurfaceZ.
@ CircularStringM
CircularStringM.
@ CurvePolygon
CurvePolygon.
@ Point25D
Point25D.
@ PointZM
PointZM.
@ TriangleM
TriangleM.
@ CircularStringZ
CircularStringZ.
@ LineStringZ
LineStringZ.
@ PolyhedralSurface
PolyhedralSurface.
@ MultiSurface
MultiSurface.
@ PolygonZ
PolygonZ.
@ Polygon25D
Polygon25D.
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 bool isMultiType(Qgis::WkbType type)
Returns true if the WKB type is a multi 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 Qgis::WkbType singleType(Qgis::WkbType type)
Returns the single type for a WKB type.
Definition qgswkbtypes.h:53
static bool hasZ(Qgis::WkbType type)
Tests whether a WKB type contains the z-dimension.
static bool hasM(Qgis::WkbType type)
Tests whether a WKB type contains m values.
static Qgis::WkbType multiType(Qgis::WkbType type)
Returns the multi type for a WKB type.
static bool isCurvedType(Qgis::WkbType type)
Returns true if the WKB type is a curved type or can contain curved geometries.
static Qgis::WkbType flatType(Qgis::WkbType type)
Returns the flat type for a WKB type.
static int coordDimensions(Qgis::WkbType type)
Returns the coordinate dimension of the geometry type as an integer.
static bool isSingleType(Qgis::WkbType type)
Returns true if the WKB type is a single type.
static Qgis::WkbType curveType(Qgis::WkbType type)
Returns the curve type for a WKB type.
#define SIP_HOLDGIL
Definition qgis_sip.h:171