[QGIS Commit] r14345 - trunk/qgis/src/mapserver

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Oct 6 15:21:44 EDT 2010


Author: jef
Date: 2010-10-06 19:21:44 +0000 (Wed, 06 Oct 2010)
New Revision: 14345

Modified:
   trunk/qgis/src/mapserver/CMakeLists.txt
   trunk/qgis/src/mapserver/qgis_map_serv.cpp
   trunk/qgis/src/mapserver/qgshttprequesthandler.cpp
   trunk/qgis/src/mapserver/qgsmslayerbuilder.cpp
   trunk/qgis/src/mapserver/qgssldparser.cpp
   trunk/qgis/src/mapserver/qgssoaprequesthandler.cpp
   trunk/qgis/src/mapserver/qgswmsserver.cpp
Log:
fix qgis mapserver on windows

Modified: trunk/qgis/src/mapserver/CMakeLists.txt
===================================================================
--- trunk/qgis/src/mapserver/CMakeLists.txt	2010-10-06 13:02:20 UTC (rev 14344)
+++ trunk/qgis/src/mapserver/CMakeLists.txt	2010-10-06 19:21:44 UTC (rev 14345)
@@ -14,7 +14,7 @@
 #MH: for this we need to locate the headers of the diagram and interpolation plugin
 #ADD_DEFINITIONS(-DDIAGRAMSERVER=1)
 
