public GeoPoint GetGeoPoint(PointD pixPoint) { // get a bearing to the point from our known point if ((pixPoint.X == this.PixPoint.X) && (pixPoint.Y == this.PixPoint.Y)) { return(this.GeoPoint); } /** draw a line to get our pixel length */ Line l1 = new Line(pixPoint, this.PixPoint); PointD vectorPoint = new PointD(_pixelReferencePoint.X + 100, _pixelReferencePoint.Y); double pixBearing = FlatGeo.Angle(pixPoint, _pixelReferencePoint, vectorPoint).Degrees + 90; double pixDistance = l1.Length; double geoBearing = FlatGeo.Radians((pixBearing + this.BearingDelta) % 360); double geoDistance = pixDistance / this.PixelsPerMeter; double lat = FlatGeo.Radians(this.GeoPoint.Y); double lon = FlatGeo.Radians(this.GeoPoint.X); double ddr = geoDistance / EarthGeo.EarthRadius; double lat2 = Math.Asin(Math.Sin(lat) * Math.Cos(ddr) + Math.Cos(lat) * Math.Sin(ddr) * Math.Cos(geoBearing)); double lon2 = lon + Math.Atan2(Math.Sin(geoBearing) * Math.Sin(ddr) * Math.Cos(lat), Math.Cos(ddr) - Math.Sin(lat) * Math.Sin(lat2)); lon2 = ((lon2 + Math.PI) % (2 * Math.PI)) - Math.PI; lat2 = FlatGeo.Degrees(lat2); lon2 = FlatGeo.Degrees(lon2); return(new GeoPoint(lat2, lon2)); }
public double GetPixelBearing(PointD pt1, PointD pt2) { double retVal = FlatGeo.Degrees(Math.Atan2(pt2.Y - pt1.Y, pt2.X - pt1.X)) + 90; if (retVal < 0) { retVal = 360 + retVal; } return(retVal); }
public static double GetBearing(GeoPoint pt1, GeoPoint pt2) { double lat1 = FlatGeo.Radians(pt1.Y); double lon1 = FlatGeo.Radians(pt1.X); double lat2 = FlatGeo.Radians(pt2.Y); double lon2 = FlatGeo.Radians(pt2.X); double y = Math.Sin(lon2 - lon1) * Math.Cos(lat2); double x = Math.Cos(lat1) * Math.Sin(lat2) - Math.Sin(lat1) * Math.Cos(lat2) * Math.Cos(lon2 - lon1); double bearing = Math.Atan2(y, x); // bearing in radians double ret = (FlatGeo.Degrees(bearing) + 360) % 360; return(ret); }
public static GeoPoint GetPoint(GeoPoint origin, Double bearing, Double distanceInMeters) { bearing = FlatGeo.Radians(bearing % 360); double ddr = distanceInMeters / EarthGeo.EarthRadius; double lat = FlatGeo.Radians(origin.Y); double lon = FlatGeo.Radians(origin.X); double lat2 = Math.Asin(Math.Sin(lat) * Math.Cos(ddr) + Math.Cos(lat) * Math.Sin(ddr) * Math.Cos(bearing)); double lon2 = lon + Math.Atan2(Math.Sin(bearing) * Math.Sin(ddr) * Math.Cos(lat), Math.Cos(ddr) - Math.Sin(lat) * Math.Sin(lat2)); lon2 = ((lon2 + Math.PI) % (2 * Math.PI)) - Math.PI; return(new GeoPoint(FlatGeo.Degrees(lat2), FlatGeo.Degrees(lon2))); }