Package org.geotools.process.raster

Source Code of org.geotools.process.raster.AddCoveragesProcess

/*
*    GeoTools - The Open Source Java GIS Toolkit
*    http://geotools.org
*
*    (C) 2011, Open Source Geospatial Foundation (OSGeo)
*    (C) 2008-2011 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;

import org.geotools.coverage.grid.GridCoverage2D;
import org.geotools.coverage.processing.CoverageProcessor;
import org.geotools.process.ProcessException;
import org.geotools.process.factory.DescribeParameter;
import org.geotools.process.factory.DescribeProcess;
import org.geotools.process.factory.DescribeResult;
import org.opengis.coverage.processing.Operation;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.util.ProgressListener;

/**
* Add two coverages together (pixel by pixel).
* Output pixel[i][j] = source0CoveragePixel[i][j] + source1CoveragePixel[i][j]  
*
* The two coverages need to have the same envelope and same resolution (same gridGeometry).
*
* @author Daniele Romagnoli - GeoSolutions
*/
@DescribeProcess(title = "Add Coverages", description = "Returns a raster generated by pixel-by-pixel addition of two source rasters.  Source rasters must have the same bounding box and resolution.")
public class AddCoveragesProcess implements RasterProcess {

    private static final CoverageProcessor PROCESSOR = CoverageProcessor.getInstance();
    private static final Operation ADD = PROCESSOR.getOperation("Add");

    @DescribeResult(name = "result", description = "Summed rasters")
    public GridCoverage2D execute(
            @DescribeParameter(name = "coverageA", description = "First input raster") GridCoverage2D coverageA,
            @DescribeParameter(name = "coverageB", description = "Second input raster") GridCoverage2D coverageB,
            ProgressListener progressListener) throws ProcessException {
       
        // //
        //
        // Initialization: compatibility checks
        //
        // //
        BaseCoverageAlgebraProcess.checkCompatibleCoverages(coverageA, coverageB);

        // //
        //
        // Doing the Operation
        //
        // //
        final ParameterValueGroup param = ADD.getParameters();
        param.parameter("Source0").setValue(coverageA);
        param.parameter("Source1").setValue(coverageB);
        return (GridCoverage2D) PROCESSOR.doOperation(param);
    }

}
TOP

Related Classes of org.geotools.process.raster.AddCoveragesProcess

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.