/// <summary> /// Smoothes out the bearings of a Route according to an int value /// </summary> /// <param name="smoothValue">The amount of bearings to smooth together</param> /// <returns>A new Route</returns> public Route SmoothBearings(int smoothValue) { Point[] points = Points; for (int i = 0; i < points.Length - smoothValue; i++) { points[i].Bearing = Bearing.Average(new ArraySegment <Point>(points, i, smoothValue).ToArray()); } return(new Route(points)); }
/// <summary> /// Calculates the resultant point if given a starting point, distance and bearing /// </summary> /// <param name="distance">The distance in metres</param> /// <param name="bearing">The direction</param> /// <returns>A new point</returns> public Point Destination(double distance, Bearing bearing) { double φ1 = Latitude * (Math.PI / 180); double λ1 = Longitude * (Math.PI / 180); double brng = bearing.Value * (Math.PI / 180); double φ2 = Math.Asin(Math.Sin(φ1) * Math.Cos(distance / Radius) + Math.Cos(φ1) * Math.Sin(distance / Radius) * Math.Cos(brng)); double λ2 = λ1 + Math.Atan2(Math.Sin(brng) * Math.Sin(distance / Radius) * Math.Cos(φ1), Math.Cos(distance / Radius) - Math.Sin(φ1) * Math.Sin(φ2)); return(new Point(φ2 * (180 / Math.PI), λ2 * (180 / Math.PI))); }
/// <summary> /// Gets the URL to the image of the PanoID /// </summary> /// <param name="bearing">The bearing of the image</param> /// <param name="pitch">The pitch of the image</param> /// <param name="res">The resolution of the image</param> /// <param name="fov">The field of view of the image</param> /// <returns>The Streetview Static API image URL</returns> public string ImageURL(Bearing bearing, double pitch, Resolution res, int fov) => URL.Sign(string.Format("https://maps.googleapis.com/maps/api/streetview?size={0}x{1}&pano={2}&heading={3}&pitch={4}&fov={5}", res.Width, res.Height, ID, bearing, pitch, fov));
public Bearing CalculateOffset(Bearing desired) => new Bearing((desired.Value + 360 - Value) % 360);
/// <summary> /// Creates a new point from a latitude, longitude and bearing /// </summary> /// <param name="lat">Latitude</param> /// <param name="lon">Longitude</param> /// <param name="bearing">Bearing</param> public Point(double lat, double lon, Bearing bearing) { Latitude = lat; Longitude = lon; Bearing = bearing; }
/// <summary> /// Creates a new point from a latitude and longitude value /// </summary> /// <param name="lat">Latitude</param> /// <param name="lon">Longitude</param> public Point(double lat, double lon) { Latitude = lat; Longitude = lon; Bearing = new Bearing(); }