Exemple #1
0
        private CrsdistResult ComputeFormCD(GeoLatLng pt1, GeoLatLng pt2)
        {
            double        d, crs12, crs21;
            CrsdistResult outValue = new CrsdistResult();
            double        lat1     = pt1.LatRadians();
            double        lat2     = pt2.LatRadians();
            double        lon1     = -pt1.LngRadians();
            double        lon2     = -pt2.LngRadians();
            double        dc       = _currentUnit == UNIT_NM ? 1 : 1.852;

            if (_currentEarthMode == EARTH_MODEL_SPHERE)
            {
                // spherical code// compute crs and Distance
                CrsdistResult cd = Crsdist(lat1, lon1, lat2, lon2);
                crs12 = cd._crs12 * (180 / MathEx.PI);
                crs21 = cd._crs21 * (180 / MathEx.PI);
                d     = cd._d * (180 / MathEx.PI) * 60 * dc; // go to physical units
            }
            else
            {
                // elliptic code // ellipse uses East negative
                CrsdistResult cde = CrsdistEll(lat1, -lon1, lat2, -lon2, _currentEarthMode);
                crs12 = cde._crs12 * (180 / MathEx.PI);
                crs21 = cde._crs21 * (180 / MathEx.PI);
                d     = cde._d * dc; // go to physical units
            }
            outValue._crs12 = crs12;
            outValue._crs21 = crs21;
            outValue._d     = d;
            return(outValue);
        }
Exemple #2
0
        private GeoLatLng ComputeFormDir(GeoLatLng pt1, double distance, double crs)
        {
            //get select  values
            double lat2, lon2;
            /* Input and validate data */

            double lat1 = pt1.LatRadians();
            double lon1 = -pt1.LngRadians();

            double d12 = distance;
            double dc  = _currentUnit == UNIT_NM ? 1 : 1.852;

            d12 /= dc;
            double crs12 = crs * MathEx.PI / 180.0;

            if (_currentEarthMode == EARTH_MODEL_SPHERE)
            {
                // spherical code
                d12 /= (180 * 60 / MathEx.PI);  // in radians
                DirectResult cd = Direct(lat1, lon1, crs12, d12);
                lat2 = cd._lat * (180 / MathEx.PI);
                lon2 = cd._lon * (180 / MathEx.PI);
            }
            else
            {
                // elliptic code// ellipse uses East negative
                DirectResult cde = DirectEll(lat1, -lon1, crs12, d12, _currentEarthMode);
                lat2 = cde._lat * (180 / MathEx.PI);
                lon2 = -cde._lon * (180 / MathEx.PI);// ellipse uses East negative
            }
            double retLat = lat2;
            double retLon = -lon2;

            return(new GeoLatLng(retLat, retLon));
        }
        private GeoLatLng ComputeFormDir(GeoLatLng pt1, double distance, double crs)
        {
            //get select  values
            double lat2, lon2;
            /* Input and validate data */

            double lat1 = pt1.LatRadians();
            double lon1 = -pt1.LngRadians();

            double d12 = distance;
            double dc = _currentUnit == UNIT_NM ? 1 : 1.852;
            d12 /= dc;
            double crs12 = crs * MathEx.PI / 180.0;
            if (_currentEarthMode == EARTH_MODEL_SPHERE)
            {
                // spherical code
                d12 /= (180 * 60 / MathEx.PI);  // in radians
                DirectResult cd = Direct(lat1, lon1, crs12, d12);
                lat2 = cd._lat * (180 / MathEx.PI);
                lon2 = cd._lon * (180 / MathEx.PI);
            }
            else
            {
                // elliptic code// ellipse uses East negative
                DirectResult cde = DirectEll(lat1, -lon1, crs12, d12, _currentEarthMode);
                lat2 = cde._lat * (180 / MathEx.PI);
                lon2 = -cde._lon * (180 / MathEx.PI);// ellipse uses East negative
            }
            double retLat = lat2;
            double retLon = -lon2;
            return new GeoLatLng(retLat, retLon);
        }
        private CrsdistResult ComputeFormCD(GeoLatLng pt1, GeoLatLng pt2)
        {
            double d, crs12, crs21;
            CrsdistResult outValue = new CrsdistResult();
            double lat1 = pt1.LatRadians();
            double lat2 = pt2.LatRadians();
            double lon1 = -pt1.LngRadians();
            double lon2 = -pt2.LngRadians();
            double dc = _currentUnit == UNIT_NM ? 1 : 1.852;

            if (_currentEarthMode == EARTH_MODEL_SPHERE)
            {
                // spherical code// compute crs and Distance
                CrsdistResult cd = Crsdist(lat1, lon1, lat2, lon2);
                crs12 = cd._crs12 * (180 / MathEx.PI);
                crs21 = cd._crs21 * (180 / MathEx.PI);
                d = cd._d * (180 / MathEx.PI) * 60 * dc; // go to physical units
            }
            else
            {
                // elliptic code // ellipse uses East negative
                CrsdistResult cde = CrsdistEll(lat1, -lon1, lat2, -lon2, _currentEarthMode);
                crs12 = cde._crs12 * (180 / MathEx.PI);
                crs21 = cde._crs21 * (180 / MathEx.PI);
                d = cde._d * dc; // go to physical units
            }
            outValue._crs12 = crs12;
            outValue._crs21 = crs21;
            outValue._d = d;
            return outValue;
        }