Package org.geoserver.wcs2_0

Examples of org.geoserver.wcs2_0.GridCoverageRequest


        } else if (WCS20Const.V20.equals(negotiatedVersion) || WCS20Const.V201.equals(negotiatedVersion)) {
            WCS20GetCapabilitiesTransformer capsTransformer = new WCS20GetCapabilitiesTransformer(wcs.getGeoServer(), responseFactory);
            capsTransformer.setEncoding(Charset.forName((wcs.getGeoServer().getSettings().getCharset())));
            return capsTransformer;
        } else {
            throw new WCS20Exception("Internal error: Could not understand version:" + negotiatedVersion,
                    OWS20Exception.OWSExceptionCode.VersionNegotiationFailed, negotiatedVersion);
        }

    }
View Full Code Here


            String axesLabel = builder.substring(0, builder.length() - 1);
            try {
                GeneralEnvelope envelope = new GeneralEnvelope(gc2d.getEnvelope());
                handleBoundedBy(envelope, axisSwap, srsName, axesLabel, null);
            } catch (IOException ex) {
                throw new WCS20Exception(ex);
            }

            // handle domain
            builder.setLength(0);
            axesNames = GMLTransformer.this.envelopeDimensionsMapper.getAxesNames(
View Full Code Here

                }
            }

            return null;
        } catch(IOException e) {
            throw new WCS20Exception("Failed to locate the reader's " + dimensionName + " dimension descriptor", e);
        }
    }
