Package org.vfny.geoserver.wcs

Examples of org.vfny.geoserver.wcs.WcsException


    public Object parse(String value) throws Exception {
        List unparsed = KvpUtils.readFlat(value, KvpUtils.INNER_DELIMETER);

        // check to make sure that the bounding box has 4 coordinates
        if (unparsed.size() < 4) {
            throw new WcsException("Requested bounding box contains wrong"
                    + "number of coordinates (should have at least 4): " + unparsed.size(),
                    WcsExceptionCode.InvalidParameterValue, "BoundingBox");
        }

        // if it does, store them in an array of doubles
        int size = unparsed.size();
        Double[] lower = new Double[(int) Math.floor(size / 2.0)];
        Double[] upper = new Double[lower.length];

        for (int i = 0; i < lower.length; i++) {
            try {
                lower[i] = Double.parseDouble((String) unparsed.get(i));
            } catch (NumberFormatException e) {
                throw new WcsException("Bounding box coordinate is not parsable:"
                        + unparsed.get(i * 2), WcsExceptionCode.InvalidParameterValue,
                        "BoundingBox");
            }

            try {
                upper[i] = Double.parseDouble((String) unparsed.get(lower.length + i));
            } catch (NumberFormatException e) {
                throw new WcsException("Bounding box coordinate is not parsable:"
                        + unparsed.get(i * 2 + 1), WcsExceptionCode.InvalidParameterValue,
                        "BoundingBox");
            }
        }

        // check for crs
        String crsName = null;
        CoordinateReferenceSystem crs = null;
        if (unparsed.size() % 2 == 1) {
            crsName = (String) unparsed.get(unparsed.size() - 1);
            try {
                if("urn:ogc:def:crs:OGC:1.3:CRS84".equals(crsName)) {
                    crsName = "EPSG:4326";
                } else {
                    crs = CRS.decode(crsName);
                    if (crs.getCoordinateSystem().getDimension() != lower.length)
                        throw new WcsException("CRS specified has dimension "
                            + crs.getCoordinateSystem().getDimension() + " but bbox specified has "
                            + lower.length, InvalidParameterValue, "BoundingBox");
                }
            } catch (Exception e) {
                throw new WcsException("Could not recognize crs " + crsName, InvalidParameterValue,
                        "BoundingBox");
            }
        }
       
        // we do not check that lower <= higher because in the case of geographic
View Full Code Here


            String interpolationType = type.getInterpolationType();
            if(interpolationType != null) {
                try {
                    InterpolationMethod method = InterpolationMethod.valueOf(interpolationType);
                } catch(IllegalArgumentException e) {
                    throw new WcsException("Unknown interpolation method " + interpolationType, InvalidParameterValue, "RangeSubset");
                }
            }
        }
       
        return result;
View Full Code Here

                            if (selectedBands.size() == 0) {
                                throw new Exception("WRONG PARAM VALUES.");
                            }
                        }
                    } catch (Exception e) {
                        throw new WcsException("Band parameters incorrectly specified: "
                                + e.getLocalizedMessage());
                    }
                }
            }
        }
View Full Code Here

        }
       
        // compute the coverage memory usage and compare with limit
        long actual = getCoverageSize(gridRange2D, sampleModel);
        if(actual > limit) {
            throw new WcsException("This request is trying to generate too much data, " +
                    "the limit is " + formatBytes(limit) + " but the actual amount of bytes to be " +
                            "written in the output is " + formatBytes(actual));
        }
    }
View Full Code Here

       
        // compute the coverage memory usage and compare with limit
        long actual = getCoverageSize(coverage.getGridGeometry().getGridRange2D(),
                coverage.getRenderedImage().getSampleModel());
        if(actual > limit) {
            throw new WcsException("This request is trying to read too much data, " +
                    "the limit is " + formatBytes(limit) + " but the actual amount of " +
                        "bytes to be read is " + formatBytes(actual));
        }
    }
View Full Code Here

                }
               
                actual = pixels * pixelSize / 8;
            }
        } catch(Throwable t) {
            throw new WcsException("An error occurred while checking serving limits", t);
        }
       
        if(actual < 0) {
            // TODO: provide some more info about the request? It seems to be we'd have to
            // log again the full request... unless the request logger starts dumping the thread
            // id, in that case we can just refer to that and tell the admin to enable
            // the request logger to debug these issues?
            LOGGER.log(Level.INFO, "Warning, we could not estimate the amount of bytes to be " +
                    "read from the coverage source for the current request");
        }
       
        if(actual > limit) {
            throw new WcsException("This request is trying to read too much data, " +
                    "the limit is " + formatBytes(limit) + " but the actual amount of bytes " +
                        "to be read is " + formatBytes(actual));
        }
    }
View Full Code Here

            pixelSize += sm.getSampleSize(band);
        }
        long actual= pixelsNumber * pixelSize / 8; // in bytes
       
        if(actual > limit) {
            throw new WcsException("This request is trying to generate too much data, " +
                    "the limit is " + formatBytes(limit) + " but the actual amount of bytes to be " +
                            "written in the output is " + formatBytes(actual));
        }
       
    }
View Full Code Here

        // parse
        Object parsed;
        try {
            parsed = parser.parse(reader);
        } catch (Exception e) {
            throw new WcsException(
                    "Parsing failed, the xml request is most probably not compliant to the wcs 2.0.1 schema",
                    e);
        }

        return parsed;
View Full Code Here

        transformer.setIndentation(4);
        transformer.setFileReference(data.fileReference);
        try {
            transformer.transform(data.coverage, os);
        } catch (TransformerException e) {
            new WcsException(e);
        }

    }
View Full Code Here

        // 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
            // the encodings and binary files gets ruined
            MimeMessage message = new GeoServerMimeMessage();
            message.setContent(multipart);
            message.writeTo(output);
            output.flush();
        } catch (MessagingException e) {
            throw new WcsException("Error occurred while encoding the mime multipart response", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.vfny.geoserver.wcs.WcsException

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.