QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
qgswmsgetschemaextension.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgswmsgetschemaextension.cpp
3 -------------------------
4 begin : December 20 , 2016
5 copyright : (C) 2007 by Marco Hugentobler (original code)
6 (C) 2014 by Alessandro Pasotti (original code)
7 (C) 2016 by David Marteau
8 email : marco dot hugentobler at karto dot baug dot ethz dot ch
9 a dot pasotti at itopen dot it
10 david dot marteau at 3liz dot com
11 ***************************************************************************/
12
13/***************************************************************************
14 * *
15 * This program is free software; you can redistribute it and/or modify *
16 * it under the terms of the GNU General Public License as published by *
17 * the Free Software Foundation; either version 2 of the License, or *
18 * (at your option) any later version. *
19 * *
20 ***************************************************************************/
22
23#include "qgsapplication.h"
24#include "qgswmsutils.h"
25
26#include <QDir>
27#include <QFileInfo>
28#include <QString>
29#include <QTextStream>
30
31using namespace Qt::StringLiterals;
32
33namespace QgsWms
34{
35
37 {
38 const QDir resourcesDir = QFileInfo( QgsApplication::serverResourcesPath() ).absoluteDir();
39 const QFileInfo xsdFileInfo( resourcesDir, u"schemaExtension.xsd"_s );
40 QString schema_str = u"<?xml version='1.0'?>"_s;
41
42 if ( !xsdFileInfo.exists() )
43 {
44 QgsMessageLog::logMessage( u"Error, xsd file 'schemaExtension.xsd' does not exist"_s, u"Server"_s, Qgis::MessageLevel::Critical );
45 }
46 else
47 {
48 QFile file( xsdFileInfo.absoluteFilePath() );
49 if ( file.open( QFile::ReadOnly | QFile::Text ) )
50 {
51 QTextStream in( &file );
52 schema_str = in.readAll();
53 file.close();
54 }
55 else
56 {
57 QgsMessageLog::logMessage( u"Error, xsd file 'schemaExtension.xsd' not readable"_s, u"Server"_s, Qgis::MessageLevel::Critical );
58 }
59 }
60 response.setHeader( u"Content-Type"_s, u"text/xml; charset=utf-8"_s );
61 response.write( schema_str );
62 }
63
64} // namespace QgsWms
@ Critical
Critical/error message.
Definition qgis.h:162
static QString serverResourcesPath()
Returns the path to the server resources directory.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE())
Adds a message to the log instance (and creates it if necessary).
Defines the response interface passed to QgsService.
virtual void write(const QString &data)
Write string This is a convenient method that will write directly to the underlying I/O device.
virtual void setHeader(const QString &key, const QString &value)=0
Set Header entry Add Header entry to the response Note that it is usually an error to set Header afte...
Median cut implementation.
void writeGetSchemaExtension(QgsServerResponse &response)
Output GetSchemaExtension response.