本文整理汇总了C#中Distance类的典型用法代码示例。如果您正苦于以下问题:C# Distance类的具体用法?C# Distance怎么用?C# Distance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Distance类属于命名空间,在下文中一共展示了Distance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SimpleLineSubdivisionOperation
/// <summary>
/// Initializes a new instance of the <see cref="SimpleLineSubdivisionOperation"/> class
/// </summary>
/// <param name="splitLine">The line to split.</param>
/// <param name="dist">The distance to the split point.</param>
/// <param name="isFromEnd">Is the distance observed from the end of the line?</param>
internal SimpleLineSubdivisionOperation(LineFeature splitLine, Distance dist, bool isFromEnd)
: base()
{
m_Line = splitLine;
m_Distance = dist;
m_IsFromEnd = isFromEnd;
}
示例2: TestConstructorValue
public void TestConstructorValue()
{
Distance dist = new Distance("5 m");
Assert.AreEqual(5, dist.Value);
Assert.AreEqual(DistanceUnit.Meters, dist.Units);
}
示例3: TestConstructorValueCulture
public void TestConstructorValueCulture()
{
Distance dist = new Distance("5 m", CultureInfo.CurrentCulture);
Assert.AreEqual(5, dist.Value);
Assert.AreEqual(DistanceUnit.Meters, dist.Units);
}
示例4: CanCreate
public void CanCreate()
{
Distance distance = new Distance(5.7, DistanceUnits.Miles);
Assert.Equal(5.7, distance.Value);
Assert.Equal(DistanceUnits.Miles, distance.Units);
}
示例5: Position
public Position(Coordinate coordinate, Accuracy accuracy, Distance altitide, DateTimeOffset timestamp)
{
Coordinate = coordinate;
Accuracy = accuracy;
Altitude = altitide;
Timestamp = timestamp;
}
示例6: ConvertToSi
public void ConvertToSi(Distance s, string dimension)
{
if (dimension != "m")
{
if (dimension == "km")
{
s.Value *= 1000;
}
else if (dimension == "dm")
{
s.Value /=10;
}
else if (dimension == "cm")
{
s.Value /= 100;
}
else if (dimension == "mm")
{
s.Value /= 1000;
}
else if (dimension == "mm")
{
s.Value /= 1000;
}
else
{
throw new IncorrectDimensionOfDistanceException();
}
}
}
示例7: CalcCalories
public ActionResult CalcCalories(WeightData weightData, Distance distanceData)
{
if (!ModelState.IsValid)
return new JsonResult { Data = new { Result = false } };
return new JsonResult { Data = new { Result = true, Calories = caloriesCalc.Calculate(distanceData, weightData) } };
}
示例8: Add
/// <summary>
/// Shifts the point to the specified distance.
/// </summary>
/// <param name="point">The point.</param>
/// <param name="distance">The distance.</param>
/// <returns>Point shifted to the specified distance.</returns>
public static Point Add(this Point point, Distance distance)
{
return new Point()
{
X = distance.X.IsNotSet() ? point.X : point.X + distance.X,
Y = distance.Y.IsNotSet() ? point.Y : point.Y + distance.Y
};
}
示例9: GreatCircleDistance
//public ICoordinate Coordinate
//{
// get { return _loc; }
// set { _loc = value; }
//}
public Distance GreatCircleDistance(Point pt2)
{
double distance = Math.Acos((Math.Sin(this.LatRad) * Math.Sin(pt2.LatRad)) + (Math.Cos(this.LatRad) * Math.Cos(pt2.LatRad) * Math.Cos(pt2.LonRad - this.LonRad)));
distance = distance * 3963.0; // Statute Miles
distance = distance * 1.609344; // to Km
Distance d = new Distance(distance, DistanceUnits.KILOMETERS);
return d;
}
示例10: CircularLeg
/// <summary>
/// Creates a new <c>CircularLeg</c> with no spans.
/// </summary>
/// <param name="radius">The radius of the circular leg.</param>
/// <param name="clockwise">True if the curve is clockwise.</param>
/// <param name="span">The number of spans on the curve.</param>
internal CircularLeg(Distance radius, bool clockwise, int nspan)
: base(nspan)
{
m_Metrics = new CircularLegMetrics(radius, clockwise);
// The circle for this leg won't be known till we create a span.
m_Circle = null;
}
示例11: CanCompareForEquality
public void CanCompareForEquality()
{
Distance distance1 = new Distance(5, DistanceUnits.Miles);
Distance distance2 = new Distance(5, DistanceUnits.Miles);
Assert.True(distance1.Equals(distance2));
Assert.Equal(distance1.GetHashCode(), distance2.GetHashCode());
}
示例12: InsertSpan
/// <summary>
/// Inserts an extra distance into the path.
/// </summary>
/// <param name="newdist">The new distance to insert.</param>
/// <param name="curdist">A distance that this leg already knows about.</param>
/// <param name="isBefore">Should the new distance go before the existing one?</param>
internal void InsertSpan(int legIndex, Distance newdist, Distance curdist, bool isBefore)
{
/*
Leg leg = m_Legs[legIndex];
int spanIndex = leg.GetIndex(curdist);
var edit = new SpanInsert((uint)legIndex,
*/
}
示例13: GetDistance_From130x450yToOwn_130f
public void GetDistance_From130x450yToOwn_130f()
{
var point = new Position(130, 450);
var act = Goal.Own.GetDistance(point);
var exp = new Distance(130);
Assert.AreEqual(exp, act);
}
示例14: TestConstructorValueCultureException
public void TestConstructorValueCultureException()
{
Distance dist;
Assert.Throws<ArgumentException>(() => dist = new Distance("5", CultureInfo.CurrentCulture));
//Assert.AreEqual(5, dist.Value);
//Assert.AreEqual(SpeedUnit.MetersPerSecond, dist.Units);
}
示例15: CircularLegMetrics
/// <summary>
/// Initializes a new instance of the <see cref="CircularLegMetrics"/> class with
/// undefined angles (both set to zero).
/// </summary>
/// <param name="radius">The observed radius.</param>
/// <param name="isClockwise">Is the leg directed clockwise?</param>
internal CircularLegMetrics(Distance radius, bool isClockwise)
{
m_Angle1 = m_Angle2 = 0.0;
m_Radius = radius;
// Remember if its NOT a clockwise arc.
if (!isClockwise)
m_Flag |= CircularLegFlag.CounterClockwise;
}