[mapserver-commits] r10168 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Wed May 19 16:58:37 EDT 2010


Author: assefa
Date: 2010-05-19 16:58:34 -0400 (Wed, 19 May 2010)
New Revision: 10168

Modified:
   trunk/mapserver/mapdraw.c
   trunk/mapserver/mapkml.cpp
   trunk/mapserver/mapkml.h
   trunk/mapserver/mapkmlrenderer.cpp
   trunk/mapserver/mapkmlrenderer.h
   trunk/mapserver/mapserv.c
   trunk/mapserver/mapserver.h
Log:
More cleaup for the kml renderer (styling, raster) #3431

Modified: trunk/mapserver/mapdraw.c
===================================================================
--- trunk/mapserver/mapdraw.c	2010-05-19 15:58:03 UTC (rev 10167)
+++ trunk/mapserver/mapdraw.c	2010-05-19 20:58:34 UTC (rev 10168)
@@ -1379,7 +1379,12 @@
     {
         if( MS_RENDERER_PLUGIN(image->format) )
         {
-            return msDrawRasterLayerPlugin(map, layer, image);
+#ifdef USE_KML
+            if (MS_RENDERER_KML(image->format))
+              return  msDrawRasterLayerKml(map, layer, image);
+            else
+#endif
+              return msDrawRasterLayerPlugin(map, layer, image);
         }
         else if( MS_RENDERER_GD(image->format) )
             return msDrawRasterLayerLow(map, layer, image, NULL);

Modified: trunk/mapserver/mapkml.cpp
===================================================================
--- trunk/mapserver/mapkml.cpp	2010-05-19 15:58:03 UTC (rev 10167)
+++ trunk/mapserver/mapkml.cpp	2010-05-19 20:58:34 UTC (rev 10168)
@@ -76,7 +76,7 @@
 
 void msRenderPolygonTiledKml(imageObj *img, shapeObj *p,  imageObj *tile)
 {
-	KmlRenderer* renderer = getKmlRenderer(img);
+  /*KmlRenderer* renderer = getKmlRenderer(img);*/
 }
 
 void msRenderLineTiledKml(imageObj *img, shapeObj *p, imageObj *tile)
@@ -204,10 +204,16 @@
 
 void msEndShapeKml(imageObj *img, shapeObj *shape)
 {
-	KmlRenderer* renderer = getKmlRenderer(img);
-	renderer->endShape(img, shape);
+    KmlRenderer* renderer = getKmlRenderer(img);
+    renderer->endShape(img, shape);
 }
 
+int  msDrawRasterLayerKml(mapObj *map, layerObj *layer, imageObj *img)
+{
+    KmlRenderer* renderer = getKmlRenderer(img);
+    return renderer->renderRasterLayer(img);
+    
+}
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/mapserver/mapkml.h
===================================================================
--- trunk/mapserver/mapkml.h	2010-05-19 15:58:03 UTC (rev 10167)
+++ trunk/mapserver/mapkml.h	2010-05-19 20:58:34 UTC (rev 10168)
@@ -63,6 +63,8 @@
 void msFreeTileKml(imageObj *tile);
 void msFreeSymbolKml(symbolObj *symbol);
 
+int  msDrawRasterLayerKml(mapObj *map, layerObj *layer, imageObj *img);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/mapserver/mapkmlrenderer.cpp
===================================================================
--- trunk/mapserver/mapkmlrenderer.cpp	2010-05-19 15:58:03 UTC (rev 10167)
+++ trunk/mapserver/mapkmlrenderer.cpp	2010-05-19 20:58:34 UTC (rev 10168)
@@ -48,6 +48,8 @@
     papszLayerIncludeItems = NULL;
     nIncludeItems=0;
     
+    LineStyle = NULL;
+    numLineStyle = 0;
 
     xmlNodePtr styleNode;
     xmlNodePtr listStyleNode;
@@ -101,18 +103,28 @@
 imageObj* KmlRenderer::createInternalImage()
 {
     rendererVTableObj *r = RasterizerOutputFormat->vtable;
-    imageObj *image = r->createImage(Width, Height, RasterizerOutputFormat, &BgColor);
-    image->format = RasterizerOutputFormat;
-    image->format->refcount++;
-    image->width = currentLayer->map->width;
-    image->height = currentLayer->map->height;
+    imageObj *image =NULL;
+    mapObj *map = currentLayer->map;
 
-    image->resolution = currentLayer->map->resolution;
-    image->resolutionfactor = currentLayer->map->resolution/currentLayer->map->defresolution;
-    if (currentLayer->map->web.imagepath)
-      image->imagepath = strdup(currentLayer->map->web.imagepath);
-    if (map->web.imageurl)
-      image->imageurl = strdup(currentLayer->map->web.imageurl);
+    if (r)
+    {
+        image = r->createImage(Width, Height, RasterizerOutputFormat, &BgColor);
+          image->format = RasterizerOutputFormat;
+          image->format->refcount++;
+          image->width = currentLayer->map->width;
+          image->height = currentLayer->map->height;
+
+          image->resolution = currentLayer->map->resolution;
+          image->resolutionfactor = currentLayer->map->resolution/currentLayer->map->defresolution;
+          if (currentLayer->map->web.imagepath)
+            image->imagepath = strdup(currentLayer->map->web.imagepath);
+          if (map->web.imageurl)
+            image->imageurl = strdup(currentLayer->map->web.imageurl);
+    }
+    else
+      image = msImageCreateAGG(map->width, map->height,  
+                               RasterizerOutputFormat,
+                               map->web.imagepath, map->web.imageurl, map->resolution, map->defresolution);
     return image;
 }
 
@@ -124,37 +136,37 @@
 int KmlRenderer::saveImage(imageObj *, FILE *fp, outputFormatObj*)
 {
     
-	/* -------------------------------------------------------------------- */
-	/*      Write out the document.                                         */
-	/* -------------------------------------------------------------------- */
+    /* -------------------------------------------------------------------- */
+    /*      Write out the document.                                         */
+    /* -------------------------------------------------------------------- */
 
-	int bufSize = 0;
-	xmlChar *buf = NULL;
-	msIOContext *context = NULL;
+    int bufSize = 0;
+    xmlChar *buf = NULL;
+    msIOContext *context = NULL;
 
-	if( msIO_needBinaryStdout() == MS_FAILURE )
-		return MS_FAILURE;
+    if( msIO_needBinaryStdout() == MS_FAILURE )
+      return MS_FAILURE;
 
-	xmlDocDumpFormatMemoryEnc(XmlDoc, &buf, &bufSize, "UTF-8", 1);
+    xmlDocDumpFormatMemoryEnc(XmlDoc, &buf, &bufSize, "UTF-8", 1);
 
-	context = msIO_getHandler(fp);
+    context = msIO_getHandler(fp);
 
-	int chunkSize = 4096;
-	for (int i=0; i<bufSize; i+=chunkSize)
-	{
-		int size = chunkSize;
-		if (i + size > bufSize)
-			size = bufSize - i;
+    int chunkSize = 4096;
+    for (int i=0; i<bufSize; i+=chunkSize)
+    {
+        int size = chunkSize;
+        if (i + size > bufSize)
+          size = bufSize - i;
 
-		if (context)
-			msIO_contextWrite(context, buf+i, size);
-		else
-			msIO_fwrite(buf+i, 1, size, fp);
-	}
+        if (context)
+          msIO_contextWrite(context, buf+i, size);
+        else
+          msIO_fwrite(buf+i, 1, size, fp);
+    }
 
-	xmlFree(buf);
+    xmlFree(buf);
 
-	return(MS_SUCCESS);
+    return(MS_SUCCESS);
 }
 
 
@@ -177,6 +189,17 @@
     for(i=0; i<layer->numclasses; i++)
       layer->_class[i]->label.position = MS_XY;
    
+    /*we do not want to draw multiple styles.
+      the new rendering architecture does not allow
+      to know if we are dealing with a multi-style.
+      So here we remove all styles beside the first one*/
+    /*
+    for(i=0; i<layer->numclasses; i++)
+    {
+        while (layer->_class[i]->numstyles > 1)
+          msDeleteStyle(layer->_class[i], layer->_class[i]->numstyles-1);
+    }
+    */
 }
 
 char* KmlRenderer::getLayerName(layerObj *layer)
