public ErrorSurfaceProperty(XmlNode nodProperty, Surface surf)
        {
            Name = nodProperty.SelectSingleNode("Name").InnerText;

            XmlNode nodUni = nodProperty.SelectSingleNode("UniformValue");
            XmlNode nodAss = nodProperty.SelectSingleNode("AssociatedSurface");
            XmlNode nodFIS = nodProperty.SelectSingleNode("FISRuleFile");

            if (nodUni is XmlNode)
            {
                UniformValue = decimal.Parse(nodUni.InnerText, CultureInfo.InvariantCulture);
            }
            else if (surf is DEMSurvey)
            {
                DEMSurvey dem = ((DEMSurvey)surf);

                if (nodFIS is XmlNode)
                {
                    FileInfo fisFile = ProjectManager.Project.GetAbsolutePath(nodFIS.InnerText);
                    FISRuleFile = new ErrorCalculation.FIS.FISLibraryItem(fisFile.FullName, ErrorCalculation.FIS.FISLibrary.FISLibraryItemTypes.Project);

                    foreach (XmlNode nodInput in nodProperty.SelectNodes("FISInputs/Input"))
                    {
                        AssocSurface assoc = dem.AssocSurfaces.First <AssocSurface>(x => string.Compare(nodInput.SelectSingleNode("AssociatedSurface").InnerText, x.Name, true) == 0);
                        FISInputs.Add(new FISInput(nodInput.SelectSingleNode("Name").InnerText, assoc));
                    }
                }
            }
        }
Exemple #2
0
        public AssocSurface(XmlNode nodAssoc, DEMSurvey dem)
            : base(nodAssoc)
        {
            DEM = dem;
            AssocSurfaceType = AssociatedSurfaceTypes.Other;
            XmlNode nodType = nodAssoc.SelectSingleNode("Type");

            if (nodType is XmlNode && !string.IsNullOrEmpty(nodType.InnerText))
            {
                try
                {
                    AssocSurfaceType = (AssociatedSurfaceTypes)Enum.Parse(typeof(AssociatedSurfaceTypes), nodType.InnerText);
                }
                catch (Exception ex)
                {
                    AssocSurfaceType = AssociatedSurfaceTypes.Other;
                    Console.WriteLine(string.Format("Error reading associated surface type from project XML. Defaulting to {0}\n\n{1}", AssociatedSurfaceTypes.Other, ex.Message));
                }
            }
        }
