QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
27 /***************************************************************************
28  * This class is considered CRITICAL and any change MUST be accompanied with
29  * full unit tests in testqgsstatisticalsummary.cpp.
30  * See details in QEP #17
31  ****************************************************************************/
32 
40 class CORE_EXPORT QgsWkbTypes
41 {
42  Q_GADGET
43  public:
44 
68  enum Type
69  {
70  Unknown = 0,
71  Point = 1,
72  LineString = 2,
73  Polygon = 3,
74  Triangle = 17,
75  MultiPoint = 4,
76  MultiLineString = 5,
77  MultiPolygon = 6,
78  GeometryCollection = 7,
79  CircularString = 8,
80  CompoundCurve = 9,
81  CurvePolygon = 10, //13, //should be 10. Seems to be correct in newer PostGIS versions
82  MultiCurve = 11,
83  MultiSurface = 12,
84  NoGeometry = 100, //attributes only
85  PointZ = 1001,
86  LineStringZ = 1002,
87  PolygonZ = 1003,
88  TriangleZ = 1017,
89  MultiPointZ = 1004,
90  MultiLineStringZ = 1005,
91  MultiPolygonZ = 1006,
92  GeometryCollectionZ = 1007,
93  CircularStringZ = 1008,
94  CompoundCurveZ = 1009,
95  CurvePolygonZ = 1010,
96  MultiCurveZ = 1011,
97  MultiSurfaceZ = 1012,
98  PointM = 2001,
99  LineStringM = 2002,
100  PolygonM = 2003,
101  TriangleM = 2017,
102  MultiPointM = 2004,
103  MultiLineStringM = 2005,
104  MultiPolygonM = 2006,
105  GeometryCollectionM = 2007,
106  CircularStringM = 2008,
107  CompoundCurveM = 2009,
108  CurvePolygonM = 2010,
109  MultiCurveM = 2011,
110  MultiSurfaceM = 2012,
111  PointZM = 3001,
112  LineStringZM = 3002,
113  PolygonZM = 3003,
114  MultiPointZM = 3004,
115  MultiLineStringZM = 3005,
116  MultiPolygonZM = 3006,
117  GeometryCollectionZM = 3007,
118  CircularStringZM = 3008,
119  CompoundCurveZM = 3009,
120  CurvePolygonZM = 3010,
121  MultiCurveZM = 3011,
122  MultiSurfaceZM = 3012,
123  TriangleZM = 3017,
124  Point25D = 0x80000001,
129  MultiPolygon25D
130  };
131  Q_ENUM( Type )
132 
133 
140  {
145  NullGeometry
146  };
147  Q_ENUM( GeometryType )
148 
149 
156  static Type singleType( Type type )
157  {
158  switch ( type )
159  {
160  case Unknown:
161  case GeometryCollection:
162  case GeometryCollectionZ:
163  case GeometryCollectionM:
164  case GeometryCollectionZM:
165  return Unknown;
166 
167  case Point:
168  case MultiPoint:
169  return Point;
170 
171  case PointZ:
172  case MultiPointZ:
173  return PointZ;
174 
175  case PointM:
176  case MultiPointM:
177  return PointM;
178 
179  case PointZM:
180  case MultiPointZM:
181  return PointZM;
182 
183  case LineString:
184  case MultiLineString:
185  return LineString;
186 
187  case LineStringZ:
188  case MultiLineStringZ:
189  return LineStringZ;
190 
191  case LineStringM:
192  case MultiLineStringM:
193  return LineStringM;
194 
195  case LineStringZM:
196  case MultiLineStringZM:
197  return LineStringZM;
198 
199  case Polygon:
200  case MultiPolygon:
201  return Polygon;
202 
203  case PolygonZ:
204  case MultiPolygonZ:
205  return PolygonZ;
206 
207  case PolygonM:
208  case MultiPolygonM:
209  return PolygonM;
210 
211  case PolygonZM:
212  case MultiPolygonZM:
213  return PolygonZM;
214 
215  case Triangle:
216  // case MultiTriangle:
217  return Triangle;
218 
219  case TriangleZ:
220  // case MultiTriangleZ:
221  return TriangleZ;
222 
223  case TriangleM:
224  // case MultiTriangleM:
225  return TriangleM;
226 
227  case TriangleZM:
228  // case MultiTriangleZM:
229  return TriangleZM;
230 
231  case CircularString:
232  return CircularString;
233 
234  case CircularStringZ:
235  return CircularStringZ;
236 
237  case CircularStringM:
238  return CircularStringM;
239 
240  case CircularStringZM:
241  return CircularStringZM;
242 
243  case CompoundCurve:
244  case MultiCurve:
245  return CompoundCurve;
246 
247  case CompoundCurveZ:
248  case MultiCurveZ:
249  return CompoundCurveZ;
250 
251  case CompoundCurveM:
252  case MultiCurveM:
253  return CompoundCurveM;
254 
255  case CompoundCurveZM:
256  case MultiCurveZM:
257  return CompoundCurveZM;
258 
259  case CurvePolygon:
260  case MultiSurface:
261  return CurvePolygon;
262 
263  case CurvePolygonZ:
264  case MultiSurfaceZ:
265  return CurvePolygonZ;
266 
267  case CurvePolygonM:
268  case MultiSurfaceM:
269  return CurvePolygonM;
270 
271  case CurvePolygonZM:
272  case MultiSurfaceZM:
273  return CurvePolygonZM;
274 
275  case NoGeometry:
276  return NoGeometry;
277 
278  case Point25D:
279  case MultiPoint25D:
280  return Point25D;
281 
282  case LineString25D:
283  case MultiLineString25D:
284  return LineString25D;
285 
286  case Polygon25D:
287  case MultiPolygon25D:
288  return Polygon25D;
289 
290  }
291  return Unknown;
292  }
293 
301  static Type multiType( Type type )
302  {
303  switch ( type )
304  {
305  case Unknown:
306  return Unknown;
307 
308  // until we support TIN types, use multipolygon
309  case Triangle:
310  return MultiPolygon;
311 
312  case TriangleZ:
313  return MultiPolygonZ;
314 
315  case TriangleM:
316  return MultiPolygonM;
317 
318  case TriangleZM:
319  return MultiPolygonZM;
320 
321  case GeometryCollection:
322  return GeometryCollection;
323 
324  case GeometryCollectionZ:
325  return GeometryCollectionZ;
326 
327  case GeometryCollectionM:
328  return GeometryCollectionM;
329 
330  case GeometryCollectionZM:
331  return GeometryCollectionZM;
332 
333  case Point:
334  case MultiPoint:
335  return MultiPoint;
336 
337  case PointZ:
338  case MultiPointZ:
339  return MultiPointZ;
340 
341  case PointM:
342  case MultiPointM:
343  return MultiPointM;
344 
345  case PointZM:
346  case MultiPointZM:
347  return MultiPointZM;
348 
349  case LineString:
350  case MultiLineString:
351  return MultiLineString;
352 
353  case LineStringZ:
354  case MultiLineStringZ:
355  return MultiLineStringZ;
356 
357  case LineStringM:
358  case MultiLineStringM:
359  return MultiLineStringM;
360 
361  case LineStringZM:
362  case MultiLineStringZM:
363  return MultiLineStringZM;
364 
365  case Polygon:
366  case MultiPolygon:
367  return MultiPolygon;
368 
369  case PolygonZ:
370  case MultiPolygonZ:
371  return MultiPolygonZ;
372 
373  case PolygonM:
374  case MultiPolygonM:
375  return MultiPolygonM;
376 
377  case PolygonZM:
378  case MultiPolygonZM:
379  return MultiPolygonZM;
380 
381  case CompoundCurve:
382  case CircularString:
383  case MultiCurve:
384  return MultiCurve;
385 
386  case CompoundCurveZ:
387  case CircularStringZ:
388  case MultiCurveZ:
389  return MultiCurveZ;
390 
391  case CompoundCurveM:
392  case CircularStringM:
393  case MultiCurveM:
394  return MultiCurveM;
395 
396  case CompoundCurveZM:
397  case CircularStringZM:
398  case MultiCurveZM:
399  return MultiCurveZM;
400 
401  case CurvePolygon:
402  case MultiSurface:
403  return MultiSurface;
404 
405  case CurvePolygonZ:
406  case MultiSurfaceZ:
407  return MultiSurfaceZ;
408 
409  case CurvePolygonM:
410  case MultiSurfaceM:
411  return MultiSurfaceM;
412 
413  case CurvePolygonZM:
414  case MultiSurfaceZM:
415  return MultiSurfaceZM;
416 
417  case NoGeometry:
418  return NoGeometry;
419 
420  case Point25D:
421  case MultiPoint25D:
422  return MultiPoint25D;
423 
424  case LineString25D:
425  case MultiLineString25D:
426  return MultiLineString25D;
427 
428  case Polygon25D:
429  case MultiPolygon25D:
430  return MultiPolygon25D;
431  }
432  return Unknown;
433  }
434 
435 
450  static Type curveType( Type type )
451  {
452  switch ( type )
453  {
454  case Unknown:
455  case Triangle:
456  case TriangleZ:
457  case TriangleM:
458  case TriangleZM:
459  return Unknown;
460 
461  case GeometryCollection:
462  return GeometryCollection;
463 
464  case GeometryCollectionZ:
465  return GeometryCollectionZ;
466 
467  case GeometryCollectionM:
468  return GeometryCollectionM;
469 
470  case GeometryCollectionZM:
471  return GeometryCollectionZM;
472 
473  case Point:
474  return Point;
475 
476  case MultiPoint:
477  return MultiPoint;
478 
479  case PointZ:
480  return PointZ;
481 
482  case MultiPointZ:
483  return MultiPointZ;
484 
485  case PointM:
486  return PointM;
487 
488  case MultiPointM:
489  return MultiPointM;
490 
491  case PointZM:
492  return PointZM;
493 
494  case MultiPointZM:
495  return MultiPointZM;
496 
497  case LineString:
498  case CompoundCurve:
499  case CircularString:
500  return CompoundCurve;
501 
502  case MultiLineString:
503  case MultiCurve:
504  return MultiCurve;
505 
506  case LineStringZ:
507  case CompoundCurveZ:
508  case CircularStringZ:
509  case LineString25D:
510  return CompoundCurveZ;
511 
512  case MultiLineStringZ:
513  case MultiCurveZ:
514  case MultiLineString25D:
515  return MultiCurveZ;
516 
517  case LineStringM:
518  case CompoundCurveM:
519  case CircularStringM:
520  return CompoundCurveM;
521 
522  case MultiLineStringM:
523  case MultiCurveM:
524  return MultiCurveM;
525 
526  case LineStringZM:
527  case CompoundCurveZM:
528  case CircularStringZM:
529  return CompoundCurveZM;
530 
531  case MultiLineStringZM:
532  case MultiCurveZM:
533  return MultiCurveZM;
534 
535  case Polygon:
536  case CurvePolygon:
537  return CurvePolygon;
538 
539  case MultiPolygon:
540  case MultiSurface:
541  return MultiSurface;
542 
543  case PolygonZ:
544  case CurvePolygonZ:
545  case Polygon25D:
546  return CurvePolygonZ;
547 
548  case MultiPolygonZ:
549  case MultiSurfaceZ:
550  case MultiPolygon25D:
551  return MultiSurfaceZ;
552 
553  case PolygonM:
554  case CurvePolygonM:
555  return CurvePolygonM;
556 
557  case MultiPolygonM:
558  case MultiSurfaceM:
559  return MultiSurfaceM;
560 
561  case PolygonZM:
562  case CurvePolygonZM:
563  return CurvePolygonZM;
564 
565  case MultiPolygonZM:
566  case MultiSurfaceZM:
567  return MultiSurfaceZM;
568 
569  case NoGeometry:
570  return NoGeometry;
571 
572  case Point25D:
573  case MultiPoint25D:
574  return MultiPoint25D;
575  }
576  return Unknown;
577  }
578 
591  static Type linearType( Type type )
592  {
593  switch ( type )
594  {
595 
596  case CircularString:
597  case CompoundCurve:
598  return LineString;
599 
600  case CircularStringM:
601  case CompoundCurveM:
602  return LineStringM;
603 
604  case CircularStringZ:
605  case CompoundCurveZ:
606  return LineStringZ;
607 
608  case CircularStringZM:
609  case CompoundCurveZM:
610  return LineStringZM;
611 
612  case MultiCurve:
613  return MultiLineString;
614 
615  case MultiCurveM:
616  return MultiLineStringM;
617 
618  case MultiCurveZ:
619  return MultiLineStringZ;
620 
621  case MultiCurveZM:
622  return MultiLineStringZM;
623 
624  case CurvePolygon:
625  return Polygon;
626 
627  case CurvePolygonM:
628  return PolygonM;
629 
630  case CurvePolygonZ:
631  return PolygonZ;
632 
633  case CurvePolygonZM:
634  return PolygonZM;
635 
636  case MultiSurface:
637  return MultiPolygon;
638 
639  case MultiSurfaceM:
640  return MultiPolygonM;
641 
642  case MultiSurfaceZ:
643  return MultiPolygonZ;
644 
645  case MultiSurfaceZM:
646  return MultiPolygonZM;
647 
648  case GeometryCollection:
649  case GeometryCollectionM:
650  case GeometryCollectionZ:
651  case GeometryCollectionZM:
652  case LineString:
653  case LineString25D:
654  case LineStringM:
655  case LineStringZ:
656  case LineStringZM:
657  case MultiLineString:
658  case MultiLineString25D:
659  case MultiLineStringM:
660  case MultiLineStringZ:
661  case MultiLineStringZM:
662  case MultiPoint:
663  case MultiPoint25D:
664  case MultiPointM:
665  case MultiPointZ:
666  case MultiPointZM:
667  case MultiPolygon:
668  case MultiPolygon25D:
669  case MultiPolygonM:
670  case MultiPolygonZ:
671  case MultiPolygonZM:
672  case NoGeometry:
673  case Point:
674  case Point25D:
675  case PointM:
676  case PointZ:
677  case PointZM:
678  case Polygon:
679  case Polygon25D:
680  case PolygonM:
681  case PolygonZ:
682  case PolygonZM:
683  case Triangle:
684  case TriangleM:
685  case TriangleZ:
686  case TriangleZM:
687  case Unknown:
688  return type;
689 
690  }
691  return Unknown;
692  }
693 
701  static Type flatType( Type type )
702  {
703  switch ( type )
704  {
705  case Unknown:
706  return Unknown;
707 
708  case Point:
709  case PointZ:
710  case PointM:
711  case PointZM:
712  case Point25D:
713  return Point;
714 
715  case LineString:
716  case LineStringZ:
717  case LineStringM:
718  case LineStringZM:
719  case LineString25D:
720  return LineString;
721 
722  case Polygon:
723  case PolygonZ:
724  case PolygonM:
725  case PolygonZM:
726  case Polygon25D:
727  return Polygon;
728 
729  case Triangle:
730  case TriangleZ:
731  case TriangleM:
732  case TriangleZM:
733  return Triangle;
734 
735  case MultiPoint:
736  case MultiPointZ:
737  case MultiPointM:
738  case MultiPointZM:
739  case MultiPoint25D:
740  return MultiPoint;
741 
742  case MultiLineString:
743  case MultiLineStringZ:
744  case MultiLineStringM:
745  case MultiLineStringZM:
746  case MultiLineString25D:
747  return MultiLineString;
748 
749  case MultiPolygon:
750  case MultiPolygonZ:
751  case MultiPolygonM:
752  case MultiPolygonZM:
753  case MultiPolygon25D:
754  return MultiPolygon;
755 
756  case GeometryCollection:
757  case GeometryCollectionZ:
758  case GeometryCollectionM:
759  case GeometryCollectionZM:
760  return GeometryCollection;
761 
762  case CircularString:
763  case CircularStringZ:
764  case CircularStringM:
765  case CircularStringZM:
766  return CircularString;
767 
768  case CompoundCurve:
769  case CompoundCurveZ:
770  case CompoundCurveM:
771  case CompoundCurveZM:
772  return CompoundCurve;
773 
774  case MultiCurve:
775  case MultiCurveZ:
776  case MultiCurveM:
777  case MultiCurveZM:
778  return MultiCurve;
779 
780  case CurvePolygon:
781  case CurvePolygonZ:
782  case CurvePolygonM:
783  case CurvePolygonZM:
784  return CurvePolygon;
785 
786  case MultiSurface:
787  case MultiSurfaceZ:
788  case MultiSurfaceM:
789  case MultiSurfaceZM:
790  return MultiSurface;
791 
792  case NoGeometry:
793  return NoGeometry;
794 
795  }
796  return Unknown;
797  }
798 
800  static Type zmType( Type type, bool hasZ, bool hasM )
801  {
802  type = flatType( type );
803  if ( hasZ )
804  type = static_cast<QgsWkbTypes::Type>( static_cast<quint32>( type ) + 1000 );
805  if ( hasM )
806  type = static_cast<QgsWkbTypes::Type>( static_cast<quint32>( type ) + 2000 );
807  return type;
808  }
809 
814  static Type parseType( const QString &wktStr );
815 
821  static bool isSingleType( Type type )
822  {
823  return ( type != Unknown && !isMultiType( type ) );
824  }
825 
831  static bool isMultiType( Type type )
832  {
833  switch ( type )
834  {
835  case Unknown:
836  case Point:
837  case LineString:
838  case Polygon:
839  case Triangle:
840  case CircularString:
841  case CompoundCurve:
842  case CurvePolygon:
843  case NoGeometry:
844  case PointZ:
845  case LineStringZ:
846  case PolygonZ:
847  case TriangleZ:
848  case CircularStringZ:
849  case CompoundCurveZ:
850  case CurvePolygonZ:
851  case PointM:
852  case LineStringM:
853  case PolygonM:
854  case TriangleM:
855  case CircularStringM:
856  case CompoundCurveM:
857  case CurvePolygonM:
858  case PointZM:
859  case LineStringZM:
860  case PolygonZM:
861  case TriangleZM:
862  case CircularStringZM:
863  case CompoundCurveZM:
864  case CurvePolygonZM:
865  case Point25D:
866  case LineString25D:
867  case Polygon25D:
868  return false;
869 
870  default:
871  return true;
872 
873  }
874  }
875 
880  static bool isCurvedType( Type type )
881  {
882  switch ( flatType( type ) )
883  {
884  case CircularString:
885  case CompoundCurve:
886  case CurvePolygon:
887  case MultiCurve:
888  case MultiSurface:
889  return true;
890 
891  default:
892  return false;
893  }
894  }
895 
903  static int wkbDimensions( Type type )
904  {
905  GeometryType gtype = geometryType( type );
906  switch ( gtype )
907  {
908  case LineGeometry:
909  return 1;
910  case PolygonGeometry:
911  return 2;
912  default: //point, no geometry, unknown geometry
913  return 0;
914  }
915  }
916 
924  static int coordDimensions( Type type )
925  {
926  if ( type == Unknown || type == NoGeometry )
927  return 0;
928 
929  return 2 + hasZ( type ) + hasM( type );
930  }
931 
938  {
939  switch ( type )
940  {
941  case Unknown:
942  case GeometryCollection:
943  case GeometryCollectionZ:
944  case GeometryCollectionM:
945  case GeometryCollectionZM:
946  return UnknownGeometry;
947 
948  case Point:
949  case MultiPoint:
950  case PointZ:
951  case MultiPointZ:
952  case PointM:
953  case MultiPointM:
954  case PointZM:
955  case MultiPointZM:
956  case Point25D:
957  case MultiPoint25D:
958  return PointGeometry;
959 
960  case LineString:
961  case MultiLineString:
962  case LineStringZ:
963  case MultiLineStringZ:
964  case LineStringM:
965  case MultiLineStringM:
966  case LineStringZM:
967  case MultiLineStringZM:
968  case LineString25D:
969  case MultiLineString25D:
970  case CircularString:
971  case CompoundCurve:
972  case MultiCurve:
973  case CircularStringZ:
974  case CompoundCurveZ:
975  case MultiCurveZ:
976  case CircularStringM:
977  case CompoundCurveM:
978  case MultiCurveM:
979  case CircularStringZM:
980  case CompoundCurveZM:
981  case MultiCurveZM:
982  return LineGeometry;
983 
984  case Polygon:
985  case MultiPolygon:
986  case Triangle:
987  case PolygonZ:
988  case TriangleZ:
989  case MultiPolygonZ:
990  case PolygonM:
991  case TriangleM:
992  case MultiPolygonM:
993  case PolygonZM:
994  case MultiPolygonZM:
995  case TriangleZM:
996  case Polygon25D:
997  case MultiPolygon25D:
998  case CurvePolygon:
999  case MultiSurface:
1000  case CurvePolygonZ:
1001  case MultiSurfaceZ:
1002  case CurvePolygonM:
1003  case MultiSurfaceM:
1004  case CurvePolygonZM:
1005  case MultiSurfaceZM:
1006  return PolygonGeometry;
1007 
1008  case NoGeometry:
1009  return NullGeometry;
1010  }
1011 
1012  return UnknownGeometry;
1013  }
1014 
1018  static QString displayString( Type type );
1019 
1034  static QString geometryDisplayString( GeometryType type );
1035 
1042  static bool hasZ( Type type )
1043  {
1044  switch ( type )
1045  {
1046  case PointZ:
1047  case LineStringZ:
1048  case PolygonZ:
1049  case TriangleZ:
1050  case MultiPointZ:
1051  case MultiLineStringZ:
1052  case MultiPolygonZ:
1053  case GeometryCollectionZ:
1054  case CircularStringZ:
1055  case CompoundCurveZ:
1056  case CurvePolygonZ:
1057  case MultiCurveZ:
1058  case MultiSurfaceZ:
1059  case PointZM:
1060  case LineStringZM:
1061  case PolygonZM:
1062  case TriangleZM:
1063  case MultiPointZM:
1064  case MultiLineStringZM:
1065  case MultiPolygonZM:
1066  case GeometryCollectionZM:
1067  case CircularStringZM:
1068  case CompoundCurveZM:
1069  case CurvePolygonZM:
1070  case MultiCurveZM:
1071  case MultiSurfaceZM:
1072  case Point25D:
1073  case LineString25D:
1074  case Polygon25D:
1075  case MultiPoint25D:
1076  case MultiLineString25D:
1077  case MultiPolygon25D:
1078  return true;
1079 
1080  default:
1081  return false;
1082 
1083  }
1084  }
1085 
1092  static bool hasM( Type type )
1093  {
1094  switch ( type )
1095  {
1096  case PointM:
1097  case LineStringM:
1098  case PolygonM:
1099  case TriangleM:
1100  case MultiPointM:
1101  case MultiLineStringM:
1102  case MultiPolygonM:
1103  case GeometryCollectionM:
1104  case CircularStringM:
1105  case CompoundCurveM:
1106  case CurvePolygonM:
1107  case MultiCurveM:
1108  case MultiSurfaceM:
1109  case PointZM:
1110  case LineStringZM:
1111  case PolygonZM:
1112  case TriangleZM:
1113  case MultiPointZM:
1114  case MultiLineStringZM:
1115  case MultiPolygonZM:
1116  case GeometryCollectionZM:
1117  case CircularStringZM:
1118  case CompoundCurveZM:
1119  case CurvePolygonZM:
1120  case MultiCurveZM:
1121  case MultiSurfaceZM:
1122  return true;
1123 
1124  default:
1125  return false;
1126 
1127  }
1128  }
1129 
1138  static Type addZ( Type type )
1139  {
1140  if ( hasZ( type ) )
1141  return type;
1142  else if ( type == Unknown )
1143  return Unknown;
1144  else if ( type == NoGeometry )
1145  return NoGeometry;
1146 
1147  //upgrade with z dimension
1148  Type flat = flatType( type );
1149  if ( hasM( type ) )
1150  return static_cast< QgsWkbTypes::Type >( flat + 3000 );
1151  else
1152  return static_cast< QgsWkbTypes::Type >( flat + 1000 );
1153  }
1154 
1163  static Type addM( Type type )
1164  {
1165  if ( hasM( type ) )
1166  return type;
1167  else if ( type == Unknown )
1168  return Unknown;
1169  else if ( type == NoGeometry )
1170  return NoGeometry;
1171  else if ( type == Point25D ||
1172  type == LineString25D ||
1173  type == Polygon25D ||
1174  type == MultiPoint25D ||
1175  type == MultiLineString25D ||
1176  type == MultiPolygon25D )
1177  return type; //can't add M dimension to these types
1178 
1179  //upgrade with m dimension
1180  Type flat = flatType( type );
1181  if ( hasZ( type ) )
1182  return static_cast< QgsWkbTypes::Type >( flat + 3000 );
1183  else
1184  return static_cast< QgsWkbTypes::Type >( flat + 2000 );
1185  }
1186 
1194  static Type dropZ( Type type )
1195  {
1196  if ( !hasZ( type ) )
1197  return type;
1198 
1199  QgsWkbTypes::Type returnType = flatType( type );
1200  if ( hasM( type ) )
1201  returnType = addM( returnType );
1202  return returnType;
1203  }
1204 
1212  static Type dropM( Type type )
1213  {
1214  if ( !hasM( type ) )
1215  return type;
1216 
1217  QgsWkbTypes::Type returnType = flatType( type );
1218  if ( hasZ( type ) )
1219  returnType = addZ( returnType );
1220  return returnType;
1221  }
1222 
1228  static Type to25D( Type type )
1229  {
1230  QgsWkbTypes::Type flat = flatType( type );
1231 
1232  if ( flat >= Point && flat <= MultiPolygon )
1233  return static_cast< QgsWkbTypes::Type >( static_cast<unsigned>( flat ) + 0x80000000U );
1234  else if ( type == QgsWkbTypes::NoGeometry )
1235  return QgsWkbTypes::NoGeometry;
1236  else
1237  return Unknown;
1238  }
1239 
1240 };
1241 
1242 #endif // QGSWKBTYPES_H
QgsWkbTypes::multiType
static Type multiType(Type type)
Returns the multi type for a WKB type.
Definition: qgswkbtypes.h:301
QgsWkbTypes::linearType
static Type linearType(Type type)
Returns the linear type for a WKB type.
Definition: qgswkbtypes.h:591
QgsWkbTypes::LineString25D
@ LineString25D
Definition: qgswkbtypes.h:125
QgsWkbTypes::coordDimensions
static int coordDimensions(Type type)
Returns the coordinate dimension of the geometry type as an integer.
Definition: qgswkbtypes.h:924
QgsWkbTypes::isMultiType
static bool isMultiType(Type type)
Returns true if the WKB type is a multi type.
Definition: qgswkbtypes.h:831
QgsWkbTypes::to25D
static Type to25D(Type type)
Will convert the 25D version of the flat type if supported or Unknown if not supported.
Definition: qgswkbtypes.h:1228
QgsWkbTypes::Type
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:68
QgsWkbTypes::hasZ
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
Definition: qgswkbtypes.h:1042
QgsWkbTypes::wkbDimensions
static int wkbDimensions(Type type)
Returns the inherent dimension of the geometry type as an integer.
Definition: qgswkbtypes.h:903
QgsWkbTypes::dropM
static Type dropM(Type type)
Drops the m dimension (if present) for a WKB type and returns the new type.
Definition: qgswkbtypes.h:1212
QgsWkbTypes::addM
static Type addM(Type type)
Adds the m dimension to a WKB type and returns the new type.
Definition: qgswkbtypes.h:1163
QgsWkbTypes::MultiPoint25D
@ MultiPoint25D
Definition: qgswkbtypes.h:127
QgsWkbTypes::PolygonGeometry
@ PolygonGeometry
Definition: qgswkbtypes.h:143
QgsWkbTypes::Polygon25D
@ Polygon25D
Definition: qgswkbtypes.h:126
QgsWkbTypes::MultiLineString25D
@ MultiLineString25D
Definition: qgswkbtypes.h:128
QgsWkbTypes::geometryType
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
Definition: qgswkbtypes.h:937
QgsWkbTypes::isSingleType
static bool isSingleType(Type type)
Returns true if the WKB type is a single type.
Definition: qgswkbtypes.h:821
QgsWkbTypes::addZ
static Type addZ(Type type)
Adds the z dimension to a WKB type and returns the new type.
Definition: qgswkbtypes.h:1138
QgsWkbTypes::zmType
static Type zmType(Type type, bool hasZ, bool hasM)
Returns the modified input geometry type according to hasZ / hasM.
Definition: qgswkbtypes.h:800
QgsWkbTypes::hasM
static bool hasM(Type type)
Tests whether a WKB type contains m values.
Definition: qgswkbtypes.h:1092
QgsWkbTypes::LineGeometry
@ LineGeometry
Definition: qgswkbtypes.h:142
QgsWkbTypes::PointGeometry
@ PointGeometry
Definition: qgswkbtypes.h:141
QgsWkbTypes::NoGeometry
@ NoGeometry
Definition: qgswkbtypes.h:84
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:139
QgsWkbTypes::UnknownGeometry
@ UnknownGeometry
Definition: qgswkbtypes.h:144
QgsWkbTypes::curveType
static Type curveType(Type type)
Returns the curve type for a WKB type.
Definition: qgswkbtypes.h:450
QgsWkbTypes::isCurvedType
static bool isCurvedType(Type type)
Returns true if the WKB type is a curved type or can contain curved geometries.
Definition: qgswkbtypes.h:880
QgsWkbTypes
Handles storage of information regarding WKB types and their properties.
Definition: qgswkbtypes.h:40
QgsWkbTypes::dropZ
static Type dropZ(Type type)
Drops the z dimension (if present) for a WKB type and returns the new type.
Definition: qgswkbtypes.h:1194
QgsWkbTypes::flatType
static Type flatType(Type type)
Returns the flat type for a WKB type.
Definition: qgswkbtypes.h:701