Exemple #1
0
outputFormatObj *msCloneOutputFormat( outputFormatObj *src )

{
  outputFormatObj *dst;
  int             i;

  dst = msAllocOutputFormat( NULL, src->name, src->driver );

  msFree( dst->mimetype );
  if( src->mimetype )
    dst->mimetype = msStrdup( src->mimetype );
  else
    dst->mimetype = NULL;

  msFree( dst->extension );
  if( src->extension )
    dst->extension = msStrdup( src->extension );
  else
    dst->extension = NULL;

  dst->imagemode = src->imagemode;
  dst->renderer = src->renderer;

  dst->transparent = src->transparent;
  dst->bands = src->bands;

  dst->numformatoptions = src->numformatoptions;
  dst->formatoptions = (char **)
                       malloc(sizeof(char *) * src->numformatoptions );

  for( i = 0; i < src->numformatoptions; i++ )
    dst->formatoptions[i] = msStrdup(src->formatoptions[i]);

  dst->inmapfile = src->inmapfile;

  return dst;
}
Exemple #2
0
outputFormatObj *msCreateDefaultOutputFormat( mapObj *map,
    const char *driver,
    const char *name )

{

  outputFormatObj *format = NULL;
  if( strncasecmp(driver,"GD/",3) == 0 ) {
    return msCreateDefaultOutputFormat( map, "AGG/PNG8", name );
  }

  if( strcasecmp(driver,"UTFGRID") == 0 ) {
    if(!name) name="utfgrid";
    format = msAllocOutputFormat( map, name, driver );
    format->mimetype = msStrdup("application/json");
    format->imagemode = MS_IMAGEMODE_RGB;
    format->extension = msStrdup("json");
    format->renderer = MS_RENDER_WITH_UTFGRID;
  }

  else if( strcasecmp(driver,"AGG/PNG") == 0 ) {
    if(!name) name="png24";
    format = msAllocOutputFormat( map, name, driver );
    format->mimetype = msStrdup("image/png");
    format->imagemode = MS_IMAGEMODE_RGB;
    format->extension = msStrdup("png");
    format->renderer = MS_RENDER_WITH_AGG;
  }

  else if( strcasecmp(driver,"AGG/PNG8") == 0 ) {
    if(!name) name="png8";
    format = msAllocOutputFormat( map, name, driver );
    format->mimetype = msStrdup("image/png; mode=8bit");
    format->imagemode = MS_IMAGEMODE_RGB;
    format->extension = msStrdup("png");
    format->renderer = MS_RENDER_WITH_AGG;
    msSetOutputFormatOption( format, "QUANTIZE_FORCE", "on");
    msSetOutputFormatOption( format, "QUANTIZE_COLORS", "256");
  }

  else if( strcasecmp(driver,"AGG/JPEG") == 0 ) {
    if(!name) name="jpeg";
    format = msAllocOutputFormat( map, name, driver );
    format->mimetype = msStrdup("image/jpeg");
    format->imagemode = MS_IMAGEMODE_RGB;
    format->extension = msStrdup("jpg");
    format->renderer = MS_RENDER_WITH_AGG;
  }

  else if( strcasecmp(driver,"AGG/MIXED") == 0 &&
           name != NULL && strcasecmp(name,"jpegpng") == 0 ) {
    format = msAllocOutputFormat( map, name, driver );
    format->mimetype = msStrdup("image/vnd.jpeg-png");
    format->imagemode = MS_IMAGEMODE_RGBA;
    format->extension = msStrdup("XXX");
    format->renderer = MS_RENDER_WITH_AGG;
    msSetOutputFormatOption( format, "OPAQUE_FORMAT", "jpeg");
    msSetOutputFormatOption( format, "TRANSPARENT_FORMAT", "png24");
  }

  else if( strcasecmp(driver,"AGG/MIXED") == 0 &&
           name != NULL && strcasecmp(name,"jpegpng8") == 0 ) {
    format = msAllocOutputFormat( map, name, driver );
    format->mimetype = msStrdup("image/vnd.jpeg-png8");
    format->imagemode = MS_IMAGEMODE_RGBA;
    format->extension = msStrdup("XXX");
    format->renderer = MS_RENDER_WITH_AGG;
    msSetOutputFormatOption( format, "OPAQUE_FORMAT", "jpeg");
    msSetOutputFormatOption( format, "TRANSPARENT_FORMAT", "png8");
  }

  else if( strcasecmp(driver,"AGG/MIXED") == 0 ) {
    if(!name) name="mixed";
    format = msAllocOutputFormat( map, name, driver );
    format->mimetype = msStrdup("image/mixed");
    format->imagemode = MS_IMAGEMODE_RGBA;
    format->extension = msStrdup("XXX");
    format->renderer = MS_RENDER_WITH_AGG;
  }

#if defined(USE_CAIRO)
  else if( strcasecmp(driver,"CAIRO/PNG") == 0 ) {
    if(!name) name="cairopng";
    format = msAllocOutputFormat( map, name, driver );
    format->mimetype = msStrdup("image/png; mode=24bit");
    format->imagemode = MS_IMAGEMODE_RGB;
    format->extension = msStrdup("png");
    format->renderer = MS_RENDER_WITH_CAIRO_RASTER;
  }
  else if( strcasecmp(driver,"CAIRO/JPEG") == 0 ) {
    if(!name) name="cairojpeg";
    format = msAllocOutputFormat( map, name, driver );
    format->mimetype = msStrdup("image/jpeg");
    format->imagemode = MS_IMAGEMODE_RGB;
    format->extension = msStrdup("jpg");
    format->renderer = MS_RENDER_WITH_CAIRO_RASTER;
  }
  else if( strcasecmp(driver,"CAIRO/PDF") == 0 ) {
    if(!name) name="pdf";
    format = msAllocOutputFormat( map, name, driver );
    format->mimetype = msStrdup("application/x-pdf");
    format->imagemode = MS_IMAGEMODE_RGB;
    format->extension = msStrdup("pdf");
    format->renderer = MS_RENDER_WITH_CAIRO_PDF;
  }
  else if( strcasecmp(driver,"CAIRO/SVG") == 0 ) {
    if(!name) name="svg";
    format = msAllocOutputFormat( map, name, driver );
    format->mimetype = msStrdup("image/svg+xml");
    format->imagemode = MS_IMAGEMODE_RGB;
    format->extension = msStrdup("svg");
    format->renderer = MS_RENDER_WITH_CAIRO_SVG;
  }
#ifdef _WIN32
  else if( strcasecmp(driver,"CAIRO/WINGDI") == 0 ) {
    if(!name) name="cairowinGDI";
    format = msAllocOutputFormat( map, name, driver );
    format->mimetype = msStrdup("");
    format->imagemode = MS_IMAGEMODE_RGB;
    format->extension = msStrdup("");
    format->renderer = MS_RENDER_WITH_CAIRO_RASTER;
  }
  else if( strcasecmp(driver,"CAIRO/WINGDIPRINT") == 0 ) {
    if(!name) name="cairowinGDIPrint";
    format = msAllocOutputFormat( map, name, driver );
    format->mimetype = msStrdup("");
    format->imagemode = MS_IMAGEMODE_RGB;
    format->extension = msStrdup("");
    format->renderer = MS_RENDER_WITH_CAIRO_RASTER;
  }
#endif
#endif

#if defined(USE_OGL)
  else if( strcasecmp(driver,"OGL/PNG") == 0 ) {
    if(!name) name="oglpng24";
    format = msAllocOutputFormat( map, name, driver );
    format->mimetype = msStrdup("image/png; mode=24bit");
    format->imagemode = MS_IMAGEMODE_RGB;
    format->extension = msStrdup("png");
    format->renderer = MS_RENDER_WITH_OGL;
  }
#endif

#if defined(USE_KML)
  else if( strcasecmp(driver,"KML") == 0 ) {
    if(!name) name="kml";
    format = msAllocOutputFormat( map, name, driver );
    format->mimetype = msStrdup("application/vnd.google-earth.kml+xml");
    format->imagemode = MS_IMAGEMODE_RGB;
    format->extension = msStrdup("kml");
    format->renderer = MS_RENDER_WITH_KML;
    msSetOutputFormatOption( format, "ATTACHMENT", "mapserver.kml");
  }
  else if( strcasecmp(driver,"KMZ") == 0 ) {
    if(!name) name="kmz";
    format = msAllocOutputFormat( map, name, driver );
    format->mimetype = msStrdup("application/vnd.google-earth.kmz");
    format->imagemode = MS_IMAGEMODE_RGB;
    format->extension = msStrdup("kmz");
    format->renderer = MS_RENDER_WITH_KML;
    msSetOutputFormatOption( format, "ATTACHMENT", "mapserver.kmz");
  }
#endif



#ifdef USE_GDAL
  else if( strncasecmp(driver,"gdal/",5) == 0 ) {
    if(!name) name=driver+5;
    format = msAllocOutputFormat( map, name, driver );
    if( msInitDefaultGDALOutputFormat( format ) == MS_FAILURE ) {
      if( map != NULL ) {
        map->numoutputformats--;
        map->outputformatlist[map->numoutputformats] = NULL;
      }

      msFreeOutputFormat( format );
      format = NULL;
    }
  }
#endif
#ifdef USE_OGR
  else if( strncasecmp(driver,"ogr/",4) == 0 ) {
    if(!name) name=driver+4;
    format = msAllocOutputFormat( map, name, driver );
    if( msInitDefaultOGROutputFormat( format ) == MS_FAILURE ) {
      if( map != NULL ) {
        map->numoutputformats--;
        map->outputformatlist[map->numoutputformats] = NULL;
      }

      msFreeOutputFormat( format );
      format = NULL;
    }
  }
#endif
  else if( strcasecmp(driver,"imagemap") == 0 ) {
    if(!name) name="imagemap";
    format = msAllocOutputFormat( map, name, driver );
    format->mimetype = msStrdup("text/html; driver=imagemap");
    format->extension = msStrdup("html");
    format->imagemode = MS_IMAGEMODE_NULL;
    format->renderer = MS_RENDER_WITH_IMAGEMAP;
  }

  else if( strcasecmp(driver,"template") == 0 ) {
    if(!name) name="template";
    format = msAllocOutputFormat( map, name, driver );
    format->mimetype = msStrdup("text/html");
    format->extension = msStrdup("html");
    format->imagemode = MS_IMAGEMODE_FEATURE;
    format->renderer = MS_RENDER_WITH_TEMPLATE;
  }

  if( format != NULL )
    format->inmapfile = MS_FALSE;


  return format;
}
Exemple #3
0
outputFormatObj *msCreateDefaultOutputFormat( mapObj *map, 
                                              const char *driver,
                                              const char *name )