Exemple #3
0
        public static GCDProject Load(FileInfo projectFile)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(projectFile.FullName);

            XmlNode  nodProject = xmlDoc.SelectSingleNode("Project");
            string   name       = nodProject.SelectSingleNode("Name").InnerText;
            string   desc       = nodProject.SelectSingleNode("Description").InnerText;
            string   gcdv       = nodProject.SelectSingleNode("GCDVersion").InnerText;
            DateTime dtCreated  = DateTime.Parse(nodProject.SelectSingleNode("DateTimeCreated").InnerText);

            UnitsNet.Units.LengthUnit   horiz = (UnitsNet.Units.LengthUnit)Enum.Parse(typeof(UnitsNet.Units.LengthUnit), nodProject.SelectSingleNode("Units/Horizontal").InnerText);
            UnitsNet.Units.LengthUnit   vert  = (UnitsNet.Units.LengthUnit)Enum.Parse(typeof(UnitsNet.Units.LengthUnit), nodProject.SelectSingleNode("Units/Vertical").InnerText);
            UnitsNet.Units.AreaUnit     area  = (UnitsNet.Units.AreaUnit)Enum.Parse(typeof(UnitsNet.Units.AreaUnit), nodProject.SelectSingleNode("Units/Area").InnerText);
            UnitsNet.Units.VolumeUnit   vol   = (UnitsNet.Units.VolumeUnit)Enum.Parse(typeof(UnitsNet.Units.VolumeUnit), nodProject.SelectSingleNode("Units/Volume").InnerText);
            GCDConsoleLib.GCD.UnitGroup units = new GCDConsoleLib.GCD.UnitGroup(vol, area, vert, horiz);

            UnitsNet.Area cellArea    = UnitsNet.Area.From(0, area);
            XmlNode       nodCellArea = nodProject.SelectSingleNode("CellArea");

            if (!string.IsNullOrEmpty(nodCellArea.InnerText))
            {
                cellArea = UnitsNet.Area.From(double.Parse(nodCellArea.InnerText, CultureInfo.InvariantCulture), area);
            }

            ProjectManager.Project = new GCDProject(name, desc, projectFile, dtCreated, gcdv, cellArea, units);

            foreach (XmlNode nodOnline in nodProject.SelectNodes("Online/*"))
            {
                ProjectManager.Project.OnlineParams[nodOnline.Name] = nodOnline.InnerText;
            }

            // Load masks before DEMs. DEMs will load error surfaces that refer to masks
            foreach (XmlNode nodMask in nodProject.SelectNodes("Masks/Mask"))
            {
                if (nodMask.SelectSingleNode("Field") is XmlNode)
                {
                    // Regular or directional mask
                    if (nodMask.SelectSingleNode("Items") is XmlNode)
                    {
                        ProjectManager.Project.Masks.Add(new Masks.RegularMask(nodMask));
                    }
                    else
                    {
                        ProjectManager.Project.Masks.Add(new Project.Masks.DirectionalMask(nodMask));
                    }
                }
                else
                {
                    // Area of interest
                    ProjectManager.Project.Masks.Add(new Project.Masks.AOIMask(nodMask));
                }
            }

            // Load profile routes before DEMs, Ref Surfs and DoDs that might refer to
            // routes in their linear extractions
            foreach (XmlNode nodRoute in nodProject.SelectNodes("ProfileRoutes/ProfileRoute"))
            {
                ProjectManager.Project.ProfileRoutes.Add(new Project.ProfileRoutes.ProfileRoute(nodRoute));
            }

            foreach (XmlNode nodDEM in nodProject.SelectNodes("DEMSurveys/DEM"))
            {
                DEMSurvey dem = new DEMSurvey(nodDEM);
                ProjectManager.Project.DEMSurveys.Add(dem);
            }

            foreach (XmlNode nodRefSurf in nodProject.SelectNodes("ReferenceSurfaces/ReferenceSurface"))
            {
                Surface surf = new Surface(nodRefSurf, true, true);
                ProjectManager.Project.ReferenceSurfaces.Add(surf);
            }

            foreach (XmlNode nodDoD in nodProject.SelectNodes("DoDs/DoD"))
            {
                DoDBase dod = null;
                if (nodDoD.SelectSingleNode("Threshold") is XmlNode)
                {
                    dod = new DoDMinLoD(nodDoD);
                }
                else if (nodDoD.SelectSingleNode("ConfidenceLevel") is XmlNode)
                {
                    dod = new DoDProbabilistic(nodDoD);
                }
                else
                {
                    dod = new DoDPropagated(nodDoD);
                }

                ProjectManager.Project.DoDs.Add(dod);
            }

            foreach (XmlNode nodInter in nodProject.SelectNodes("InterComparisons/InterComparison"))
            {
                InterComparison inter = new InterComparison(nodInter, ProjectManager.Project.DoDs);
                ProjectManager.Project.InterComparisons.Add(inter);
            }

            foreach (XmlNode nodItem in nodProject.SelectNodes("MetaData/Item"))
            {
                ProjectManager.Project.MetaData[nodItem.SelectSingleNode("Key").InnerText] = nodItem.SelectSingleNode("Value").InnerText;
            }

            return(ProjectManager.Project);
        }
Exemple #4
0
 public bool IsDEMNameUnique(string name, DEMSurvey ignore)
 {
     return(IsNameUnique(name, DEMSurveys.Select(x => x as GCDProjectItem).ToList <GCDProjectItem>(), ignore));
 }
Exemple #5
0
 public AssocSurface(string name, FileInfo rasterPath, DEMSurvey dem, AssociatedSurfaceTypes eType)
     : base(name, rasterPath)
 {
     AssocSurfaceType = eType;
     DEM = dem;
 }