Package org.vfny.geoserver.wcs

Examples of org.vfny.geoserver.wcs.WcsException


        final String responseCRS = request.getResponseCRS();

        // - first check if the responseCRS is present on the Coverage
        // ResponseCRSs list
        if (!meta.getResponseSRS().contains(responseCRS)) {
            throw new WcsException("This Coverage does not support the requested Response-CRS.");
        }

        // - then create the Coordinate Reference System
        final CoordinateReferenceSystem targetCRS = CRS.decode(responseCRS);

        // This is the CRS of the requested Envelope
        final String requestCRS = request.getCRS();

        // - first check if the requestCRS is present on the Coverage
        // RequestCRSs list
        if (!meta.getResponseSRS().contains(requestCRS)) {
            throw new WcsException("This Coverage does not support the requested CRS.");
        }

        // - then create the Coordinate Reference System
        final CoordinateReferenceSystem sourceCRS = CRS.decode(requestCRS);

        // This is the CRS of the Coverage Envelope
        final CoordinateReferenceSystem cvCRS = ((GeneralEnvelope) coverageReader
            .getOriginalEnvelope()).getCoordinateReferenceSystem();
        final MathTransform GCCRSTodeviceCRSTransformdeviceCRSToGCCRSTransform = CRS
            .findMathTransform(cvCRS, sourceCRS, true);
        final MathTransform GCCRSTodeviceCRSTransform = CRS.findMathTransform(cvCRS, targetCRS, true);
        final MathTransform deviceCRSToGCCRSTransform = GCCRSTodeviceCRSTransformdeviceCRSToGCCRSTransform
            .inverse();

        com.vividsolutions.jts.geom.Envelope envelope = request.getEnvelope();
        GeneralEnvelope destinationEnvelope;
        final boolean lonFirst = sourceCRS.getCoordinateSystem().getAxis(0).getDirection().absolute()
                                          .equals(AxisDirection.EAST);

        // the envelope we are provided with is lon,lat always
        if (!lonFirst) {
            destinationEnvelope = new GeneralEnvelope(new double[] {
                        envelope.getMinY(), envelope.getMinX()
                    }, new double[] { envelope.getMaxY(), envelope.getMaxX() });
        } else {
            destinationEnvelope = new GeneralEnvelope(new double[] {
                        envelope.getMinX(), envelope.getMinY()
                    }, new double[] { envelope.getMaxX(), envelope.getMaxY() });
        }

        destinationEnvelope.setCoordinateReferenceSystem(sourceCRS);

        // this is the destination envelope in the coverage crs
        final GeneralEnvelope destinationEnvelopeInSourceCRS = (!deviceCRSToGCCRSTransform
            .isIdentity()) ? CRS.transform(deviceCRSToGCCRSTransform, destinationEnvelope)
                           : new GeneralEnvelope(destinationEnvelope);
        destinationEnvelopeInSourceCRS.setCoordinateReferenceSystem(cvCRS);

        /**
         * Reading Coverage on Requested Envelope
         */
        Rectangle destinationSize = null;

        if ((request.getGridLow() != null) && (request.getGridHigh() != null)) {
            final int[] lowers = new int[] {
                    request.getGridLow()[0].intValue(), request.getGridLow()[1].intValue()
                };
            final int[] highers = new int[] {
                    request.getGridHigh()[0].intValue(), request.getGridHigh()[1].intValue()
                };

            destinationSize = new Rectangle(lowers[0], lowers[1], highers[0], highers[1]);
        } else {
            /*destinationSize = coverageReader.getOriginalGridRange().toRectangle();*/
            throw new WcsException("Neither Grid Size nor Grid Resolution have been specified.");
        }

        /**
         * Checking for supported Interpolation Methods
         */
        Interpolation interpolation = Interpolation.getInstance(Interpolation.INTERP_NEAREST);
        final String interpolationType = request.getInterpolation();

        if (interpolationType != null) {
            boolean interpolationSupported = false;
            Iterator internal = meta.getInterpolationMethods().iterator();

            while (internal.hasNext()) {
                if (interpolationType.equalsIgnoreCase((String) internal.next())) {
                    interpolationSupported = true;
                }
            }

            if (!interpolationSupported) {
                throw new WcsException(
                    "The requested Interpolation method is not supported by this Coverage.");
            } else {
                if (interpolationType.equalsIgnoreCase("bilinear")) {
                    interpolation = Interpolation.getInstance(Interpolation.INTERP_BILINEAR);
                } else if (interpolationType.equalsIgnoreCase("bicubic")) {
View Full Code Here


                break;
            }
        }

        if (type == null)
            throw new WcsException("Could not understand grid type '" + value + "'",
                    InvalidParameterValue, "GridType");

        if (type == GridType.GT2dGridIn3dCrs)
            throw new WcsException("GeoServer does not support type " + type.name(),
                    InvalidParameterValue, "GridType");

        return type.getXmlConstant();
    }
