/// <summary> /// transform the geodetic datum /// </summary> /// <param name="point">geodetic point</param> /// <param name="ellipsoid">source ellipsoid</param> /// <param name="da">semi-major difference of ellipsoids</param> /// <param name="df">flattening difference of ellipsoids</param> /// <param name="dX">translation along the X-axis</param> /// <param name="dY">translation along the Y-axis</param> /// <param name="dZ">translation along the Z-axis</param> /// <returns>geodetic point in new datum</returns> public static GeodeticCoord Transform(GeodeticCoord point, Ellipsoid ellipsoid, double da, double df, double dX, double dY, double dZ) { double B = point.Latitude.Radians; double L = point.Longitude.Radians; double H = point.Height; double sinB = Math.Sin(B); double cosB = Math.Cos(B); double sinL = Math.Sin(L); double cosL = Math.Cos(L); double a = ellipsoid.SemiMajorAxis; double b_a = 1 - ellipsoid.Flattening; double ee = ellipsoid.ee; double w = 1.0 - ee * sinB * sinB; double Rm = a * (1.0 - ee) / Math.Pow(w, 1.5); double Rn = a / Math.Sqrt(w); // formula is from http://earth-info.nga.mil/GandG/coordsys/datums/standardmolodensky.html double dB = (-dX * sinB * cosL - dY * sinB * sinL + dZ * cosB + da * (Rn * ee * sinB * cosB) / a + df * (Rm / b_a + Rn * b_a) * sinB * cosB) / (Rm + H); double dL = (-dX * sinL + dY * cosL) / ((Rn + H) * cosB); double dH = dX * cosB * cosL + dY * cosB * sinL + dZ * sinB - da * a / Rn + df * Rn * b_a * sinB * sinB; return(new GeodeticCoord(Latitude.FromRadians(B + dB), Longitude.FromRadians(L + dL), H + dH)); }
/// <summary> /// set geodetic origin data /// </summary> /// <param name="point">getdetic point</param> /// <param name="azm">azimuth</param> public void SetValue(GeodeticCoord point, Angle azm) { Longitude = point.Longitude; Latitude = point.Latitude; Height = point.Height; Azimuth = azm; }
/// <summary> /// transform the geodetic datum /// </summary> /// <param name="point">geodetic point</param> /// <param name="from">source ellipsoid</param> /// <param name="to">target ellipsoid</param> /// <param name="para">three translation parameters</param> /// <returns>geodetic point in new datum</returns> public static GeodeticCoord Transform(GeodeticCoord point, Ellipsoid from, Ellipsoid to, TransParameters para) { double B = point.Latitude.Radians; double L = point.Longitude.Radians; double H = point.Height; double sinB = Math.Sin(B); double cosB = Math.Cos(B); double sinL = Math.Sin(L); double cosL = Math.Cos(L); double a = from.SemiMajorAxis; double b_a = 1 - from.Flattening; double da = to.SemiMajorAxis - from.SemiMajorAxis; double df = to.Flattening - from.Flattening; double ee = from.ee; double w = 1.0 - ee * sinB * sinB; double Rm = a * (1.0 - ee) / Math.Pow(w, 1.5); double Rn = a / Math.Sqrt(w); // formula is from http://earth-info.nga.mil/GandG/coordsys/datums/standardmolodensky.html double dB = (-para.Tx * sinB * cosL - para.Ty * sinB * sinL + para.Tz * cosB + da * (Rn * ee * sinB * cosB) / a + df * (Rm / b_a + Rn * b_a) * sinB * cosB) / (Rm + H); double dL = (-para.Tx * sinL + para.Ty * cosL) / ((Rn + H) * cosB); double dH = para.Tx * cosB * cosL + para.Ty * cosB * sinL + para.Tz * sinB - da * a / Rn + df * Rn * b_a * sinB * sinB; return(new GeodeticCoord(Latitude.FromRadians(B + dB), Longitude.FromRadians(L + dL), H + dH)); }
/// <summary> /// create a geodetic origin object /// </summary> /// <param name="pnt">origin point</param> /// <param name="azm">azimuth</param> /// <param name="name">origin point name</param> public GeodeticOrigin(GeodeticCoord pnt, Angle azm, string name = "") { Name = name; Latitude = pnt.Latitude; Longitude = pnt.Longitude; Height = pnt.Height; Azimuth = azm; }
/// <summary> /// Create a point with a coordinate and its ellipsoid /// </summary> /// <param name="pnt">geodetic coordinate</param> /// <param name="ellipsoid">Ellipsoid</param> public GeoPoint(GeodeticCoord pnt, Ellipsoid ellipsoid) { Latitude = pnt.Latitude; Longitude = pnt.Longitude; Ellipsoid = ellipsoid; _a = ellipsoid.a; _es = ellipsoid.ee; }
/// <summary> /// Create an origin point by geodetic coordinate. /// </summary> /// <param name="coord">geodetic coordinate</param> public Origin(GeodeticCoord coord) { _elements = new List <object> { coord.Latitude, coord.Longitude, coord.Height }; }
/// <summary> /// datum transformation by Helmert formula /// </summary> /// <param name="point">geodetic point in old datum</param> /// <param name="from">source earth ellipsoid</param> /// <param name="to">target earth ellipsoid</param> /// <param name="para">parameters</param> /// <returns>geodetic point in new datum</returns> public GeodeticCoord Transform(GeodeticCoord point, Ellipsoid from, Ellipsoid to) { // convert geodetic coordinate to space rectangular coordinate. Conversion.BLH_XYZ(from, point.Latitude, point.Longitude, point.Height, out double X, out double Y, out double Z); // Transform the datum (double x, double y, double z) = Transform(X, Y, Z); // convert space rectangular coordinate to geodetic coordinate. Conversion.XYZ_BLH(to, x, y, z, out Latitude lat, out Longitude lng, out double hgt); // return the coordinate. return(new GeodeticCoord(lat, lng, hgt)); }
static void Main(string[] args) { GeoPoint point = new GeoPoint(new Latitude(0), new Longitude(0), Ellipsoid.CGCS2000); Angle angle = new Angle(90, 0, 0.01); Bessel bessel = new Bessel(point, 1000.0, angle); Gauss gauss = new Gauss(point, 1000.0, angle); Vincenty vincenty = new Vincenty(point, 1000.0, angle); TransParameters trans = new TransParameters(null, null, -15.415, 157.025, 94.74, -1.465, 0.312, 0.08, 0.102); BursaWolf bursa = new BursaWolf(trans); GeodeticCoord pnt1 = new GeodeticCoord(new Latitude(35), new Longitude(100), 0); SpaceRectangularCoord xyz = Conversion.BLH_XYZ(Ellipsoid.Krassovsky, pnt1); xyz = bursa.Transform(xyz); GeodeticCoord p11 = Conversion.XYZ_BLH(Ellipsoid.WGS84, xyz); GeodeticCoord pnt2 = new GeodeticCoord(new Latitude(35), new Longitude(100), 3000); xyz = Conversion.BLH_XYZ(Ellipsoid.Krassovsky, pnt2); xyz = bursa.Transform(xyz); GeodeticCoord p22 = Conversion.XYZ_BLH(Ellipsoid.WGS84, xyz); double d = Math.Abs(pnt1.Height - pnt2.Height) - Math.Abs(p11.Height - p22.Height); //Origin origin = new Origin(lat, lng, 123); //object[] value = origin.GetPoint(); //Longitude lg = (Longitude)value[1]; //string json = JsonConvert.SerializeObject(Ellipsoid.CGCS2000); //Ellipsoid ellip = JsonConvert.DeserializeObject<Ellipsoid>(json); //GeoPoint point = new GeoPoint(lat, lng, ellip); //json = JsonConvert.SerializeObject(point); //GeoPoint pnt = JsonConvert.DeserializeObject<GeoPoint>(json); //Bessel bessel = new Bessel(new GeoPoint(lat, lng), 1000, new Angle(12, 23, 34), Ellipsoid.CGCS2000); //Angle a = bessel.Bearing; //Ellipsoid w84 = new Ellipsoid(6378137, 298.257222101, 7.292115e-5, 3.986004418e14); //Ellipsoid g84 = new Ellipsoid(6378137.0, 1.082629832258e-3, Angle.FromRadians(7.292115e-5), 3.986004418e14); //double ep = w84.ivf - g84.ivf; //Ellipsoid ellipsoid = Ellipsoid.WGS84; //GaussKrueger gauss = new GaussKrueger(new Ellipsoid(6378140, 298.257)); //gauss.Inverse(2280131, 465804, out Latitude lat, out Longitude lng); //lng += new Angle(111); //string aa = lat.Degrees.ToString() +"\\" +lng.Degrees.ToString(); //Dictionary<ProjectionParameter, double> parameters = new Dictionary<ProjectionParameter, double>(); //parameters.Add(ProjectionParameter.SemiMajor, Ellipsoid.WGS84.a); //parameters.Add(ProjectionParameter.InverseFlattening, -1); //parameters.Add(ProjectionParameter.FalseEasting, 5.0); //parameters.Add(ProjectionParameter.FalseNorthing, 6.0); //parameters.Add(ProjectionParameter.CenterMeridian, 120.0); //parameters.Add(ProjectionParameter.LatitudeOfOrigin, 30.0); //CassiniSoldner cassini = new CassiniSoldner(parameters); //cassini.Forward(new Latitude(34), new Longitude(123), out double northing, out double easting); //cassini.Inverse(northing, easting, out Latitude lat, out Longitude lng); }
/// <summary> /// Conversion of geodetic coordinate space rectangular coordinate. /// </summary> /// <param name="ellipsoid">ellipsoid</param> /// <param name="blh">geodetic coordinate</param> /// <returns>space rectangular coordinate</returns> public static SpaceRectangularCoord BLH_XYZ(Ellipsoid ellipsoid, GeodeticCoord blh) { BLH_XYZ(ellipsoid, blh.Latitude, blh.Longitude, blh.Height, out double X, out double Y, out double Z); return(new SpaceRectangularCoord(X, Y, Z)); }
/// <summary> /// Conversion of space rectangular coordinate to topocentric rectangular coordinate. /// </summary> /// <param name="ellipsoid">ellipsoid</param> /// <param name="XYZ">space rectangular coordinate</param> /// <param name="site">geodetic coordinate of station</param> /// <returns>topocentric rectangular coordinate</returns> public static TopocentricRectCoord XYZ_NEU(Ellipsoid ellipsoid, SpaceRectangularCoord XYZ, GeodeticCoord site) { XYZ_NEU(ellipsoid, site.Latitude, site.Longitude, site.Height, XYZ.X, XYZ.Y, XYZ.Z, out double N, out double E, out double U); return(new TopocentricRectCoord(N, E, U)); }
/// <summary> /// Conversion of topocentric rectangular coordinate to space rectangular coordinate /// </summary> /// <param name="ellipsoid">ellipsoid</param> /// <param name="neu">topocentric rectangular coordinate</param> /// <param name="site">geodetic coordinate of station</param> /// <returns>space rectangular coordinate</returns> public static SpaceRectangularCoord NEU_XYZ(Ellipsoid ellipsoid, TopocentricRectCoord neu, GeodeticCoord site) { NEU_XYZ(ellipsoid, site.Latitude, site.Longitude, site.Height, neu.Northing, neu.Easting, neu.Upping, out double X, out double Y, out double Z); return(new SpaceRectangularCoord(X, Y, Z)); }
/// <summary> /// get geodetic origin data /// </summary> /// <param name="point">geodetic point</param> /// <param name="azm">azimuth</param> public void GetValue(out GeodeticCoord point, out Angle azm) { point = new Coordinate.GeodeticCoord(Latitude, Longitude, Height); azm = Azimuth; }
/// <summary> /// Create a point with a coordinate /// </summary> /// <param name="pnt">geodetic coordinate</param> public GeoPoint(GeodeticCoord pnt) : this() { Longitude = pnt.Longitude; Latitude = pnt.Latitude; }
/// <summary> /// projection direct solution from geodetic coordinate to projected coordinate. /// </summary> /// <param name="point">geodetic point</param> /// <returns>projected point</returns> public ProjectedCoord Forward(GeodeticCoord point) { Forward(point.Latitude, point.Longitude, out double northing, out double easting); return(new ProjectedCoord(northing, easting)); }