@@ -212,6 +235,7 @@
     else
       VectorMode = MS_TRUE;
 
+
     /*check if a vector layer will be dumped as a raster*/
     const char *outputAsRaster=msLookupHashTable(&(layer->metadata),"KML_OUTPUTASRASTER");
     if (outputAsRaster && strlen(outputAsRaster) > 0 && 
@@ -266,6 +290,14 @@
         if (layer->map->mappath)
           sprintf(MapPath, "%s", layer->map->mappath);
 
+        /*First rendered layer - check mapfile projection*/
+        checkProjection(layer->map);
+
+        /*check for image path and image url*/
+        if (layer->map->debug && (layer->map->web.imageurl == NULL ||   layer->map->web.imagepath == NULL))
+          msDebug("KmlRenderer::startNewLayer: imagepath and imageurl sould be set in the web object\n");
+
+
         /*map rect for ground overlay*/
         MapExtent = layer->map->extent;
         MapCellsize = layer->map->cellsize;
@@ -273,10 +305,7 @@
 
          xmlNewChild(DocNode, NULL, BAD_CAST "name", BAD_CAST layer->map->name);
 
-        /*First rendered layer - check mapfile projection*/
-        checkProjection(layer->map);
-
-              
+        
     }
 
     currentLayer = layer;