-IF (CMAKE_BUILD_TYPE MATCHES Debug)
+IF (CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
   ADD_DEFINITIONS(-DQGSMSDEBUG=1)
 ENDIF (CMAKE_BUILD_TYPE MATCHES Debug)
 ########################################################

Modified: trunk/qgis/src/mapserver/qgis_map_serv.cpp
===================================================================
--- trunk/qgis/src/mapserver/qgis_map_serv.cpp	2010-10-06 13:02:20 UTC (rev 14344)
+++ trunk/qgis/src/mapserver/qgis_map_serv.cpp	2010-10-06 19:21:44 UTC (rev 14345)
@@ -31,16 +31,11 @@
 #include <QDomDocument>
 #include <QImage>
 #include <QSettings>
-#include <iostream>
-#include <stdlib.h>
+#include <QDateTime>
 
 //for CMAKE_INSTALL_PREFIX
 #include "qgsconfig.h"
 
-
-#ifdef WIN32
-#include <fcntl.h>
-#endif //WIN32
 #include <fcgi_stdio.h>
 
 
@@ -54,13 +49,7 @@
 #ifdef QGSMSDEBUG
   //print out some infos about the request
   QgsMSDebugMsg( "************************new request**********************" )
-  time_t t;
-  struct tm *currentTime;
-  time( &t );
-  currentTime = localtime( &t );
-  QgsMSDebugMsg( QString::number( currentTime->tm_year + 1900 ) + "/" \
-                 + QString::number( currentTime->tm_mon + 1 ) + "/" + QString::number( currentTime->tm_mday ) + ", " \
-                 + QString::number( currentTime->tm_hour ) + ":" + QString::number( currentTime->tm_min ) )
+  QgsMSDebugMsg( QDateTime::currentDateTime().toString( "yyyy-mm-dd hh:mm:ss" ) );
 
   if ( getenv( "REMOTE_ADDR" ) != NULL )
   {
@@ -96,6 +85,8 @@
 QFileInfo defaultProjectFile()
 {
   QDir currentDir;
+  QgsMSDebugMsg( "current directory: " + currentDir.absolutePath() );
+  fprintf( FCGI_stderr, "current directory: %s\n", currentDir.absolutePath().toUtf8().constData() );
   QStringList nameFilterList;
   nameFilterList << "*.qgs";
   QFileInfoList projectFiles = currentDir.entryInfoList( nameFilterList, QDir::Files, QDir::Name );
@@ -115,12 +106,6 @@
 
 int main( int argc, char * argv[] )
 {
-  //#ifdef WIN32 //not needed any more since the QGIS mapserver uses a modified version of libfcgi
-  //_setmode(_fileno(FCGI_stdout->stdio_stream),_O_BINARY); //we need binary mode to print images to stdout on windows
-  //#endif
-
-  //close disturbing output chanels
-  fclose( FCGI_stderr );
   qInstallMsgHandler( dummyMessageHandler );
 
   QgsApplication qgsapp( argc, argv, false );
@@ -131,14 +116,14 @@
   {
     QgsApplication::setPrefixPath( prefixPath, TRUE );
   }
+#if !defined(Q_OS_WIN)
   else
   {
     // init QGIS's paths - true means that all path will be inited from prefix
     QgsApplication::setPrefixPath( CMAKE_INSTALL_PREFIX, TRUE );
   }
+#endif
 
-
-
   // Instantiate the plugin directory so that providers are loaded
   QgsProviderRegistry::instance( QgsApplication::pluginPath() );
 #ifdef QGSMSDEBUG

Modified: trunk/qgis/src/mapserver/qgshttprequesthandler.cpp
===================================================================
--- trunk/qgis/src/mapserver/qgshttprequesthandler.cpp	2010-10-06 13:02:20 UTC (rev 14344)
+++ trunk/qgis/src/mapserver/qgshttprequesthandler.cpp	2010-10-06 19:21:44 UTC (rev 14345)
@@ -17,11 +17,7 @@
 
 #include "qgshttprequesthandler.h"
 #include <QByteArray>
-#ifdef WIN32 //don't use fast cgi on windows
-#include <stdio.h>
-#else
 #include <fcgi_stdio.h>
-#endif //WIN32
 
 QgsHttpRequestHandler::QgsHttpRequestHandler(): QgsRequestHandler()
 {
@@ -50,9 +46,5 @@
   printf( "\n" );
   printf( "Content-Length: %d\n", ba->size() );
   printf( "\n" );
-#ifdef WIN32
-  fwrite( ba->data(), ba->size(), 1, stdout );
-#else
   fwrite( ba->data(), ba->size(), 1, FCGI_stdout );
-#endif //WIN32
 }

Modified: trunk/qgis/src/mapserver/qgsmslayerbuilder.cpp
===================================================================
--- trunk/qgis/src/mapserver/qgsmslayerbuilder.cpp	2010-10-06 13:02:20 UTC (rev 14344)
+++ trunk/qgis/src/mapserver/qgsmslayerbuilder.cpp	2010-10-06 19:21:44 UTC (rev 14345)
@@ -74,25 +74,14 @@
   int randomNumber = rand();
   QString tempFileName = QString::number( randomNumber );
   QString tempFilePath;
-  //on windows, store the temporary file in current_path/tmp directory,
-  //on unix, store it in /tmp/qgis_wms_serv
-#ifndef WIN32
-  QDir tempFileDir( "/tmp/qgis_wms_serv" );
+  // store temporary file in temporary qgis_wms_serv in temporary directory
+  QDir tempFileDir( QDir::tempPath() + "/qgis_wms_serv" );
   if ( !tempFileDir.exists() ) //make sure the directory exists
   {
-    QDir tmpDir( "/tmp" );
+    QDir tmpDir( QDir::tempPath() );
     tmpDir.mkdir( "qgis_wms_serv" );
   }
-  tempFilePath = "/tmp/qgis_wms_serv/" + tempFileName;
-#else
-  QDir tempFileDir( QDir::currentPath() + "/tmp" );
-  if ( !tempFileDir.exists() )
-  {
-    QDir currentDir( QDir::currentPath() );
-    currentDir.mkdir( "tmp" );
-  }
-  tempFilePath = QDir::currentPath() + "/tmp" + "/" + tempFileName;
-#endif //WIN32
+  tempFilePath = QDir::tempPath() + "/qgis_wms_serv/" + tempFileName;
   return tempFilePath;
 }
 

Modified: trunk/qgis/src/mapserver/qgssldparser.cpp
===================================================================
--- trunk/qgis/src/mapserver/qgssldparser.cpp	2010-10-06 13:02:20 UTC (rev 14344)
+++ trunk/qgis/src/mapserver/qgssldparser.cpp	2010-10-06 19:21:44 UTC (rev 14345)
@@ -47,6 +47,7 @@
 #include <time.h>
 #include "qgslabel.h"
 #include <stdlib.h>
+#include <fcgi_stdio.h>
 
 
 //layer builders
@@ -1350,7 +1351,7 @@
 
   if ( hDriver == NULL )
   {
-    fprintf( stderr, "Unable to find format driver named %s.\n",
+    fprintf( FCGI_stderr, "Unable to find format driver named %s.\n",
              pszFormat );
     exit( 10 );
   }

Modified: trunk/qgis/src/mapserver/qgssoaprequesthandler.cpp
===================================================================
--- trunk/qgis/src/mapserver/qgssoaprequesthandler.cpp	2010-10-06 13:02:20 UTC (rev 14344)
+++ trunk/qgis/src/mapserver/qgssoaprequesthandler.cpp	2010-10-06 19:21:44 UTC (rev 14345)
@@ -25,11 +25,7 @@
 #include <QImage>
 #include <QTextStream>
 #include <time.h>
-#ifdef WIN32 //don't use fast cgi on windows
-#include <stdio.h>
-#else
 #include <fcgi_stdio.h>
-#endif //WIN32
 
 QgsSOAPRequestHandler::QgsSOAPRequestHandler()
 {
@@ -736,11 +732,7 @@
   printf( "Content-ID: <xml at mapservice>\n" );
   printf( "\n" );
   printf( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" );
-#ifdef WIN32
-  fwrite( xmlByteArray.data(), xmlByteArray.size(), 1, stdout );
-#else
   fwrite( xmlByteArray.data(), xmlByteArray.size(), 1, FCGI_stdout );
-#endif //WIN32
   printf( "\n" );
   printf( "\r\n" );
   printf( "--MIME_boundary\r\n" );
@@ -755,11 +747,7 @@
   printf( "Content-Transfer-Encoding: binary\n" );
   printf( "Content-ID: <image at mapservice>\n" );
   printf( "\n" );
-#ifdef WIN32
-  fwrite( ba.data(), ba.size(), 1, stdout );
-#else
   fwrite( ba.data(), ba.size(), 1, FCGI_stdout );
-#endif //WIN32
   printf( "\r\n" );
   printf( "--MIME_boundary\r\n" );
 

Modified: trunk/qgis/src/mapserver/qgswmsserver.cpp
===================================================================
--- trunk/qgis/src/mapserver/qgswmsserver.cpp	2010-10-06 13:02:20 UTC (rev 14344)
+++ trunk/qgis/src/mapserver/qgswmsserver.cpp	2010-10-06 19:21:44 UTC (rev 14345)
@@ -43,6 +43,7 @@
 #include <QPainter>
 #include <QStringList>
 #include <QTextStream>
+#include <QDir>
 
 QgsWMSServer::QgsWMSServer( std::map<QString, QString> parameters, QgsMapRenderer* renderer ): mParameterMap( parameters ), mConfigParser( 0 ), mMapRenderer( renderer )
 {
@@ -213,7 +214,7 @@
   QgsMSDebugMsg( "Entering layersAndStylesCapabilities" )
 
   //for debugging: save the document to disk
-  QFile capabilitiesFile( "/tmp/capabilities.txt" );
+  QFile capabilitiesFile( QDir::tempPath() + "/capabilities.txt" );
   if ( capabilitiesFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
   {
     QTextStream capabilitiesStream( &capabilitiesFile );



More information about the QGIS-commit mailing list