public void Update()
        {
            FireMap fm = this.Clone();

            for (int x = 1; x < Width - 1; x++)
            {
                for (int y = 1; y < Height - 1; y++)
                {
                    _firemap[x, y].Adjust(GetNeighbourhood(fm, x, y));
                }
            }
        }
        public FireMap Clone()
        {
            FireMap fm = new FireMap(Width, Height);

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    fm._firemap[x, y] = this._firemap[x, y].Clone();
                }
            }
            return(fm);
        }
Beispiel #3
0
        private void OpenButton_Click(object sender, RoutedEventArgs e)
        {
            //NationalPark
            //string burnedDataFile = @"D:\Dropbox\Personal\NASASpaceApps\data\BurnedArea.csv";
            //string fireStartPointDataFile = @"D:\Dropbox\Personal\NASASpaceApps\data\FireStartPoints.csv";
            //string VegitationDataFile = @"D:\Dropbox\Personal\NASASpaceApps\data\VegitationResources_2.csv";
            //string WaterDataFile = @"D:\Dropbox\Personal\NASASpaceApps\data\WaterResources.csv";
            //bkg = ByteArrayBitmap.FromFile(@"D:\Dropbox\Personal\NASASpaceApps\data\Bkg_Map.jpg");

            //Brisbane
            //string burnedDataFile = @"D:\Dropbox\Personal\NASASpaceApps\data\BurnedArea.csv";
            //string fireStartPointDataFile = @"D:\Dropbox\Personal\NASASpaceApps\data\FireStartPoints.csv";
            string VegitationDataFile = @"D:\Dropbox\Personal\NASASpaceApps\Brisbane\BrisbaneSmallVeg.csv";

            //string WaterDataFile = @"D:\Dropbox\Personal\NASASpaceApps\data\WaterResources.csv";
            bkg = ByteArrayBitmap.FromFile(@"D:\Dropbox\Personal\NASASpaceApps\Brisbane\SmallBrisbane.jpg");

            //int[,] waterdata = CSVReader.Read(WaterDataFile);
            int[,] VegData = CSVReader.Read(VegitationDataFile);
            //int[,] firestartData = CSVReader.Read(fireStartPointDataFile);
            //int[,] burnedData = CSVReader.Read(burnedDataFile);

            int width  = VegData.GetUpperBound(0) + 1;
            int height = VegData.GetUpperBound(1) + 1;

            firemap           = new FireMap(width, height);
            firemap.FireCells = new FireCell[width, height];

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    firemap.FireCells[x, y] = new FireCell()
                    {
                        Fuel = VegData[x, y],
                        //FireIntensity = firestartData[x, y]*255,
                        //Water = waterdata[x,y]
                    };
                }
            }

            firemap.RandomFireStarts();

            //firemap.WindXIntensity = 15;

            _image.Source = bkg.ToBitmapSource();
        }
        //public double WindXIntensity { get; set; }
        //public double WindYIntensity { get; set; }

        //private double[] GenerateWindFactor()
        //{
        //    double[] data = new double[8];
        //    data[0] = 0.5; //0, 0
        //    data[1] = 1;   //0, 1
        //    data[2] = 0.5; //0, 2

        //    data[3] = 1;   //1, 0
        //    data[4] = 1;   //1, 2

        //    data[5] = 0.5; //2, 0
        //    data[6] = 1;   //2, 1
        //    data[7] = 0.5; //2, 2
        //    return data;
        //}

        private FireCell[] GetNeighbourhood(FireMap fm, int x, int y)
        {
            FireCell[] firecells = new FireCell[]
            { fm._firemap[x - 1, y - 1],
              fm._firemap[x - 1, y],
              fm._firemap[x - 1, y + 1],
              fm._firemap[x, y - 1]
              , fm._firemap[x, y + 1],
              fm._firemap[x + 1, y - 1],
              fm._firemap[x + 1, y],
              fm._firemap[x + 1, y + 1] };
            double[] wf = GenerateWindFactor();
            for (int i = 0; i < 8; i++)
            {
                firecells[i].DirectionWeighting = wf[i];
            }

            return(firecells);
        }
Beispiel #5
0
 private void _GenerateRandomDatat(object sender, RoutedEventArgs e)
 {
     firemap       = new FireMap(200, 200, true);
     _image.Source = firemap.ToByteArrayBitmap().ToBitmapSource();
     //Start();
 }