[mapserver-commits] r11197 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Thu Mar 17 12:15:22 EDT 2011


Author: tbonfort
Date: 2011-03-17 09:15:22 -0700 (Thu, 17 Mar 2011)
New Revision: 11197

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapoutput.c
Log:
don't allocate/initialize default outputformats until they are actually used


Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2011-03-17 15:54:29 UTC (rev 11196)
+++ trunk/mapserver/HISTORY.TXT	2011-03-17 16:15:22 UTC (rev 11197)
@@ -14,6 +14,10 @@
 Current Version (SVN trunk):
 ----------------------------
 
+- don't initialize outputformats until they are selected
+
+- use "seamless" creation of tiles for polygon fills with vector symbols
+
 - Ability to escape single/double quotes inside a string (#3706)
 
 - Globally replace msCaseFindSubstring with strcasestr (#3255)

Modified: trunk/mapserver/mapoutput.c
===================================================================
--- trunk/mapserver/mapoutput.c	2011-03-17 15:54:29 UTC (rev 11196)
+++ trunk/mapserver/mapoutput.c	2011-03-17 16:15:22 UTC (rev 11197)
@@ -89,6 +89,33 @@
 
  *************************************************************************/
 
+
+struct defaultOutputFormatEntry{
+   const char *name;
+   const char *driver;
+   const char *mimetype;
+} ;
+
+struct defaultOutputFormatEntry defaultoutputformats[] = {
+   {"png","AGG/PNG","image/png"},
+   {"jpeg","AGG/JPEG","image/jpeg"},
+   {"gif","GD/GIF","image/gif"},
+   {"png24","AGG/PNG","image/png; mode=24bit"},
+#ifdef USE_CAIRO
+   {"pdf","CAIRO/PDF","application/x-pdf"},
+   {"svg","CAIRO/SVG","image/svg+xml"},
+   {"cairopng","CAIRO/PNG","image/png"},
+#endif
+#ifdef USE_GDAL
+   {"GTiff","GDAL/GTiff","image/tiff"},
+#endif
+#ifdef USE_KML
+   {"kml","KML","application/vnd.google-earth.kml+xml"},
+   {"kmz","KMZ","application/vnd.google-earth.kmz"}
+#endif
+   {NULL,NULL,NULL}
+};
+
 /************************************************************************/
 /*                  msPostMapParseOutputFormatSetup()                   */
 /************************************************************************/
@@ -98,12 +125,9 @@
 {
     outputFormatObj *format;
 
-    /* Provide default output formats. */
-    msApplyDefaultOutputFormats( map );
-
     /* default to the first of these if IMAGETYPE not set. */
-    if( map->imagetype == NULL && map->numoutputformats > 0 )
-        map->imagetype = msStrdup(map->outputformatlist[0]->name);
+    if( map->imagetype == NULL)
+        map->imagetype = msStrdup(defaultoutputformats[0].name);
 
     /* select the current outputformat into map->outputformat */
     format = msSelectOutputFormat( map, map->imagetype );
@@ -332,8 +356,8 @@
 /*                    msApplyDefaultOutputFormats()                     */
 /************************************************************************/
 
+
 void msApplyDefaultOutputFormats( mapObj *map )
-
 {
     char *saved_imagetype;
 
@@ -342,49 +366,12 @@
     else
         saved_imagetype = msStrdup(map->imagetype);
 
-    if( msSelectOutputFormat( map, "gif" ) == NULL )
-        msCreateDefaultOutputFormat( map, "GD/GIF" );
-
-    if( msSelectOutputFormat( map, "png" ) == NULL )
-        msCreateDefaultOutputFormat( map, "GD/PNG" );
-
-    if( msSelectOutputFormat( map, "png24" ) == NULL )
-        msCreateDefaultOutputFormat( map, "AGG/PNG" );
-    
-    if( msSelectOutputFormat( map, "jpeg" ) == NULL )
-        msCreateDefaultOutputFormat( map, "AGG/JPEG" );
-
- 
-    if( msSelectOutputFormat( map, "imagemap" ) == NULL )
-        msCreateDefaultOutputFormat( map, "imagemap" );
-
-    if( msSelectOutputFormat( map, "GTiff" ) == NULL )
-        msCreateDefaultOutputFormat( map, "GDAL/GTiff" );
-
-
-#if defined(USE_CAIRO)
-    if( msSelectOutputFormat( map, "cairopng" ) == NULL )
-        msCreateDefaultOutputFormat( map, "CAIRO/PNG" );
-    if( msSelectOutputFormat( map, "cairojpeg" ) == NULL )
-        msCreateDefaultOutputFormat( map, "CAIRO/JPEG" );
-    if( msSelectOutputFormat( map, "pdf" ) == NULL )
-        msCreateDefaultOutputFormat( map, "CAIRO/PDF" );
-    if( msSelectOutputFormat( map, "svg" ) == NULL )
-        msCreateDefaultOutputFormat( map, "CAIRO/SVG" );
-#endif
-
-#if defined(USE_OGL)
-    if( msSelectOutputFormat( map, "oglpng24" ) == NULL )
-        msCreateDefaultOutputFormat( map, "OGL/PNG" );
-#endif 
-
-#if defined(USE_KML)
-    if( msSelectOutputFormat( map, "kml" ) == NULL )
-        msCreateDefaultOutputFormat( map, "kml" );
-    if( msSelectOutputFormat( map, "kmz" ) == NULL )
-        msCreateDefaultOutputFormat( map, "kmz" );
-#endif
-
+    struct defaultOutputFormatEntry *defEntry = defaultoutputformats;
+    while(defEntry->name) {
+       if( msSelectOutputFormat( map, defEntry->name ) == NULL )
+          msCreateDefaultOutputFormat( map, defEntry->driver );
+       defEntry++;
+    }
     if( map->imagetype != NULL )
         free( map->imagetype );
     map->imagetype = saved_imagetype;
@@ -566,6 +553,8 @@
 /*                        msSelectOutputFormat()                        */
 /************************************************************************/
 
+
+
 outputFormatObj *msSelectOutputFormat( mapObj *map, 
                                        const char *imagetype )
 
@@ -581,9 +570,20 @@
 /*      mime type, and then by output format name.                      */
 /* -------------------------------------------------------------------- */
     index = msGetOutputFormatIndex(map, imagetype);
-    if (index >= 0)
+    if (index >= 0) {
         format = map->outputformatlist[index];
+    } else {
+       struct defaultOutputFormatEntry *formatEntry = defaultoutputformats;
+       while(formatEntry->name) {
+          if(!strcasecmp(imagetype,formatEntry->name) || !strcasecmp(imagetype,formatEntry->mimetype)) {
+             format = msCreateDefaultOutputFormat( map, formatEntry->driver );
+             break;
+          }
+          formatEntry++;
+       }
 
+    }
+
     if (format)
     {
         if (map->imagetype)
@@ -903,7 +903,7 @@
     char **tokens = NULL;
     int numtokens = 0;
     outputFormatObj *format;
-
+    msApplyDefaultOutputFormats(map);
     format_list = msOWSLookupMetadata(&(map->web.metadata), "M","getmap_formatlist");
     if ( format_list && strlen(format_list) > 0)
       tokens = msStringSplit(format_list,  ',', &numtokens);



More information about the mapserver-commits mailing list