Package org.geoserver.catalog.util

Examples of org.geoserver.catalog.util.ReaderDimensionsAccessor


            if(ci.getNativeCoverageName() != null) {
                reader = SingleGridCoverage2DReader.wrap(reader, ci.getNativeCoverageName());
            }

            // inspect dimensions
            final ReaderDimensionsAccessor ra = new ReaderDimensionsAccessor(reader);
            for (String domain : ra.getCustomDomains()) {
                if (LOGGER.isLoggable(Level.FINE)) {
                    boolean hasRange = ra.hasRange(domain);
                    boolean hasResolution = ra.hasResolution(domain);
                    LOGGER.fine(ci.getName() + ": found " + domain + " dimension (hasRange: "
                            + hasRange + ", hasResolution: " + hasResolution + ")");
                }

                DimensionInfo dimension = new DimensionInfoImpl();
View Full Code Here


            parameterDescriptors.addAll(dynamicParameters);

            //
            // TIME
            //
            ReaderDimensionsAccessor dimensions = new ReaderDimensionsAccessor(reader);
            DimensionInfo timeDimension = meta.getMetadata().get(ResourceInfo.TIME, DimensionInfo.class);
            if(timeDimension != null && timeDimension.isEnabled() && dimensions.hasTime()) {
                final List<Object> timeValues = new ArrayList<Object>();
                if (temporalSubset != null && temporalSubset.getTimePosition() != null) {
                    // grab the time positions
                    final EList timePosition = temporalSubset.getTimePosition();
                    for (Iterator it = timePosition.iterator(); it.hasNext();) {
                        TimePositionType tp = (TimePositionType) it.next();
                        Date date = (Date) tp.getValue();
                        if(date == null) {
                            date = dimensions.getMaxTime();
                        }
                        timeValues.add(date);
                    }
                    // grab the time intervals
                    final EList timePeriods = temporalSubset.getTimePeriod();
                    for (Iterator it = timePeriods.iterator(); it.hasNext();) {
                        TimePeriodType tp = (TimePeriodType) it.next();
                        Date begin = (Date) tp.getBeginPosition().getValue();
                        Date end = (Date) tp.getEndPosition().getValue();
                        timeValues.add(new DateRange(begin, end));
                    }
                }
               
                if(timeValues.isEmpty()) {
                    Date date = dimensions.getMaxTime();
                    timeValues.add(date);
                }
               
                readParameters = CoverageUtils.mergeParameter(parameterDescriptors,
                        readParameters, timeValues, "TIME", "Time");
            }
           
            //
            // ELEVATION SUPPORT VIA A SPECIFIC AXIS ELEVATION
            //
            DimensionInfo elevationDimension = meta.getMetadata().get(ResourceInfo.ELEVATION, DimensionInfo.class);
            if(elevationDimension != null && elevationDimension.isEnabled() && dimensions.hasElevation()) {
                List<Double> elevations = new ArrayList<Double>();
                // extract elevation values
                List axisSubset = null;
                if (request.getRangeSubset() != null) {
                    axisSubset = request.getRangeSubset().getAxisSubset();
                    if (axisSubset.size() > 0) {
                        for (int a = 0; a < axisSubset.size(); a++) {
                            AxisSubsetType axis = (AxisSubsetType) axisSubset.get(a);

                            String axisName = axis.getName();
                            if (axisName.equalsIgnoreCase(WCSUtils.ELEVATION)) {
                                if (axis.getSingleValue().size() > 0) {
                                    for (int s = 0; s < axis.getSingleValue().size(); s++) {
                                        elevations.add(Double.parseDouble(((TypedLiteralType) axis
                                                .getSingleValue().get(s)).getValue()));
                                    }
                                } else if (axis.getInterval().size() > 0) {
                                    IntervalType interval = (IntervalType) axis.getInterval().get(0);
                                    int min = Integer.parseInt(interval.getMin().getValue());
                                    int max = Integer.parseInt(interval.getMax().getValue());
                                    int res = (interval.getRes() != null ? Integer.parseInt(interval
                                            .getRes().getValue()) : 1);

                                    int count = (int) (Math.floor(max - min) / res + 1);
                                    for (int b = 0; b < count; b++) {
                                        elevations.add(new Double(min + b * res));
                                    }
                                }
                            }
                        }
                    }
                }
               
                if(elevations.isEmpty()) {
                    elevations.add(dimensions.getMinElevation());
                }
               
                readParameters = CoverageUtils.mergeParameter(parameterDescriptors,
                        readParameters, elevations, "ELEVATION", "Elevation");
            }
           
            //
            // CUSTOM DIMENSION SUPPORT
            //
            if (request.getRangeSubset() != null) {
                EList<?> axisSubset = request.getRangeSubset().getAxisSubset();
                final int asCount = axisSubset == null ? 0 : axisSubset.size();
                for (int i = 0; i < asCount; i++) {
                    AxisSubsetType axis = (AxisSubsetType)axisSubset.get(i);
                    String axisName = axis.getName();
                    if (!axisName.equalsIgnoreCase(WCSUtils.ELEVATION)) {
                        Object dimInfo = meta.getMetadata().get(ResourceInfo.CUSTOM_DIMENSION_PREFIX + axisName);
                        axisName = axisName.toUpperCase(); // using uppercase with imagemosaic
                        if (dimInfo instanceof DimensionInfo && dimensions.hasDomain(axisName)) {
                            int valueCount = axis.getSingleValue().size();
                            if (valueCount > 0) {
                                List<String> dimValues = new ArrayList<String>(valueCount);
                                for (int s = 0; s < valueCount; s++) {
                                    dimValues.add(((TypedLiteralType) axis
View Full Code Here

               
                if(reader == null)
                    throw new WcsException("Unable to acquire a reader for this coverage with format: " + csinfo.getFormat().getName());

                DimensionInfo timeInfo = cv.getMetadata().get(ResourceInfo.TIME, DimensionInfo.class);
                ReaderDimensionsAccessor dimensions = new ReaderDimensionsAccessor(reader);
                handleEnvelope(cv.getLatLonBoundingBox(), timeInfo, dimensions);
                handleKeywords(cv.getKeywords());

                end("wcs:CoverageOfferingBrief");
            }
View Full Code Here

                element("gml:pos", maxCP);
               
                // are we going to report time?
                DimensionInfo timeInfo = ci.getMetadata().get(ResourceInfo.TIME, DimensionInfo.class);
                if (timeInfo != null && timeInfo.isEnabled()) {
                    ReaderDimensionsAccessor dimensions = new ReaderDimensionsAccessor(reader);
                    SimpleDateFormat format = dimensions.getTimeFormat();
                    element("gml:timePosition", format.format(dimensions.getMinTime()));
                    element("gml:timePosition", format.format(dimensions.getMaxTime()));
                }

                end("wcs:lonLatEnvelope");
            }
        }
View Full Code Here

                throw new WcsException("Unable to acquire a reader for this coverage with format: "
                        + csinfo.getFormat().getName());
            }

            DimensionInfo timeInfo = ci.getMetadata().get(ResourceInfo.TIME, DimensionInfo.class);
            ReaderDimensionsAccessor dimensions = new ReaderDimensionsAccessor(reader);
            start("wcs:domainSet");
            start("wcs:spatialDomain");
            handleBoundingBox(ci.getSRS(), ci.getNativeBoundingBox(), timeInfo, dimensions);
            handleGrid(ci);
            end("wcs:spatialDomain");
View Full Code Here

                if(reader == null) {
                    throw new WcsException("Unable to acquire a reader for this coverage with format: "
                            + ci.getStore().getFormat().getName());
                }
               
                ReaderDimensionsAccessor dimensions = new ReaderDimensionsAccessor(reader);
                if (dimensions.hasElevation()) {
                    // we can only report values one at a time here, there is no interval concept
                    start("wcs:axisDescription");
                    start("wcs:AxisDescription");
                    element("wcs:name", "ELEVATION");
                    element("wcs:label", "ELEVATION");
                    start("wcs:values");
                   
                    TreeSet<Object> rawElevations = dimensions.getElevationDomain();
                    // we cannot expose ranges, so if we find them, we turn them into
                    // their mid point
                    TreeSet<Double> elevations = new TreeSet<Double>();
                    for (Object raw : rawElevations) {
                        if(raw instanceof Double) {
View Full Code Here

        }
        if (reader == null) {
            throw new ServiceException("Unable to acquire a reader for this coverage with format: "
                    + csinfo.getFormat().getName());
        }
        ReaderDimensionsAccessor dimensions = new ReaderDimensionsAccessor(reader);
       
        // Process only custom dimensions supported by the reader
        if (hasCustomDimensions) {
            for (String key : customDimensions.keySet()) {
                if (!dimensions.hasDomain(key)) customDimensions.remove(key);
            }
        }
       
        if (mode == Mode.WMS11) {
            String elevUnits = hasElevation ? elevInfo.getUnits() : "";
            String elevUnitSymbol = hasElevation ? elevInfo.getUnitSymbol() : "";
            declareWMS11Dimensions(hasTime, hasElevation, elevUnits, elevUnitSymbol, customDimensions);
        }
       

        // timeDimension
        if (hasTime && dimensions.hasTime()) {
            handleTimeDimensionRaster(cvInfo, timeInfo, dimensions);
        }

        // elevationDomain
        if (hasElevation && dimensions.hasElevation()) {
            handleElevationDimensionRaster(cvInfo, elevInfo, dimensions);
        }
       
        // custom dimensions
        if (hasCustomDimensions) {
View Full Code Here

        if (resource instanceof CoverageInfo) {
            CoverageInfo ci = (CoverageInfo) resource;
            try {
                GridCoverage2DReader reader = (GridCoverage2DReader) ci
                        .getGridCoverageReader(null, null);
                ReaderDimensionsAccessor ra = new ReaderDimensionsAccessor(reader);

                for (String domain : ra.getCustomDomains()) {
                    boolean hasRange = ra.hasRange(domain);
                    boolean hasResolution = ra.hasResolution(domain);
                    RasterDimensionModel mm = new RasterDimensionModel(metadata, domain,
                            DimensionInfo.class, hasRange, hasResolution);
                    if (mm.getObject() == null) {
                        mm.setObject(new DimensionInfoImpl());
                    }
View Full Code Here

        final ParameterValueGroup readParametersDescriptor = reader.getFormat().getReadParameters();
        CoverageInfo coverage = mapLayerInfo.getCoverage();
        MetadataMap metadata = coverage.getMetadata();
        GeneralParameterValue[] readParameters = CoverageUtils.getParameters(
                readParametersDescriptor, coverage.getParameters(), readGeom);
        ReaderDimensionsAccessor dimensions = new ReaderDimensionsAccessor(reader);
        // pass down time
        final DimensionInfo timeInfo = metadata.get(ResourceInfo.TIME, DimensionInfo.class);
        // add the descriptors for custom dimensions
        final List<GeneralParameterDescriptor> parameterDescriptors =
                new ArrayList<GeneralParameterDescriptor>(readParametersDescriptor.getDescriptor().descriptors());
        Set<ParameterDescriptor<List>> dynamicParameters = reader.getDynamicParameters();
        parameterDescriptors.addAll(dynamicParameters);
        if (timeInfo != null && timeInfo.isEnabled()) {
            // handle "default"
            List<Object> fixedTimes = new ArrayList<Object>(times);
            for (int i = 0; i < fixedTimes.size(); i++) {
                if (fixedTimes.get(i) == null) {
                    fixedTimes.set(i, getDefaultTime(coverage));
                }
            }
            // pass down the parameters
            readParameters = CoverageUtils.mergeParameter(parameterDescriptors, readParameters,
                    fixedTimes, "TIME", "Time");
        }

        // pass down elevation
        final DimensionInfo elevationInfo = metadata.get(ResourceInfo.ELEVATION,
                DimensionInfo.class);
        if (elevationInfo != null && elevationInfo.isEnabled()) {
            // handle "default"
            List<Object> fixedElevations = new ArrayList<Object>(elevations);
            for (int i = 0; i < fixedElevations.size(); i++) {
                if (fixedElevations.get(i) == null) {
                    fixedElevations.set(i, getDefaultElevation(coverage));
                }
            }
            readParameters = CoverageUtils.mergeParameter(parameterDescriptors, readParameters,
                    fixedElevations, "ELEVATION", "Elevation");
        }

        if (layerFilter != null && readParameters != null) {
            // test for default [empty is replaced with INCLUDE filter] ]filter
            for (int i = 0; i < readParameters.length; i++) {

                GeneralParameterValue param = readParameters[i];
                GeneralParameterDescriptor pd = param.getDescriptor();

                if (pd.getName().getCode().equalsIgnoreCase("FILTER")) {
                    final ParameterValue pv = (ParameterValue) pd.createValue();
                    // if something different from the default INCLUDE filter is specified
                    if (layerFilter != Filter.INCLUDE) {
                        // override the default filter
                        pv.setValue(layerFilter);
                        readParameters[i] = pv;
                    }
                    break;
                }
            }
        }
       
        // custom dimensions

        List<String> customDomains = new ArrayList(dimensions.getCustomDomains());
        for (String domain : new ArrayList<String>(customDomains)) {
            List<String> values = request.getCustomDimension(domain);
            if (values != null) {
                readParameters = CoverageUtils.mergeParameter(parameterDescriptors, readParameters,
                        values, domain);
View Full Code Here

                    reader = (GridCoverage2DReader) layer.getCoverageReader();
                } catch (IOException e) {
                    throw new ServiceException(e);
                }
                if (reader != null) {
                    ReaderDimensionsAccessor dimensions = new ReaderDimensionsAccessor(reader);
                    DimensionInfo elevationInfo = metadata.get(ResourceInfo.ELEVATION, DimensionInfo.class);
                    hasElevation |= elevationInfo != null && elevationInfo.isEnabled() && dimensions.hasElevation();
                    DimensionInfo timeInfo = metadata.get(ResourceInfo.TIME, DimensionInfo.class);
                    hasTime |= timeInfo != null && timeInfo.isEnabled() && dimensions.hasTime();
                }
            }
        }
       
        // force in the default if nothing was requested
View Full Code Here

TOP

Related Classes of org.geoserver.catalog.util.ReaderDimensionsAccessor

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.