/* * GeoTools - The Open Source Java GIS Toolkit * http://geotools.org * * (C) 2011, Open Source Geospatial Foundation (OSGeo) * (C) 2001-2007 TOPP - www.openplans.org. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package org.geotools.process.raster.gs; import java.io.IOException; import javax.media.jai.Interpolation; import org.geotools.process.factory.DescribeParameter; import org.geotools.process.factory.DescribeProcess; import org.geotools.process.factory.DescribeResult; import org.geotools.process.gs.GSProcess; import org.geotools.coverage.grid.GridCoverage2D; import org.geotools.coverage.processing.CoverageProcessor; import org.opengis.coverage.processing.Operation; import org.opengis.parameter.ParameterValueGroup; /** * Applies a generic scale and translate operation to a coverage * * @author Andrea Aime - GeoSolutions * @author ETj <etj at geo-solutions.it> * * @source $URL$ */ @DescribeProcess(title = "scaleCoverage", description = "Applies a generic scale and translate operation to a coverage") public class ScaleCoverage implements GSProcess { private static final CoverageProcessor PROCESSOR = CoverageProcessor.getInstance(); private static final Operation SCALE = PROCESSOR.getOperation("Scale"); @DescribeResult(name = "result", description = "The scaled raster") public GridCoverage2D execute( @DescribeParameter(name = "coverage", description = "The raster to be scaled") GridCoverage2D coverage, @DescribeParameter(name = "xScale", description = "Scale factor along the x axis") double xScale, @DescribeParameter(name = "yScale", description = "Scale factor along the y axis") double yScale, @DescribeParameter(name = "xTranslate", description = "Offset along the x axis") double xTranslate, @DescribeParameter(name = "yTranslate", description = "Offset along the y axis") double yTranslate, @DescribeParameter(name = "interpolation", description = "Interpolation type", min = 0) Interpolation interpolation) throws IOException { final ParameterValueGroup param = SCALE.getParameters(); param.parameter("Source").setValue(coverage); param.parameter("xScale").setValue(xScale); param.parameter("yScale").setValue(yScale); param.parameter("xTrans").setValue(Float.valueOf(0.0f)); param.parameter("yTrans").setValue(Float.valueOf(0.0f)); if(interpolation != null) { param.parameter("Interpolation").setValue(interpolation); } return (GridCoverage2D) PROCESSOR.doOperation(param); } }