Versions Compared

Key

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

...

Currently there is 1:1 relationship between an AbstractGridCoverage2DReader instance and a coverage. Suppose you are working against a NetCDF file which contains several measurements like AirTemperature, AirPressure which are 4D datasets (with elevation and time) and an additional SurfaceTemperature which is a 2D dataset. We can think about 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.

Moreover, we may consider changing metadata management from returning simple string to returning Object instances.

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;
    }
}

/**
 * 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(coverageName);  
    
    ...
    final ParameterValue<String> coverageNameParameter = AbstractGridFormat.COVERAGE_NAME.createValue();
    coverageNameParameter.setValue(coverageName);
    GridCoverage2D coverage = (GridCoverage2D) reader.read(new GeneralParameterValue[] {coverageNameParameter});
    ...
}

...

list the pages effected by this proposal