예제 #1
0
        static void Main(string[] args)
        {
            StructPixel sp;
            ClassPixel  cp;

            sp = new StructPixel(10, 20);
            cp = new ClassPixel(100, 200);
            movePixel(ref sp);
            movePixel(cp);
        }
        //---------------------------------------------------------------------
        /// <summary>
        /// Runs the component for a particular timestep.
        /// </summary>
        /// <param name="currentTime">
        /// The current model timestep.
        /// </param>
        public override void Run()
        {
            foreach (IMapDefinition map in mapDefs)
            {
                List<IForestType> forestTypes = map.ForestTypes;
                IOutputRaster<ClassPixel> newmap = CreateMap(map.Name);
                string path = newmap.Path;
                using (newmap) {
                    ClassPixel pixel = new ClassPixel();
                    foreach (Site site in modelCore.Landscape.AllSites) {
                        if (site.IsActive)
                            pixel.Band0 = CalcForestType(site,forestTypes);
                        else
                            pixel.Band0 = 0;
                        newmap.WritePixel(pixel);
                    }
                }

            }
        }
예제 #3
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Runs the component for a particular timestep.
        /// </summary>
        /// <param name="currentTime">
        /// The current model timestep.
        /// </param>
        public override void Run()
        {
            //if (SiteVars.TimeOfLastFire == null)
            //    SiteVars.ReInitialize();

            UI.WriteLine("  Re-initializing all values to zero...");
            SiteVars.FuelType.ActiveSiteValues = 0;
            SiteVars.DecidFuelType.ActiveSiteValues = 0;

            UI.WriteLine("  Calculating the Fuel Type Index for all active cells...");
            foreach (ActiveSite site in Model.Core.Landscape)  //ActiveSites
            {
                CalcFuelType(site, fuelTypes, disturbanceTypes);
                SiteVars.PercentDeadFir[site] = CalcPercentDeadFir(site);
            }

            IOutputRaster<ClassPixel> newmap = CreateMap();
            string path = newmap.Path;
            using (newmap)
            {
                ClassPixel pixel = new ClassPixel();
                foreach (Site site in Model.Core.Landscape.AllSites)
                {
                    if (site.IsActive)
                        pixel.Band0 = (byte) ((int) SiteVars.FuelType[site] + 1);
                    else
                        pixel.Band0 = 0;
                    newmap.WritePixel(pixel);
                }
            }

            IOutputRaster<ClassPixel> conmap = CreateConMap();
            string conpath = conmap.Path;
            using (conmap)
            {
                ClassPixel pixel = new ClassPixel();
                foreach (Site site in Model.Core.Landscape.AllSites)
                {
                    if (site.IsActive)
                        pixel.Band0 = (byte)((int)SiteVars.PercentConifer[site]);
                    else
                        pixel.Band0 = 0;
                    conmap.WritePixel(pixel);
                }
            }
            IOutputRaster<ClassPixel> firmap = CreateFirMap();
            string firpath = firmap.Path;
            using (firmap)
            {
                ClassPixel pixel = new ClassPixel();
                foreach (Site site in Model.Core.Landscape.AllSites)
                {
                    if (site.IsActive)
                        pixel.Band0 = (byte)((int)SiteVars.PercentDeadFir[site]);
                    else
                        pixel.Band0 = 0;
                    firmap.WritePixel(pixel);
                }
            }
        }
        //---------------------------------------------------------------------
        /// <summary>
        /// Runs the component for a particular timestep.
        /// </summary>
        /// <param name="currentTime">
        /// The current model timestep.
        /// </param>
        public override void Run()
        {
            foreach (IMapDefinition map in mapDefs)
            {
                IForestType[] forestTypes = map.ForestTypes;

                string path = MapFileNames.ReplaceTemplateVars(mapNameTemplate, map.Name, modelCore.CurrentTime);

                IOutputRaster<ClassPixel> newmap = CreateMap(path);
                using (newmap) {
                    ClassPixel pixel = new ClassPixel();
                    foreach (Site site in modelCore.Landscape.AllSites) {
                        if (site.IsActive)
                            pixel.Band0 = CalcForestType(forestTypes, site);
                        else
                            pixel.Band0 = 0;
                        newmap.WritePixel(pixel);
                    }
                }

                //Erdas74TrailerFile.Write(path, map.ForestTypes);
            }
        }
        //---------------------------------------------------------------------
        /// <summary>
        /// Runs the component for a particular timestep.
        /// </summary>
        /// <param name="currentTime">
        /// The current model timestep.
        /// </param>
        public void Run(int currentTime)
        {
            foreach (IMapDefinition map in mapDefs)
            {
                IForestType[] forestTypes = map.ForestTypes;
                IOutputRaster<ClassPixel> newmap = CreateMap(map.Name, currentTime);
                string path = newmap.Path;
                using (newmap) {
                    ClassPixel pixel = new ClassPixel();
                    foreach (Site site in Model.Landscape.AllSites) {
                        if (site.IsActive)
                            pixel.Band0 = CalcForestType(cohorts[site],
                                forestTypes);
                        else
                            pixel.Band0 = 0;
                        newmap.WritePixel(pixel);
                    }
                }

                //Erdas74TrailerFile.Write(path, map.ForestTypes);
            }

            nextTimeToRun += timestep;
        }
예제 #6
0
 static void movePixel(ClassPixel cp)
 {
     cp.x++;
     cp.y++;
 }