public void GetCoordinateArgs_ReturnsExpected() { var box = new BoundingBox(Coordinates.NewYork(), 50); var coordinates = BoundingBoxCoordinates.GetInKilometers(box.Point, box.Radius); var expected = string.Format("north={0}&south={1}&east={2}&west={3}", coordinates.MaxPoint.Latitude, coordinates.MinPoint.Latitude, coordinates.MaxPoint.Longitude, coordinates.MinPoint.Longitude); Assert.AreEqual(expected, GeoNamesProviderBase.GetCoordinateArgs(box)); }
/// <summary> /// returns GeoNames Api queystring parameters for a BoundingBox intstance /// </summary> /// <param name="boundingBox">required</param> /// <returns></returns> public static string GetCoordinateArgs(BoundingBox boundingBox) { if (boundingBox == null) { throw new ArgumentNullException(nameof(boundingBox)); } //north=48.3124&south=45.2246&east=-120.8716&west=-123.0235 var coordinates = BoundingBoxCoordinates.GetInKilometers(boundingBox.Point, boundingBox.Radius); return(string.Format("north={0}&south={1}&east={2}&west={3}", coordinates.MaxPoint.Latitude, coordinates.MinPoint.Latitude, coordinates.MaxPoint.Longitude, coordinates.MinPoint.Longitude)); }
/// <summary> /// Equality method between two objects of the same type. /// Because the Equals method is strongly typed by generic constraints, /// it is not necessary to test for the correct object type. We need to test for /// property equality - which in this case means the comparing double vlaues to each other, which is imprecise. So we need to accept some small level of imprecision /// </summary> /// <param name="obj">The other object of this type we are testing equality with</param> /// <returns></returns> public bool Equals(AreaOfInterest <TIdType> obj) { if (obj != null) { if ( BoundingBoxCoordinates.Equals(obj.BoundingBoxCoordinates) ) { return(true); } else { return(false); } } return(false); }
/// <summary> /// Computes and retrieves a hash code for an object. /// </summary> /// <remarks> /// This method implements the <see cref="Object">Object</see> method. /// </remarks> /// <returns>A hash code for an object.</returns> public override int GetHashCode() { return(Id.GetHashCode() + Culture.GetHashCode() + BoundingBoxCoordinates.GetHashCode()); }