51 wkbPtr -= 1 +
sizeof( int );
59 geom->fromWkb( wkbPtr );
74 QString trimmed = text.trimmed();
75 std::unique_ptr< QgsAbstractGeometry> geom;
76 if ( trimmed.startsWith( QLatin1String(
"Point" ), Qt::CaseInsensitive ) )
78 geom = qgis::make_unique< QgsPoint >();
80 else if ( trimmed.startsWith( QLatin1String(
"LineString" ), Qt::CaseInsensitive ) )
82 geom = qgis::make_unique< QgsLineString >();
84 else if ( trimmed.startsWith( QLatin1String(
"CircularString" ), Qt::CaseInsensitive ) )
86 geom = qgis::make_unique< QgsCircularString >();
88 else if ( trimmed.startsWith( QLatin1String(
"CompoundCurve" ), Qt::CaseInsensitive ) )
90 geom = qgis::make_unique< QgsCompoundCurve>();
92 else if ( trimmed.startsWith( QLatin1String(
"Polygon" ), Qt::CaseInsensitive ) )
94 geom = qgis::make_unique< QgsPolygon >();
96 else if ( trimmed.startsWith( QLatin1String(
"CurvePolygon" ), Qt::CaseInsensitive ) )
98 geom = qgis::make_unique< QgsCurvePolygon >();
100 else if ( trimmed.startsWith( QLatin1String(
"MultiPoint" ), Qt::CaseInsensitive ) )
102 geom = qgis::make_unique< QgsMultiPoint >();
104 else if ( trimmed.startsWith( QLatin1String(
"MultiCurve" ), Qt::CaseInsensitive ) )
106 geom = qgis::make_unique< QgsMultiCurve >();
108 else if ( trimmed.startsWith( QLatin1String(
"MultiLineString" ), Qt::CaseInsensitive ) )
110 geom = qgis::make_unique< QgsMultiLineString >();
112 else if ( trimmed.startsWith( QLatin1String(
"MultiSurface" ), Qt::CaseInsensitive ) )
114 geom = qgis::make_unique< QgsMultiSurface >();
116 else if ( trimmed.startsWith( QLatin1String(
"MultiPolygon" ), Qt::CaseInsensitive ) )
118 geom = qgis::make_unique< QgsMultiPolygon >();
120 else if ( trimmed.startsWith( QLatin1String(
"GeometryCollection" ), Qt::CaseInsensitive ) )
122 geom = qgis::make_unique< QgsGeometryCollection >();
127 if ( !geom->fromWkt( text ) )
137 return qgis::make_unique< QgsPoint >( point.
x(), point.
y() );
142 std::unique_ptr< QgsMultiPoint > mp = qgis::make_unique< QgsMultiPoint >();
143 QgsMultiPointXY::const_iterator ptIt = multipoint.constBegin();
144 for ( ; ptIt != multipoint.constEnd(); ++ptIt )
147 mp->addGeometry( pt );
154 return linestringFromPolyline( polyline );
159 std::unique_ptr< QgsMultiLineString > mLine = qgis::make_unique< QgsMultiLineString >();
160 for (
int i = 0; i < multiline.size(); ++i )
162 mLine->addGeometry(
fromPolylineXY( multiline.at( i ) ).release() );
169 std::unique_ptr< QgsPolygon > poly = qgis::make_unique< QgsPolygon >();
171 QVector<QgsCurve *> holes;
172 holes.reserve( polygon.size() );
173 for (
int i = 0; i < polygon.size(); ++i )
175 std::unique_ptr< QgsLineString > l = linestringFromPolyline( polygon.at( i ) );
180 poly->setExteriorRing( l.release() );
184 holes.push_back( l.release() );
187 poly->setInteriorRings( holes );
193 std::unique_ptr< QgsMultiPolygon > mp = qgis::make_unique< QgsMultiPolygon >();
194 for (
int i = 0; i < multipoly.size(); ++i )
196 mp->addGeometry(
fromPolygonXY( multipoly.at( i ) ).release() );
201 std::unique_ptr<QgsLineString> QgsGeometryFactory::linestringFromPolyline(
const QgsPolylineXY &polyline )
204 x.reserve( polyline.size() );
206 y.reserve( polyline.size() );
207 QgsPolylineXY::const_iterator it = polyline.constBegin();
208 for ( ; it != polyline.constEnd(); ++it )
213 std::unique_ptr< QgsLineString > line = qgis::make_unique< QgsLineString >( x, y );
223 return qgis::make_unique< QgsPoint >();
225 return qgis::make_unique< QgsLineString >();
227 return qgis::make_unique< QgsCircularString >();
229 return qgis::make_unique< QgsCompoundCurve >();
231 return qgis::make_unique< QgsPolygon >();
233 return qgis::make_unique< QgsCurvePolygon >();
235 return qgis::make_unique< QgsMultiLineString >();
237 return qgis::make_unique< QgsMultiPolygon >();
239 return qgis::make_unique< QgsMultiPoint >();
241 return qgis::make_unique< QgsMultiCurve >();
243 return qgis::make_unique< QgsMultiSurface >();
245 return qgis::make_unique< QgsGeometryCollection >();
247 return qgis::make_unique< QgsTriangle >();
256 std::unique_ptr< QgsGeometryCollection > collect;
260 collect = qgis::make_unique< QgsMultiPoint >();
263 collect = qgis::make_unique< QgsMultiLineString >();
266 collect = qgis::make_unique< QgsMultiCurve >();
269 collect = qgis::make_unique< QgsMultiPolygon >();
272 collect = qgis::make_unique< QgsMultiSurface >();
275 collect = qgis::make_unique< QgsGeometryCollection >();
282 collect->addMValue();
284 collect->addZValue();
static std::unique_ptr< QgsAbstractGeometry > geomFromWkb(QgsConstWkbPtr &wkb)
Construct geometry from a WKB string.
static std::unique_ptr< QgsAbstractGeometry > geomFromWkbType(QgsWkbTypes::Type t)
Returns empty geometry from wkb type.
static Type multiType(Type type)
Returns the multi type for a WKB type.
static std::unique_ptr< QgsAbstractGeometry > fromPointXY(const QgsPointXY &point)
Construct geometry from a point.
static std::unique_ptr< QgsAbstractGeometry > fromPolylineXY(const QgsPolylineXY &polyline)
Construct geometry from a polyline.
A class to represent a 2D point.
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item...
static std::unique_ptr< QgsGeometryCollection > createCollectionOfType(QgsWkbTypes::Type type)
Returns a new geometry collection matching a specified WKB type.
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.
static std::unique_ptr< QgsPolygon > fromPolygonXY(const QgsPolygonXY &polygon)
Construct geometry from a polygon.
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
QVector< QgsPolygonXY > QgsMultiPolygonXY
A collection of QgsPolygons that share a common collection of attributes.
static std::unique_ptr< QgsMultiPoint > fromMultiPointXY(const QgsMultiPointXY &multipoint)
Construct geometry from a multipoint.
QVector< QgsPolylineXY > QgsMultiPolylineXY
A collection of QgsPolylines that share a common collection of attributes.
Type
The WKB type describes the number of dimensions a geometry has.
static std::unique_ptr< QgsMultiLineString > fromMultiPolylineXY(const QgsMultiPolylineXY &multiline)
Construct geometry from a multipolyline.
QgsWkbTypes::Type readHeader() const
readHeader
Point geometry type, with support for z-dimension and m-values.
Custom exception class for Wkb related exceptions.
QVector< QgsPointXY > QgsPolylineXY
Polyline as represented as a vector of two-dimensional points.
static std::unique_ptr< QgsAbstractGeometry > geomFromWkt(const QString &text)
Construct geometry from a WKT string.
static bool hasM(Type type)
Tests whether a WKB type contains m values.
static Type flatType(Type type)
Returns the flat type for a WKB type.
static std::unique_ptr< QgsMultiPolygon > fromMultiPolygonXY(const QgsMultiPolygonXY &multipoly)
Construct geometry from a multipolygon.