{
    outputFormatObj *format = NULL;

    if( strcasecmp(driver,"GD/PC256") == 0 )
    {
#ifdef USE_GD_GIF
        return msCreateDefaultOutputFormat( map, "GD/GIF", "gif" );
#elif defined(USE_GD_PNG)
        return msCreateDefaultOutputFormat( map, "GD/PNG", "gdpng" );
#else
        return NULL;
#endif
    }

#ifdef USE_GD_GIF
    if( strcasecmp(driver,"GD/GIF") == 0 )
    {
        if(!name) name="gif";
        format = msAllocOutputFormat( map, name, driver );
        format->mimetype = msStrdup("image/gif");
        format->imagemode = MS_IMAGEMODE_PC256;
        format->extension = msStrdup("gif");
        format->renderer = MS_RENDER_WITH_GD;
    }
#endif

#ifdef USE_GD_PNG
    if( strcasecmp(driver,"GD/PNG") == 0 )
    {
        if(!name) name="gdpng";
        format = msAllocOutputFormat( map, name, driver );
        format->mimetype = msStrdup("image/png");
        format->imagemode = MS_IMAGEMODE_PC256;
        format->extension = msStrdup("png");
        format->renderer = MS_RENDER_WITH_GD;
    }
#endif /* USE_GD_PNG */

    if( strcasecmp(driver,"AGG/PNG") == 0 )
    {
        if(!name) name="png24";
        format = msAllocOutputFormat( map, name, driver );
        format->mimetype = msStrdup("image/png");
        format->imagemode = MS_IMAGEMODE_RGB;
        format->extension = msStrdup("png");
        format->renderer = MS_RENDER_WITH_AGG;
    }

    if( strcasecmp(driver,"AGG/PNG8") == 0 )
    {
        if(!name) name="png8";
        format = msAllocOutputFormat( map, name, driver );
        format->mimetype = msStrdup("image/png; mode=8bit");
        format->imagemode = MS_IMAGEMODE_RGB;
        format->extension = msStrdup("png");
        format->renderer = MS_RENDER_WITH_AGG;
        msSetOutputFormatOption( format, "QUANTIZE_FORCE", "on");
        msSetOutputFormatOption( format, "QUANTIZE_COLORS", "256");
    }
    
    if( strcasecmp(driver,"AGG/JPEG") == 0 )
    {
        if(!name) name="jpeg";
        format = msAllocOutputFormat( map, name, driver );
        format->mimetype = msStrdup("image/jpeg");
        format->imagemode = MS_IMAGEMODE_RGB;
        format->extension = msStrdup("jpg");
        format->renderer = MS_RENDER_WITH_AGG;
    }
    
#if defined(USE_CAIRO)
    if( strcasecmp(driver,"CAIRO/PNG") == 0 )
    {
        if(!name) name="cairopng";
        format = msAllocOutputFormat( map, name, driver );
        format->mimetype = msStrdup("image/png; mode=24bit");
        format->imagemode = MS_IMAGEMODE_RGB;
        format->extension = msStrdup("png");
        format->renderer = MS_RENDER_WITH_CAIRO_RASTER;
    }
    if( strcasecmp(driver,"CAIRO/JPEG") == 0 )
    {
        if(!name) name="cairojpeg";
        format = msAllocOutputFormat( map, name, driver );
        format->mimetype = msStrdup("image/jpeg");
        format->imagemode = MS_IMAGEMODE_RGB;
        format->extension = msStrdup("jpg");
        format->renderer = MS_RENDER_WITH_CAIRO_RASTER;
    }
    if( strcasecmp(driver,"CAIRO/PDF") == 0 )
    {
        if(!name) name="pdf";
        format = msAllocOutputFormat( map, name, driver );
        format->mimetype = msStrdup("application/x-pdf");
        format->imagemode = MS_IMAGEMODE_RGB;
        format->extension = msStrdup("pdf");
        format->renderer = MS_RENDER_WITH_CAIRO_PDF;
    }
    if( strcasecmp(driver,"CAIRO/SVG") == 0 )
    {
        if(!name) name="svg";
        format = msAllocOutputFormat( map, name, driver );
        format->mimetype = msStrdup("image/svg+xml");
        format->imagemode = MS_IMAGEMODE_RGB;
        format->extension = msStrdup("svg");
        format->renderer = MS_RENDER_WITH_CAIRO_SVG;
    }
#ifdef _WIN32
    if( strcasecmp(driver,"CAIRO/WINGDI") == 0 )
    {
        if(!name) name="cairowinGDI";
        format = msAllocOutputFormat( map, name, driver );
        format->mimetype = msStrdup("");
        format->imagemode = MS_IMAGEMODE_RGB;
        format->extension = msStrdup("");
        format->renderer = MS_RENDER_WITH_CAIRO_RASTER;
    }
    if( strcasecmp(driver,"CAIRO/WINGDIPRINT") == 0 )
    {
        if(!name) name="cairowinGDIPrint";
        format = msAllocOutputFormat( map, name, driver );
        format->mimetype = msStrdup("");
        format->imagemode = MS_IMAGEMODE_RGB;
        format->extension = msStrdup("");
        format->renderer = MS_RENDER_WITH_CAIRO_RASTER;
    }
#endif
#endif

#if defined(USE_OGL) 
    if( strcasecmp(driver,"OGL/PNG") == 0 ) 
    { 
        if(!name) name="oglpng24";
        format = msAllocOutputFormat( map, name, driver );
        format->mimetype = msStrdup("image/png; mode=24bit"); 
        format->imagemode = MS_IMAGEMODE_RGB; 
        format->extension = msStrdup("png"); 
        format->renderer = MS_RENDER_WITH_OGL; 
    } 
#endif 

#if defined(USE_KML) 
    if( strcasecmp(driver,"KML") == 0 ) 
    { 
        if(!name) name="kml";
        format = msAllocOutputFormat( map, name, driver );
        format->mimetype = msStrdup("application/vnd.google-earth.kml+xml"); 
        format->imagemode = MS_IMAGEMODE_RGB; 
        format->extension = msStrdup("kml"); 
        format->renderer = MS_RENDER_WITH_KML; 
        msSetOutputFormatOption( format, "ATTACHMENT", "mapserver.kml");
    } 
    if( strcasecmp(driver,"KMZ") == 0 ) 
    { 
        if(!name) name="kmz";
        format = msAllocOutputFormat( map, name, driver );
        format->mimetype = strdup("application/vnd.google-earth.kmz"); 
        format->imagemode = MS_IMAGEMODE_RGB; 
        format->extension = strdup("kmz"); 
        format->renderer = MS_RENDER_WITH_KML; 
        msSetOutputFormatOption( format, "ATTACHMENT", "mapserver.kmz");
    } 
#endif



#ifdef USE_GDAL
    if( strncasecmp(driver,"gdal/",5) == 0 )
    {
        if(!name) name=driver+5;
        format = msAllocOutputFormat( map, name, driver );
        if( msInitDefaultGDALOutputFormat( format ) == MS_FAILURE )
        {
            if( map != NULL )
            {
                map->numoutputformats--;
                map->outputformatlist[map->numoutputformats] = NULL;
            }

            msFreeOutputFormat( format );
            format = NULL;
        }
    }
#endif
#ifdef USE_OGR
    if( strncasecmp(driver,"ogr/",4) == 0 )
    {
        if(!name) name=driver+4;
        format = msAllocOutputFormat( map, name, driver );
        if( msInitDefaultOGROutputFormat( format ) == MS_FAILURE )
        {
            if( map != NULL )
            {
                map->numoutputformats--;
                map->outputformatlist[map->numoutputformats] = NULL;
            }

            msFreeOutputFormat( format );
            format = NULL;
        }
    }
#endif
    if( strcasecmp(driver,"imagemap") == 0 )
    {
        if(!name) name="imagemap";
        format = msAllocOutputFormat( map, name, driver );
        format->mimetype = msStrdup("text/html; driver=imagemap");
        format->extension = msStrdup("html");
        format->imagemode = MS_IMAGEMODE_NULL;
        format->renderer = MS_RENDER_WITH_IMAGEMAP;
    }

    if( strcasecmp(driver,"template") == 0 ) {
        if(!name) name="template";
        format = msAllocOutputFormat( map, name, driver );
        format->mimetype = msStrdup("text/html");
        format->extension = msStrdup("html");
        format->imagemode = MS_IMAGEMODE_FEATURE;
        format->renderer = MS_RENDER_WITH_TEMPLATE;
    }

    if( format != NULL )
        format->inmapfile = MS_FALSE;
    
    
    return format;
}