@@ -339,10 +368,15 @@
       The agg should be the only one used but at this point it is not completed; so
       use cairo for vector layer that are rasterized and agg2 for raster layers*/
     if (layer->type ==  MS_LAYER_RASTER)
-      sprintf(rasterizerFomatName, "agg2png"); 
+      sprintf(rasterizerFomatName, "agg2png"); //"aggpng24"); 
     else
-      sprintf(rasterizerFomatName, "cairopng");
-
+    {
+#ifdef USE_CAIRO
+        sprintf(rasterizerFomatName, "cairopng");
+#else
+        sprintf(rasterizerFomatName, "agg2png"); 
+#endif
+    }
         
     for (int i=0; i<layer->map->numoutputformats; i++)
     {     
@@ -415,6 +449,8 @@
 
     if (papszLayerIncludeItems && nIncludeItems>0)
       msFreeCharArray(papszLayerIncludeItems, nIncludeItems);
+
+    papszLayerIncludeItems=NULL;
 }
 
 
@@ -456,28 +492,33 @@
 #ifdef USE_PROJ
     if (projection && projection->numargs > 0 && pj_is_latlong(projection->proj))
     {
-        char *projStr = msGetProjectionString(projection);
-
-        /* is ellipsoid WGS84 or projection code epsg:4326 */
-        if (strcasestr(projStr, "WGS84") || strcasestr(projStr,"epsg:4326"))
-        {
-            return MS_SUCCESS;
-        }
+        return MS_SUCCESS;
     }
     else
     {
-        //TODO: give a warning in debug mode 
         char epsg_string[100];
-        //??The only projection valid
+        rectObj sRect;
+        projectionObj out;
         strcpy(epsg_string, "epsg:4326" );
+        msInitProjection(&out);
+        msLoadProjectionString(&out, epsg_string);
+
+        sRect = map->extent;
+        msProjectRect(projection, &out, &sRect);
         msFreeProjection(projection);
         msLoadProjectionString(projection, epsg_string);
+
+        /*change also units and extents*/
+        map->extent = sRect;
+        map->units = MS_DD;
+
+
+        if (map->debug)
+          msDebug("KmlRenderer::checkProjection: Mapfile projection set to epsg:4326\n");
+
         return MS_SUCCESS;
     }
 
-    msSetError(MS_PROJERR, "Mapfile projection not defined, KML output driver requires projection WGS84 (epsg:4326)", "KmlRenderer::checkProjection()" );
-    return MS_FAILURE;
-
 #else
     msSetError(MS_MISCERR, "Projection support not enabled", "KmlRenderer::checkProjection" );
     return MS_FAILURE;
@@ -491,7 +532,7 @@
     /*always add a name. It will be replaced by a text value if available*/
     char tmpid[100];
     char *stmp=NULL, *layerName=NULL;
-    sprintf(tmpid, ".%d", (int)CurrentShape->index);
+    sprintf(tmpid, ".%d", CurrentShapeIndex);
     layerName = getLayerName(currentLayer);
     stmp = msStringConcatenate(stmp, layerName);
     stmp = msStringConcatenate(stmp, tmpid);
@@ -515,11 +556,12 @@
     if (!PlacemarkNode)
       return;
 
-    memcpy(&LineStyle, style, sizeof(strokeStyleObj));
+    addLineStyleToList(style);    
     SymbologyFlag[Line] = 1;
 
-    
-    if (p != CurrentShapeDrawn)
+    /*p->index > CurrentDrawnShapeIndexneed to be reviewd. Added since the hight
+      level code caches shapes when rendering lines*/
+    if (CurrentDrawnShapeIndex == -1 || p->index > CurrentDrawnShapeIndex)
     {
     
       xmlNodePtr geomNode = getGeomParentNode("LineString");
@@ -538,7 +580,7 @@
         }
       }
       
