This page last changed on Jul 17, 2008 by jdeolive.

Overview

A cleanup of the Output Format apis in GeoServer.

Motivation
Proposal
Backwards Compatability
Feedback
Voting
Links

Proposed By

Justin Deoliveira

Assigned to Release

1.7.0

State

Deferred

Motivation

The output format api is one the most implemented and important extension points in GeoServer. Currently there are a number of issues with it.

Overlap Between WMS and WFS

Both WFS and WMS provide a way to plug-in output formats for GetMap,GetFeatureInfo,GetFeature, and DescribeFeatureType operations. There are a number of formats which apply to both services. Examples include KML, SVG, and OpenLayers to name a few. Currently there is no easy way to apply a single format to both services.

Format Code Integrated

All the output format code is "baked" into the wms and wfs modules. Separating out each format into its own module would have benefits. The most notable being the ability to release them as separate release artifacts. Often it is the case that a full release must be done just to release a small change to a particular output format.

Move From Delegate Pattern Confusing

In GeoServer 1.5 a new dispatch system was introduced. The dispatcher treats an output format as a regular Response instance. This forces an output format to extend Response, which has certain limitations, and is confusing.

Proposal

This proposal involves two major steps:

  1. Coming up with a new output format api
  2. Separating out current output formats into modules

OutputFormat API

The following class diagram summarizes the current state of the output format apis in GeoServer:

The following class diagram summarizes the newly proposed output format api:

OutputFormat
interface OutputFormat {

   /** Primary name of the format */
   String getName();

   /** Secondary names for the format (often used to provide a shorthand) */
   List<String> getAlias();

   /** Mime type of the format */
   String getMimeType();

   /** Content-disposition header, or null if not applicable */
   String getContentDisposition();

   /** Additional headers */
   Map<String,String> getContentHeaders();
}

The base interface for all output formats. Contains methods for getting at all the metadata for a single output format.

FeatureOutputFormat
interface FeatureOutputFormat extends OutputFormat {
  
   /** encodes a set of feature collection to a target output stream */
   void encode( FeatureCollection[] features, OutputStream output) throws IOException;

}

An output format for features or vector data. This output format is used in GetFeature, and GetFeatureInfo operations. It could possibly be used by GetMap as well, although MapOutputFormat is more applicable.

MapOutputFormat
interface MapOutputFormat extends OutputFormat {

  /** encodes a map context to a target output stream */
  void encode( WMSMapContext context, OutputStream output ) throws IOException;
}

An output format for a full map context, handling both vector and raster data, and the associated styling information. This format is used by the GetMap operation.

SchemaOutputFormat
interface MapOutputFormat extends OutputFormat {

  /** encodes a set of feature types to a target output stream */
  void encode( FeatureTypeInfo[] types, OutputStream output ) throws IOException;
}

An output format for schemas or feature types. It is used by the DescribeFeatureType operation.

Implementing

Implementing these interfaces is similar to implementing the interfaces as they live in GeoServer today. The interesting part is for output format that wish to support both Feature and Map output. For instance, consider KML:

class KMLOutputFormat implements FeatureOutputFormat, MapOutputFormat {

   void encode( FeatureCollection[] features, OutputStream output ) {
      ...
   }


   void encode( WMSMapContext context, OutputStream output ) {
      ...
   }

}

The upshot and benefit of this is that an output format can implement both interfaces, while keeping all the code in a single class.

Feedback

Backwards Compatibility

Voting

Andrea Aime:
Alessio Fabiani
Justin Deoliveira:
[~jgarnett]:
[~sfarber]:
[~roba]:

Links

[JIRA Task|]
[Email Discussion|]
[Wiki Page|]


formats2.png (image/png)
formats1.png (image/png)
Document generated by Confluence on May 14, 2014 23:00