View Full Code Here

        int base = 0;
        for (;;) {
            // search the open parenthesis
            int idxOpen = value.indexOf("(", base);
            if (idxOpen == -1) {
                throw new WCS20Exception(
                        "Invalid ScaleExtent syntax, expecting a comma separate list of axisName(min,max)*",
                        WCS20Exception.WCS20ExceptionCode.InvalidEncodingSyntax, "scaleExtent");
            }
            int idxNextOpen = value.indexOf("(", idxOpen + 1);

            // search the closed parens
            int idxClosed = value.indexOf(")", idxOpen);
            if (idxClosed == -1 || (idxNextOpen > 0 && idxClosed > idxNextOpen)) {
                throw new WCS20Exception(
                        "Invalid ScaleExtent syntax, expecting a comma separate list of axisName(min,max)*",
                        WCS20Exception.WCS20ExceptionCode.InvalidEncodingSyntax, "scaleExtent");
            }
            int idxNextClosed = value.indexOf(")", idxClosed + 1);

            // the comma between the parens (we start from base to make sure it's actually between the parens)
            int idxMid = value.indexOf(",", base);
            if (idxMid == -1 || idxMid >= idxClosed - 1 || idxMid <= idxOpen + 1) {
                throw new WCS20Exception(
                        "Invalid ScaleExtent syntax, expecting a comma separate list of axisName(min,max)*",
                        WCS20Exception.WCS20ExceptionCode.InvalidEncodingSyntax, "scaleExtent");

            }
            int idxNextMid = value.indexOf(",", idxMid + 1);
            if(idxNextMid != -1 && idxNextMid < idxClosed) {
                throw new WCS20Exception(
                        "Invalid ScaleExtent syntax, expecting a comma separate list of axisName(min,max)*",
                        WCS20Exception.WCS20ExceptionCode.InvalidEncodingSyntax, "scaleExtent");
            }

            // extract the three components
            String axisName = value.substring(base, idxOpen);
            String low = value.substring(idxOpen + 1, idxMid);
            String high = value.substring(idxMid + 1, idxClosed);

            try {
                TargetAxisExtentType te = Wcs20Factory.eINSTANCE.createTargetAxisExtentType();
                te.setAxis(axisName.trim());
                te.setLow(Double.valueOf(low));
                te.setHigh(Double.valueOf(high));
   
                se.getTargetAxisExtent().add(te);
            } catch(NumberFormatException e) {
                WCS20Exception ex = new WCS20Exception(
                        "Invalid ScaleExtent syntax, expecting a comma separate list of axisName(min,max)*",
                        WCS20Exception.WCS20ExceptionCode.InvalidEncodingSyntax, "scaleExtent");
                ex.initCause(e);
                throw ex;
            }

            // we should also have a comma after the closed parens
            int idxSeparator = value.indexOf(",", idxClosed);
            if (idxSeparator == -1) {
                if (idxClosed == value.length() - 1) {
                    return se;
                } else {
                    throw new WCS20Exception(
                            "Invalid ScaleExtent syntax, expecting a comma separate list of axisName(min,max)*",
                            WCS20Exception.WCS20ExceptionCode.InvalidEncodingSyntax, "scaleExtent");
                }
            } else {
                if(idxSeparator > idxNextClosed) {
                    throw new WCS20Exception(
                            "Invalid ScaleExtent syntax, expecting a comma separate list of axisName(min,max)*",
                            WCS20Exception.WCS20ExceptionCode.InvalidEncodingSyntax, "scaleExtent");
                }
                base = idxSeparator + 1;
            }
View Full Code Here

        //
        // get the coverage info from the catalog or throw an exception if we don't find it
        //
        final LayerInfo linfo = NCNameResourceCodec.getCoverage(catalog, request.getCoverageId());
        if(linfo == null) {
            throw new WCS20Exception("Could not locate coverage " + request.getCoverageId(),
                    WCS20Exception.WCS20ExceptionCode.NoSuchCoverage, "coverageId");
        }
        final CoverageInfo cinfo = (CoverageInfo) linfo.getResource();
        if(LOGGER.isLoggable(Level.FINE)){
            LOGGER.fine("Executing GetCoverage request on coverage :"+linfo.toString());
        }

        // === k, now start the execution
        GridCoverage coverage = null;
        try {

            // === extract all extensions for later usage
            Map<String, ExtensionItemType> extensions = extractExtensions(request);

            // === prepare the hints to use
            // here I find if I can use overviews and do subsampling
            final Hints hints = GeoTools.getDefaultHints();
            hints.add(WCSUtils.getReaderHints(wcs));
            hints.add(new RenderingHints(JAI.KEY_BORDER_EXTENDER,BorderExtender.createInstance(BorderExtender.BORDER_COPY)));
//            hints.add(new RenderingHints(JAI.KEY_REPLACE_INDEX_COLOR_MODEL,Boolean.FALSE));// TODO check interpolation

            // get a reader for this coverage
            final GridCoverage2DReader reader = (GridCoverage2DReader) cinfo.getGridCoverageReader(
                    new DefaultProgressListener(),
                    hints);

            WCSDimensionsSubsetHelper helper = parseGridCoverageRequest(cinfo, reader, request, extensions);
            GridCoverageRequest gcr = helper.getGridCoverageRequest();

            //TODO consider dealing with the Format instance instead of a String parsing or check against WCSUtils.isSupportedMDOutputFormat(String).
            final GridCoverageFactory coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(hints);
            if (reader instanceof StructuredGridCoverage2DReader && formatSupportMDOutput(request.getFormat())) {
                // Split the main request into a List of requests in order to read more coverages to be stacked
                final Set<GridCoverageRequest> requests = helper.splitRequestToSet();
                if (requests == null || requests.isEmpty()) {
                    throw new IllegalArgumentException("Splitting requests returned nothing");
                } else {
                    if (LOGGER.isLoggable(Level.FINE)) {
                        LOGGER.fine("Splitting request generated " + requests.size() + " sub requests");
                    }
                }
                final List<DimensionBean> dimensions = helper.setupDimensions();
                final String nativeName = cinfo.getNativeCoverageName();
                final String coverageName = nativeName != null ? nativeName : reader.getGridCoverageNames()[0];
                final GranuleStackImpl stack = new GranuleStackImpl(coverageName, reader.getCoordinateReferenceSystem(), dimensions);
                // Geoserver max memory limit definition
                long outputLimit = wcs.getMaxOutputMemory() * 1024;
                long inputLimit = wcs.getMaxInputMemory() * 1024;
                // Object value used for storing the sum of the output size of each internal coverage
                ImageSizeRecorder incrementalOutputSize=new ImageSizeRecorder(outputLimit,false);
                // Object used for storing the sum of the output size of each internal coverage
                ImageSizeRecorder incrementalInputSize=new ImageSizeRecorder(inputLimit,true);
                // Image size estimation
                final int numRequests = requests.size();
                final Iterator<GridCoverageRequest> requestsIterator = requests.iterator();
                GridCoverageRequest firstRequest = requestsIterator.next();
                GridCoverage2D firstCoverage = setupCoverage(helper, firstRequest, request, reader, hints, extensions, dimensions,
                        incrementalOutputSize, incrementalInputSize, coverageFactory);
                // check the first coverage memory usage
                long actual = incrementalInputSize.finalSize();
                // Estimated size
                long estimatedSize = actual*numRequests;
                //Check if the estimated size is greater than that of the maximum output memory
                // Limit check is performed only when the limit is defined
                if(outputLimit > 0 && estimatedSize > outputLimit){
                    throw new WcsException("This request is trying to generate too much data, " +
                            "the limit is " + formatBytes(outputLimit) + " but the estimated amount of bytes to be " +
                                    "written in the output is " + formatBytes(estimatedSize));
                }
                // If the estimated size does not exceed the limit, the first coverage is added to the GranuleStack
                stack.addCoverage(firstCoverage);

                // Get a coverage for each subrequest
                while (requestsIterator.hasNext()) {
                    GridCoverageRequest subRequest = requestsIterator.next();
                    GridCoverage2D singleCoverage = setupCoverage(helper, subRequest, request, reader, hints, extensions, dimensions,
                            incrementalOutputSize, incrementalInputSize, coverageFactory);
                    stack.addCoverage(singleCoverage);
                }
                coverage = stack;
            } else {
                // IncrementalSize not used
                coverage = setupCoverage(helper, gcr, request, reader, hints, extensions, null, null, null, coverageFactory);
            }
        } catch(ServiceException e) {
            throw e;
        } catch(Exception e) {
            throw new WCS20Exception("Failed to read the coverage " + request.getCoverageId(), e);
        } finally {
            // make sure the coverage will get cleaned at the end of the processing
            if (coverage != null) {
                CoverageCleanerCallback.addCoverages(coverage);
            }
View Full Code Here

        if (extensionItem.getName().equals(WCS20Const.OVERVIEW_POLICY_EXTENSION)) {
            String overviewPolicy = extensionItem.getSimpleContent();

            // checks
            if (overviewPolicy == null) {
                throw new WCS20Exception(WCS20Const.OVERVIEW_POLICY_EXTENSION + " was null", WCS20ExceptionCode.MissingParameterValue,
                        "null");
            }

            // instantiate the OverviewPolicy
            try {
                return OverviewPolicy.valueOf(overviewPolicy);
            } catch (Exception e) {
                final WCS20Exception exception = new WCS20Exception("Invalid " + WCS20Const.OVERVIEW_POLICY_EXTENSION,
                        WCS20Exception.WCS20ExceptionCode.InvalidParameterValue, overviewPolicy);
                exception.initCause(e);
                throw exception;
            }
        }
        return null;
    }
View Full Code Here

            // get URI
            String crsName = extensionItem.getSimpleContent();

            // checks
            if (crsName == null) {
                throw new WCS20Exception(identifier+" was null",
                        WCS20ExceptionCode.NotACrs, "null");
            }

            // instantiate
            try {
                return lonLatCRSFactory.createCoordinateReferenceSystem(crsName);
            } catch (Exception e) {
                final WCS20Exception exception = new WCS20Exception("Invalid "+identifier,
                        isOutputCRS?WCS20Exception.WCS20ExceptionCode.OutputCrsNotSupported:WCS20Exception.WCS20ExceptionCode.SubsettingCrsNotSupported,
                                crsName);
                exception.initCause(e);
                throw exception;
            }       

        }
       