-      CurrentShapeDrawn = p;
+      CurrentDrawnShapeIndex = p->index;
     }
       
 }
@@ -577,7 +619,7 @@
     SymbologyFlag[Polygon] = 1;
 
     
-    if (p != CurrentShapeDrawn)
+    if (p->index != CurrentDrawnShapeIndex)
     {
     
       xmlNodePtr geomParentNode = getGeomParentNode("Polygon");
@@ -596,8 +638,8 @@
         addCoordsNode(ringNode, p->line[i].point, p->line[i].numpoints);
       }
 
+      CurrentDrawnShapeIndex = p->index;
       
-      CurrentShapeDrawn = p;
     }
       
 }
@@ -880,16 +922,16 @@
 
     char crdStr[64];
     xmlNodePtr latLonBoxNode = xmlNewChild(groundOverlayNode, NULL, BAD_CAST "LatLonBox", NULL);
-    sprintf(crdStr, "%.8f", MapExtent.maxy);
+    sprintf(crdStr, "%.8f", currentLayer->map->extent.maxy);
     xmlNewChild(latLonBoxNode, NULL, BAD_CAST "north", BAD_CAST crdStr);
 
-    sprintf(crdStr, "%.8f", MapExtent.miny);
+    sprintf(crdStr, "%.8f", currentLayer->map->extent.miny);
     xmlNewChild(latLonBoxNode, NULL, BAD_CAST "south", BAD_CAST crdStr);
 
-    sprintf(crdStr, "%.8f", MapExtent.minx);
+    sprintf(crdStr, "%.8f", currentLayer->map->extent.minx);
     xmlNewChild(latLonBoxNode, NULL, BAD_CAST "west", BAD_CAST crdStr);
 
-    sprintf(crdStr, "%.8f", MapExtent.maxx);
+    sprintf(crdStr, "%.8f", currentLayer->map->extent.maxx);
     xmlNewChild(latLonBoxNode, NULL, BAD_CAST "east", BAD_CAST crdStr);
 
     xmlNewChild(latLonBoxNode, NULL, BAD_CAST "rotation", BAD_CAST "0.0");
@@ -902,9 +944,22 @@
     if (PlacemarkNode)
       flushPlacemark();
 
-    CurrentShapeDrawn = NULL;
-    CurrentShape = shape;
+    CurrentShapeIndex=-1;
+    CurrentDrawnShapeIndex = -1;
 
+    /*should be done at endshape but the plugin architecture does not call endshape yet*/
+    if(LineStyle)
+    {
+        msFree(LineStyle);
+
+        LineStyle = NULL;
+        numLineStyle = 0;
+    }
+
+    if (shape)
+    {
+        CurrentShapeIndex = shape->index;
+    }
     PlacemarkNode = NULL;
     GeomNode = NULL;
 
@@ -918,7 +973,7 @@
 
 void KmlRenderer::endShape(imageObj*, shapeObj*)
 {
-
+    CurrentShapeIndex = -1;
 }
 
 xmlNodePtr KmlRenderer::getGeomParentNode(char *geomName)
@@ -1020,17 +1075,20 @@
             <width>1</width>                   <!-- float -->
             </LineStyle>
           */
-          
-      if (currentLayer && currentLayer->opacity > 0 && currentLayer->opacity < 100 &&
-          LineStyle.color.alpha == 255)
-        LineStyle.color.alpha = MS_NINT(currentLayer->opacity*2.55);
+    
+        for (int i=0; i<numLineStyle; i++)
+        {
+            if (currentLayer && currentLayer->opacity > 0 && currentLayer->opacity < 100 &&
+                LineStyle[i].color.alpha == 255)
+              LineStyle[i].color.alpha = MS_NINT(currentLayer->opacity*2.55);
               
-      sprintf(lineHexColor,"%02x%02x%02x%02x", LineStyle.color.alpha, LineStyle.color.blue,
-              LineStyle.color.green, LineStyle.color.red);
+            sprintf(lineHexColor,"%02x%02x%02x%02x", LineStyle[i].color.alpha, LineStyle[0].color.blue,
+                    LineStyle[i].color.green, LineStyle[i].color.red);
 
-      char lineStyleName[32];
-      sprintf(lineStyleName, "_line_%s_w%.1f", lineHexColor, LineStyle.width);
-      styleName = msStringConcatenate(styleName, lineStyleName);
+            char lineStyleName[32];
+            sprintf(lineStyleName, "_line_%s_w%.1f", lineHexColor, LineStyle[i].width);
+            styleName = msStringConcatenate(styleName, lineStyleName);
+        }
     }
 
     if (SymbologyFlag[Polygon])
