QGIS API Documentation 3.29.0-Master (ade4f0cf0f)
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"
19#include "qgsrectangle.h"
22
23#include "qgis_sip.h"
24
25#include <QStringList>
26#include <QVariant>
27#include <QTimeZone>
28
29#include <functional>
30#include <memory>
31
32class QNetworkReply;
34class QgsFields;
38class QgsFeedback;
39class QgsSymbol;
40class QgsLineSymbol;
41class QgsFillSymbol;
42class QgsMarkerSymbol;
44class QgsPoint;
48class QgsMultiPoint;
49class QgsMultiSurface;
51class QgsPolygon;
52class QgsMultiCurve;
53class QgsMultiPolygon;
54class QgsCurvePolygon;
55
64class CORE_EXPORT QgsArcGisRestContext
65{
66 public:
67
73 void setTimeZone( const QTimeZone &zone ) { mTimeZone = zone; }
74
80 QTimeZone timeZone() const { return mTimeZone; }
81
87 void setObjectIdFieldName( const QString &name ) { mObjectIdFieldName = name; }
88
94 QString objectIdFieldName() const { return mObjectIdFieldName; }
95
96 private:
97
98 QTimeZone mTimeZone;
99
100 QString mObjectIdFieldName;
101
102};
103
112class CORE_EXPORT QgsArcGisRestUtils
113{
114 Q_GADGET
115
116 public:
117
121 static QVariant::Type convertFieldType( const QString &type );
122
126 static QgsWkbTypes::Type convertGeometryType( const QString &type );
127
141 static QgsAbstractGeometry *convertGeometry( const QVariantMap &geometry, const QString &esriGeometryType, bool hasM, bool hasZ, QgsCoordinateReferenceSystem *crs SIP_OUT = nullptr ) SIP_FACTORY;
142
146 static QgsCoordinateReferenceSystem convertSpatialReference( const QVariantMap &spatialReferenceMap );
147
153 static QgsSymbol *convertSymbol( const QVariantMap &definition ) SIP_FACTORY;
154
160 static QgsFeatureRenderer *convertRenderer( const QVariantMap &rendererData ) SIP_FACTORY;
161
167 static QgsAbstractVectorLayerLabeling *convertLabeling( const QVariantList &data ) SIP_FACTORY;
168
172 static QString convertLabelingExpression( const QString &string );
173
177 static QColor convertColor( const QVariant &data );
178
182 static Qt::PenStyle convertLineStyle( const QString &style );
183
187 static Qt::BrushStyle convertFillStyle( const QString &style );
188
192 static QDateTime convertDateTime( const QVariant &value );
193
201 static QVariantMap geometryToJson( const QgsGeometry &geometry, const QgsArcGisRestContext &context, const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() );
202
210 static QVariantMap crsToJson( const QgsCoordinateReferenceSystem &crs );
211
217 enum class FeatureToJsonFlag : int
218 {
219 IncludeGeometry = 1 << 0,
220 IncludeNonObjectIdAttributes = 1 << 1,
221 };
223
229 Q_DECLARE_FLAGS( FeatureToJsonFlags, FeatureToJsonFlag )
230 Q_FLAG( FeatureToJsonFlags )
231
232
237 static QVariantMap featureToJson( const QgsFeature &feature,
238 const QgsArcGisRestContext &context,
240 QgsArcGisRestUtils::FeatureToJsonFlags flags = QgsArcGisRestUtils::FeatureToJsonFlags( static_cast< int >( QgsArcGisRestUtils::FeatureToJsonFlag::IncludeGeometry ) | static_cast< int >( QgsArcGisRestUtils::FeatureToJsonFlag::IncludeNonObjectIdAttributes ) ) );
241
247 static QVariant variantToAttributeValue( const QVariant &variant, QVariant::Type expectedType, const QgsArcGisRestContext &context );
248
254 static QVariantMap fieldDefinitionToJson( const QgsField &field );
255
261 static Qgis::ArcGisRestServiceType serviceTypeFromString( const QString &type );
262
263 private:
264
268 static std::unique_ptr< QgsPoint > convertPoint( const QVariantList &list, QgsWkbTypes::Type type );
269
275 static std::unique_ptr< QgsCircularString > convertCircularString( const QVariantMap &data, QgsWkbTypes::Type type, const QgsPoint &startPoint );
276
280 static std::unique_ptr< QgsCompoundCurve > convertCompoundCurve( const QVariantList &list, QgsWkbTypes::Type type );
281
285 static std::unique_ptr< QgsPoint > convertGeometryPoint( const QVariantMap &data, QgsWkbTypes::Type pointType );
286
290 static std::unique_ptr< QgsMultiPoint > convertMultiPoint( const QVariantMap &geometryData, QgsWkbTypes::Type pointType );
291
295 static std::unique_ptr< QgsMultiCurve > convertGeometryPolyline( const QVariantMap &data, QgsWkbTypes::Type pointType );
296
300 static std::unique_ptr< QgsMultiSurface > convertGeometryPolygon( const QVariantMap &data, QgsWkbTypes::Type pointType );
301
305 static std::unique_ptr< QgsPolygon > convertEnvelope( const QVariantMap &data );
306
307 static std::unique_ptr< QgsLineSymbol > parseEsriLineSymbolJson( const QVariantMap &symbolData );
308 static std::unique_ptr< QgsFillSymbol > parseEsriFillSymbolJson( const QVariantMap &symbolData );
309 static std::unique_ptr< QgsFillSymbol > parseEsriPictureFillSymbolJson( const QVariantMap &symbolData );
310 static std::unique_ptr< QgsMarkerSymbol > parseEsriMarkerSymbolJson( const QVariantMap &symbolData );
311 static std::unique_ptr< QgsMarkerSymbol > parseEsriPictureMarkerSymbolJson( const QVariantMap &symbolData );
312
313 static Qgis::MarkerShape parseEsriMarkerShape( const QString &style );
314
315 static QVariantMap pointToJson( const QgsPoint *point );
316 static QVariantMap multiPointToJson( const QgsMultiPoint *multiPoint );
317 static QVariantList lineStringToJsonPath( const QgsLineString *line );
318 static QVariantList curveToJsonCurve( const QgsCurve *curve, bool includeStart );
319 static QVariantMap lineStringToJson( const QgsLineString *line );
320 static QVariantMap curveToJson( const QgsCurve *curve );
321 static QVariantMap multiLineStringToJson( const QgsMultiLineString *multiLine );
322 static QVariantMap multiCurveToJson( const QgsMultiCurve *multiCurve );
323 static QVariantList polygonToJsonRings( const QgsPolygon *polygon );
324 static QVariantList curvePolygonToJsonRings( const QgsCurvePolygon *polygon );
325 static QVariantMap polygonToJson( const QgsPolygon *polygon );
326 static QVariantMap curvePolygonToJson( const QgsCurvePolygon *polygon );
327 static QVariantMap multiPolygonToJson( const QgsMultiPolygon *polygon );
328 static QVariantMap multiSurfaceToJson( const QgsMultiSurface *multiSurface );
329
330 friend class TestQgsArcGisRestUtils;
331};
332
333Q_DECLARE_OPERATORS_FOR_FLAGS( QgsArcGisRestUtils::FeatureToJsonFlags )
334
335#endif // QGSARCGISRESTUTILS_H
ArcGisRestServiceType
Available ArcGIS REST service types.
Definition: qgis.h:2402
MarkerShape
Marker shapes.
Definition: qgis.h:1739
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:51
Container of fields for a vector layer.
Definition: qgsfields.h:45
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
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:70
#define SIP_OUT
Definition: qgis_sip.h:58
#define SIP_FACTORY
Definition: qgis_sip.h:76
const QgsField & field
Definition: qgsfield.h:463
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