Package org.geoserver.wcs.responses

Examples of org.geoserver.wcs.responses.CoverageResponseDelegate


        for (Iterator it = supportedFormats.iterator(); it.hasNext();) {
            String sf = (String) it.next();
            if (sf.equalsIgnoreCase(format)) {
                return sf;
            } else {
                CoverageResponseDelegate delegate = responseFactory.encoderFor(sf);
                if (delegate != null && delegate.canProduce(format))
                    return sf;
            }
        }
        return null;
    }
View Full Code Here


        GridCoverage[] coverages = (GridCoverage[]) value;

        // grab the delegate for coverage encoding
        GetCoverageType request = (GetCoverageType) operation.getParameters()[0];
        String outputFormat = request.getOutput().getFormat();
        CoverageResponseDelegate delegate = responseFactory.encoderFor(outputFormat);
        if (delegate == null)
            throw new WcsException("Could not find encoder for output format " + outputFormat);

        // grab the coverage info for Coverages document encoding
        final GridCoverage2D coverage = (GridCoverage2D) coverages[0];
        CoverageInfo coverageInfo = catalog.getCoverageByName(request.getIdentifier().getValue());

        // use javamail classes to actually encode the document
        try {
            // coverages xml structure (always set the headers after the data
            // handlers, setting
            // the data handlers kills some of them)
            BodyPart coveragesPart = new MimeBodyPart();
            final CoveragesData coveragesData = new CoveragesData(coverageInfo, request);
            coveragesPart.setDataHandler(new DataHandler(coveragesData, "geoserver/coverages11"));
            coveragesPart.setHeader("Content-ID", "<urn:ogc:wcs:1.1:coverages>");
            coveragesPart.setHeader("Content-Type", "text/xml");
            multipart.addBodyPart(coveragesPart);

            // the actual coverage
            BodyPart coveragePart = new MimeBodyPart();
            CoverageEncoder encoder = new CoverageEncoder(delegate, coverage, outputFormat, new HashMap<String, String>());
            coveragePart.setDataHandler(new DataHandler(encoder, "geoserver/coverageDelegate"));
            coveragePart.setHeader("Content-ID", "<theCoverage>");
            coveragePart.setHeader("Content-Type", delegate.getMimeType(outputFormat));
            coveragePart.setHeader("Content-Transfer-Encoding", "base64");
            multipart.addBodyPart(coveragePart);

            // write out the multipart (we need to use mime message trying to
            // encode directly with multipart or BodyPart does not set properly
View Full Code Here

                encodingParameters.put(ext.getName(), ext.getSimpleContent());
            }
        }

        // grab the delegate
        CoverageResponseDelegate delegate = responseFactory.encoderFor(format);

        // use javamail classes to actually encode the document
        try {
            MimeMultipart multipart = new MimeMultipart();
            multipart.setSubType("related");
           
            String fileName = "/coverages/" + getCoverage.getCoverageId() + "." + delegate.getFileExtension(format);
           
            // coverages xml structure, which is very close to the DescribeFeatureType output
            BodyPart coveragesPart = new MimeBodyPart();
            FileReference reference = new FileReference(fileName, delegate.getMimeType(format), delegate.getConformanceClass(format));
            final CoverageData coveragesData = new CoverageData(coverage, reference, envelopeDimensionsMapper);
            coveragesPart.setDataHandler(new DataHandler(coveragesData, "geoserver/coverages20"));
            coveragesPart.setHeader("Content-ID", "wcs");
            coveragesPart.setHeader("Content-Type", "application/gml+xml");
            multipart.addBodyPart(coveragesPart);

            // the actual coverage
            BodyPart coveragePart = new MimeBodyPart();
            CoverageEncoder encoder = new CoverageEncoder(delegate, coverage, format, encodingParameters);
            coveragePart.setDataHandler(new DataHandler(encoder, "geoserver/coverageDelegate"));
            coveragePart.setHeader("Content-ID", fileName);
            coveragePart.setHeader("Content-Type", delegate.getMimeType(format));
            coveragePart.setHeader("Content-Transfer-Encoding", "binary");
            multipart.addBodyPart(coveragePart);

            // write out the multipart (we need to use mime message trying to
            // encode directly with multipart or BodyPart does not set properly
View Full Code Here

        GridCoverage[] coverages = (GridCoverage[]) value;

        // grab the delegate for coverage encoding
        GetCoverageType request = (GetCoverageType) operation.getParameters()[0];
        String outputFormat = request.getOutput().getFormat();
        CoverageResponseDelegate delegate = responseFactory.encoderFor(outputFormat);
        if (delegate == null)
            throw new WcsException("Could not find encoder for output format " + outputFormat);

        // grab the coverage info for Coverages document encoding
        final GridCoverage2D coverage = (GridCoverage2D) coverages[0];
        CoverageInfo coverageInfo = catalog.getCoverageByName(request.getIdentifier().getValue());
       
        // write the coverage to temporary storage in the data dir
        File wcsStore = null;
        try {
            GeoServerResourceLoader loader = geoServer.getCatalog().getResourceLoader();
            Resource wcs = loader.get("temp/wcs");
            wcsStore = wcs.dir();
//            File temp = GeoserverDataDirectory.findCreateConfigDir("temp");
//            wcsStore = new File(temp, "wcs");
//            if(!wcsStore.exists())
//                wcsStore.mkdir();
        } catch(Exception e) {
            throw new WcsException("Could not create the temporary storage directory for WCS");
        }
       
        // Make sure we create a file name that's not already there (even if splitting the same nanosecond
        // with two requests should not ever happen...)
        File coverageFile = null;
        while(true) {
            // TODO: find a way to get good extensions
            coverageFile = new File(wcsStore, coverageInfo.getName().replace(':', '_') + "_" + System.nanoTime() + "." + delegate.getFileExtension(outputFormat));
            if(!coverageFile.exists())
                break;
        }
      
        // store the coverage
        OutputStream os = null;
        try {
            os = new BufferedOutputStream(new FileOutputStream(coverageFile));
            delegate.encode(coverage, outputFormat,Collections.EMPTY_MAP, os);
            os.flush();
        } finally {
            if(os != null) os.close();
        }
        System.out.println(coverageFile);
View Full Code Here

        GetCoverageType getCoverage = (GetCoverageType) operation.getParameters()[0];
        String format = getCoverage.getFormat();
        if (format == null) {
            return "image/tiff";
        } else {
            CoverageResponseDelegate delegate = responseFactory.encoderFor(format);
            if (delegate == null) {
                throw new WCS20Exception("Unsupported format " + format,
                        OWSExceptionCode.InvalidParameterValue, "format");
            } else {
                return format;
View Full Code Here

            }           
        }


        // grab the delegate
        CoverageResponseDelegate delegate = responseFactory.encoderFor(format);
       
        delegate.encode(coverage, format,encodingParameters, output);
    }