@@ -1125,12 +1183,17 @@
 
         if (SymbologyFlag[Line])
         {
-            xmlNodePtr lineStyleNode = xmlNewChild(styleNode, NULL, BAD_CAST "LineStyle", NULL);
-            xmlNewChild(lineStyleNode, NULL, BAD_CAST "color", BAD_CAST lineHexColor);
+            for (int i=0; i<numLineStyle; i++)
+            {
+                xmlNodePtr lineStyleNode = xmlNewChild(styleNode, NULL, BAD_CAST "LineStyle", NULL);
+                sprintf(lineHexColor,"%02x%02x%02x%02x", LineStyle[i].color.alpha, LineStyle[i].color.blue,
+                    LineStyle[i].color.green, LineStyle[i].color.red);
+                xmlNewChild(lineStyleNode, NULL, BAD_CAST "color", BAD_CAST lineHexColor);
 
-            char width[16];
-            sprintf(width, "%.1f", LineStyle.width);
-            xmlNewChild(lineStyleNode, NULL, BAD_CAST "width", BAD_CAST width);
+                char width[16];
+                sprintf(width, "%.1f", LineStyle[i].width);
+                xmlNewChild(lineStyleNode, NULL, BAD_CAST "width", BAD_CAST width);
+            }
         }
 
         if (SymbologyFlag[Symbol])
@@ -1144,7 +1207,18 @@
                 sprintf(scale, "%.1f", style->scale);
                 xmlNewChild(iconStyleNode, NULL, BAD_CAST "scale", BAD_CAST scale);*/
         }
+        else
+        {
+            const char *value=msLookupHashTable(&currentLayer->metadata, "kml_default_symbol_href");
+            if (value && strlen(value) > 0)
+            {
+                xmlNodePtr iconStyleNode = xmlNewChild(styleNode, NULL, BAD_CAST "IconStyle", NULL);
 
+                xmlNodePtr iconNode = xmlNewChild(iconStyleNode, NULL, BAD_CAST "Icon", NULL);
+                xmlNewChild(iconNode, NULL, BAD_CAST "href", BAD_CAST value);
+            }
+        }
+
         if (SymbologyFlag[Label])
         {
             xmlNodePtr labelStyleNode = xmlNewChild(styleNode, NULL, BAD_CAST "LabelStyle", NULL);
@@ -1249,8 +1323,36 @@
     return NULL;
 }
 
-int KmlRenderer::renderRasterLayer(imageObj *img)
+int KmlRenderer::renderRasterLayer(imageObj*)
 {
     return msDrawRasterLayer(currentLayer->map, currentLayer, ImgLayer);
 }
+
+void KmlRenderer::addLineStyleToList(strokeStyleObj *style)
+{
+    /*actually this is not necessary. kml only uses the last LineStyle
+      so we should not bother keeping them all*/
+    int i =0;
+    for (i=0; i<numLineStyle; i++)
+    {
+        if (style->width == LineStyle[i].width &&
+            LineStyle[i].color.alpha == style->color.alpha &&
+            LineStyle[i].color.red == style->color.red &&
+            LineStyle[i].color.green == style->color.green &&
+            LineStyle[i].color.blue == style->color.blue)
+          break;
+    }
+    if (i == numLineStyle)
+    {
+        numLineStyle++;
+        if (LineStyle == NULL)
+          LineStyle = (strokeStyleObj *)malloc(sizeof(strokeStyleObj));
+        else
+          LineStyle = (strokeStyleObj *)realloc(LineStyle, sizeof(strokeStyleObj)*numLineStyle);
+
+        memcpy(&LineStyle[numLineStyle-1], style, sizeof(strokeStyleObj));
+    }
+
+}
+
 #endif

Modified: trunk/mapserver/mapkmlrenderer.h
===================================================================
--- trunk/mapserver/mapkmlrenderer.h	2010-05-19 15:58:03 UTC (rev 10167)
+++ trunk/mapserver/mapkmlrenderer.h	2010-05-19 20:58:34 UTC (rev 10168)
@@ -63,8 +63,8 @@
 	xmlNodePtr	GeomNode;
 	xmlNodePtr	DescriptionNode;
 
-	shapeObj	*CurrentShape;
-        shapeObj        *CurrentShapeDrawn;
+	int	        CurrentShapeIndex;
+	int	        CurrentDrawnShapeIndex;
 	char		**Items;
 	int			NumItems;
 	int			DumpAttributes;
