示例#1
0
 protected HomeRangeFinder()
 {
     this.rn = RandomNumbers.getInstance();
     this.myDataManipulator = new DataManipulator();
     this.fileNameIndex     = 0;
     this.myMapManager      = MapManager.GetUniqueInstance();
     this.siteList          = new List <EligibleHomeSite>();
 }
 protected HomeRangeFinder()
 {
     this.buildLogger();
     rn = RandomNumbers.getInstance();
     this.myDataManipulator       = new DataManipulator();
     myAvailableAreaFileName      = @"\tempAvailable";
     myAvailableAreaFileExtension = ".shp";
     fileNameIndex = 0;
 }
示例#3
0
        public string BuildHomeRange(Animal inAnimal, string currSocialFileName)
        {
            myDataManipulator = new DataManipulator();
            string   returnVal     = "";
            double   minArea       = 0;
            double   stretchFactor = 1.0;
            int      index         = 0;
            IPolygon tempPoly      = null;
            string   path          = String.Empty;

            try
            {
                mLog.Debug("inside BuildHomeRange for George number " + inAnimal.IdNum.ToString());
                mLog.Debug("the current social map is " + currSocialFileName);
                if (String.IsNullOrEmpty(inAnimal.MapManager.getAnimalMapName(inAnimal.IdNum)))
                {
                    path = inAnimal.MapManager.OutMapPath;
                }
                else
                {
                    path = System.IO.Path.GetDirectoryName(inAnimal.MapManager.getAnimalMapName(inAnimal.IdNum));
                }


                mLog.Debug("path value is " + path);
                while (minArea < inAnimal.HomeRangeCriteria.Area && returnVal != "No Home Found" && stretchFactor <= 2.0)
                {
                    mLog.Debug("inside loop for making the polygon with a stretch factor of " + stretchFactor.ToString());
                    this.buildPathNames(path, index.ToString());
                    mLog.Debug("going to call buildHomeRangePolygon with a stretch factor of " + stretchFactor.ToString());
                    tempPoly = this.buildHomeRangePolygon(inAnimal, stretchFactor);
                    mLog.Debug("is temp poly null = " + (tempPoly == null).ToString());
                    mLog.Debug("now add it to a feature class");
                    this.myDataManipulator.AddHomeRangePolyGon(homeRangeFileName, tempPoly);
                    mLog.Debug("now clip it against the current social map");
                    this.myDataManipulator.Clip(currSocialFileName, homeRangeFileName, clipPath);
                    mLog.Debug("now get all the good polygons from the clip to meassure the area");//HACK
                    IFeatureClass fc  = this.myDataManipulator.GetSuitablePolygons(clipPath, inAnimal.Sex, availablePolygonsFileName);
                    IFeatureClass fc2 = this.myDataManipulator.DissolveBySexAndReturn(fc, this.dissolveHomeRangePolygon, inAnimal.Sex);
                    if (fc2 != null)
                    {
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(fc);
                        minArea = this.getArea(fc2);
                        mLog.Debug("ok we have " + minArea.ToString() + " and George needs " + inAnimal.HomeRangeCriteria.Area.ToString());
                        MapManager.RemoveFiles(homeRangeFileName);
                        index++;
                        if (minArea < inAnimal.HomeRangeCriteria.Area)
                        {
                            stretchFactor += .1;
                            MapManager.RemoveFiles(availablePolygonsFileName);
                            fc2      = null;
                            tempPoly = null;
                            MapManager.RemoveFiles(clipPath);
                            MapManager.RemoveFiles(dissolveHomeRangePolygon);
                            mLog.Debug("was not big enough so now the stretch factor is " + stretchFactor.ToString());
                        }
                        else
                        {
                            returnVal = this.dissolveHomeRangePolygon;
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(fc2);
                        }
                        //release them, otherwise ARCGis has r problem when trying to reuse the same name
                        if (fc != null)
                        {
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(fc);
                        }
                        if (fc2 != null)
                        {
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(fc2);
                        }
                    }
                    else
                    {
                        returnVal = "No Home Found";
                    }
                }



                if (stretchFactor >= 2)
                {
                    mLog.Debug("stretch factor = 2");
                    returnVal = "No Home Found";
                }
            }
            catch (System.Exception ex)
            {
                returnVal = "No Home Found";
                eLog.Debug(ex);
            }
            finally
            {
                if (tempPoly != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(tempPoly);
                }
                mLog.Debug("leaving with a file name of " + returnVal);
            }
            return(returnVal);
        }
示例#4
0
 public HomeRangeBuilder()
 {
     myDataManipulator = new DataManipulator();
     this.buildLogger();
 }