QGIS API Documentation 3.41.0-Master (d5b93354e9c)
Loading...
Searching...
No Matches
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 QMetaType::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
221 static QgsRectangle convertRectangle( const QVariant &value );
222
228 enum class FeatureToJsonFlag : int SIP_ENUM_BASETYPE( IntFlag )
229 {
230 IncludeGeometry = 1 << 0,
231 IncludeNonObjectIdAttributes = 1 << 1,
232 };
234
241 Q_FLAG( FeatureToJsonFlags )
242
243
248 static QVariantMap featureToJson( const QgsFeature &feature,
249 const QgsArcGisRestContext &context,
252
258 static QVariant variantToAttributeValue( const QVariant &variant, QMetaType::Type expectedType, const QgsArcGisRestContext &context );
259
265 static QVariantMap fieldDefinitionToJson( const QgsField &field );
266
272 static Qgis::ArcGisRestServiceType serviceTypeFromString( const QString &type );
273
274 private:
275
279 static std::unique_ptr< QgsPoint > convertPoint( const QVariantList &list, Qgis::WkbType type );
280
286 static std::unique_ptr< QgsCircularString > convertCircularString( const QVariantMap &data, Qgis::WkbType type, const QgsPoint &startPoint );
287
291 static std::unique_ptr< QgsCompoundCurve > convertCompoundCurve( const QVariantList &list, Qgis::WkbType type );
292
296 static std::unique_ptr< QgsPoint > convertGeometryPoint( const QVariantMap &data, Qgis::WkbType pointType );
297
301 static std::unique_ptr< QgsMultiPoint > convertMultiPoint( const QVariantMap &geometryData, Qgis::WkbType pointType );
302
306 static std::unique_ptr< QgsMultiCurve > convertGeometryPolyline( const QVariantMap &data, Qgis::WkbType pointType );
307
311 static std::unique_ptr< QgsMultiSurface > convertGeometryPolygon( const QVariantMap &data, Qgis::WkbType pointType );
312
316 static std::unique_ptr< QgsPolygon > convertEnvelope( const QVariantMap &data );
317
318 static std::unique_ptr< QgsLineSymbol > parseEsriLineSymbolJson( const QVariantMap &symbolData );
319 static std::unique_ptr< QgsFillSymbol > parseEsriFillSymbolJson( const QVariantMap &symbolData );
320 static std::unique_ptr< QgsFillSymbol > parseEsriPictureFillSymbolJson( const QVariantMap &symbolData );
321 static std::unique_ptr< QgsMarkerSymbol > parseEsriMarkerSymbolJson( const QVariantMap &symbolData );
322 static std::unique_ptr< QgsMarkerSymbol > parseEsriPictureMarkerSymbolJson( const QVariantMap &symbolData );
323 static std::unique_ptr< QgsMarkerSymbol > parseEsriTextMarkerSymbolJson( const QVariantMap &symbolData );
324
325 static Qgis::MarkerShape parseEsriMarkerShape( const QString &style );
326
327 static QVariantMap pointToJson( const QgsPoint *point );
328 static QVariantMap multiPointToJson( const QgsMultiPoint *multiPoint );
329 static QVariantList lineStringToJsonPath( const QgsLineString *line );
330 static QVariantList curveToJsonCurve( const QgsCurve *curve, bool includeStart );
331 static QVariantMap lineStringToJson( const QgsLineString *line );
332 static QVariantMap curveToJson( const QgsCurve *curve );
333 static QVariantMap multiLineStringToJson( const QgsMultiLineString *multiLine );
334 static QVariantMap multiCurveToJson( const QgsMultiCurve *multiCurve );
335 static QVariantList polygonToJsonRings( const QgsPolygon *polygon );
336 static QVariantList curvePolygonToJsonRings( const QgsCurvePolygon *polygon );
337 static QVariantMap polygonToJson( const QgsPolygon *polygon );
338 static QVariantMap curvePolygonToJson( const QgsCurvePolygon *polygon );
339 static QVariantMap multiPolygonToJson( const QgsMultiPolygon *polygon );
340 static QVariantMap multiSurfaceToJson( const QgsMultiSurface *multiSurface );
341
342 friend class TestQgsArcGisRestUtils;
343};
344
346
347#endif // QGSARCGISRESTUTILS_H
ArcGisRestServiceType
Available ArcGIS REST service types.
Definition qgis.h:4120
MarkerShape
Marker shapes.
Definition qgis.h:2902
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:256
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.
QFlags< FeatureToJsonFlag > FeatureToJsonFlags
Flags which control the behavior of converting features to JSON.
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:35
Abstract base class for all 2D vector feature renderers.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
Encapsulate a field in an attribute table or data source.
Definition qgsfield.h:53
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
A geometry is the spatial representation of a feature.
Line string geometry type, with support for z-dimension and m-values.
A line symbol type, for rendering LineString and MultiLineString geometries.
A marker symbol type, for rendering Point and MultiPoint geometries.
Multi curve geometry collection.
Multi line string geometry collection.
Multi point geometry collection.
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:33
A rectangle specified with double values.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:231
#define SIP_ENUM_BASETYPE(type)
Definition qgis_sip.h:278
#define SIP_OUT
Definition qgis_sip.h:58
#define SIP_FACTORY
Definition qgis_sip.h:76
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsTextRendererUtils::CurvedTextFlags)
const QgsCoordinateReferenceSystem & crs