Exemplo n.º 1
0
        //---------------------------------------------------------------------

        public override void Run()
        {
            if (SiteLog.Enabled)
            {
                SiteLog.TimestepSetUp();
            }

            if (pauseFunction != null)
            {
                pauseFunction.PauseTimestep();
            }

            ProcessInputMap(
                delegate(Site site,
                         LandUse newLandUse)
            {
                LandUse currentLandUse = SiteVars.LandUse[site];
                string siteKey         = null;

                if (newLandUse != currentLandUse)
                {
                    SiteVars.LandUse[site] = newLandUse;
                    siteKey = string.Format("{0} --> {1}", currentLandUse.Name, newLandUse.Name);
                    if (!currentLandUse.AllowEstablishment && newLandUse.AllowEstablishment)
                    {
                        Reproduction.EnableEstablishment((ActiveSite)site);
                    }
                    else if (currentLandUse.AllowEstablishment && !newLandUse.AllowEstablishment)
                    {
                        Reproduction.PreventEstablishment((ActiveSite)site);
                    }

                    if (isDebugEnabled)
                    {
                        log.DebugFormat("    LU at {0}: {1}", site.Location, siteKey);
                    }

                    for (int i = 0; i < newLandUse.LandCoverChanges.Length; i++)
                    {
                        LandCover.IChange LandCoverChange = newLandUse.LandCoverChanges[i];
                        LandCoverChange.ApplyTo((ActiveSite)site, true);
                    }
                }
                else
                {
                    /*if (!currentLandUse.AllowEstablishment)
                     * {
                     *  Reproduction.PreventEstablishment((ActiveSite)site);
                     * }
                     * else
                     * {
                     *  Reproduction.EnableEstablishment((ActiveSite)site);
                     * }*/

                    for (int i = 0; i < currentLandUse.LandCoverChanges.Length; i++)
                    {
                        LandCover.IChange LandCoverChange = newLandUse.LandCoverChanges[i];
                        LandCoverChange.ApplyTo((ActiveSite)site, false);
                    }
                }

                if (SiteLog.Enabled)
                {
                    SiteLog.WriteTotalsFor((ActiveSite)site);
                }

                return(siteKey);
            });

            if (SiteLog.Enabled)
            {
                SiteLog.TimestepTearDown();
            }
        }