QGIS API Documentation 4.1.0-Master (60fea48833c)
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:
45 // clang-format off
54 // clang-format on
55 {
56 switch ( type )
57 {
64
68
72
76
80
84
88
92
96
100
104
108
112
115
118
121
124
127
130
133
136
139
142
145
148
152
156
160
164
168
172
176
180
183
186
189
192
194 return Qgis::WkbType::TIN;
195
197 return Qgis::WkbType::TINZ;
198
200 return Qgis::WkbType::TINM;
201
204
207
211
215
219 }
221 }
222
233 {
234 switch ( type )
235 {
238
241
244
247
250
253
256
259
262
266
270
274
278
282
286
290
294
300
306
312
318
324
330
336
342
346
350
354
358
361
365
369
373 }
375 }
376
377
391 {
392 switch ( geometryType( type ) )
393 {
397 return type;
398
401 return multiType( type );
402 }
404 }
405
421 {
422 switch ( type )
423 {
430
433
436
439
442
445
448
451
454
457
460
463
466
472
476
483
488
494
498
504
508
512
518
523
530
534
540
544
550
553
557 }
559 }
560
574 {
575 switch ( type )
576 {
581
586
591
596
599
602
605
608
611
614
617
620
623
626
629
632
681 return type;
682 }
684 }
685
694 {
695 switch ( type )
696 {
699
706
713
720
726
733
740
747
753
759
765
771
777
783
789
795
800 return Qgis::WkbType::TIN;
801
804 }
806 }
807
810 {
811 type = flatType( type );
812 if ( hasZ )
813 type = static_cast<Qgis::WkbType>( static_cast<quint32>( type ) + 1000 );
814 if ( hasM )
815 type = static_cast<Qgis::WkbType>( static_cast<quint32>( type ) + 2000 );
816 return type;
817 }
818
823 static Qgis::WkbType parseType( const QString &wktStr );
824
830 Q_INVOKABLE static bool isSingleType( Qgis::WkbType type ) SIP_HOLDGIL
831 {
832 return ( type != Qgis::WkbType::Unknown && !isMultiType( type ) );
833 }
834
840 Q_INVOKABLE static bool isMultiType( Qgis::WkbType type ) SIP_HOLDGIL
841 {
842 switch ( type )
843 {
889 return false;
890
891 default:
892 return true;
893 }
894 }
895
899 Q_INVOKABLE static bool isCurvedType( Qgis::WkbType type ) SIP_HOLDGIL
900 {
901 switch ( flatType( type ) )
902 {
909 return true;
910
911 default:
912 return false;
913 }
914 }
915
922 Q_INVOKABLE static bool isNurbsType( Qgis::WkbType type ) SIP_HOLDGIL
923 {
924 return flatType( type ) == Qgis::WkbType::NurbsCurve;
925 }
926
935 {
936 const Qgis::GeometryType gtype = geometryType( type );
937 switch ( gtype )
938 {
940 return 1;
942 return 2;
943 default: //point, no geometry, unknown geometry
944 return 0;
945 }
946 }
947
954 Q_INVOKABLE static int coordDimensions( Qgis::WkbType type ) SIP_HOLDGIL
955 {
956 if ( type == Qgis::WkbType::Unknown || type == Qgis::WkbType::NoGeometry )
957 return 0;
958
959 return 2 + hasZ( type ) + hasM( type );
960 }
961
968 {
969 switch ( type )
970 {
977
989
1017
1035 case Qgis::WkbType::TIN:
1049
1052 }
1053
1055 }
1056
1060 Q_INVOKABLE static QString displayString( Qgis::WkbType type ) SIP_HOLDGIL;
1061
1067 Q_INVOKABLE static QString translatedDisplayString( Qgis::WkbType type ) SIP_HOLDGIL;
1068
1082 Q_INVOKABLE static QString geometryDisplayString( Qgis::GeometryType type ) SIP_HOLDGIL;
1083
1090 Q_INVOKABLE static bool hasZ( Qgis::WkbType type ) SIP_HOLDGIL
1091 {
1092 switch ( type )
1093 {
1132 return true;
1133
1134 default:
1135 return false;
1136 }
1137 }
1138
1187
1196 {
1197 if ( hasZ( type ) )
1198 return type;
1199 else if ( type == Qgis::WkbType::Unknown )
1201 else if ( type == Qgis::WkbType::NoGeometry )
1203
1204 //upgrade with z dimension
1205 const Qgis::WkbType flat = flatType( type );
1206 if ( hasM( type ) )
1207 return static_cast< Qgis::WkbType >( static_cast< quint32>( flat ) + 3000 );
1208 else
1209 return static_cast<Qgis::WkbType >( static_cast< quint32>( flat ) + 1000 );
1210 }
1211
1220 {
1221 if ( hasM( type ) )
1222 return type;
1223 else if ( type == Qgis::WkbType::Unknown )
1225 else if ( type == Qgis::WkbType::NoGeometry )
1227 else if ( type == Qgis::WkbType::Point25D )
1229 else if ( type == Qgis::WkbType::LineString25D )
1231 else if ( type == Qgis::WkbType::Polygon25D )
1233 else if ( type == Qgis::WkbType::MultiPoint25D )
1235 else if ( type == Qgis::WkbType::MultiLineString25D )
1237 else if ( type == Qgis::WkbType::MultiPolygon25D )
1239
1240 //upgrade with m dimension
1241 const Qgis::WkbType flat = flatType( type );
1242 if ( hasZ( type ) )
1243 return static_cast< Qgis::WkbType >( static_cast< quint32 >( flat ) + 3000 );
1244 else
1245 return static_cast< Qgis::WkbType >( static_cast< quint32 >( flat ) + 2000 );
1246 }
1247
1255 {
1256 if ( !hasZ( type ) )
1257 return type;
1258
1259 Qgis::WkbType returnType = flatType( type );
1260 if ( hasM( type ) )
1261 returnType = addM( returnType );
1262 return returnType;
1263 }
1264
1272 {
1273 if ( !hasM( type ) )
1274 return type;
1275
1276 Qgis::WkbType returnType = flatType( type );
1277 if ( hasZ( type ) )
1278 returnType = addZ( returnType );
1279 return returnType;
1280 }
1281
1288 {
1289 const Qgis::WkbType flat = flatType( type );
1290
1291 if ( static_cast< quint32 >( flat ) >= static_cast< quint32>( Qgis::WkbType::Point ) && static_cast< quint32 >( flat ) <= static_cast< quint32>( Qgis::WkbType::MultiPolygon ) )
1292 return static_cast< Qgis::WkbType >( static_cast< quint32 >( flat ) + 0x80000000U );
1293 else if ( type == Qgis::WkbType::NoGeometry )
1295 else
1297 }
1298};
1299
1300#endif // QGSWKBTYPES_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:379
@ Point
Points.
Definition qgis.h:380
@ Line
Lines.
Definition qgis.h:381
@ Polygon
Polygons.
Definition qgis.h:382
@ Unknown
Unknown types.
Definition qgis.h:383
@ Null
No geometry.
Definition qgis.h:384
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:294
@ LineString25D
LineString25D.
Definition qgis.h:362
@ MultiSurfaceM
MultiSurfaceM.
Definition qgis.h:341
@ PolyhedralSurfaceM
PolyhedralSurfaceM.
Definition qgis.h:342
@ MultiLineStringZM
MultiLineStringZM.
Definition qgis.h:349
@ MultiPointZM
MultiPointZM.
Definition qgis.h:348
@ MultiPointZ
MultiPointZ.
Definition qgis.h:317
@ CompoundCurve
CompoundCurve.
Definition qgis.h:305
@ MultiPolygonZM
MultiPolygonZM.
Definition qgis.h:350
@ LineStringM
LineStringM.
Definition qgis.h:330
@ Point
Point.
Definition qgis.h:296
@ LineString
LineString.
Definition qgis.h:297
@ MultiLineStringM
MultiLineStringM.
Definition qgis.h:334
@ NurbsCurveM
NurbsCurveM.
Definition qgis.h:344
@ TIN
TIN.
Definition qgis.h:310
@ MultiPolygon25D
MultiPolygon25D.
Definition qgis.h:366
@ MultiPointM
MultiPointM.
Definition qgis.h:333
@ MultiPoint
MultiPoint.
Definition qgis.h:300
@ LineStringZM
LineStringZM.
Definition qgis.h:346
@ GeometryCollectionZM
GeometryCollectionZM.
Definition qgis.h:351
@ TriangleZ
TriangleZ.
Definition qgis.h:316
@ Polygon
Polygon.
Definition qgis.h:298
@ CompoundCurveZM
CompoundCurveZM.
Definition qgis.h:353
@ CompoundCurveM
CompoundCurveM.
Definition qgis.h:338
@ MultiLineString25D
MultiLineString25D.
Definition qgis.h:365
@ MultiPolygon
MultiPolygon.
Definition qgis.h:302
@ GeometryCollectionZ
GeometryCollectionZ.
Definition qgis.h:320
@ GeometryCollectionM
GeometryCollectionM.
Definition qgis.h:336
@ CircularStringZM
CircularStringZM.
Definition qgis.h:352
@ Triangle
Triangle.
Definition qgis.h:299
@ NurbsCurve
NurbsCurve.
Definition qgis.h:311
@ PolygonM
PolygonM.
Definition qgis.h:331
@ NoGeometry
No geometry.
Definition qgis.h:312
@ MultiSurfaceZ
MultiSurfaceZ.
Definition qgis.h:325
@ CurvePolygonZM
CurvePolygonZM.
Definition qgis.h:354
@ TINZ
TINZ.
Definition qgis.h:327
@ MultiLineString
MultiLineString.
Definition qgis.h:301
@ MultiPolygonM
MultiPolygonM.
Definition qgis.h:335
@ MultiCurveZM
MultiCurveZM.
Definition qgis.h:355
@ MultiSurfaceZM
MultiSurfaceZM.
Definition qgis.h:356
@ PolygonZM
PolygonZM.
Definition qgis.h:347
@ MultiPoint25D
MultiPoint25D.
Definition qgis.h:364
@ Unknown
Unknown.
Definition qgis.h:295
@ NurbsCurveZ
NurbsCurveZ.
Definition qgis.h:328
@ PointM
PointM.
Definition qgis.h:329
@ CurvePolygonM
CurvePolygonM.
Definition qgis.h:339
@ NurbsCurveZM
NurbsCurveZM.
Definition qgis.h:360
@ CircularString
CircularString.
Definition qgis.h:304
@ TINZM
TINZM.
Definition qgis.h:358
@ PointZ
PointZ.
Definition qgis.h:313
@ TriangleZM
TriangleZM.
Definition qgis.h:359
@ MultiLineStringZ
MultiLineStringZ.
Definition qgis.h:318
@ GeometryCollection
GeometryCollection.
Definition qgis.h:303
@ PolyhedralSurfaceZM
PolyhedralSurfaceM.
Definition qgis.h:357
@ MultiPolygonZ
MultiPolygonZ.
Definition qgis.h:319
@ CurvePolygonZ
CurvePolygonZ.
Definition qgis.h:323
@ MultiCurve
MultiCurve.
Definition qgis.h:307
@ CompoundCurveZ
CompoundCurveZ.
Definition qgis.h:322
@ MultiCurveZ
MultiCurveZ.
Definition qgis.h:324
@ MultiCurveM
MultiCurveM.
Definition qgis.h:340
@ PolyhedralSurfaceZ
PolyhedralSurfaceZ.
Definition qgis.h:326
@ CircularStringM
CircularStringM.
Definition qgis.h:337
@ CurvePolygon
CurvePolygon.
Definition qgis.h:306
@ Point25D
Point25D.
Definition qgis.h:361
@ TINM
TINM.
Definition qgis.h:343
@ PointZM
PointZM.
Definition qgis.h:345
@ TriangleM
TriangleM.
Definition qgis.h:332
@ CircularStringZ
CircularStringZ.
Definition qgis.h:321
@ LineStringZ
LineStringZ.
Definition qgis.h:314
@ PolyhedralSurface
PolyhedralSurface.
Definition qgis.h:309
@ MultiSurface
MultiSurface.
Definition qgis.h:308
@ PolygonZ
PolygonZ.
Definition qgis.h:315
@ Polygon25D
Polygon25D.
Definition qgis.h:363
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:53
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:178