Beispiel #1
0
 public void Bind(object pArgument)
 {
     if (pArgument is conditionalFunctionArguments)
     {
         conditionalFunctionArguments args = (conditionalFunctionArguments)pArgument;
         coefRs = args.CoefRaster;
         outRs  = args.OutRaster;
         myFunctionHelper.Bind(outRs);
         myFunctionHelperCoef.Bind(coefRs);
         myRasterInfo = myFunctionHelper.RasterInfo;
         myPixeltype  = myRasterInfo.PixelType;
         myValidFlag  = true;
     }
     else
     {
         throw new System.Exception("Incorrect arguments object. Expected: Conditional arguments");
     }
 }
 /// <summary>
 /// Used as an if then else statement. The condRaster raster is meant to have values of 1 or 0. If a cell within the input raster has a value 1
 /// then the cell gets the value of inRaster1's corresponding cell. Otherwise that cell gets the value of the inRaster2's corresponding cell.
 /// </summary>
 /// <param name="condRaster">string path, IRaster, IRasterDataset thats cell values are 0 or 1</param>
 /// <param name="inRaster1">string path, IRaster, IRasterDataset, or a numeric value</param>
 /// <param name="inRaster2">string path, IRaster, IRasterDataset, or a numeric value</param>
 /// <returns>IRaster</returns>
 public IFunctionRasterDataset conditionalRasterFunction(object condRaster, object trueRaster, object falseRaster)
 {
     string tempAr = funcDir + "\\" + FuncCnt + ".afr";
     IFunctionRasterDataset frDset = new FunctionRasterDatasetClass();
     IFunctionRasterDatasetName frDsetName = new FunctionRasterDatasetNameClass();
     frDsetName.FullName = tempAr;
     frDset.FullName = (IName)frDsetName;
     FunctionRasters.conditionalFunctionDataset rsFunc = new FunctionRasters.conditionalFunctionDataset();
     FunctionRasters.conditionalFunctionArguments args = new FunctionRasters.conditionalFunctionArguments(this);
     IFunctionRasterDataset conRs = createIdentityRaster(condRaster);
     if (conRs==null)
     {
         Console.WriteLine("Condition Raster must be a raster");
         return null;
     }
     IFunctionRasterDataset iR1, iR2;
     if (isNumeric(trueRaster.ToString()) && !isNumeric(falseRaster.ToString()))
     {
         iR2 = createIdentityRaster(falseRaster,rstPixelType.PT_FLOAT);
         iR1 = constantRasterFunction(conRs, System.Convert.ToDouble(trueRaster));
     }
     else if (isNumeric(falseRaster.ToString()) && !isNumeric(trueRaster.ToString()))
     {
         iR1 = createIdentityRaster(trueRaster,rstPixelType.PT_FLOAT);
         iR2 = constantRasterFunction(conRs, System.Convert.ToDouble(falseRaster));
     }
     else if (isNumeric(falseRaster.ToString()) && isNumeric(trueRaster.ToString()))
     {
         iR1 = constantRasterFunction(conRs, System.Convert.ToDouble(trueRaster));
         iR2 = constantRasterFunction(conRs, System.Convert.ToDouble(falseRaster));
     }
     else
     {
         iR1 = createIdentityRaster(trueRaster, rstPixelType.PT_FLOAT);
         iR2 = createIdentityRaster(falseRaster,rstPixelType.PT_FLOAT);
     }
     args.ConditionalRaster = conRs;
     args.TrueRaster = iR1;
     args.FalseRaster = iR2;
     frDset.Init(rsFunc, args);
     return frDset;
 }