コード例 #1
0
        public static void SetNewPointElevation(FeatureLine fl,
                                                Point3d point, double elevationDelta)
        {
            // get all points on the Feature Line
            Point3dCollection pointsOnFL =
                fl.GetPoints(FeatureLinePointType.AllPoints);

            // find the closest point and index
            double  distance            = double.MaxValue;
            int     index               = 0;
            Point3d closestPointOnCurve = Point3d.Origin;

            for (int i = 0; i < pointsOnFL.Count; i++)
            {
                Point3d p = pointsOnFL[i];
                if (p.DistanceTo(point) < distance)
                {
                    distance            = p.DistanceTo(point);
                    closestPointOnCurve = p;
                    index = i;
                }
            }

            // apply the delta
            fl.SetPointElevation(index,
                                 closestPointOnCurve.Z + elevationDelta);
        }
コード例 #2
0
        private static void ApplyElevationCorrection(FeatureLine fl, double mean, double flMaxElevation)
        {
            try
            {
                if (mean <= 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(mean));
                }


                fl.UpgradeOpen();
                COMS.MessengerManager.AddLog("Start ApplyElevationCorrection");

                using (var tr = Active.StartTransaction())
                {
                    Point3dCollection pointsOnFL =
                        fl.GetPoints(FeatureLinePointType.AllPoints);

                    for (int i = 0; i < pointsOnFL.Count; i++)
                    {
                        Point3d p = pointsOnFL[i];


                        var diff = Math.Abs(flMaxElevation - p.Z);
                        if (diff > MaxDiff)
                        {
                            try
                            {
                                fl.SetPointElevation(i, mean);
                                COMS.MessengerManager.AddLog
                                    ("Changed Feature Line: " +
                                    fl.Name + " Old Elevation=" +
                                    p.Z + " New Elevation=" +
                                    mean);
                            }
                            catch (Exception ex)
                            {
                                COMS.MessengerManager.LogException(ex);
                            }
                        }
                    }

                    tr.Commit();
                }

                COMS.MessengerManager.AddLog("End ApplyElevationCorrection");
            }
            catch (Exception ex)

            {
                MessengerManager.MessengerManager.LogException(ex);
            }
        }
コード例 #3
0
        /// <summary>
        /// Corrects the water featurelines.
        /// Has been omitted until further notice due to 25 swings in elevation for wier and structures
        /// </summary>
        /// <param name="fl">The fl.</param>
        /// <param name="mean">The mean.</param>
        /// <exception cref="System.ArgumentOutOfRangeException"></exception>
        public static void CorrectWaterFeaturelines(FeatureLine fl, double mean)
        {
            try
            {
                if (mean <= 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(mean));
                }

                fl.UpgradeOpen();
                if (fl.Layer.Contains("S-WATER"))
                {
                    using (var tr = Active.StartTransaction())
                    {
                        Point3dCollection pointsOnFL =
                            fl.GetPoints(FeatureLinePointType.AllPoints);
                        COMS.MessengerManager.AddLog("Start CorrectWaterFeaturelines");

                        for (int i = 0; i < pointsOnFL.Count; i++)
                        {
                            Point3d p    = pointsOnFL[i];
                            var     last = pointsOnFL.Count - 1;
                            var     diff = Math.Abs(p.Z - mean);

                            if ((diff > MaxWater) && (Math.Abs(mean) > 0.01))
                            {
                                COMS.MessengerManager.AddLog("S-Changed to Mean = " + mean);
                                try
                                {
                                    if (i != last)
                                    {
                                        fl.SetPointElevation(i, mean);
                                    }
                                }
                                catch (System.ArgumentOutOfRangeException)
                                {
                                }

                                catch (Exception ex)
                                {
                                    MessengerManager.MessengerManager.LogException(ex);
                                    MessengerManager.MessengerManager.AddLog("Failure = " + i + "and Mean = " + mean);
                                }

                                COMS.MessengerManager.AddLog("E-Changed to Mean = " + mean);
                            }
                        }

                        tr.Commit();
                    }
                }

                COMS.MessengerManager.AddLog("End CorrectWaterFeaturelines");
            }

            catch (Exception ex)

            {
                MessengerManager.MessengerManager.LogException(ex);
            }
        }