QgsWkbTypes class

Handles storage of information regarding WKB types and their properties.

Public types

enum GeometryType { PointGeometry, LineGeometry, PolygonGeometry, UnknownGeometry, NullGeometry }
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
enum Type { Unknown = 0, Point = 1, LineString = 2, Polygon = 3, Triangle = 17, MultiPoint = 4, MultiLineString = 5, MultiPolygon = 6, GeometryCollection = 7, CircularString = 8, CompoundCurve = 9, CurvePolygon = 10, MultiCurve = 11, MultiSurface = 12, NoGeometry = 100, PointZ = 1001, LineStringZ = 1002, PolygonZ = 1003, TriangleZ = 1017, MultiPointZ = 1004, MultiLineStringZ = 1005, MultiPolygonZ = 1006, GeometryCollectionZ = 1007, CircularStringZ = 1008, CompoundCurveZ = 1009, CurvePolygonZ = 1010, MultiCurveZ = 1011, MultiSurfaceZ = 1012, PointM = 2001, LineStringM = 2002, PolygonM = 2003, TriangleM = 2017, MultiPointM = 2004, MultiLineStringM = 2005, MultiPolygonM = 2006, GeometryCollectionM = 2007, CircularStringM = 2008, CompoundCurveM = 2009, CurvePolygonM = 2010, MultiCurveM = 2011, MultiSurfaceM = 2012, PointZM = 3001, LineStringZM = 3002, PolygonZM = 3003, MultiPointZM = 3004, MultiLineStringZM = 3005, MultiPolygonZM = 3006, GeometryCollectionZM = 3007, CircularStringZM = 3008, CompoundCurveZM = 3009, CurvePolygonZM = 3010, MultiCurveZM = 3011, MultiSurfaceZM = 3012, TriangleZM = 3017, Point25D = 0x80000001, LineString25D, Polygon25D, MultiPoint25D, MultiLineString25D, MultiPolygon25D }
The WKB type describes the number of dimensions a geometry has.

Public static functions

static auto addM(Type type) -> Type
Adds the m dimension to a WKB type and returns the new type.
static auto addZ(Type type) -> Type
Adds the z dimension to a WKB type and returns the new type.
static auto coordDimensions(Type type) -> int
Returns the coordinate dimension of the geometry type as an integer.
static auto displayString(Type type) -> QString
Returns a display string type for a WKB type, e.g., the geometry name used in WKT geometry representations.
static auto dropM(Type type) -> Type
Drops the m dimension (if present) for a WKB type and returns the new type.
static auto dropZ(Type type) -> Type
Drops the z dimension (if present) for a WKB type and returns the new type.
static auto flatType(Type type) -> Type
Returns the flat type for a WKB type.
static auto geometryDisplayString(GeometryType type) -> QString
Returns a display string for a geometry type.
static auto geometryType(Type type) -> GeometryType
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a PolygonGeometry geometry type.
static auto hasM(Type type) -> bool
Tests whether a WKB type contains m values.
static auto hasZ(Type type) -> bool
Tests whether a WKB type contains the z-dimension.
static auto isCurvedType(Type type) -> bool
Returns true if the WKB type is a curved type or can contain curved geometries.
static auto isMultiType(Type type) -> bool
Returns true if the WKB type is a multi type.
static auto isSingleType(Type type) -> bool
Returns true if the WKB type is a single type.
static auto multiType(Type type) -> Type
Returns the multi type for a WKB type.
static auto parseType(const QString& wktStr) -> Type
Attempts to extract the WKB type from a WKT string.
static auto singleType(Type type) -> Type
Returns the single type for a WKB type.
static auto to25D(Type type) -> Type
Will convert the 25D version of the flat type if supported or Unknown if not supported.
static auto wkbDimensions(Type type) -> int
Returns the inherent dimension of the geometry type as an integer.
static auto zmType(Type type, bool hasZ, bool hasM) -> Type
Returns the modified input geometry type according to hasZ / hasM.

Enum documentation

enum QgsWkbTypes::GeometryType

The geometry types are used to group QgsWkbTypes::Type in a coarse way.

enum QgsWkbTypes::Type

The WKB type describes the number of dimensions a geometry has.

  • Point
  • LineString
  • Polygon

as well as the number of dimensions for each individual vertex

  • X (always)
  • Y (always)
  • Z (optional)
  • M (measurement value, optional)

it also has values for multi types, collections, unknown geometry, null geometry, no geometry and curve support.

These classes of geometry are often used for data sources to communicate what kind of geometry should be expected for a given geometry field. It is also used for tools or algorithms to decide if they should be available for a given geometry type or act in a different mode.

Function documentation

static Type QgsWkbTypes::addM(Type type)

Adds the m dimension to a WKB type and returns the new type.

Parameters
type original type

static Type QgsWkbTypes::addZ(Type type)

Adds the z dimension to a WKB type and returns the new type.

Parameters
type original type

static int QgsWkbTypes::coordDimensions(Type type)

Returns the coordinate dimension of the geometry type as an integer.

Returned value will be between 2-4, depending on whether the geometry type contains the Z or M dimensions. Invalid geometry types will return a dimension of 0.

static Type QgsWkbTypes::dropM(Type type)

Drops the m dimension (if present) for a WKB type and returns the new type.

Parameters
type original type

static Type QgsWkbTypes::dropZ(Type type)

Drops the z dimension (if present) for a WKB type and returns the new type.

Parameters
type original type

static Type QgsWkbTypes::flatType(Type type)

Returns the flat type for a WKB type.

This is the WKB type minus any Z or M dimensions. For example, for PolygonZM WKB types the single type would be Polygon.

static QString QgsWkbTypes::geometryDisplayString(GeometryType type)

Returns a display string for a geometry type.

This will return one of the following strings:

  • Point
  • Line
  • Polygon
  • Unknown Geometry
  • No Geometry
  • Invalid Geometry

static GeometryType QgsWkbTypes::geometryType(Type type)

Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a PolygonGeometry geometry type.

GeometryCollections are reported as QgsWkbTypes::UnknownGeometry.

static bool QgsWkbTypes::hasM(Type type)

Tests whether a WKB type contains m values.

Returns true if type has m values

static bool QgsWkbTypes::hasZ(Type type)

Tests whether a WKB type contains the z-dimension.

Returns true if type has z values

static bool QgsWkbTypes::isCurvedType(Type type)

Returns true if the WKB type is a curved type or can contain curved geometries.

static bool QgsWkbTypes::isMultiType(Type type)

Returns true if the WKB type is a multi type.

static bool QgsWkbTypes::isSingleType(Type type)

Returns true if the WKB type is a single type.

static Type QgsWkbTypes::multiType(Type type)

Returns the multi type for a WKB type.

For example, for Polygon WKB types the multi type would be MultiPolygon.

static Type QgsWkbTypes::parseType(const QString& wktStr)

Attempts to extract the WKB type from a WKT string.

Parameters
wktStr a valid WKT string

static Type QgsWkbTypes::singleType(Type type)

Returns the single type for a WKB type.

For example, for MultiPolygon WKB types the single type would be Polygon.

static Type QgsWkbTypes::to25D(Type type)

Will convert the 25D version of the flat type if supported or Unknown if not supported.

Parameters
type The type to convert
Returns the 25D version of the type or Unknown

static int QgsWkbTypes::wkbDimensions(Type type)

Returns the inherent dimension of the geometry type as an integer.

Returns 0 for point geometries, 1 for line geometries, 2 for polygon geometries Invalid geometry types will return a dimension of 0.

Returned value will always be less than or equal to the coordinate dimension.