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