当前位置: 首页>>代码示例>>C#>>正文


C# Distance.GetPlanarMetric方法代码示例

本文整理汇总了C#中Distance.GetPlanarMetric方法的典型用法代码示例。如果您正苦于以下问题:C# Distance.GetPlanarMetric方法的具体用法?C# Distance.GetPlanarMetric怎么用?C# Distance.GetPlanarMetric使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Distance的用法示例。


在下文中一共展示了Distance.GetPlanarMetric方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Calculate

        /// <summary>
        /// Calculates the start and end positions of an extension to a circular arc.
        /// </summary>
        /// <param name="extendLine">The line being extended.</param>
        /// <param name="isFromEnd">True if extending from the end of the line.</param>
        /// <param name="dist">The length of the extension.</param>
        /// <param name="start">The position of the start of the extension.</param>
        /// <param name="end">The position of the end of the extension.</param>
        /// <param name="center">The center of the circle on which the arc lies.</param>
        /// <param name="iscw">Is the circular arc directed clockwise?</param>
        /// <returns>True if position have been worked out. False if there is insufficient data,
        /// or the extension is not on a circular arc, or the length is more than the circumference
        /// of the circle (in those cases, the start and end positions come back as nulls)</returns>
        internal static bool Calculate(LineFeature extendLine, bool isFromEnd, Distance dist,
            out IPosition start, out IPosition end, out IPosition center, out bool iscw)
        {
            start = end = null;
            center = null;
            iscw = true;

            // Can't calculate if there is insufficient data.
            if (extendLine==null || dist==null)
                return false;

            // The length must be defined.
            if (!dist.IsDefined)
                return false;

            // The line that's being extended must be a circular arc.
            ArcFeature arc = (extendLine as ArcFeature);
            if (arc==null)
                return false;

            center = arc.Circle.Center;
            double radius = arc.Circle.Radius;
            iscw = arc.IsClockwise;

            // Get the length of the arc extension, in meters on the ground.
            double arclen = dist.Meters;

            // If the arc length exceeds the length of the circumference,
            // the end point can't be calculated.
            double circumf = Constants.PIMUL2 * radius;
            if (arclen > circumf)
                return false;

            // If we're extending from the start of the arc, the curve direction has
            // to be reversed too.
            if (!isFromEnd)
                iscw = !iscw;

            // Get the point we're extending from.
            start = (isFromEnd ? extendLine.EndPoint : extendLine.StartPoint);

            // Get the point we're extending to ...

            // Get the bearing from the center of the circle to the start of the arc.
            Turn turn = new Turn(center, start);
            double sbearing = turn.BearingInRadians;

            // Get the sector angle (in radians).
            double sector = arclen / radius;

            double ebearing = sbearing;
            if (iscw)
                ebearing += sector;
            else
                ebearing -= sector;

            end = Geom.Polar(center, ebearing, radius);

            // Re-calculate the arc length on the mapping plane,
            arclen = dist.GetPlanarMetric(start, end, extendLine.SpatialSystem);

            // And adjust the end position accordingly.
            sector = arclen / radius;

            if (iscw)
                ebearing = sbearing + sector;
            else
                ebearing = sbearing - sector;

            end = Geom.Polar(center, ebearing, radius);
            return true;
        }
开发者ID:steve-stanton,项目名称:backsight,代码行数:85,代码来源:LineExtensionUI.cs

