本文整理汇总了C#中GeoCoordinate.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# GeoCoordinate.Equals方法的具体用法?C# GeoCoordinate.Equals怎么用?C# GeoCoordinate.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeoCoordinate
的用法示例。
在下文中一共展示了GeoCoordinate.Equals方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GeoCoordinate_EqualsTwoInstancesWithDifferentValuesExceptLongitudeAndLatitude_ReturnsTrue
public void GeoCoordinate_EqualsTwoInstancesWithDifferentValuesExceptLongitudeAndLatitude_ReturnsTrue()
{
var first = new GeoCoordinate(11, 12, 13, 14, 15, 16, 17);
var second = new GeoCoordinate(11, 12, 14, 15, 16, 17, 18);
Assert.IsTrue(first.Equals(second));
}
示例2: GeoTriangle
/// <summary>
/// Create a triangle of type T.
/// </summary>
/// <param name="Pixel1">The first pixel of the triangle.</param>
/// <param name="Pixel2">The second pixel of the triangle.</param>
/// <param name="Pixel3">The third pixel of the triangle.</param>
public GeoTriangle(GeoCoordinate Pixel1, GeoCoordinate Pixel2, GeoCoordinate Pixel3)
{
#region Initial Checks
if (Pixel1 == null)
throw new ArgumentNullException("The given first pixel must not be null!");
if (Pixel2 == null)
throw new ArgumentNullException("The given second pixel must not be null!");
if (Pixel3 == null)
throw new ArgumentNullException("The given third pixel must not be null!");
#endregion
#region Math Checks
if (Pixel1.Equals(Pixel2) ||
Pixel1.Equals(Pixel3) ||
Pixel2.Equals(Pixel3))
throw new ArgumentException("All distances between the pixels must be larger than zero!");
//if (Pixel1.Longitude.Equals(Pixel2.Longitude) &&
// Pixel2.Longitude.Equals(Pixel3.Longitude))
// throw new ArgumentException("All three pixels must not be on a single line!");
//if (Pixel1.Latitude.Equals(Pixel2.Latitude) &&
// Pixel2.Latitude.Equals(Pixel3.Latitude))
// throw new ArgumentException("All three pixels must not be on a single line!");
#endregion
#region Sort Pixels
// Sort by x-coordinate.
while (true)
{
if (Pixel1.Longitude > Pixel2.Longitude)
{
GeoCoordinate.Swap(ref Pixel1, ref Pixel2);
continue;
}
if (Pixel1.Longitude > Pixel3.Longitude)
{
GeoCoordinate.Swap(ref Pixel1, ref Pixel3);
continue;
}
if (Pixel2.Longitude > Pixel3.Longitude)
{
GeoCoordinate.Swap(ref Pixel2, ref Pixel3);
continue;
}
break;
}
// Sort by y-coordinate if x-coordinates are the same
if (Pixel1.Longitude.Equals(Pixel2.Longitude))
if (Pixel1.Latitude > Pixel2.Latitude)
GeoCoordinate.Swap(ref Pixel1, ref Pixel2);
if (Pixel2.Longitude.Equals(Pixel3.Longitude))
if (Pixel2.Latitude > Pixel3.Latitude)
GeoCoordinate.Swap(ref Pixel1, ref Pixel2);
#endregion
this.P1 = Pixel1;
this.P2 = Pixel2;
this.P3 = Pixel3;
this.E12 = new GeoLine(P1, P2);
this.E23 = new GeoLine(P2, P3);
this.E31 = new GeoLine(P3, P1);
this._Borders = new GeoLine[3] { E12, E23, E31 };
this.Tags = new List<String>();
}
示例3: GeoCircle
/// <summary>
/// Creates a circumcircle of type T based on three pixels.
/// </summary>
/// <param name="Pixel1">The first pixel of the triangle.</param>
/// <param name="Pixel2">The second pixel of the triangle.</param>
/// <param name="Pixel3">The third pixel of the triangle.</param>
public GeoCircle(GeoCoordinate Pixel1, GeoCoordinate Pixel2, GeoCoordinate Pixel3)
{
#region Initial Checks
if (Pixel1 == null)
throw new ArgumentNullException("The given first pixel must not be null!");
if (Pixel2 == null)
throw new ArgumentNullException("The given second pixel must not be null!");
if (Pixel3 == null)
throw new ArgumentNullException("The given third pixel must not be null!");
#endregion
#region Math Checks
if (Pixel1.Equals(Pixel2) ||
Pixel1.Equals(Pixel3) ||
Pixel2.Equals(Pixel3))
throw new ArgumentException("All distances between the pixels must be larger than zero!");
//if (Pixel1.Longitude.Value.Equals(Pixel2.Longitude.Value) &&
// Pixel2.Longitude.Value.Equals(Pixel3.Longitude.Value))
// throw new ArgumentException("All three pixels must not be on a single line!");
//if (Pixel1.Latitude.Value.Equals(Pixel2.Latitude.Value) &&
// Pixel2.Latitude.Value.Equals(Pixel3.Latitude.Value))
// throw new ArgumentException("All three pixels must not be on a single line!");
#endregion
var _Line12 = new GeoLine(Pixel1, Pixel2);
var _Line23 = new GeoLine(Pixel2, Pixel3);
this.Center = new GeoLine(_Line12.Center, _Line12.Normale).
Intersection(
new GeoLine(_Line23.Center, _Line23.Normale));
this.Radius = (Center != null) ? Center.DistanceTo(Pixel1) : 0;
}
示例4: IsInCircle
/// <summary>
/// Checks if the given first pixel is within the circle
/// defined by the remaining three edge pixels.
/// </summary>
/// <param name="Pixel">The pixel to be checked.</param>
/// <param name="EdgePixel1">The first edge pixel defining a circle.</param>
/// <param name="EdgePixel2">The second edge pixel defining a circle.</param>
/// <param name="EdgePixel3">The third edge pixel defining a circle.</param>
public static Boolean IsInCircle(GeoCoordinate Pixel, GeoCoordinate EdgePixel1, GeoCoordinate EdgePixel2, GeoCoordinate EdgePixel3)
{
#region Initial Checks
if (Pixel == null)
throw new ArgumentNullException("The given first pixel must not be null!");
if (EdgePixel1 == null)
throw new ArgumentNullException("The given first edgepixel must not be null!");
if (EdgePixel2 == null)
throw new ArgumentNullException("The given second edgepixel must not be null!");
if (EdgePixel3 == null)
throw new ArgumentNullException("The given third edgepixel must not be null!");
#endregion
#region Math Checks
if (EdgePixel1.Equals(EdgePixel2) ||
EdgePixel1.Equals(EdgePixel3) ||
EdgePixel2.Equals(EdgePixel3))
throw new ArgumentException("All distances between the pixels must be larger than zero!");
if (EdgePixel1.Longitude.Value.Equals(EdgePixel2.Longitude.Value) &&
EdgePixel2.Longitude.Value.Equals(EdgePixel3.Longitude.Value))
throw new ArgumentException("All three pixels must not be on a single line!");
if (EdgePixel1.Latitude.Value.Equals(EdgePixel2.Latitude.Value) &&
EdgePixel2.Latitude.Value.Equals(EdgePixel3.Latitude.Value))
throw new ArgumentException("All three pixels must not be on a single line!");
#endregion
var _Line12 = new GeoLine(EdgePixel1, EdgePixel2);
var _Line23 = new GeoLine(EdgePixel2, EdgePixel3);
var Center = new GeoLine(_Line12.Center, _Line12.Normale).
Intersection(
new GeoLine(_Line23.Center, _Line23.Normale));
return Center.DistanceTo(Pixel) <= Center.DistanceTo(EdgePixel1);
}
示例5: ToGeoHashTest3
public void ToGeoHashTest3()
{
var geo01 = new GeoCoordinate(new Latitude(-38.897), new Longitude(-77.036));
var geo01hash = geo01.ToGeoHash(20);
var geo01hash32 = geo01.ToGeoHash32(16);
var geo01hash64 = geo01.ToGeoHash64(32);
Assert.AreEqual("6314xp00e1ej140gw3hz", geo01hash.Value);
Assert.AreEqual(817991144U, geo01hash32.Value);
Assert.AreEqual(3513245211907368736UL, geo01hash64.Value);
var geo01rev = geo01hash.ToGeoCoordinate(3);
var geo01rev32 = geo01hash.ToGeoCoordinate(3);
var geo01rev64 = geo01hash.ToGeoCoordinate(3);
Assert.IsTrue(geo01.Equals(geo01rev));
Assert.IsTrue(geo01 == geo01rev);
Assert.AreEqual(geo01.Latitude.Value, geo01rev.Latitude.Value, 0.000001);
Assert.AreEqual(geo01.Longitude.Value, geo01rev.Longitude.Value, 0.000001);
Assert.IsTrue(geo01.Equals(geo01rev32));
Assert.IsTrue(geo01 == geo01rev32);
Assert.AreEqual(geo01.Latitude.Value, geo01rev32.Latitude.Value, 0.000001);
Assert.AreEqual(geo01.Longitude.Value, geo01rev32.Longitude.Value, 0.000001);
Assert.IsTrue(geo01.Equals(geo01rev64));
Assert.IsTrue(geo01 == geo01rev64);
Assert.AreEqual(geo01.Latitude.Value, geo01rev64.Latitude.Value, 0.000001);
Assert.AreEqual(geo01.Longitude.Value, geo01rev64.Longitude.Value, 0.000001);
}
示例6: ToGeoHashTest2
public void ToGeoHashTest2()
{
var geo01 = new GeoCoordinate(new Latitude(38.897), new Longitude(-77.036));
var geo01hash = geo01.ToGeoHash(20);
var geo01hash32 = geo01.ToGeoHash32(16);
var geo01hash64 = geo01.ToGeoHash64(32);
Assert.AreEqual("dqcjr0bp7n74cjbuqqub", geo01hash.Value);
Assert.AreEqual(2590713666U, geo01hash32.Value);
Assert.AreEqual(11127030471626460554UL, geo01hash64.Value);
var geo01rev = geo01hash.ToGeoCoordinate(3);
var geo01rev32 = geo01hash.ToGeoCoordinate(3);
var geo01rev64 = geo01hash.ToGeoCoordinate(3);
Assert.IsTrue(geo01.Equals(geo01rev));
Assert.IsTrue(geo01 == geo01rev);
Assert.AreEqual(geo01.Latitude.Value, geo01rev.Latitude.Value, 0.000001);
Assert.AreEqual(geo01.Longitude.Value, geo01rev.Longitude.Value, 0.000001);
Assert.IsTrue(geo01.Equals(geo01rev32));
Assert.IsTrue(geo01 == geo01rev32);
Assert.AreEqual(geo01.Latitude.Value, geo01rev32.Latitude.Value, 0.000001);
Assert.AreEqual(geo01.Longitude.Value, geo01rev32.Longitude.Value, 0.000001);
Assert.IsTrue(geo01.Equals(geo01rev64));
Assert.IsTrue(geo01 == geo01rev64);
Assert.AreEqual(geo01.Latitude.Value, geo01rev64.Latitude.Value, 0.000001);
Assert.AreEqual(geo01.Longitude.Value, geo01rev64.Longitude.Value, 0.000001);
}
示例7: ToGeoHashTest1
public void ToGeoHashTest1()
{
var geo01 = new GeoCoordinate(new Latitude(57.64911), new Longitude(10.40744));
var geo01hash = geo01.ToGeoHash(11);
var geo01hash32 = geo01.ToGeoHash32(16);
var geo01hash64 = geo01.ToGeoHash64(32);
Assert.AreEqual("u4pruydqqvj", geo01hash.Value);
Assert.AreEqual(3793206966U, geo01hash32.Value);
Assert.AreEqual(16291699867698975045UL, geo01hash64.Value);
var geo01rev = geo01hash.ToGeoCoordinate(5);
var geo01rev32 = geo01hash.ToGeoCoordinate(5);
var geo01rev64 = geo01hash.ToGeoCoordinate(5);
Assert.IsTrue(geo01.Equals(geo01rev));
Assert.IsTrue(geo01 == geo01rev);
Assert.AreEqual(geo01.Latitude.Value, geo01rev.Latitude.Value, 0.000001);
Assert.AreEqual(geo01.Longitude.Value, geo01rev.Longitude.Value, 0.000001);
Assert.IsTrue(geo01.Equals(geo01rev32));
Assert.IsTrue(geo01 == geo01rev32);
Assert.AreEqual(geo01.Latitude.Value, geo01rev32.Latitude.Value, 0.000001);
Assert.AreEqual(geo01.Longitude.Value, geo01rev32.Longitude.Value, 0.000001);
Assert.IsTrue(geo01.Equals(geo01rev64));
Assert.IsTrue(geo01 == geo01rev64);
Assert.AreEqual(geo01.Latitude.Value, geo01rev64.Latitude.Value, 0.000001);
Assert.AreEqual(geo01.Longitude.Value, geo01rev64.Longitude.Value, 0.000001);
}
示例8: GeoCoordinate_EqualsTwoInstancesWithSameValues_ReturnsTrue
public void GeoCoordinate_EqualsTwoInstancesWithSameValues_ReturnsTrue()
{
var first = new GeoCoordinate(11, 12, 13, 14, 15, 16, 17);
var second = new GeoCoordinate(11, 12, 13, 14, 15, 16, 17);
Assert.IsTrue(first.Equals(second));
}
示例9: GeoCoordinate_Unit_Equals2_ObjIsUnequivalent
public void GeoCoordinate_Unit_Equals2_ObjIsUnequivalent()
{
Double latitude = -32;
Double longitude = 32;
GeoCoordinate target = new GeoCoordinate(latitude, longitude);
GeoCoordinate other = new GeoCoordinate();
Boolean actual = target.Equals(other);
Assert.AreEqual(false, actual);
}
示例10: GeoCoordinate_Unit_Equals1_ObjIsNull
public void GeoCoordinate_Unit_Equals1_ObjIsNull()
{
Double latitude = -32;
Double longitude = 32;
GeoCoordinate target = new GeoCoordinate(latitude, longitude);
Object obj = null;
Boolean actual = target.Equals(obj);
Assert.AreEqual(false, actual);
}