/// <summary> /// Move a coordinate a specified distance towards a target coordinate. /// </summary> /// <param name="target">Target coordinate</param> /// <param name="distance">Distance toward target</param> /// <param name="shape">Shape of earth</param> /// <example> /// The following example moves a coordinate 10km towards a target coordinate using /// ellipsoidal earth calculations. /// <code> /// //N 25º 0' 0" E 25º 0' 0" /// Coordinate coord = Coordinate(25,25); /// /// //Target Coordinate /// Coordinate target = new Coordinate(26.5, 23.2); /// /// Distance distance = new Distance(10, DistanceType.Kilometers); /// /// //Move coordinate the specified distance /// //towards target using ellipsoidal calculations /// coord.Move(target, distance, Shape.Ellipsoid); /// /// //New Coordinate - N 24º 56' 21.526" E 25º 4' 23.944" /// </code> /// </example> public void Move(Coordinate target, Distance distance, Shape shape) { Distance d = new Distance(this, target, shape); //Convert to Radians for formula double lat1 = latitude.ToRadians(); double lon1 = longitude.ToRadians(); double crs12 = d.Bearing * Math.PI / 180; //Convert bearing to radians double[] ellipse = new double[] { equatorial_radius, inverse_flattening }; if (shape == Shape.Sphere) { double[] cd = Distance_Assistant.Direct(lat1, lon1, crs12, distance.Meters); double lat2 = cd[0] * (180 / Math.PI); double lon2 = cd[1] * (180 / Math.PI); //ADJUST CORD Latitude.DecimalDegree = lat2; Longitude.DecimalDegree = -lon2; //v2.1.1.1 update } else { double[] cde = Distance_Assistant.Direct_Ell(lat1, -lon1, crs12, distance.Meters, ellipse); //Convert back from radians double lat2 = cde[0] * (180 / Math.PI); double lon2 = cde[1] * (180 / Math.PI); //v2.1.1.1 //ADJUST CORD Latitude.DecimalDegree = lat2; Longitude.DecimalDegree = lon2; } CoordinateChanged?.Invoke(this, new EventArgs()); }
/*DATUM-ELLIPSOID METHODS*/ /// <summary> /// Set a custom datum for coordinate conversions and distance calculation. /// Objects must be loaded prior to setting if EagerLoading is turned off or else the items Datum won't be set. /// Use overload if EagerLoading options are used. /// </summary> /// <param name="radius">Equatorial Radius</param> /// <param name="flattening">Inverse Flattening</param> /// <example> /// The following example demonstrates how to set the earths ellipsoid values for UTM/MGRS and ECEF conversion as well as Distance calculations /// that use ellipsoidal earth values. /// <code> /// //Initialize a coordinate with the default WGS84 Ellipsoid. /// Coordinate c = new Coordinate(25,25); /// /// //Change Ellipsoid to GRS80 Datum /// c.Set_Datum(6378160.000, 298.25); /// </code> /// </example> public void Set_Datum(double radius, double flattening) { //WGS84 //RADIUS 6378137.0; //FLATTENING 298.257223563; if (utm != null) { utm.inverse_flattening = flattening; utm.ToUTM(Latitude.ToDouble(), Longitude.ToDouble(), utm); mgrs = new MilitaryGridReferenceSystem(utm); NotifyPropertyChanged("UTM"); NotifyPropertyChanged("MGRS"); } if (ecef != null) { ecef.equatorial_radius = radius; ecef.inverse_flattening = flattening; ecef.ToECEF(this); NotifyPropertyChanged("ECEF"); } equatorial_radius = radius; inverse_flattening = flattening; NotifyPropertyChanged("Equatorial_Radius"); NotifyPropertyChanged("Inverse_Flattening"); CoordinateChanged?.Invoke(this, new EventArgs()); }
public void Update(double _x, double _y, double _z) { X = _x; Y = _y; Z = _z; if (sumxyz != X + Y + Z) { CoordinateChanged?.Invoke(this, new EventArgs()); } sumxyz = X + Y + Z; }
/// <summary> /// Set a custom datum for coordinate conversions and distance calculation for specified coordinate formats only. /// Objects must be loaded prior to setting if EagerLoading is turned off. /// </summary> /// <param name="radius">Equatorial Radius</param> /// <param name="flattening">Inverse Flattening</param> /// <param name="datum">Coordinate_Datum</param> /// <example> /// The following example demonstrates how to set the earths ellipsoid values for UTM/MGRS conversions only. /// <code> /// //Initialize a coordinate with the default WGS84 Ellipsoid that eagerloads UTM/MGRS only. /// EagerLoadType et = EagerLoadType.UTM_MGRS; /// EagerLoad eagerLoad = new EagerLoad(et); /// Coordinate c = new Coordinate(25, 25, et); /// /// //Change Ellipsoid to GRS80 Datum for UTM_MGRS calculations only. /// c.Set_Datum(6378160.000, 298.25, Coordinate_Datum.UTM_MGRS); /// </code> /// </example> public void Set_Datum(double radius, double flattening, Coordinate_Datum datum) { //WGS84 //RADIUS 6378137.0; //FLATTENING 298.257223563; if (datum.HasFlag(Coordinate_Datum.UTM_MGRS)) { if (utm == null || mgrs == null) { throw new NullReferenceException("UTM/MGRS objects must be loaded prior to changing the datum."); } utm.inverse_flattening = flattening; utm.equatorial_radius = radius; utm.ToUTM(Latitude.ToDouble(), Longitude.ToDouble(), utm); mgrs = new MilitaryGridReferenceSystem(utm); NotifyPropertyChanged("UTM"); NotifyPropertyChanged("MGRS"); } if (datum.HasFlag(Coordinate_Datum.ECEF)) { if (ECEF == null) { throw new NullReferenceException("ECEF objects must be loaded prior to changing the datum."); } ecef.equatorial_radius = radius; ecef.inverse_flattening = flattening; ecef.ToECEF(this); NotifyPropertyChanged("ECEF"); } if (datum.HasFlag(Coordinate_Datum.LAT_LONG)) { equatorial_radius = radius; inverse_flattening = flattening; } NotifyPropertyChanged("Equatorial_Radius"); NotifyPropertyChanged("Inverse_Flattening"); CoordinateChanged?.Invoke(this, new EventArgs()); }
internal void InvokeCoordinateChanged() { CoordinateChanged?.Invoke(this, new EventArgs()); }
private void WPOS_CoordinateChanged(object sender, EventArgs e) { CoordinateChanged?.Invoke(sender, e); }