QGIS API Documentation 3.39.0-Master (52f98f8c831)
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
113 // case MultiTriangle:
115
117 // case MultiTriangleZ:
119
121 // case MultiTriangleM:
123
125 // case MultiTriangleZM:
127
130
133
136
139
143
147
151
155
159
163
167
171
174
178
182
186
187 }
189 }
190
201 {
202 switch ( type )
203 {
206
207 // until we support TIN types, use multipolygon
210
213
216
219
222
225
228
231
235
239
243
247
251
255
259
263
267
271
275
279
284
289
294
299
303
307
311
315
318
322
326
330 }
332 }
333
334
348 {
349 switch ( geometryType( type ) )
350 {
354 return type;
355
358 return multiType( type );
359 }
361 }
362
378 {
379 switch ( type )
380 {
387
390
393
396
399
402
405
408
411
414
417
420
423
428
432
438
443
448
452
457
461
465
469
474
479
483
487
491
495
498
502 }
504 }
505
519 {
520 switch ( type )
521 {
522
526
530
534
538
541
544
547
550
553
556
559
562
565
568
571
574
615 return type;
616
617 }
619 }
620
629 {
630 switch ( type )
631 {
634
641
648
655
661
668
675
682
688
694
700
706
712
718
721
722 }
724 }
725
727 static Qgis::WkbType zmType( Qgis::WkbType type, bool hasZ, bool hasM ) SIP_HOLDGIL
728 {
729 type = flatType( type );
730 if ( hasZ )
731 type = static_cast<Qgis::WkbType>( static_cast<quint32>( type ) + 1000 );
732 if ( hasM )
733 type = static_cast<Qgis::WkbType>( static_cast<quint32>( type ) + 2000 );
734 return type;
735 }
736
741 static Qgis::WkbType parseType( const QString &wktStr );
742
749 {
750 return ( type != Qgis::WkbType::Unknown && !isMultiType( type ) );
751 }
752
802
807 {
808 switch ( flatType( type ) )
809 {
815 return true;
816
817 default:
818 return false;
819 }
820 }
821
830 {
831 const Qgis::GeometryType gtype = geometryType( type );
832 switch ( gtype )
833 {
835 return 1;
837 return 2;
838 default: //point, no geometry, unknown geometry
839 return 0;
840 }
841 }
842
850 {
851 if ( type == Qgis::WkbType::Unknown || type == Qgis::WkbType::NoGeometry )
852 return 0;
853
854 return 2 + hasZ( type ) + hasM( type );
855 }
856
863 {
864 switch ( type )
865 {
872
884
908
932
935 }
936
938 }
939
943 static QString displayString( Qgis::WkbType type ) SIP_HOLDGIL;
944
950 static QString translatedDisplayString( Qgis::WkbType type ) SIP_HOLDGIL;
951
965 static QString geometryDisplayString( Qgis::GeometryType type ) SIP_HOLDGIL;
966
1016
1060
1069 {
1070 if ( hasZ( type ) )
1071 return type;
1072 else if ( type == Qgis::WkbType::Unknown )
1074 else if ( type == Qgis::WkbType::NoGeometry )
1076
1077 //upgrade with z dimension
1078 const Qgis::WkbType flat = flatType( type );
1079 if ( hasM( type ) )
1080 return static_cast< Qgis::WkbType >( static_cast< quint32>( flat ) + 3000 );
1081 else
1082 return static_cast<Qgis::WkbType >( static_cast< quint32>( flat ) + 1000 );
1083 }
1084
1093 {
1094 if ( hasM( type ) )
1095 return type;
1096 else if ( type == Qgis::WkbType::Unknown )
1098 else if ( type == Qgis::WkbType::NoGeometry )
1100 else if ( type == Qgis::WkbType::Point25D )
1102 else if ( type == Qgis::WkbType::LineString25D )
1104 else if ( type == Qgis::WkbType::Polygon25D )
1106 else if ( type == Qgis::WkbType::MultiPoint25D )
1108 else if ( type == Qgis::WkbType::MultiLineString25D )
1110 else if ( type == Qgis::WkbType::MultiPolygon25D )
1112
1113 //upgrade with m dimension
1114 const Qgis::WkbType flat = flatType( type );
1115 if ( hasZ( type ) )
1116 return static_cast< Qgis::WkbType >( static_cast< quint32 >( flat ) + 3000 );
1117 else
1118 return static_cast< Qgis::WkbType >( static_cast< quint32 >( flat ) + 2000 );
1119 }
1120
1128 {
1129 if ( !hasZ( type ) )
1130 return type;
1131
1132 Qgis::WkbType returnType = flatType( type );
1133 if ( hasM( type ) )
1134 returnType = addM( returnType );
1135 return returnType;
1136 }
1137
1145 {
1146 if ( !hasM( type ) )
1147 return type;
1148
1149 Qgis::WkbType returnType = flatType( type );
1150 if ( hasZ( type ) )
1151 returnType = addZ( returnType );
1152 return returnType;
1153 }
1154
1161 {
1162 const Qgis::WkbType flat = flatType( type );
1163
1164 if ( static_cast< quint32 >( flat ) >= static_cast< quint32>( Qgis::WkbType::Point ) && static_cast< quint32 >( flat ) <= static_cast< quint32>( Qgis::WkbType::MultiPolygon ) )
1165 return static_cast< Qgis::WkbType >( static_cast< quint32 >( flat ) + 0x80000000U );
1166 else if ( type == Qgis::WkbType::NoGeometry )
1168 else
1170 }
1171
1172};
1173
1174#endif // QGSWKBTYPES_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:274
@ Polygon
Polygons.
@ Unknown
Unknown types.
@ Null
No geometry.
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:201
@ 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: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