Esempio n. 1
0
        internal void AddTransitionSpatialMultiplier(TransitionSpatialMultiplier multiplier)
        {
            if (multiplier.TransitionMultiplierTypeId != this.m_TransitionMultiplierTypeId)
            {
                throw new ArgumentException("The transition multiplier type is not correct.");
            }

            this.m_TransitionSpatialMultipliers.Add(multiplier);
        }
        private double GetTransitionSpatialMultiplier(Cell cell, int transitionTypeId, int iteration, int timestep)
        {
            if (this.m_TransitionSpatialMultipliers.Count == 0)
            {
#if DEBUG
                foreach (TransitionMultiplierType tmt in this.m_TransitionMultiplierTypes)
                {
                    Debug.Assert(tmt.TransitionSpatialMultiplierMap == null);
                }
#endif

                return(1.0);
            }

            Debug.Assert(this.m_TransitionMultiplierTypes.Count > 0);

            double         Product = 1.0;
            TransitionType tt      = this.m_TransitionTypes[transitionTypeId];

            foreach (TransitionMultiplierType tmt in this.m_TransitionMultiplierTypes)
            {
                if (tmt.TransitionSpatialMultiplierMap != null)
                {
                    foreach (TransitionGroup tg in tt.TransitionGroups)
                    {
                        TransitionSpatialMultiplier tsmr = tmt.TransitionSpatialMultiplierMap.GetMultiplier(
                            tg.TransitionGroupId, iteration, timestep);

                        if (tsmr != null)
                        {
                            //Using a single instance of each uniquely named TSM raster

                            Debug.Assert(this.m_TransitionSpatialMultiplierRasters.ContainsKey(tsmr.FileName));

                            if (this.m_TransitionSpatialMultiplierRasters.ContainsKey(tsmr.FileName))
                            {
                                StochasticTimeRaster rastMult = this.m_TransitionSpatialMultiplierRasters[tsmr.FileName];
                                double spatialMult            = rastMult.DblCells[cell.CollectionIndex];

                                //Test for NODATA_VALUE

                                if (spatialMult < 0.0 | MathUtils.CompareDoublesEqual(spatialMult, rastMult.NoDataValue, double.Epsilon))
                                {
                                    spatialMult = 1.0;
                                }

                                Product *= spatialMult;
                            }
                        }
                    }
                }
            }

            return(Product);
        }