Example #1
0
        public CFireSites(int a, int b)
        {
            m_iRows = a;
            m_iCols = b;
            //m_pFireLAND = new FIRESITE[i*j]; //commented By Qia on Nov 24 2008
            map = new FIRESITE[a * b]; //Add By Qia on Nov 24 2008
            Console.WriteLine("LandisPro fire map allocated");
            FIRESITE temp;
            int      x;

            sitetouse       = new FIRESITE();
            temp            = new FIRESITE();
            temp.FRUIndex   = 0;
            temp.DEM        = 0;
            temp.numofsites = a * b;
            SortedIndex.Add(temp);
            for (int i = 1; i <= m_iRows; i++)
            {
                for (int j = 1; j <= m_iCols; j++)
                {
                    //this->operator ()(i,j)->DEM = 0;
                    x      = (i - 1) * m_iCols;
                    x      = x + j - 1;
                    map[x] = temp;
                }
            }

            for (int i = 0; i < 70000; i++)
            {
                FireRegimeUnitsList.Add(new List <LDPOINT>());
            }
        }
Example #2
0
        public int SITE_insert(int pos_sortIndex, FIRESITE site, int i, int j)
        //when there is a new site during succession or whatever, we need to
        //check if the new site already exists, if yes combine with existing one
        //if not insert to the position according to sort
        {
            int      x;
            int      ifexist = 0;
            int      pos     = 0;
            FIRESITE temp;

            x = (i - 1) * m_iCols;
            x = x + j - 1;

            SITE_LocateinSortIndex(site, ref pos, ref ifexist);
            if (ifexist != 0)
            {
                map[x] = SortedIndex[pos];
                map[x].numofsites++;
                //delete  site;
            }
            else
            {
                temp            = new FIRESITE();
                temp.FRUIndex   = site.FRUIndex;
                temp.DEM        = site.DEM;
                temp.numofsites = 1;
                map[x]          = temp;
                //std::vector<FIRESITE*>::iterator temp_sitePtr;
                //temp_sitePtr = SortedIndex.begin();
                SortedIndex.Insert(pos, temp);
            }
            return(1);
        }
Example #3
0
        public void fillinSitePt(int i, int j, FIRESITE site)
        {
            int x;

            x      = (i - 1) * m_iCols;
            x      = x + j - 1;
            map[x] = site;
        }
Example #4
0
        public void Dispose()
        {
            //if (m_pFireLAND)
            //delete [] m_pFireLAND;  //commented By Qia on Nov 24 2008
            if (map != null)
            {
                map = null; //Add By Qia on Nov 24 2008
            }
            //<Add By Qia on Nov 24 2008>

            SortedIndex.Clear();
            //for (int i = 0; i < SortedIndex.Count; i++)
            //{
            //    FIRESITE temp;
            //    temp = SortedIndex[i];
            //    temp = null;
            //}
            //</Add By Qia on Nov 24 2008>
            sitetouse = null;
        }
Example #5
0
 public int SITE_compare(FIRESITE site1, FIRESITE site2)
 {
     if (site1.FRUIndex > site2.FRUIndex)
     {
         return(1);
     }
     if (site1.FRUIndex < site2.FRUIndex)
     {
         return(2);
     }
     if (site1.DEM > site2.DEM)
     {
         return(1);
     }
     if (site1.DEM < site2.DEM)
     {
         return(2);
     }
     return(0);
 }
Example #6
0
        public int SITE_delete(int pos_sortIndex, FIRESITE site, int i, int j)
        //When a site disappears, delete it
        {
            int x;

            x = (i - 1) * m_iCols;
            x = x + j - 1;
            if (site != SortedIndex[pos_sortIndex])
            {
                return(0);
            }
            if (site != map[x])
            {
                return(0);
            }
            site = null;
            //std::vector<FIRESITE*>::iterator temp_sitePtr;
            //temp_sitePtr = SortedIndex.begin();
            SortedIndex.RemoveAt(pos_sortIndex);
            return(1);
        }
Example #7
0
        public int SITE_LocateinSortIndex(FIRESITE site, ref int pos, ref int ifexist)
        //Find if a new site exists in sorted list
        //If a new site exists, find its location and set *ifexist as 1
        //if this no site matches this one, find location before which new site pointer should be inserted
        //By Qia Oct 09 2008
        {
            int      begin;
            int      end;
            int      mid;
            FIRESITE temp;
            int      temp_flag;

            ifexist = 0;
            begin   = 0;
            end     = SortedIndex.Count;

            if (end == 0)
            {
                Console.Write("No site at all wrong wrong wrong\n");
                return(-1);
            }

            end--;
            mid  = (begin + end) / 2;
            temp = SortedIndex[mid];

            while (begin < end)
            {
                temp_flag = SITE_compare(site, temp);
                if (temp_flag == 0)
                {
                    ifexist = 1;
                    pos     = mid;
                    return(1);
                }
                else if (temp_flag == 1)
                {
                    begin = mid + 1;
                    mid   = (begin + end) / 2;
                }
                else if (temp_flag == 2)
                {
                    end = mid - 1;
                    mid = (begin + end) / 2;
                }
                else
                {
                    return(-1);
                }
                temp = SortedIndex[mid];
            }

            temp_flag = SITE_compare(site, temp);
            if (temp_flag == 0)
            {
                ifexist = 1;
                pos     = mid;
                return(1);
            }
            else if (temp_flag == 2)
            {
                ifexist = 0;
                pos     = mid;
                return(0);
            }
            else if (temp_flag == 1)
            {
                ifexist = 0;
                pos     = mid + 1;
                return(0);
            }
            else
            {
                return(-1);
            }
        }