コード例 #1
0
        /// <summary>
        /// Modify cross section
        /// </summary>
        /// <param name="csData">Cross section data from the CrossSection example data</param>
        public static void ModifyCrossSectionProcessed(CrossSectionData csData)
        {
            ICrossSection crossSection = csData.FindCrossSection(new Location("river B", 1000), "1");

            if (crossSection == null)
            {
                throw new Exception("Cross section not found at location");
            }

            // This is a cross section with raw data
            XSBase xsBase = crossSection.BaseCrossSection;

            if (xsBase == null)
            {
                throw new Exception("Not a cross section with processed data");
            }

            for (int i = 0; i < xsBase.NumberOfProcessedLevels; i++)
            {
                xsBase.ProcessedResistanceFactors[i] *= 1.1;
            }

            // Do not call CalculateProcessedData in this case, because that will reset the
            // processed data. Instead set the protected flag, such that data is not updated
            // automatically
            xsBase.ProcessedDataProtected = true;
        }
コード例 #2
0
        /// <summary>
        /// Example of how to navigate and find cross sections.
        /// <para>
        /// There are two ways to get cross sections: Find or Get
        /// </para>
        /// <para>
        /// Find will search the cross section data object for a cross
        /// section at the specified location. If no cross section is
        /// found, null is returned.
        /// </para>
        /// <para>
        /// Get will search the cross section data object for a cross
        /// section at the specified location. If no cross section is
        /// found, it will interpolate/extrapolate if possible, and only
        /// if that interpolation/extrapolation is not possible, null
        /// is returned. The get methods are used by the engine.
        /// </para>
        /// <para>
        /// Users that want to update or in other ways process the cross
        /// sections should always use the Find methods.
        /// </para>
        /// </summary>
        /// <param name="xns11Filepath">Filepath to xns11 file</param>
        public static void Navigation(string xns11Filepath)
        {
            // Load cross section data
            Diagnostics             diagnostics   = new Diagnostics("Errors");
            CrossSectionDataFactory csDataFactory = new CrossSectionDataFactory();
            CrossSectionData        csData        = csDataFactory.Open(Connection.Create(xns11Filepath), diagnostics);

            ICrossSection crossSection;

            // Find a cross section on a given location
            crossSection = csData.FindCrossSection(new Location("LINDSKOV", 1370), "TOPO-95");
            if (crossSection == null)
            {
                throw new Exception("Could not find cross section at location");
            }

            // Find a cross section closest to a given location
            crossSection = csData.FindClosestCrossSection(new Location("LINDSKOV", 1250), "TOPO-95");
            if (crossSection == null || crossSection.Location.Chainage != 1172)
            {
                throw new Exception("Expected cross section at chainage 1172");
            }

            // Find all cross sections inside a given location span
            IList <ICrossSection> css = csData.FindCrossSectionsForLocationSpan(new LocationSpan("LINDSKOV", 1000, 2000), "TOPO-95", true);

            if (css.Count != 6)
            {
                throw new Exception("Expected 6 cross sections");
            }

            // Find cross sections that are neighbours to a given locatin.
            ICrossSection csAfter;
            ICrossSection csBefore;

            csData.FindNeighborCrossSections(new Location("LINDSKOV", 1250), "TOPO-95", true, out csBefore, out csAfter);
            if (csBefore == null || csBefore.Location.Chainage != 1172)
            {
                throw new Exception("Expected cross section at chainage 1172");
            }
            if (csAfter == null || csAfter.Location.Chainage != 1370)
            {
                throw new Exception("Expected cross section at chainage 1370");
            }
        }
コード例 #3
0
        /// <summary>
        /// Modify cross section
        /// </summary>
        /// <param name="csData">Cross section data from the CrossSection example data</param>
        public static void ModifyCrossSectionRaw(CrossSectionData csData)
        {
            ICrossSection crossSection = csData.FindCrossSection(new Location("river B", 1000), "1");

            if (crossSection == null)
            {
                throw new Exception("Cross section not found at location");
            }

            // This is a cross section with raw data
            XSBaseRaw xsBaseRaw = crossSection.BaseCrossSection as XSBaseRaw;

            if (xsBaseRaw == null)
            {
                throw new Exception("Not a cross section with raw data");
            }

            // This cross section has 3 points.
            // Update the first two points
            xsBaseRaw.Points[1].X = 0.5;
            xsBaseRaw.Points[1].Z = 0.5;
            xsBaseRaw.Points[2]   = new CrossSectionPoint(0.5, 0.0);
            // Add two additional points
            xsBaseRaw.Points.Add(new CrossSectionPoint(1.0, 0.2));
            xsBaseRaw.Points.Add(new CrossSectionPoint(1.0, 1.0));

            // Update marker to default
            xsBaseRaw.UpdateMarkersToDefaults(true, true, true);

            // Calculates the processed levels, storage areas, radii, etc, ie, fill in all
            // ProcessedXXX properties.
            xsBaseRaw.CalculateProcessedData();

            // Validates the data. The constraints are that the levels and the areas after sorting
            // must be monotonically increasing.
            IDiagnostics diagnostics = xsBaseRaw.Validate();

            if (diagnostics.ErrorCountRecursive > 0)
            {
                throw new Exception(String.Format("Number of errors: {0}", diagnostics.Errors.Count));
            }
        }