本文整理汇总了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;
}
示例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);
}
示例3: DistanceTo_ExpectedValuesAreReturned
public int DistanceTo_ExpectedValuesAreReturned(Position first, Position second)
{
return (int)first.DistanceTo(second);
}
示例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);
}
}