Esempio n. 1
0
        public override Point fromWgs(WgsPoint point)
        {
            double lat = point.getLatitude() * Math.PI / 180.0;
            double lon = point.getLongitude() * Math.PI / 180.0;
            double n   = Math.Pow(wgsMajorAxis, 2) /
                         Math.Sqrt(
                Math.Pow(wgsMajorAxis, 2) * Math.Pow(Math.Cos(lat), 2) +
                (Math.Pow(wgsMinorAxis, 2) * Math.Pow(Math.Sin(lat), 2)));
            double z;

            if (point.getAltitude() == null)
            {
                z = 0;
            }
            else
            {
                z = (double)point.getAltitude();
            }
            double x = (n + z) * Math.Cos(lat) * Math.Cos(lon);
            double y = (n + z) * Math.Cos(lat) * Math.Sin(lon);

            z = ((Math.Pow((wgsMinorAxis / wgsMajorAxis), 2)) * n + z)
                * Math.Sin(point.getLatitude() * Math.PI / 180.0);

            double x_, y_, z_;

            x_ = -dX + (1 + (-1) * e) * (x - rZ * y + rY * z);
            y_ = -dY + (1 + (-1) * e) * (rZ * x + y - rX * z);
            z_ = -dZ + (1 + (-1) * e) * (-rY * x + rX * y + z);

            double p     = Math.Sqrt(Math.Pow(x_, 2) + Math.Pow(y_, 2));
            double theta = Math.Atan((z_ * hayMajorAxis)
                                     / (p * hayMinorAxis));
            double pow_eccentricity = (Math.Pow(hayMajorAxis, 2)
                                       - Math.Pow(hayMinorAxis, 2))
                                      / Math.Pow(hayMajorAxis, 2);
            double pow_second_eccentricity = (Math.Pow(hayMajorAxis, 2)
                                              - Math.Pow(hayMinorAxis, 2))
                                             / Math.Pow(hayMinorAxis, 2);
            double latf = Math.Atan((z_ + pow_second_eccentricity
                                     * hayMinorAxis * Math.Pow(Math.Sin(theta), 3))
                                    / (p - pow_eccentricity * hayMajorAxis
                                       * Math.Pow(Math.Cos(theta), 3)));
            double lonf = Math.Atan(y_ / x_);
            double nf   = Math.Pow(hayMajorAxis, 2) /
                          Math.Sqrt(
                Math.Pow(hayMajorAxis, 2) * Math.Pow(Math.Cos(latf), 2) +
                Math.Pow(hayMinorAxis, 2) * Math.Pow(Math.Sin(latf), 2));
            double hf = (p / Math.Cos(latf)) - nf;

            latf = latf * 180 / Math.PI;
            lonf = lonf * 180 / Math.PI;
            HayPoint _point = new HayPoint(latf, lonf, hf);

            return(_point);
        }
Esempio n. 2
0
        //---------------------------------------------------------------------
        /// <summary>
        /// Returns a
        /// </summary>
        /// <param name="bottomLeft">
        /// </param>
        /// <param name="topRight">
        /// </param>
        /// <param name="precision">
        /// </param>
        /// <returns></returns>
        //---------------------------------------------------------------------
        public Dem getSelection(Point bottomLeft, Point topRight,
                                Dem.Precision precision)
        {
            if (bottomLeft.getLatitude() > topRight.getLatitude())
            {
                if (bottomLeft.getLongitude() > topRight.getLongitude())
                {
                    Point aux = bottomLeft;
                    bottomLeft = topRight;
                    topRight   = aux;
                }
                else
                {
                    WgsPoint aux  = bottomLeft.toWgs();
                    WgsPoint aux2 = topRight.toWgs();
                    bottomLeft = new WgsPoint(aux2.getLatitude(),
                                              aux.getLongitude(), aux.getAltitude());
                    topRight = new WgsPoint(aux.getLatitude(),
                                            aux2.getLongitude(), aux2.getAltitude());
                }
            }
            else
            {
                if (bottomLeft.getLongitude() > topRight.getLongitude())
                {
                    WgsPoint aux  = bottomLeft.toWgs();
                    WgsPoint aux2 = topRight.toWgs();
                    bottomLeft = new WgsPoint(aux.getLatitude(),
                                              aux2.getLongitude(), aux.getAltitude());
                    topRight = new WgsPoint(aux2.getLatitude(),
                                            aux.getLongitude(), aux2.getAltitude());
                }
            }
            Dem dem = this.addDem(bottomLeft, topRight, precision);

            return(dem.getSelection(bottomLeft, topRight));
        }
Esempio n. 3
0
        public override Point fromWgs(WgsPoint point)
        {
            double lat = point.getLatitude() * Math.PI / 180.0;
            double lon = point.getLongitude() * Math.PI / 180.0;
            double n = Math.Pow(wgsMajorAxis, 2) /
            Math.Sqrt(
                Math.Pow(wgsMajorAxis, 2) * Math.Pow(Math.Cos(lat), 2) +
                (Math.Pow(wgsMinorAxis, 2) * Math.Pow(Math.Sin(lat), 2)));
            double z;
            if (point.getAltitude() == null)
                z = 0;
            else
                z = (double)point.getAltitude();
            double x = (n + z) * Math.Cos(lat) * Math.Cos(lon);
            double y = (n + z) * Math.Cos(lat) * Math.Sin(lon);
            z = ((Math.Pow((wgsMinorAxis / wgsMajorAxis), 2)) * n + z)
                * Math.Sin(point.getLatitude()*Math.PI/180.0);

            double x_, y_, z_;

            x_ = -dX + (1 + (-1) * e) * (x - rZ * y + rY * z);
            y_ = -dY + (1 + (-1) * e) * (rZ * x + y - rX * z);
            z_ = -dZ + (1 + (-1) * e) * (-rY * x + rX * y + z);

            double p = Math.Sqrt(Math.Pow(x_, 2) + Math.Pow(y_, 2));
            double theta = Math.Atan((z_ * hayMajorAxis)
                / (p * hayMinorAxis));
            double pow_eccentricity = (Math.Pow(hayMajorAxis, 2)
                - Math.Pow(hayMinorAxis, 2))
                / Math.Pow(hayMajorAxis, 2);
            double pow_second_eccentricity = (Math.Pow(hayMajorAxis, 2)
                - Math.Pow(hayMinorAxis, 2))
                / Math.Pow(hayMinorAxis, 2);
            double latf = Math.Atan((z_ + pow_second_eccentricity
                * hayMinorAxis * Math.Pow(Math.Sin(theta), 3))
                / (p - pow_eccentricity * hayMajorAxis
                * Math.Pow(Math.Cos(theta), 3)));
            double lonf = Math.Atan(y_ / x_);
            double nf = Math.Pow(hayMajorAxis, 2) /
                Math.Sqrt(
                    Math.Pow(hayMajorAxis, 2) * Math.Pow(Math.Cos(latf), 2) +
                    Math.Pow(hayMinorAxis, 2) * Math.Pow(Math.Sin(latf), 2));
            double hf = (p / Math.Cos(latf)) - nf;
            latf = latf * 180 / Math.PI;
            lonf = lonf * 180 / Math.PI;
            HayPoint _point = new HayPoint(latf, lonf, hf);
            return _point;
        }