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. There is no way to deal with multiple coverages.

 

Suppose you are working against a NetCDF file which contains several measurements like Temperature, Pressure. We can think about a different coverage for each of them.

We aim 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() {
    throw new UnsupportedOperationException("Unsupported operation.");
}

public int getGridCoverageCount() {
    throw new UnsupportedOperationException("Unsupported operation.");
}

public final GeneralEnvelope getOriginalEnvelope() {
    ...
    return new GeneralEnvelope(originalEnvelope);
originalEnvelope;
 }

public final GridEnvelope getOriginalGridRange() {
    ...
    return originalGridRange; 
}

public void testReadfinal MathTransform getOriginalGridToWorld(final PixelInCell pixInCell) {
    ...
    return mathTransform;
}

public void testSingleCoverageReader() {
    ...
    AbstractGridCoverage2DReader reader = ...;
    final GeneralEnvelope envelope = reader.getOriginalEnvelope();
    final GridEnvelope gridRange = reader.getOriginalGridRange();    
    ...
    GridCoverage2D GridCoverage2D coverage = (GridCoverage2D) reader.read(null);
    ...
}
 

...

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

public int getGridCoverageCount() {
    return coverageNames.size();
} 


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) {
    if (coverageNames.size() ...
}

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 new GeneralEnvelope(originalEnvelopemathTransform;
    }
}

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 GeneralEnvelopeMathTransform getOriginalEnvelope(getOriginalGridToWorld(final PixelInCell pixInCell, final String coverageName) {
    ...
}


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



...