View Full Code Here

    @Override
    public Object parse(String value) throws Exception {
        LayerInfo layer = catalog.getLayerByName(value);
        if (layer == null || layer.getType() != LayerInfo.Type.RASTER)
            throw new WcsException("Could not find coverage '" + value + "'",
                    InvalidParameterValue, "identifier");
        return super.parse(value);
    }
View Full Code Here

    public Object parse(String epsgCode) throws Exception {
        if (epsgCode != null) {
            try {
                CRS.decode(epsgCode);
            } catch (Exception e) {
                throw new WcsException("Invalid SRS code " + epsgCode, InvalidParameterValue, "GridBaseCRS");
            }
        }
       
        return epsgCode;
    }
View Full Code Here

    }
   
    @Override
    public Object parse(String value) throws Exception {
        if(!GridCS.GCSGrid2dSquare.getXmlConstant().equalsIgnoreCase(value))
            throw new WcsException("Unrecognized GridCS " + value, WcsExceptionCode.InvalidParameterValue, "GridCS");
       
        return GridCS.GCSGrid2dSquare.getXmlConstant();
    }
View Full Code Here

       
        // we need at least one coverage
        final String identifiersValue = (String) rawKvp.get("identifiers");
        final List identifiers = KvpUtils.readFlat(identifiersValue);
        if(identifiers == null || identifiers.size() == 0) {
            throw new WcsException("Required paramer, identifiers, missing", WcsExceptionCode.MissingParameterValue, "identifiers");
        }
       
        // all right, set into the model (note there is a mismatch between the kvp name and the
        // xml name, that's why we have to parse the identifiers by hand)
        describeCoverage.getIdentifier().addAll(identifiers);
       
       
        // if not specified, throw a resounding exception (by spec)
        if(!describeCoverage.isSetVersion())
            throw new WcsException("Version has not been specified", WcsExceptionCode.MissingParameterValue, "version");

        return request;
    }
View Full Code Here

    public Object read(Object request, Map kvp, Map rawKvp) throws Exception {
        GetCoverageType getCoverage = (GetCoverageType) super.read(request, kvp, rawKvp);

        // grab coverage info to perform further checks
        if (getCoverage.getIdentifier() == null)
            throw new WcsException("identifier parameter is mandatory", MissingParameterValue,
                    "identifier");

        // build the domain subset
        getCoverage.setDomainSubset(parseDomainSubset(kvp));
View Full Code Here

        // either bbox or timesequence must be there
        BoundingBoxType bbox = (BoundingBoxType) kvp.get("BoundingBox");
        TimeSequenceType timeSequence = (TimeSequenceType) kvp.get("TemporalSubset");
        if (timeSequence == null && bbox == null)
            throw new WcsException(
                    "Bounding box cannot be null, TimeSequence has not been specified",
                    WcsExceptionCode.MissingParameterValue, "BoundingBox");

        domainSubset.setBoundingBox(bbox);
        domainSubset.setTemporalSubset(timeSequence);
View Full Code Here

            output.setStore(store.booleanValue());

        // check and set format
        String format = (String) kvp.get("format");
        if (format == null)
            throw new WcsException("format parameter is mandatory", MissingParameterValue, "format");
        output.setFormat(format);

        // set the other gridcrs properties
        final GridCrsType gridCRS = output.getGridCRS();
        gridCRS.setGridBaseCRS((String) kvp.get("gridBaseCrs"));
View Full Code Here

    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

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.