001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005: package org.vfny.geoserver.wms.responses.map.svg;
006:
007: import java.io.IOException;
008: import java.io.OutputStream;
009: import java.util.logging.Logger;
010:
011: import org.vfny.geoserver.ServiceException;
012: import org.vfny.geoserver.global.Service;
013: import org.vfny.geoserver.wms.GetMapProducer;
014: import org.vfny.geoserver.wms.WmsException;
015: import org.vfny.geoserver.wms.responses.AbstractGetMapProducer;
016:
017: /**
018: * Handles a GetMap request that spects a map in SVG format.
019: *
020: * @author Gabriel Rold?n
021: * @version $Id: SVGMapProducer.java 7746 2007-11-13 15:38:35Z aaime $
022: */
023: public class SVGMapProducer extends AbstractGetMapProducer implements
024: GetMapProducer {
025: /** DOCUMENT ME! */
026: private static final Logger LOGGER = org.geotools.util.logging.Logging
027: .getLogger("org.vfny.geoserver.responses.wms.map");
028:
029: /** DOCUMENT ME! */
030: private EncodeSVG svgEncoder;
031:
032: /**
033: * DOCUMENT ME!
034: *
035: * @param gs
036: * DOCUMENT ME!
037: */
038: public void abort(Service gs) {
039: this .svgEncoder.abort();
040: }
041:
042: /**
043: * DOCUMENT ME!
044: *
045: * @param gs
046: * DOCUMENT ME!
047: *
048: * @return DOCUMENT ME!
049: */
050: public String getContentType() {
051: return SvgMapProducerFactory.MIME_TYPE;
052: }
053:
054: /**
055: * DOCUMENT ME!
056: *
057: * @return DOCUMENT ME!
058: */
059: public String getContentEncoding() {
060: return null;
061: }
062:
063: /**
064: * aborts the encoding.
065: */
066: public void abort() {
067: LOGGER.fine("aborting SVG map response");
068:
069: if (this .svgEncoder != null) {
070: LOGGER.info("aborting SVG encoder");
071: this .svgEncoder.abort();
072: }
073: }
074:
075: /**
076: * DOCUMENT ME!
077: *
078: * @param map
079: * DOCUMENT ME!
080: *
081: * @throws WmsException
082: * DOCUMENT ME!
083: */
084: public void produceMap() throws WmsException {
085: if (mapContext == null) {
086: throw new WmsException("The map context is not set");
087: }
088:
089: this .svgEncoder = new EncodeSVG(mapContext);
090: }
091:
092: /**
093: * DOCUMENT ME!
094: *
095: * @param out
096: * DOCUMENT ME!
097: *
098: * @throws ServiceException
099: * DOCUMENT ME!
100: * @throws IOException
101: * DOCUMENT ME!
102: */
103: public void writeTo(OutputStream out) throws ServiceException,
104: IOException {
105: this .svgEncoder.encode(out);
106: }
107:
108: public String getContentDisposition() {
109: // can be null
110: return null;
111: }
112: }
|