Skip to content

Commit

Permalink
Added more debugging info to wms server. Also when compiled in debug …
Browse files Browse the repository at this point in the history
…mode, it will write the last rendered image out to the system temp dir (overwriting it with each render)
  • Loading branch information
timlinux committed Dec 6, 2011
1 parent 6ddf1f6 commit a5d2844
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/mapserver/qgis_map_serv.cpp
Expand Up @@ -346,7 +346,7 @@ int main( int argc, char * argv[] )
}
catch ( QgsMapServiceException& ex )
{
QgsDebugMsg( "Catched exception during GetMap request" );
QgsDebugMsg( "Caught exception during GetMap request" );
theRequestHandler->sendServiceException( ex );
delete theRequestHandler;
delete theServer;
Expand All @@ -357,6 +357,7 @@ int main( int argc, char * argv[] )
{
QgsDebugMsg( "Sending GetMap response" );
theRequestHandler->sendGetMapResponse( serviceString, result );
QgsDebugMsg( "Response sent" );
}
else
{
Expand Down Expand Up @@ -477,6 +478,7 @@ int main( int argc, char * argv[] )
}

delete theMapRenderer;
QgsDebugMsg( "************* all done ***************" );
return 0;
}

Expand Down
10 changes: 9 additions & 1 deletion src/mapserver/qgshttprequesthandler.cpp
Expand Up @@ -29,6 +29,7 @@
#include <QStringList>
#include <QUrl>
#include <fcgi_stdio.h>
#include "qgslogger.h"

QgsHttpRequestHandler::QgsHttpRequestHandler(): QgsRequestHandler()
{
Expand All @@ -42,6 +43,7 @@ QgsHttpRequestHandler::~QgsHttpRequestHandler()

void QgsHttpRequestHandler::sendHttpResponse( QByteArray* ba, const QString& format ) const
{
QgsDebugMsg("Checking byte array is ok to send...");
if ( !ba )
{
return;
Expand All @@ -52,12 +54,16 @@ void QgsHttpRequestHandler::sendHttpResponse( QByteArray* ba, const QString& for
return;
}

QgsDebugMsg("Byte array looks good, returning response...");
QgsDebugMsg(QString("Content size: %1").arg(ba->size()));
QgsDebugMsg(QString("Content format: %1").arg(format));
printf( "Content-Type: " );
printf( format.toLocal8Bit() );
printf( "\n" );
printf( "Content-Length: %d\n", ba->size() );
printf( "\n" );
fwrite( ba->data(), ba->size(), 1, FCGI_stdout );
int result=fwrite( ba->data(), ba->size(), 1, FCGI_stdout );
QgsDebugMsg(QString("Sent %1 bytes").arg(result));
}

QString QgsHttpRequestHandler::formatToMimeType( const QString& format ) const
Expand All @@ -84,10 +90,12 @@ QString QgsHttpRequestHandler::formatToMimeType( const QString& format ) const
void QgsHttpRequestHandler::sendGetMapResponse( const QString& service, QImage* img ) const
{
Q_UNUSED( service );
QgsDebugMsg("Sending getmap response...");
if ( img )
{
if ( mFormat != "PNG" && mFormat != "JPG" )
{
QgsDebugMsg("service exception - incorrect image format requested...");
sendServiceException( QgsMapServiceException( "InvalidFormat", "Output format '" + mFormat + "' is not supported in the GetMap request" ) );
return;
}
Expand Down
5 changes: 5 additions & 0 deletions src/mapserver/qgswmsserver.cpp
Expand Up @@ -581,7 +581,12 @@ QImage* QgsWMSServer::getMap()
restoreLayerFilters( originalLayerFilters );
clearFeatureSelections( selectedLayerIdList );

QgsDebugMsg("clearing filters");
QgsMapLayerRegistry::instance()->mapLayers().clear();

#ifdef QGISDEBUG
theImage->save( QDir::tempPath() + QDir::separator() + "lastrender.png" );
#endif
return theImage;
}

Expand Down

0 comments on commit a5d2844

Please sign in to comment.