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


C# Position.DistanceTo方法代码示例

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


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

示例1: SimplifySegment

        private ITrackSegment SimplifySegment(ITrackSegment segment)
        {
            GeoFramework.Position prevPosition = new Position();
            List<IWayPoint> wayPointsToRemove = new List<IWayPoint>();
            foreach (IWayPoint wayPoint in segment.SegmentWaypoints)
            {
                Position position = new Position(wayPoint.Latitude.ToString(), wayPoint.Longitude.ToString());

                if (position.DistanceTo(prevPosition) < _SimplifyingDistance)
                {
                    wayPointsToRemove.Add(wayPoint);

                }
                else
                {
                    prevPosition = position;
                }
                
            }

            foreach (IWayPoint wayPoint in wayPointsToRemove)
            {
                segment.SegmentWaypoints.Remove(wayPoint);
            }
            return segment;

        }
开发者ID:chinnisuraj1984,项目名称:navigational,代码行数:27,代码来源:Services.cs

示例2: DistanceTo

 /// <summary>
 /// Returns the distance from the segment to the specified position.
 /// </summary>
 /// <param name="position">The position.</param>
 /// <returns></returns>
 /// <remarks>This method analyzes the relative position of the segment to the line to determine the
 /// best mathematical approach.</remarks>
 public Distance DistanceTo(Position position)
 {
     if (_start.Equals(_end))
         return position.DistanceTo(_start);
     Position delta = _end.Subtract(_start);
     double ratio = ((position.Longitude.DecimalDegrees - _start.Longitude.DecimalDegrees)
         * delta.Longitude.DecimalDegrees + (position.Latitude.DecimalDegrees - _start.Latitude.DecimalDegrees)
         * delta.Latitude.DecimalDegrees) / (delta.Longitude.DecimalDegrees * delta.Longitude.DecimalDegrees + delta.Latitude.DecimalDegrees
         * delta.Latitude.DecimalDegrees);
     if (ratio < 0)
         return position.DistanceTo(_start);
     if (ratio > 1)
         return position.DistanceTo(_end);
     Position destination = new Position(
         new Latitude((1 - ratio) * _start.Latitude.DecimalDegrees + ratio * _end.Latitude.DecimalDegrees),
         new Longitude((1 - ratio) * _start.Longitude.DecimalDegrees + ratio * _end.Longitude.DecimalDegrees));
     return position.DistanceTo(destination);
 }
开发者ID:JoeGilkey,项目名称:RadioLog,代码行数:25,代码来源:Segment.cs

示例3: DistanceTo_ExpectedValuesAreReturned

 public int DistanceTo_ExpectedValuesAreReturned(Position first, Position second)
 {
     return (int)first.DistanceTo(second);
 }
开发者ID:krabicezpapundeklu,项目名称:Exercises,代码行数:4,代码来源:PositionTest.cs

示例4: CalculateGhostPoint

        private void CalculateGhostPoint(int index, Position otherPosition, Position currentPosition, GMapRoute route)
        {
            double x, y;
            var point = new GMap.NET.PointLatLng();

            if (currentPosition.DistanceTo(otherPosition) > _ghostMarkerThresholdDistance)
            {
                x = (currentPosition.Latitude.DecimalDegrees + otherPosition.Latitude.DecimalDegrees) / 2;
                y = (currentPosition.Longitude.DecimalDegrees + otherPosition.Longitude.DecimalDegrees) / 2;

                point.Lat = x;
                point.Lng = y;

                int ghostPointIndex = IsGhostPointExist(index, route);
                if (ghostPointIndex == -1)
                {
                    point = CreateGhostPoint(index, point, route);
                }
                else
                {
                    _ghostPointDictionary[route][ghostPointIndex].Marker.Position = point;
                }
            }
            else
            {
                RemoveGhostPointAt(index, route);
            }
        }
开发者ID:chinnisuraj1984,项目名称:navigational,代码行数:28,代码来源:TrackEditor.cs


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