Exemple #1
0
        /// <summary>
        /// Creates an instance of this class
        /// </summary>
        /// <param name="parameters">An enumeration of projection parameters</param>
        protected MapProjection(IEnumerable <ProjectionParameter> parameters)
        {
            _Parameters = new ProjectionParameterSet(parameters);

            _semiMajor = _Parameters.GetParameterValue("semi_major");
            _semiMinor = _Parameters.GetParameterValue("semi_minor");

            //_es = 1.0 - (_semiMinor * _semiMinor) / (_semiMajor * _semiMajor);
            _es = EccentricySquared(_semiMajor, _semiMinor);
            _e  = Math.Sqrt(_es);

            scale_factor = _Parameters.GetOptionalParameterValue("scale_factor", 1);

            central_meridian = Degrees2Radians(_Parameters.GetParameterValue("central_meridian", "longitude_of_center"));
            lat_origin       = Degrees2Radians(_Parameters.GetParameterValue("latitude_of_origin", "latitude_of_center"));

            _metersPerUnit = _Parameters.GetParameterValue("unit");

            false_easting  = _Parameters.GetOptionalParameterValue("false_easting", 0) * _metersPerUnit;
            false_northing = _Parameters.GetOptionalParameterValue("false_northing", 0) * _metersPerUnit;

            // TODO: Should really convert to the correct linear units??

            //  Compute constants for the mlfn
            double t;

            en0 = C00 - _es * (C02 + _es *
                               (C04 + _es * (C06 + _es * C08)));
            en1 = _es * (C22 - _es *
                         (C04 + _es * (C06 + _es * C08)));
            en2 = (t = _es * _es) *
                  (C44 - _es * (C46 + _es * C48));
            en3 = (t *= _es) * (C66 - _es * C68);
            en4 = t * _es * C88;
        }
Exemple #2
0
        /// <summary>
        /// Checks this projection parameter set with <paramref name="other"/>-
        /// </summary>
        /// <param name="other">The other projection parameter set.</param>
        /// <returns><value>true</value> if both sets are equal.</returns>
        public bool Equals(ProjectionParameterSet other)
        {
            if (other == null)
            {
                return(false);
            }

            if (other.Count != Count)
            {
                return(false);
            }

            foreach (var kvp in this)
            {
                if (!other.ContainsKey(kvp.Key))
                {
                    return(false);
                }

                double otherValue = other.GetParameterValue(kvp.Key);
                if (otherValue != kvp.Value)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #3
0
        private static IEnumerable <ProjectionParameter> VerifyParameters(IEnumerable <ProjectionParameter> parameters)
        {
            var    p          = new ProjectionParameterSet(parameters);
            double semi_major = p.GetParameterValue("semi_major");

            p.SetParameterValue("semi_minor", semi_major);
            p.SetParameterValue("scale_factor", 1);

            return(p.ToProjectionParameter());
        }