void writeGetSchemaExtension( QgsServerInterface* serverIface, const QString& version, const QgsServerRequest& request, QgsServerResponse& response ) { QDomDocument doc = getSchemaExtension( serverIface, version, request ); response.setHeader( QStringLiteral( "Content-Type" ), QStringLiteral( "text/xml; charset=utf-8" ) ); response.write( doc.toByteArray() ); }
/** * Output WCS GetCapabilities response */ void writeGetCapabilities( QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response ) { #ifdef HAVE_SERVER_PYTHON_PLUGINS QgsAccessControl *accessControl = serverIface->accessControls(); #endif QDomDocument doc; const QDomDocument *capabilitiesDocument = nullptr; #ifdef HAVE_SERVER_PYTHON_PLUGINS QgsServerCacheManager *cacheManager = serverIface->cacheManager(); if ( cacheManager && cacheManager->getCachedDocument( &doc, project, request, accessControl ) ) { capabilitiesDocument = &doc; } else //capabilities xml not in cache. Create a new one { doc = createGetCapabilitiesDocument( serverIface, project, version, request ); if ( cacheManager ) { cacheManager->setCachedDocument( &doc, project, request, accessControl ); } capabilitiesDocument = &doc; } #else doc = createGetCapabilitiesDocument( serverIface, project, version, request ); #endif response.setHeader( QStringLiteral( "Content-Type" ), QStringLiteral( "text/xml; charset=utf-8" ) ); response.write( capabilitiesDocument->toByteArray() ); }
void writeDescribeLayer( QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response ) { QDomDocument doc = describeLayer( serverIface, project, version, request ); response.setHeader( QStringLiteral( "Content-Type" ), QStringLiteral( "text/xml; charset=utf-8" ) ); response.write( doc.toByteArray() ); }
/** * Output WCS DescribeCoverage response */ void writeDescribeCoverage( QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response ) { QgsAccessControl *accessControl = nullptr; #ifdef HAVE_SERVER_PYTHON_PLUGINS accessControl = serverIface->accessControls(); #endif QDomDocument doc; const QDomDocument *describeDocument = nullptr; QgsServerCacheManager *cacheManager = nullptr; #ifdef HAVE_SERVER_PYTHON_PLUGINS cacheManager = serverIface->cacheManager(); #endif if ( cacheManager && cacheManager->getCachedDocument( &doc, project, request, accessControl ) ) { describeDocument = &doc; } else //describe feature xml not in cache. Create a new one { doc = createDescribeCoverageDocument( serverIface, project, version, request ); if ( cacheManager ) { cacheManager->setCachedDocument( &doc, project, request, accessControl ); } describeDocument = &doc; } response.setHeader( "Content-Type", "text/xml; charset=utf-8" ); response.write( describeDocument->toByteArray() ); }
/** * Output WFS GetCapabilities response */ void writeGetCapabilities( QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response ) { QDomDocument doc = createGetCapabilitiesDocument( serverIface, project, version, request ); response.setHeader( "Content-Type", "text/xml; charset=utf-8" ); response.write( doc.toByteArray() ); }
void writeGetCapabilities( QgsServerInterface* serverIface, const QString& version, const QgsServerRequest& request, QgsServerResponse& response, bool projectSettings ) { QgsServerRequest::Parameters params = request.parameters(); QString configFilePath = serverIface->configFilePath(); QgsServerSettings* serverSettings = serverIface->serverSettings(); QgsAccessControl* accessControl = serverIface->accessControls(); QgsCapabilitiesCache* capabilitiesCache = serverIface->capabilitiesCache(); QStringList cacheKeyList; cacheKeyList << ( projectSettings ? QStringLiteral( "projectSettings" ) : version ); cacheKeyList << getenv( "SERVER_NAME" ); bool cache = true; if ( accessControl ) cache = accessControl->fillCacheKey( cacheKeyList ); QString cacheKey = cacheKeyList.join( QStringLiteral( "-" ) ); const QDomDocument* capabilitiesDocument = capabilitiesCache->searchCapabilitiesDocument( configFilePath, cacheKey ); if ( !capabilitiesDocument ) //capabilities xml not in cache. Create a new one { QgsMessageLog::logMessage( QStringLiteral( "Capabilities document not found in cache" ) ); QDomDocument doc; QgsWmsServer server( configFilePath, *serverSettings, params, getConfigParser( serverIface ), accessControl ); doc = server.getCapabilities( version, projectSettings ); if ( cache ) { capabilitiesCache->insertCapabilitiesDocument( configFilePath, cacheKey, &doc ); capabilitiesDocument = capabilitiesCache->searchCapabilitiesDocument( configFilePath, cacheKey ); } else { doc = doc.cloneNode().toDocument(); capabilitiesDocument = &doc; } } else { QgsMessageLog::logMessage( QStringLiteral( "Found capabilities document in cache" ) ); } response.setHeader( QStringLiteral( "Content-Type" ), QStringLiteral( "text/xml; charset=utf-8" ) ); response.write( capabilitiesDocument->toByteArray() ); }
void writeGetSchemaExtension( QgsServerInterface* serverIface, const QString& version, const QgsServerRequest& request, QgsServerResponse& response ) { Q_UNUSED( version ); QgsServerRequest::Parameters params = request.parameters(); QgsWmsServer server( serverIface->configFilePath(), *serverIface->serverSettings(), params, getConfigParser( serverIface ), serverIface->accessControls() ); QDomDocument doc = server.getSchemaExtension(); response.setHeader( QStringLiteral( "Content-Type" ), QStringLiteral( "text/xml; charset=utf-8" ) ); response.write( doc.toByteArray() ); }
void writeGetCapabilities( QgsServerInterface* serverIface, const QString& version, const QgsServerRequest& request, QgsServerResponse& response, bool projectSettings ) { QString configFilePath = serverIface->configFilePath(); QgsCapabilitiesCache* capabilitiesCache = serverIface->capabilitiesCache(); QStringList cacheKeyList; cacheKeyList << ( projectSettings ? QStringLiteral( "projectSettings" ) : version ); cacheKeyList << request.url().host(); bool cache = true; #ifdef HAVE_SERVER_PYTHON_PLUGINS QgsAccessControl* accessControl = serverIface->accessControls(); if ( accessControl ) cache = accessControl->fillCacheKey( cacheKeyList ); #endif QString cacheKey = cacheKeyList.join( QStringLiteral( "-" ) ); const QDomDocument* capabilitiesDocument = capabilitiesCache->searchCapabilitiesDocument( configFilePath, cacheKey ); if ( !capabilitiesDocument ) //capabilities xml not in cache. Create a new one { QgsMessageLog::logMessage( QStringLiteral( "Capabilities document not found in cache" ) ); QDomDocument doc; doc = getCapabilities( serverIface, version, request, projectSettings ); if ( cache ) { capabilitiesCache->insertCapabilitiesDocument( configFilePath, cacheKey, &doc ); capabilitiesDocument = capabilitiesCache->searchCapabilitiesDocument( configFilePath, cacheKey ); } else { doc = doc.cloneNode().toDocument(); capabilitiesDocument = &doc; } } else { QgsMessageLog::logMessage( QStringLiteral( "Found capabilities document in cache" ) ); } response.setHeader( QStringLiteral( "Content-Type" ), QStringLiteral( "text/xml; charset=utf-8" ) ); response.write( capabilitiesDocument->toByteArray() ); }
void writeGetPrint( QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response ) { QgsServerRequest::Parameters params = request.parameters(); Q_UNUSED( version ); QgsWmsParameters wmsParameters( QUrlQuery( request.url() ) ); QgsRenderer renderer( serverIface, project, wmsParameters ); QString format = params.value( "FORMAT" ); QString contentType; // GetPrint supports svg/png/pdf if ( format.compare( QLatin1String( "image/png" ), Qt::CaseInsensitive ) == 0 || format.compare( QLatin1String( "png" ), Qt::CaseInsensitive ) == 0 ) { format = "png"; contentType = "image/png"; } else if ( format.compare( QLatin1String( "image/svg" ), Qt::CaseInsensitive ) == 0 || format.compare( QLatin1String( "image/svg+xml" ), Qt::CaseInsensitive ) == 0 || format.compare( QLatin1String( "svg" ), Qt::CaseInsensitive ) == 0 ) { format = "svg"; contentType = "image/svg+xml"; } else if ( format.compare( QLatin1String( "application/pdf" ), Qt::CaseInsensitive ) == 0 || format.compare( QLatin1String( "pdf" ), Qt::CaseInsensitive ) == 0 ) { format = "pdf"; contentType = "application/pdf"; } else { throw QgsServiceException( QStringLiteral( "InvalidFormat" ), QString( "Output format %1 is not supported by the GetPrint request" ).arg( format ) ); } response.setHeader( QStringLiteral( "Content-Type" ), contentType ); response.write( renderer.getPrint( format ) ); }
void writeGetFeatureInfo( QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response ) { // get wms parameters from query QgsWmsParameters parameters( QUrlQuery( request.url() ) ); // prepare render context QgsWmsRenderContext context( project, serverIface ); context.setFlag( QgsWmsRenderContext::AddQueryLayers ); context.setFlag( QgsWmsRenderContext::UseFilter ); context.setFlag( QgsWmsRenderContext::UseScaleDenominator ); context.setFlag( QgsWmsRenderContext::SetAccessControl ); context.setParameters( parameters ); const QString infoFormat = request.parameters().value( QStringLiteral( "INFO_FORMAT" ), QStringLiteral( "text/plain" ) ); response.setHeader( QStringLiteral( "Content-Type" ), infoFormat + QStringLiteral( "; charset=utf-8" ) ); QgsRenderer renderer( context ); response.write( renderer.getFeatureInfo( version ) ); }