-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
qgsserverprojectutils.h
471 lines (407 loc) · 16.8 KB
/
qgsserverprojectutils.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
/***************************************************************************
qgsserverprojectutils.h
-----------------------
begin : December 19, 2016
copyright : (C) 2016 by Paul Blottiere
email : paul dot blottiere at oslandia dot com
***************************************************************************/
/***************************************************************************
* *
* 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 QGSSERVERPROJECTUTILS_H
#define QGSSERVERPROJECTUTILS_H
#include <QString>
#include <QHash>
#include <cmath>
#include "qgis_server.h"
#include "qgis_sip.h"
#include "qgsserverrequest.h"
#include "qgsserversettings.h"
class QgsProject;
class QgsRectangle;
#ifdef SIP_RUN
% ModuleHeaderCode
#include "qgsserverprojectutils.h"
% End
#endif
/**
* \ingroup server
* \brief The QgsServerProjectUtils namespace provides a way to retrieve specific
* entries from a QgsProject.
* \since QGIS 3.0
*/
namespace QgsServerProjectUtils
{
/**
* Returns a double greater than \a number to the specified number of \a places.
*
* \since QGIS 3.10.1
*/
SERVER_EXPORT double ceilWithPrecision( double number, int places ) SIP_SKIP;
/**
* Returns a double less than \a number to the specified number of \a places.
*
* \since QGIS 3.10.1
*/
SERVER_EXPORT double floorWithPrecision( double number, int places ) SIP_SKIP;
/**
* Returns if owsService capabilities are enabled.
* \param project the QGIS project
* \returns if owsService capabilities are enabled.
*/
SERVER_EXPORT bool owsServiceCapabilities( const QgsProject &project );
/**
* Returns the owsService title defined in project.
* \param project the QGIS project
* \returns the owsService title if defined in project with project title as fallback, "Untitled" otherwise.
*/
SERVER_EXPORT QString owsServiceTitle( const QgsProject &project );
/**
* Returns the owsService abstract defined in project.
* \param project the QGIS project
* \returns the owsService abstract if defined in project.
*/
SERVER_EXPORT QString owsServiceAbstract( const QgsProject &project );
/**
* Returns the owsService keywords defined in project.
* \param project the QGIS project
* \returns the owsService keywords if defined in project.
*/
SERVER_EXPORT QStringList owsServiceKeywords( const QgsProject &project );
/**
* Returns the owsService online resource defined in project.
* \param project the QGIS project
* \returns the owsService online resource if defined in project.
*/
SERVER_EXPORT QString owsServiceOnlineResource( const QgsProject &project );
/**
* Returns the owsService contact organization defined in project.
* \param project the QGIS project
* \returns the owsService contact organization if defined in project.
*/
SERVER_EXPORT QString owsServiceContactOrganization( const QgsProject &project );
/**
* Returns the owsService contact position defined in project.
* \param project the QGIS project
* \returns the owsService contact position if defined in project.
*/
SERVER_EXPORT QString owsServiceContactPosition( const QgsProject &project );
/**
* Returns the owsService contact person defined in project.
* \param project the QGIS project
* \returns the owsService contact person if defined in project.
*/
SERVER_EXPORT QString owsServiceContactPerson( const QgsProject &project );
/**
* Returns the owsService contact mail defined in project.
* \param project the QGIS project
* \returns the owsService contact mail if defined in project.
*/
SERVER_EXPORT QString owsServiceContactMail( const QgsProject &project );
/**
* Returns the owsService contact phone defined in project.
* \param project the QGIS project
* \returns the owsService contact phone if defined in project.
*/
SERVER_EXPORT QString owsServiceContactPhone( const QgsProject &project );
/**
* Returns the owsService fees defined in project.
* \param project the QGIS project
* \returns the owsService fees if defined in project.
*/
SERVER_EXPORT QString owsServiceFees( const QgsProject &project );
/**
* Returns the owsService access constraints defined in project.
* \param project the QGIS project
* \returns the owsService access constraints if defined in project.
*/
SERVER_EXPORT QString owsServiceAccessConstraints( const QgsProject &project );
/**
* Returns the maximum width for WMS images defined in a QGIS project.
* \param project the QGIS project
* \returns width if defined in project, -1 otherwise.
*/
SERVER_EXPORT int wmsMaxWidth( const QgsProject &project );
/**
* Returns the maximum height for WMS images defined in a QGIS project.
* \param project the QGIS project
* \returns height if defined in project, -1 otherwise.
*/
SERVER_EXPORT int wmsMaxHeight( const QgsProject &project );
/**
* Returns the quality for WMS images defined in a QGIS project.
* \param project the QGIS project
* \returns quality if defined in project, -1 otherwise.
*/
SERVER_EXPORT int wmsImageQuality( const QgsProject &project );
/**
* Returns the tile buffer in pixels for WMS images defined in a QGIS project.
* \param project the QGIS project
* \returns tile buffer if defined in project, 0 otherwise.
* \since QGIS 3.10
*/
SERVER_EXPORT int wmsTileBuffer( const QgsProject &project );
/**
* Returns TRUE if WMS requests should use the QgsMapSettings::RenderMapTile flag,
* so that no visible artifacts are visible between adjacent tiles.
*
* This flag can slow down rendering considerably, so it is only used if the corresponding
* setting is enabled in the project.
*
* \param project the QGIS project
* \returns TRUE if the flag should be used, or FALSE if not.
*
* \since QGIS 3.18
*/
SERVER_EXPORT bool wmsRenderMapTiles( const QgsProject &project );
/**
* Returns the maximum number of atlas features which can be printed in a request
* \param project the QGIS project
* \return the number of atlas features
*/
SERVER_EXPORT int wmsMaxAtlasFeatures( const QgsProject &project );
/**
* Returns the default number of map units per millimeters in case of the scale is not given
* \param project the QGIS project
* \returns the default number of map units per millimeter
* \since QGIS 3.4
*/
SERVER_EXPORT double wmsDefaultMapUnitsPerMm( const QgsProject &project );
/**
* Returns if layer ids are used as name in WMS.
* \param project the QGIS project
* \returns if layer ids are used as name.
*/
SERVER_EXPORT bool wmsUseLayerIds( const QgsProject &project );
/**
* Returns if the info format is SIA20145.
* \param project the QGIS project
* \returns if the info format is SIA20145.
*/
SERVER_EXPORT bool wmsInfoFormatSia2045( const QgsProject &project );
/**
* Returns if the geometry is displayed as Well Known Text in GetFeatureInfo request.
* \param project the QGIS project
* \returns if the geometry is displayed as Well Known Text in GetFeatureInfo request.
*/
SERVER_EXPORT bool wmsFeatureInfoAddWktGeometry( const QgsProject &project );
/**
* Returns if feature form settings should be considered for the format of the feature info response
* \param project the QGIS project
* \returns true if the feature form settings shall be considered for the feature info response
*/
SERVER_EXPORT bool wmsFeatureInfoUseAttributeFormSettings( const QgsProject &project );
/**
* Returns if the geometry has to be segmentize in GetFeatureInfo request.
* \param project the QGIS project
* \returns if the geometry has to be segmentize in GetFeatureInfo request.
*/
SERVER_EXPORT bool wmsFeatureInfoSegmentizeWktGeometry( const QgsProject &project );
/**
* Returns if legend groups should be in the legend graphic response if GetLegendGraphic is called on a layer group.
* \param project the QGIS project
* \returns if the GetLegendGraphic response has to contain legend groups
*/
SERVER_EXPORT bool wmsAddLegendGroupsLegendGraphic( const QgsProject &project );
/**
* Returns the geometry precision for GetFeatureInfo request.
* \param project the QGIS project
* \returns the geometry precision for GetFeatureInfo request.
*/
SERVER_EXPORT int wmsFeatureInfoPrecision( const QgsProject &project );
/**
* Returns the document element name for XML GetFeatureInfo request.
* \param project the QGIS project
* \returns the document element name for XML GetFeatureInfo request.
*/
SERVER_EXPORT QString wmsFeatureInfoDocumentElement( const QgsProject &project );
/**
* Returns the document element namespace for XML GetFeatureInfo request.
* \param project the QGIS project
* \returns the document element namespace for XML GetFeatureInfo request.
*/
SERVER_EXPORT QString wmsFeatureInfoDocumentElementNs( const QgsProject &project );
/**
* Returns the schema URL for XML GetFeatureInfo request.
* \param project the QGIS project
* \returns the schema URL for XML GetFeatureInfo request.
*/
SERVER_EXPORT QString wmsFeatureInfoSchema( const QgsProject &project );
/**
* Returns the mapping between layer name and wms layer name for GetFeatureInfo request.
* \param project the QGIS project
* \returns the mapping between layer name and wms layer name for GetFeatureInfo request.
*/
SERVER_EXPORT QHash<QString, QString> wmsFeatureInfoLayerAliasMap( const QgsProject &project );
/**
* Returns if Inspire is activated.
* \param project the QGIS project
* \returns if Inspire is activated.
*/
SERVER_EXPORT bool wmsInspireActivate( const QgsProject &project );
/**
* Returns the Inspire language.
* \param project the QGIS project
* \returns the Inspire language if defined in project.
*/
SERVER_EXPORT QString wmsInspireLanguage( const QgsProject &project );
/**
* Returns the Inspire metadata URL.
* \param project the QGIS project
* \returns the Inspire metadata URL if defined in project.
*/
SERVER_EXPORT QString wmsInspireMetadataUrl( const QgsProject &project );
/**
* Returns the Inspire metadata URL type.
* \param project the QGIS project
* \returns the Inspire metadata URL type if defined in project.
*/
SERVER_EXPORT QString wmsInspireMetadataUrlType( const QgsProject &project );
/**
* Returns the Inspire temporal reference.
* \param project the QGIS project
* \returns the Inspire temporal reference if defined in project.
*/
SERVER_EXPORT QString wmsInspireTemporalReference( const QgsProject &project );
/**
* Returns the Inspire metadata date.
* \param project the QGIS project
* \returns the Inspire metadata date if defined in project.
*/
SERVER_EXPORT QString wmsInspireMetadataDate( const QgsProject &project );
/**
* Returns the restricted composer list.
* \param project the QGIS project
* \returns the restricted composer list if defined in project.
*/
SERVER_EXPORT QStringList wmsRestrictedComposers( const QgsProject &project );
/**
* Returns the WMS service url.
* The URL defined in the project or if not defined the URL from serviceUrl.
*
* \param project the QGIS project
* \param request the request
* \param settings the server settings
* \returns url to use for this service
*/
SERVER_EXPORT QString wmsServiceUrl( const QgsProject &project, const QgsServerRequest &request = QgsServerRequest(), const QgsServerSettings &settings = QgsServerSettings() );
/**
* Returns the WMS root layer name defined in a QGIS project.
* \param project the QGIS project
* \returns root layer name to use for this service
*/
SERVER_EXPORT QString wmsRootName( const QgsProject &project );
/**
* Returns the restricted layer name list.
* \param project the QGIS project
* \returns the restricted layer name list if defined in project.
*/
SERVER_EXPORT QStringList wmsRestrictedLayers( const QgsProject &project );
/**
* Returns the WMS output CRS list.
* \param project the QGIS project
* \returns the WMS output CRS list.
*/
SERVER_EXPORT QStringList wmsOutputCrsList( const QgsProject &project );
/**
* Returns the WMS Extent restriction.
* \param project the QGIS project
* \returns the WMS Extent restriction.
*/
SERVER_EXPORT QgsRectangle wmsExtent( const QgsProject &project );
/**
* Returns the WFS service url.
* The URL defined in the project or if not defined the URL from serviceUrl.
*
* \param project the QGIS project
* \param request the request
* \param settings the server settings
* \returns url to use for this service
*/
SERVER_EXPORT QString wfsServiceUrl( const QgsProject &project, const QgsServerRequest &request = QgsServerRequest(), const QgsServerSettings &settings = QgsServerSettings() );
/**
* Returns the Layer ids list defined in a QGIS project as published in WFS.
* \param project the QGIS project
* \return the Layer ids list.
*/
SERVER_EXPORT QStringList wfsLayerIds( const QgsProject &project );
/**
* Returns the Layer precision defined in a QGIS project for the WFS GetFeature.
* \param project the QGIS project
* \param layerId the layer id in the project
* \return the layer precision for WFS GetFeature.
*/
SERVER_EXPORT int wfsLayerPrecision( const QgsProject &project, const QString &layerId );
/**
* Returns the Layer ids list defined in a QGIS project as published as WFS-T with update capabilities.
* \param project the QGIS project
* \return the Layer ids list.
*/
SERVER_EXPORT QStringList wfstUpdateLayerIds( const QgsProject &project );
/**
* Returns the Layer ids list defined in a QGIS project as published as WFS-T with insert capabilities.
* \param project the QGIS project
* \return the Layer ids list.
*/
SERVER_EXPORT QStringList wfstInsertLayerIds( const QgsProject &project );
/**
* Returns the Layer ids list defined in a QGIS project as published as WFS-T with delete capabilities.
* \param project the QGIS project
* \return the Layer ids list.
*/
SERVER_EXPORT QStringList wfstDeleteLayerIds( const QgsProject &project );
/**
* Returns the WCS service url.
* The URL defined in the project or if not defined the URL from serviceUrl.
*
* \param project the QGIS project
* \param request the request
* \param settings the server settings
* \returns url to use for this service
*/
SERVER_EXPORT QString wcsServiceUrl( const QgsProject &project, const QgsServerRequest &request = QgsServerRequest(), const QgsServerSettings &settings = QgsServerSettings() );
/**
* Returns the Layer ids list defined in a QGIS project as published in WCS.
* \param project the QGIS project
* \returns the Layer ids list.
*/
SERVER_EXPORT QStringList wcsLayerIds( const QgsProject &project );
/**
* Returns the WMTS service url.
* The URL defined in the project or if not defined the URL from serviceUrl.
*
* \param project the QGIS project
* \param request the request
* \param settings the server settings
* \returns url to use for this service
* \since QGIS 3.4
*/
SERVER_EXPORT QString wmtsServiceUrl( const QgsProject &project, const QgsServerRequest &request = QgsServerRequest(), const QgsServerSettings &settings = QgsServerSettings() );
/**
* Returns the service url defined in the environment variable or with HTTP header.
* This is calculated from (in order of precedence):
*
* - Value defined in the project per service
* - The ``QGIS_SERVER_<service>_SERVICE_URL`` environment variable
* - The ``QGIS_SERVER_SERVICE_URL`` environment variable
* - The custom ``X-Qgis-<service>-Service-Url`` header
* - The custom ``X-Qgis-Service-Url`` header
* - Build from the standard ``Forwarded`` header
* - Build from the pseudo standard ``X-Forwarded-Host`` and ``X-Forwarded-Proto`` headers
* - Build from the standard ``Host`` header and the server protocol
* - Build from the server name and the server protocol.
*
* \param request the request
* \param service the used service
* \param settings the server settings
* \returns url to use for this service
* \since QGIS 3.20
*/
SERVER_EXPORT QString serviceUrl( const QString &service, const QgsServerRequest &request, const QgsServerSettings &settings );
};
#endif