Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Description

As quoted from their the Javadoc, GridCoverageReader interface is intended to

read GridCoverages from the input stream in a sequential order .

Base class implementing GridCoverageReader is AbstractGridCoverage2DReader.

 

Currently there is 1:1 relationship between an AbstractGridCoverage2DReader instance and a coverage. There is no way to deal with multiple coverages.

 

Suppose you are working against a NetCDF file which contains several measurements like Temperature, PressureAirTemperature, AirPressure which are 4D datasets (with elevation and time) and an additional SurfaceTemperature which is a 2D dataset. We can think about a different coverage for each of them.We aim 3 different coverages. Currently, there is no way to deal with multiple coverages stored in the same file.

I propose to deprecate AbstractGridCoverage2DReader in favor of a new AbstractGridCoverageReader which preserves current methods for simpler readers (which allow to access single coverages) but which allows to get geospatial context (like GridEnvelope, GridRange, GridToWorld transformation, CoordinateReferenceSystem) and read access capabilities by coverage name. Current geospatial context getter method won't be changed to grant backward compatibility.

 

 

 

Status

This proposal is under construction.

...

Code Block
public String[] listSubNames() {
    return coverageNames;
}

public int getGridCoverageCount() {
    return coveragesNumber;
} 

public final GeneralEnvelope getOriginalEnvelope() {
    if (coveragesNumber > 1) {
        throw new IllegalArgumentException("You must specify a coverage name");
    } else { 
        // Backward compatibility
        ...
        return originalEnvelope;
    }
}
 
/**
 * Get the envelope of the specified coverage 
 */
public final GeneralEnvelope getOriginalEnvelope(final String coverageName) {
    ...
}

public final GridEnvelope getOriginalGridRange() {
    if (coveragesNumber > 1) {
        throw new IllegalArgumentException("You must specify a coverage name");
    } else { 
        // Backward compatibility
        ...
        return originalGridRange; 
    }
}

/**
 * Get the gridRange of the specified coverage 
 */
public final GridEnvelope getOriginalGridRange(final String coverageName) {
    ...
}

public final MathTransform getOriginalGridToWorld(final PixelInCell pixInCell) {
    if (coveragesNumber > 1) {
        throw new IllegalArgumentException("You must specify a coverage name");
    } else { 
        // Backward compatibility
        ...
        return mathTransform;
    }
}

public final MathTransform getOriginalGridToWorld(final PixelInCell pixInCell) {
    if (coveragesNumber > 1) {
        throw new IllegalArgumentException("You must specify a coverage name");
    } else { 
        // Backward compatibility
        ...
        return mathTransform;
    }
}

/**
 * Get the grid to world transformation of the specified coverage 
 */
public final MathTransform getOriginalGridToWorld(final PixelInCell pixInCell, final String coverageName) {
    ...
}


public void testMultipleCoverageReader() {
    ...
    AbstractGridCoverageReader reader = ...;
    String coverageName = "temperature";
    final GeneralEnvelope envelope = reader.getOriginalEnvelope(coverageName);
    final GridEnvelope gridRange = reader.getOriginalGridRange();  
    
    ...
    final ParameterValue<String> coverageNameParameter = ggAbstractGridFormatAbstractGridFormat.COVERAGE_NAME.createValue();
    coverageNameParameter.setValue(coverageName);
    GridCoverage2D coverage = (GridCoverage2D) reader.read(new GeneralParameterValue[] {coverageNameParameter});
    ...
}

AbstractGridFormat

AFTER:

Code Block
public static final DefaultParameterDescriptor<String> COVERAGE_NAME = new DefaultParameterDescriptor<String>(SUGGESTED_TILESIZE, String.class, null, null); 

 

Documentation Changes

list the pages effected by this proposal

...