@@ -72,8 +72,9 @@
 	// placemark symbology
 	hashTableObj	*StyleHashTable;
 
-	labelStyleObj	LabelStyle;
-	strokeStyleObj	LineStyle;
+	labelStyleObj	        LabelStyle;
+	strokeStyleObj	        *LineStyle;
+        int                     numLineStyle;
 	colorObj		PolygonColor;
 
 	char			SymbolName[128];
@@ -138,6 +139,7 @@
 	xmlNodePtr getGeomParentNode(char *geomName);
         char* getLayerName(layerObj *layer);
         void processLayer(layerObj *layer);
+        void addLineStyleToList(strokeStyleObj *style);
 
 public:
 

Modified: trunk/mapserver/mapserv.c
===================================================================
--- trunk/mapserver/mapserv.c	2010-05-19 15:58:03 UTC (rev 10167)
+++ trunk/mapserver/mapserv.c	2010-05-19 20:58:34 UTC (rev 10168)
@@ -1161,7 +1161,8 @@
       }
             
       exit(0);
-    } else if( strncmp(argv[iArg], "QUERY_STRING=", 13) == 0) {
+    } else if( strncmp(argv[iArg], "QUERY_STRING=", 13) == 0 ||
+               strncmp(argv[iArg], "XMLPOST_QUERY_STRING=", 13) == 0) {
       /* Debugging hook... pass "QUERY_STRING=..." on the command-line */
       putenv( "REQUEST_METHOD=GET" );
       putenv( argv[iArg] );
@@ -1420,7 +1421,11 @@
         msIO_printf("Cache-Control: max-age=%s%c", msLookupHashTable(&(mapserv->map->web.metadata), "http_max_age"), 10);
       }
 
-      if(mapserv->sendheaders) msIO_printf("Content-type: %s%c%c", MS_IMAGE_MIME_TYPE(mapserv->map->outputformat), 10,10);
+      if(mapserv->sendheaders)  {
+        const char *attachment = msGetOutputFormatOption(mapserv->map->outputformat, "ATTACHMENT", NULL ); 
+        if(attachment) msIO_printf("Content-disposition: attachment; filename=%s\n", attachment);
+        msIO_printf("Content-type: %s%c%c", MS_IMAGE_MIME_TYPE(mapserv->map->outputformat), 10,10);
+      }
             
       if( mapserv->Mode == MAP || mapserv->Mode == TILE )
         status = msSaveImage(mapserv->map, img, NULL);
@@ -1804,7 +1809,11 @@
         img = msDrawMap(mapserv->map, MS_TRUE);
         if(!img) writeError();
 
-        if(mapserv->sendheaders) msIO_printf("Content-type: %s%c%c",MS_IMAGE_MIME_TYPE(mapserv->map->outputformat), 10,10);
+        if(mapserv->sendheaders) {
+          const char *attachment = msGetOutputFormatOption(mapserv->map->outputformat, "ATTACHMENT", NULL ); 
+          if(attachment) msIO_printf("Content-disposition: attachment; filename=%s\n", attachment);
+          msIO_printf("Content-type: %s%c%c",MS_IMAGE_MIME_TYPE(mapserv->map->outputformat), 10,10);
+         }
         status = msSaveImage(mapserv->map, img, NULL);
         if(status != MS_SUCCESS) writeError();
         msFreeImage(img);

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2010-05-19 15:58:03 UTC (rev 10167)
+++ trunk/mapserver/mapserver.h	2010-05-19 20:58:34 UTC (rev 10168)
@@ -360,6 +360,7 @@
 #define MS_RENDERER_AGG(format) ((format)->renderer == MS_RENDER_WITH_AGG)
 #define MS_RENDERER_PLUGIN(format) ((format)->renderer >= MS_RENDER_WITH_CAIRO_RASTER)
 #define MS_RENDERER_TEMPLATE(format) ((format)->renderer == MS_RENDER_WITH_TEMPLATE)
+#define MS_RENDERER_KML(format) ((format)->renderer == MS_RENDER_WITH_KML)
 
 #define MS_CELLSIZE(min,max,d) ((max - min)/(d-1)) /* where min/max are from an MapServer pixel center-to-pixel center extent */
 #define MS_OWS_CELLSIZE(min,max,d) ((max - min)/d) /* where min/max are from an OGC pixel outside edge-to-pixel outside edge extent */



More information about the mapserver-commits mailing list