View Full Code Here

        if (format == null) {
            format = "image/tiff";
        }
       
        // grab the delegate and thus the extension
        CoverageResponseDelegate delegate = responseFactory.encoderFor(format);
        String extension = delegate.getFileExtension(format);
       
        // collect the name of the coverages that have been requested
        return getCoverage.getCoverageId() + "." + extension;
    }
View Full Code Here

     *
     */
    private MIMETypeMapper(CoverageResponseDelegateFinder finder, Catalog catalog) {
        // collect all of the output mime types
        for (String of : finder.getOutputFormats()) {
            CoverageResponseDelegate delegate = finder.encoderFor(of);
            String mime = delegate.getMimeType(of);
            outputMimeTypes.add(mime);
        }
        catalog.addListener(new MimeTypeCacheClearingListener());
    }
View Full Code Here

        // the configured list
        for (String sf : supportedFormats) {
            if (sf.equalsIgnoreCase(format.trim())) {
                return sf;
            } else {
                CoverageResponseDelegate delegate = responseFactory.encoderFor(sf);
                if (delegate != null && delegate.canProduce(format))
                    return sf;
            }
        }
        return null;
    }
View Full Code Here

            end("GetCoverage");
        }

        private void handleOutput(GetCoverageRequest request) {
            String format = request.outputFormat;
            final CoverageResponseDelegate encoder = responseFactory.encoderFor(format);
            String mime = encoder.getMimeType(request.outputFormat);
            start("Output", attributes("store", "true", "format", mime));
            if (request.targetCRS != null) {
                start("GridCRS");
                element("GridBaseCRS", epsgUrnCode(request.targetCRS));
                AffineTransform at = request.targetGridToWorld;
View Full Code Here

TOP

Related Classes of org.geoserver.wcs.responses.CoverageResponseDelegate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.