QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgsgeometryfactory.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgeometryfactory.h
3  -----------------------
4  begin : September 2014
5  copyright : (C) 2014 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 QGSGEOMETRYFACTORY_H
19 #define QGSGEOMETRYFACTORY_H
20 
21 #define SIP_NO_FILE
22 
23 #include "qgis_core.h"
24 #include <QString>
25 #include <memory>
26 
28 class QgsLineString;
29 class QgsConstWkbPtr;
30 class QgsRectangle;
32 class QgsMultiPoint;
33 class QgsMultiLineString;
34 class QgsPolygon;
36 
37 //compatibility with old classes
38 #include "qgspointxy.h"
39 typedef QVector<QgsPointXY> QgsPolylineXY;
40 typedef QVector<QgsPolylineXY> QgsPolygonXY;
41 typedef QVector<QgsPointXY> QgsMultiPointXY;
42 typedef QVector<QgsPolylineXY> QgsMultiPolylineXY;
43 typedef QVector<QgsPolygonXY> QgsMultiPolygonXY;
44 
52 class CORE_EXPORT QgsGeometryFactory
53 {
54  public:
55 
60  static std::unique_ptr< QgsAbstractGeometry > geomFromWkb( QgsConstWkbPtr &wkb );
61 
65  static std::unique_ptr< QgsAbstractGeometry > geomFromWkt( const QString &text );
66 
68  static std::unique_ptr< QgsAbstractGeometry > fromPointXY( const QgsPointXY &point );
70  static std::unique_ptr<QgsMultiPoint> fromMultiPointXY( const QgsMultiPointXY &multipoint );
72  static std::unique_ptr< QgsAbstractGeometry > fromPolylineXY( const QgsPolylineXY &polyline );
74  static std::unique_ptr<QgsMultiLineString> fromMultiPolylineXY( const QgsMultiPolylineXY &multiline );
76  static std::unique_ptr<QgsPolygon> fromPolygonXY( const QgsPolygonXY &polygon );
78  static std::unique_ptr<QgsMultiPolygon> fromMultiPolygonXY( const QgsMultiPolygonXY &multipoly );
80  static std::unique_ptr< QgsAbstractGeometry > geomFromWkbType( QgsWkbTypes::Type t );
81 
86  static std::unique_ptr< QgsGeometryCollection > createCollectionOfType( QgsWkbTypes::Type type );
87 
88  private:
89  static std::unique_ptr< QgsLineString > linestringFromPolyline( const QgsPolylineXY &polyline );
90 };
91 
92 #endif // QGSGEOMETRYFACTORY_H
A rectangle specified with double values.
Definition: qgsrectangle.h:40
Multi point geometry collection.
Definition: qgsmultipoint.h:29
QVector< QgsPolylineXY > QgsMultiPolylineXY
QVector< QgsPolylineXY > QgsPolygonXY
QVector< QgsPolygonXY > QgsMultiPolygonXY
A class to represent a 2D point.
Definition: qgspointxy.h:43
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item...
Definition: qgsgeometry.h:68
Multi line string geometry collection.
Contains geometry creation routines.
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.
Definition: qgsgeometry.h:74
QVector< QgsPolygonXY > QgsMultiPolygonXY
A collection of QgsPolygons that share a common collection of attributes.
Definition: qgsgeometry.h:85
QVector< QgsPolylineXY > QgsMultiPolylineXY
A collection of QgsPolylines that share a common collection of attributes.
Definition: qgsgeometry.h:78
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:68
Geometry collection.
QVector< QgsPointXY > QgsPolylineXY
Abstract base class for all geometries.
QVector< QgsPointXY > QgsMultiPointXY
QVector< QgsPointXY > QgsPolylineXY
Polyline as represented as a vector of two-dimensional points.
Definition: qgsgeometry.h:44
Multi polygon geometry collection.
Line string geometry type, with support for z-dimension and m-values.
Definition: qgslinestring.h:43
Polygon geometry type.
Definition: qgspolygon.h:31