Skip to content

Commit

Permalink
Fixed minor issue on mosaic operation
Browse files Browse the repository at this point in the history
  • Loading branch information
n-lagomarsini committed Apr 16, 2015
1 parent 83dcec0 commit 8a95746
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
Expand Up @@ -815,28 +815,24 @@ private GridCoverage2D deriveGridCoverage(final GridCoverage2D[] sources,

return properties;
}

protected void extractSources(final ParameterValueGroup parameters,
final Collection<GridCoverage2D> sources, final String[] sourceNames)
throws ParameterNotFoundException, InvalidParameterValueException {
if (!JAIExt.isJAIExtOperation(JAIExt.getOperationName(getName()))) {
super.extractSources(parameters, sources, sourceNames);
} else {
Utilities.ensureNonNull("parameters", parameters);
Utilities.ensureNonNull("sources", sources);
Utilities.ensureNonNull("parameters", parameters);
Utilities.ensureNonNull("sources", sources);

// Extraction of the sources from the parameters
Object srcCoverages = parameters.parameter("Sources").getValue();
// Extraction of the sources from the parameters
Object srcCoverages = parameters.parameter("Sources").getValue();

if (!(srcCoverages instanceof Collection) || ((Collection) srcCoverages).isEmpty()
|| !(((Collection) srcCoverages).iterator().next() instanceof GridCoverage2D)) {
throw new InvalidParameterValueException(Errors.format(
ErrorKeys.ILLEGAL_ARGUMENT_$1, "sources"), "sources", srcCoverages);
}
// Collection of the sources to use
Collection<GridCoverage2D> sourceCoverages = (Collection<GridCoverage2D>) srcCoverages;
sources.addAll(sourceCoverages);
if (!(srcCoverages instanceof Collection) || ((Collection) srcCoverages).isEmpty()
|| !(((Collection) srcCoverages).iterator().next() instanceof GridCoverage2D)) {
throw new InvalidParameterValueException(Errors.format(ErrorKeys.ILLEGAL_ARGUMENT_$1,
"sources"), "sources", srcCoverages);
}
// Collection of the sources to use
Collection<GridCoverage2D> sourceCoverages = (Collection<GridCoverage2D>) srcCoverages;
sources.addAll(sourceCoverages);
}

/**
Expand Down
Expand Up @@ -237,6 +237,17 @@ public void testMosaicSimple() {
disposeCoveragePlanarImage(mosaic);
}

// Simple test which tries to mosaic an input coverage without settings sources parameter
@Test(expected=ParameterNotFoundException.class)
public void testMosaicNoSource() {
/*
* Getting parameters
*/
ParameterValueGroup param = processor.getOperation("Mosaic").getParameters();
// Setting source0 parameter
param.parameter("source0").setValue(coverage1);
}

// Simple test which mosaics two input coverages with a different value for the output nodata
@Test
public void testMosaicWithAnotherNoData() {
Expand Down

0 comments on commit 8a95746

Please sign in to comment.