View Full Code Here

        if(extension!=null){
            final EList<ExtensionItemType> extensions = extension.getContents();
            for (final ExtensionItemType extensionItem : extensions) {
                final String extensionName = extensionItem.getName();
                if (extensionName == null || extensionName.length() <= 0) {
                    throw new WCS20Exception("Null extension");
                }
                if(LOGGER.isLoggable(Level.FINE)){
                    LOGGER.fine("Parsing extension "+extensionName);
                }               
                if (extensionName.equals("subsettingCrs")) {
View Full Code Here

                final String axisLabel = (index >= 0 ? axis.substring(index+1, axis.length())
                        : axis);
               
                // did we already set this interpolation?
                if(foundAxes.contains(axisLabel)){
                    throw new WCS20Exception("Duplicated axis",WCS20Exception.WCS20ExceptionCode.InvalidAxisLabel,axisLabel);
                }
                foundAxes.add(axisLabel);
               
                // do we have this axis?
                if(!returnValue.containsKey(axisLabel)){
                    throw new WCS20Exception("Invalid axes URI",WCS20Exception.WCS20ExceptionCode.NoSuchAxis,axisLabel);
                }
                returnValue.put(axisLabel, policy);
            }
        }
       
        // final checks, we dont' supported different interpolations on Long and Lat
        InterpolationPolicy lat=null,lon=null;
        if(returnValue.containsKey("Long")){
            lon=returnValue.get("Long");
        }
        if(returnValue.containsKey("Lat")){
            lat=returnValue.get("Lat");
        }
        if(lat!=lon){
            throw new WCS20Exception("We don't support different interpolations on Lat,Lon", WCS20Exception.WCS20ExceptionCode.InterpolationMethodNotSupported,"");
        }
        returnValue.get("Lat");
        return returnValue;
    }
