/
qgsgeometryfactory.h
85 lines (73 loc) · 3.37 KB
/
qgsgeometryfactory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/***************************************************************************
qgsgeometryfactory.h
-----------------------
begin : September 2014
copyright : (C) 2014 by Marco Hugentobler
email : marco at sourcepole dot ch
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSGEOMETRYFACTORY_H
#define QGSGEOMETRYFACTORY_H
#include "qgis_core.h"
#include <QString>
#include <memory>
class QgsAbstractGeometry;
class QgsLineString;
class QgsConstWkbPtr;
class QgsRectangle;
class QgsGeometryCollection;
//compatibility with old classes
#include "qgspointxy.h"
typedef QVector<QgsPointXY> QgsPolyline;
typedef QVector<QgsPolyline> QgsPolygon;
typedef QVector<QgsPointXY> QgsMultiPoint;
typedef QVector<QgsPolyline> QgsMultiPolyline;
typedef QVector<QgsPolygon> QgsMultiPolygon;
/** \ingroup core
* \class QgsGeometryFactory
* \brief Contains geometry creation routines.
* \since QGIS 2.10
* \note not available in Python bindings
*/
class CORE_EXPORT QgsGeometryFactory
{
public:
/** Construct geometry from a WKB string.
* Updates position of the passed WKB pointer.
*/
static QgsAbstractGeometry *geomFromWkb( QgsConstWkbPtr &wkb );
/** Construct geometry from a WKT string.
*/
static QgsAbstractGeometry *geomFromWkt( const QString &text );
//! Construct geometry from a point
static QgsAbstractGeometry *fromPoint( const QgsPointXY &point );
//! Construct geometry from a multipoint
static QgsAbstractGeometry *fromMultiPoint( const QgsMultiPoint &multipoint );
//! Construct geometry from a polyline
static QgsAbstractGeometry *fromPolyline( const QgsPolyline &polyline );
//! Construct geometry from a multipolyline
static QgsAbstractGeometry *fromMultiPolyline( const QgsMultiPolyline &multiline );
//! Construct geometry from a polygon
static QgsAbstractGeometry *fromPolygon( const QgsPolygon &polygon );
//! Construct geometry from a multipolygon
static QgsAbstractGeometry *fromMultiPolygon( const QgsMultiPolygon &multipoly );
//! Construct geometry from a rectangle
static QgsAbstractGeometry *fromRect( const QgsRectangle &rect );
//! Return empty geometry from wkb type
static QgsAbstractGeometry *geomFromWkbType( QgsWkbTypes::Type t );
/**
* Returns a new geometry collection matching a specified WKB \a type. For instance, if
* type is PolygonM the returned geometry will be a QgsMultiPolygonV2 with M values.
*/
static std::unique_ptr< QgsGeometryCollection > createCollectionOfType( QgsWkbTypes::Type type );
private:
static QgsLineString *linestringFromPolyline( const QgsPolyline &polyline );
};
#endif // QGSGEOMETRYFACTORY_H