示例2: Calculate

        /// <summary>
        /// Calculates the positions of the split point.
        /// </summary>
        /// <param name="line">The line being subdivided.</param>
        /// <param name="dist">The distance to the split point.</param>
        /// <param name="isFromEnd">Is the distance from the end of the line?</param>
        /// <returns>The calculated position (null if the distance is longer than the line being subdivided,
        /// or supplied information is incomplete)</returns>
        internal static IPosition Calculate(LineFeature line, Distance dist, bool isFromEnd)
        {
            // Can't calculate if there is insufficient data.
            if (line == null || dist == null)
                return null;

            // The length must be defined.
            if (!dist.IsDefined)
                return null;

            // Return if the observed distance is longer than the total
            // length of the line.
            double maxlen = line.Length.Meters;
            double obsvlen = dist.Meters;
            if (obsvlen > maxlen)
                return null;

            // Get the approximate position of the split point.
            IPosition start, approx;
            LineGeometry g = line.LineGeometry;
            if (isFromEnd)
            {
                start = line.EndPoint;
                g.GetPosition(new Length(maxlen - obsvlen), out approx);
            }
            else
            {
                start = line.StartPoint;
                g.GetPosition(new Length(obsvlen), out approx);
            }

            // Get the distance to the approximate position on the mapping plane.
            ISpatialSystem sys = CadastralMapModel.Current.SpatialSystem;
            double planlen = dist.GetPlanarMetric(start, approx, sys);

            // Figure out the true position on the line.
            IPosition splitpos;
            if (isFromEnd)
                g.GetPosition(new Length(maxlen - planlen), out splitpos);
            else
                g.GetPosition(new Length(planlen), out splitpos);

            return splitpos;
        }
开发者ID:steve-stanton,项目名称:backsight,代码行数:52,代码来源:SimpleLineSubdivisionOperation.cs

示例3: Calculate

        /// <summary>
        /// Calculates positions that are parallel to a line.
        /// </summary>
        /// <param name="line">The reference line.</param>
        /// <param name="offset">The offset to the parallel, in ground units. Signed to denote
        /// which side (less than zero means it's to the left of the reference line).</param>
        /// <param name="sres">The position of the start of the parallel.</param>
        /// <param name="eres">The position of the end of the parallel.</param>
        /// <returns>True if positions calculated ok</returns>
        static bool Calculate(LineFeature line, Distance offset, out IPosition sres, out IPosition eres)
        {
            // No result positions so far.
            sres = eres = null;

            // Get the ends of the reference line.
            IPosition spos = line.StartPoint;
            IPosition epos = line.EndPoint;

            ISpatialSystem sys = CadastralMapModel.Current.SpatialSystem;

            // If the reference line is a circular arc, get the curve info.
            ArcFeature arc = line.GetArcBase();
            if (arc != null)
            {
                Circle circle = arc.Circle;
                double radius = circle.Radius;
                IPosition centre = circle.Center;
                bool iscw = arc.IsClockwise;

                // Get the midpoint of the curve. The reduction of the
                // ground distance will be along the line that goes
                // from the centre of the circle & through this position.

                ILength len = line.Length;
                ILength halfLen = new Length(len.Meters * 0.5);
                IPosition middle;
                line.LineGeometry.GetPosition(halfLen, out middle);

                // Get the bearing from the centre to the mid-position
                // and use that to reduce the offset to the mapping plane.
                double bearing = Geom.BearingInRadians(centre, middle);
                double offdist = offset.GetPlanarMetric(middle, bearing, sys);

                // No parallel if the offset exceeds the radius.
                // if ( offdist > radius ) return FALSE;

                // Calculate the parallel points.
                double sbear = Geom.BearingInRadians(centre, spos);
                sres = Geom.Polar(centre, sbear, offdist+radius);

                double ebear = Geom.BearingInRadians(centre, epos);
                eres = Geom.Polar(centre, ebear, offdist+radius);
            }
            else
            {
                // Get the bearing.of the line.
                double bearing = Geom.BearingInRadians(spos, epos);

                // Get the planar distance for a perpendicular line that passes
                // through the midpoint of the reference line. The planar distance
                // will have the same sign as the ground value.

                IPosition middle = Position.CreateMidpoint(spos, epos);
                bearing += Constants.PIDIV2;
                double offdist = offset.GetPlanarMetric(middle, bearing, sys);

                // Calculate the parallel points.
                sres = Geom.Polar(spos, bearing, offdist);
                eres = Geom.Polar(epos, bearing, offdist);
            }

            return true;
        }
开发者ID:steve-stanton,项目名称:backsight,代码行数:73,代码来源:ParallelLineUI.cs


注:本文中的Distance.GetPlanarMetric方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。