View Full Code Here

            if(rangeComponent==null){
                final RangeIntervalType rangeInterval = rangeItem.getRangeInterval();
                final String startRangeComponent=rangeInterval.getStartComponent();    
                final String endRangeComponent=rangeInterval.getEndComponent();
                if(!bandsNames.contains(startRangeComponent)){
                    throw new WCS20Exception("Invalid Band Name",WCS20Exception.WCS20ExceptionCode.NoSuchField,rangeComponent);
                }
                if(!bandsNames.contains(endRangeComponent)){
                    throw new WCS20Exception("Invalid Band Name",WCS20Exception.WCS20ExceptionCode.NoSuchField,rangeComponent);
                }               
               
                // loop
                boolean add=false;
                for(SampleDimension sd: bands){
                    if(sd instanceof GridSampleDimension){
                        final GridSampleDimension band=(GridSampleDimension) sd;
                        final String name=band.getDescription().toString();
                        if(name.equals(startRangeComponent)){
                            returnValue.add(startRangeComponent);
                            add=true;
                        } else if(name.equals(endRangeComponent)){
                            returnValue.add(endRangeComponent);
                            add=false;
                        } else if(add){
                            returnValue.add(name);
                        }
                    }
                }
                // paranoiac check add a false
                if(add){
                    throw new IllegalStateException("Unable to close range in band identifiers");
                }
            } else {
                if(bandsNames.contains(rangeComponent)){
                    returnValue.add(rangeComponent);
                } else {
                    throw new WCS20Exception("Invalid Band Name",WCS20Exception.WCS20ExceptionCode.NoSuchField,rangeComponent);
                }
            }
        }
  
        // kk now let's see what we got to do
View Full Code Here

TOP

Related Classes of org.geoserver.wcs2_0.GridCoverageRequest

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.