Proposing to support for creating maps with mapserv.exe using the command line

Tamas Szekeres szekerest at GMAIL.COM
Wed Jun 21 11:07:03 EDT 2006


Developers,

I would be required to enable using mapserv.exe as a commandline tool
for the map image creation. The current implementation already has a
QUERY_STRING argument to receive the cgi style parameter list.
However mapserv.exe is creating the generated image onto the stdout
including the content type header information. With the following
patch one could specify the output file as an additional commandline
parameter, like:

mapserv.exe "QUERY_STRING=map=mymap.map&mode=map" -omymap.png

In order to achieve this functionality the following changes should be made

--- mapserv.c	14 Dec 2005 19:55:07 -0000	1.150
+++ mapserv.c	21 Jun 2006 14:50:07 -0000
@@ -1109,6 +1109,7 @@
     char buffer[1024];
     imageObj *img=NULL;
     int status;
+    char* outfile = NULL;

 /* -------------------------------------------------------------------- */
 /*      Process arguments.  In normal use as a cgi-bin there are no     */
@@ -1147,6 +1148,9 @@
             putenv( "REQUEST_METHOD=GET" );
             putenv( argv[1] );
         }
+        else if(strncmp(argv[iArg], "-o", 2) == 0) {
+            outfile = argv[iArg] + 2;
+        }
         else
         {
             /* we don't produce a usage message as some web servers pass
@@ -1318,9 +1322,9 @@

       msIO_printf("Content-type:
%s%c%c",MS_IMAGE_MIME_TYPE(msObj->Map->outputformat), 10,10);
       if( msObj->Mode == MAP )
-          status = msSaveImage(msObj->Map,img, NULL);
+          status = msSaveImage(msObj->Map,img, outfile);
       else
-          status = msSaveImage(NULL,img, NULL);
+          status = msSaveImage(NULL,img, outfile);

       if(status != MS_SUCCESS) writeError();

@@ -1344,7 +1348,7 @@
           if(!img) writeError();

           msIO_printf("Content-type:
%s%c%c",MS_IMAGE_MIME_TYPE(msObj->Map->outputformat), 10,10);
-          status = msSaveImage(NULL, img, NULL);
+          status = msSaveImage(NULL, img, outfile);
           if(status != MS_SUCCESS) writeError();

           msFreeImage(img);
@@ -1579,7 +1583,7 @@
 	if(!img) writeError();

 	msIO_printf("Content-type:
%s%c%c",MS_IMAGE_MIME_TYPE(msObj->Map->outputformat), 10,10);
-	status = msSaveImage(msObj->Map, img, NULL);
+    status = msSaveImage(msObj->Map, img, outfile);
 	if(status != MS_SUCCESS) writeError();
 	msFreeImage(img);


Any objections?

Best Regards,

Tamas



More information about the mapserver-dev mailing list