本文整理汇总了C#中Segment.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Segment.Equals方法的具体用法?C# Segment.Equals怎么用?C# Segment.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Segment
的用法示例。
在下文中一共展示了Segment.Equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SegmentEqualsReturnsFalseForNull
public void SegmentEqualsReturnsFalseForNull()
{
PointGeo startPoint = new PointGeo(21, 34);
PointGeo endPoint = new PointGeo(26, 31);
Segment<PointGeo> target = new Segment<PointGeo>(startPoint, endPoint);
Assert.False(target.Equals(null));
}
示例2: SegmentEqualsReturnsTrueForSegmentsWithTheSameEndPoints
public void SegmentEqualsReturnsTrueForSegmentsWithTheSameEndPoints()
{
PointGeo startPoint = new PointGeo(21, 34);
PointGeo endPoint = new PointGeo(26, 31);
Segment<PointGeo> target = new Segment<PointGeo>(startPoint, endPoint);
Segment<PointGeo> theSame = new Segment<PointGeo>(startPoint, endPoint);
Assert.True(target.Equals(theSame));
}
示例3: SegmentEqualsReturnsFalseForSegmentsWithTheDifferentEndPoints
public void SegmentEqualsReturnsFalseForSegmentsWithTheDifferentEndPoints()
{
PointGeo startPoint = new PointGeo(21, 34);
PointGeo startPoint2 = new PointGeo(21.1, 34.1);
PointGeo endPoint = new PointGeo(26, 31);
Segment<PointGeo> target = new Segment<PointGeo>(startPoint, endPoint);
Segment<PointGeo> other = new Segment<PointGeo>(startPoint2, endPoint);
Assert.False(target.Equals(other));
}
示例4: GetPathLength
/// <summary>
/// Calculates length of the path between two points along the specifid Polyline
/// </summary>
/// <param name="from">The point where path starts</param>
/// <param name="fromSegment">The Segment, where the point From lies</param>
/// <param name="to">The point where path ends</param>
/// <param name="toSegment">The Segment, where the point To lies</param>
/// <param name="path">Polyline that defines path geometry</param>
/// <returns>The length of the path between points from and to along the polyline</returns>
public static double GetPathLength(IPointGeo from, Segment<IPointGeo> fromSegment, IPointGeo to, Segment<IPointGeo> toSegment, IPolyline<IPointGeo> path)
{
int pointFound = 0;
int pointFoundLast = 0;
bool fromFound = false; bool toFound = false;
double distance = 0;
foreach (var segment in path.Segments) {
pointFoundLast = pointFound;
IPointGeo[] points = new IPointGeo[] { segment.StartPoint, segment.EndPoint };
if (!fromFound && fromSegment.Equals(segment)) {
fromFound = true;
points[pointFound++] = from;
}
if (!toFound && toSegment.Equals(segment)) {
toFound = true;
points[pointFound++] = to;
}
if (pointFound > 0) {
if (pointFound == pointFoundLast)
distance += segment.Length;
else
distance += Calculations.GetDistance2D(points[0], points[1]);
if (pointFound == 2)
return distance;
}
}
throw new ArgumentException("One or more points do not lie on the given path");
}