QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
qgsarcgisrestutils.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsarcgisrestutils.h
3 --------------------
4 begin : Nov 25, 2015
5 copyright : (C) 2015 by Sandro Mani
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15#ifndef QGSARCGISRESTUTILS_H
16#define QGSARCGISRESTUTILS_H
17
18#include "qgswkbtypes.h"
20
21#include "qgis_sip.h"
22
23#include <QStringList>
24#include <QVariant>
25#include <QTimeZone>
26
27#include <functional>
28#include <memory>
29
30class QNetworkReply;
32class QgsField;
33class QgsGeometry;
37class QgsFeedback;
38class QgsSymbol;
39class QgsLineSymbol;
40class QgsFillSymbol;
41class QgsMarkerSymbol;
43class QgsPoint;
47class QgsMultiPoint;
48class QgsMultiSurface;
50class QgsPolygon;
51class QgsMultiCurve;
52class QgsMultiPolygon;
53class QgsCurvePolygon;
54class QgsFeature;
55class QgsLineString;
56class QgsCurve;
57
66class CORE_EXPORT QgsArcGisRestContext
67{
68 public:
69
75 void setTimeZone( const QTimeZone &zone ) { mTimeZone = zone; }
76
82 QTimeZone timeZone() const { return mTimeZone; }
83
89 void setObjectIdFieldName( const QString &name ) { mObjectIdFieldName = name; }
90
96 QString objectIdFieldName() const { return mObjectIdFieldName; }
97
98 private:
99
100 QTimeZone mTimeZone;
101
102 QString mObjectIdFieldName;
103
104};
105
114class CORE_EXPORT QgsArcGisRestUtils
115{
116 Q_GADGET
117
118 public:
119
123 static QVariant::Type convertFieldType( const QString &type );
124
128 static Qgis::WkbType convertGeometryType( const QString &type );
129
143 static QgsAbstractGeometry *convertGeometry( const QVariantMap &geometry, const QString &esriGeometryType, bool hasM, bool hasZ, QgsCoordinateReferenceSystem *crs SIP_OUT = nullptr ) SIP_FACTORY;
144
148 static QgsCoordinateReferenceSystem convertSpatialReference( const QVariantMap &spatialReferenceMap );
149
155 static QgsSymbol *convertSymbol( const QVariantMap &definition ) SIP_FACTORY;
156
162 static QgsFeatureRenderer *convertRenderer( const QVariantMap &rendererData ) SIP_FACTORY;
163
169 static QgsAbstractVectorLayerLabeling *convertLabeling( const QVariantList &data ) SIP_FACTORY;
170
174 static QString convertLabelingExpression( const QString &string );
175
179 static QColor convertColor( const QVariant &data );
180
184 static Qt::PenStyle convertLineStyle( const QString &style );
185
189 static Qt::BrushStyle convertFillStyle( const QString &style );
190
194 static QDateTime convertDateTime( const QVariant &value );
195
203 static QVariantMap geometryToJson( const QgsGeometry &geometry, const QgsArcGisRestContext &context, const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() );
204
212 static QVariantMap crsToJson( const QgsCoordinateReferenceSystem &crs );
213
219 enum class FeatureToJsonFlag : int
220 {
221 IncludeGeometry = 1 << 0,
222 IncludeNonObjectIdAttributes = 1 << 1,
223 };
225
231 Q_DECLARE_FLAGS( FeatureToJsonFlags, FeatureToJsonFlag )
232 Q_FLAG( FeatureToJsonFlags )
233
234
239 static QVariantMap featureToJson( const QgsFeature &feature,
240 const QgsArcGisRestContext &context,
242 QgsArcGisRestUtils::FeatureToJsonFlags flags = QgsArcGisRestUtils::FeatureToJsonFlags( static_cast< int >( QgsArcGisRestUtils::FeatureToJsonFlag::IncludeGeometry ) | static_cast< int >( QgsArcGisRestUtils::FeatureToJsonFlag::IncludeNonObjectIdAttributes ) ) );
243
249 static QVariant variantToAttributeValue( const QVariant &variant, QVariant::Type expectedType, const QgsArcGisRestContext &context );
250
256 static QVariantMap fieldDefinitionToJson( const QgsField &field );
257
263 static Qgis::ArcGisRestServiceType serviceTypeFromString( const QString &type );
264
265 private:
266
270 static std::unique_ptr< QgsPoint > convertPoint( const QVariantList &list, Qgis::WkbType type );
271
277 static std::unique_ptr< QgsCircularString > convertCircularString( const QVariantMap &data, Qgis::WkbType type, const QgsPoint &startPoint );
278
282 static std::unique_ptr< QgsCompoundCurve > convertCompoundCurve( const QVariantList &list, Qgis::WkbType type );
283
287 static std::unique_ptr< QgsPoint > convertGeometryPoint( const QVariantMap &data, Qgis::WkbType pointType );
288
292 static std::unique_ptr< QgsMultiPoint > convertMultiPoint( const QVariantMap &geometryData, Qgis::WkbType pointType );
293
297 static std::unique_ptr< QgsMultiCurve > convertGeometryPolyline( const QVariantMap &data, Qgis::WkbType pointType );
298
302 static std::unique_ptr< QgsMultiSurface > convertGeometryPolygon( const QVariantMap &data, Qgis::WkbType pointType );
303
307 static std::unique_ptr< QgsPolygon > convertEnvelope( const QVariantMap &data );
308
309 static std::unique_ptr< QgsLineSymbol > parseEsriLineSymbolJson( const QVariantMap &symbolData );
310 static std::unique_ptr< QgsFillSymbol > parseEsriFillSymbolJson( const QVariantMap &symbolData );
311 static std::unique_ptr< QgsFillSymbol > parseEsriPictureFillSymbolJson( const QVariantMap &symbolData );
312 static std::unique_ptr< QgsMarkerSymbol > parseEsriMarkerSymbolJson( const QVariantMap &symbolData );
313 static std::unique_ptr< QgsMarkerSymbol > parseEsriPictureMarkerSymbolJson( const QVariantMap &symbolData );
314
315 static Qgis::MarkerShape parseEsriMarkerShape( const QString &style );
316
317 static QVariantMap pointToJson( const QgsPoint *point );
318 static QVariantMap multiPointToJson( const QgsMultiPoint *multiPoint );
319 static QVariantList lineStringToJsonPath( const QgsLineString *line );
320 static QVariantList curveToJsonCurve( const QgsCurve *curve, bool includeStart );
321 static QVariantMap lineStringToJson( const QgsLineString *line );
322 static QVariantMap curveToJson( const QgsCurve *curve );
323 static QVariantMap multiLineStringToJson( const QgsMultiLineString *multiLine );
324 static QVariantMap multiCurveToJson( const QgsMultiCurve *multiCurve );
325 static QVariantList polygonToJsonRings( const QgsPolygon *polygon );
326 static QVariantList curvePolygonToJsonRings( const QgsCurvePolygon *polygon );
327 static QVariantMap polygonToJson( const QgsPolygon *polygon );
328 static QVariantMap curvePolygonToJson( const QgsCurvePolygon *polygon );
329 static QVariantMap multiPolygonToJson( const QgsMultiPolygon *polygon );
330 static QVariantMap multiSurfaceToJson( const QgsMultiSurface *multiSurface );
331
332 friend class TestQgsArcGisRestUtils;
333};
334
335Q_DECLARE_OPERATORS_FOR_FLAGS( QgsArcGisRestUtils::FeatureToJsonFlags )
336
337#endif // QGSARCGISRESTUTILS_H
ArcGisRestServiceType
Available ArcGIS REST service types.
Definition: qgis.h:2609
MarkerShape
Marker shapes.
Definition: qgis.h:1909
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition: qgis.h:155
Abstract base class for all geometries.
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
Contains the context of a ArcGIS REST service operation.
void setTimeZone(const QTimeZone &zone)
Sets the time zone for datetime values.
QTimeZone timeZone() const
Returns the time zone for datetime values.
QString objectIdFieldName() const
Returns the name of the objectId field.
void setObjectIdFieldName(const QString &name)
Sets the name of the objectId field.
Utility functions for working with ArcGIS REST services.
Q_ENUM(FeatureToJsonFlag)
FeatureToJsonFlag
Flags which control the behavior of converting features to JSON.
@ IncludeGeometry
Whether to include the geometry definition.
@ IncludeNonObjectIdAttributes
Whether to include any non-objectId attributes.
Circular string geometry type.
Compound curve geometry type.
This class represents a coordinate reference system (CRS).
Curve polygon geometry type.
Abstract base class for curved geometry type.
Definition: qgscurve.h:36
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:52
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgsfillsymbol.h:30
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:164
Line string geometry type, with support for z-dimension and m-values.
Definition: qgslinestring.h:45
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:30
A marker symbol type, for rendering Point and MultiPoint geometries.
Multi curve geometry collection.
Definition: qgsmulticurve.h:30
Multi line string geometry collection.
Multi point geometry collection.
Definition: qgsmultipoint.h:30
Multi polygon geometry collection.
Multi surface geometry collection.
network access manager for QGIS
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:49
Polygon geometry type.
Definition: qgspolygon.h:34
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:93
#define SIP_OUT
Definition: qgis_sip.h:58
#define SIP_FACTORY
Definition: qgis_sip.h:76
const QgsField & field
Definition: qgsfield.h:501
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
const QgsCoordinateReferenceSystem & crs