public static IMathTransform CreateCoordinateOperation(IProjection projection, IEllipsoid ellipsoid)
        {
            ParameterList parameterList = new ParameterList();
            for(int i=0; i< projection.NumParameters; i++)
            {
                ProjectionParameter param = projection.GetParameter(i);
                parameterList.Add(param.Name,param.Value);
            }
            parameterList.Add("semi_major",ellipsoid.SemiMajorAxis);
            parameterList.Add("semi_minor",ellipsoid.SemiMinorAxis);

            IMathTransform transform = null;
            switch(projection.Name.ToLower())
            {
                case "mercator":
                    //1SP
                    transform = new MercatorProjection(parameterList);
                    break;
                case "transverse_mercator":
                    transform = new TransverseMercatorProjection(parameterList);
                    break;
                case "albers":
                    transform = new AlbersProjection(parameterList);
                    break;
                case "lambert":
                    transform = new LambertConformalConic2SPProjection(parameterList);
                    break;
                default:
                    throw new NotSupportedException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Projection {0} is not supported.",projection.AuthorityCode));
            }
            return transform;
        }
示例#2
0
 /// <summary>
 /// Returns the inverse of this projection.
 /// </summary>
 /// <returns>IMathTransform that is the reverse of the current projection.</returns>
 public override IMathTransform GetInverse()
 {
     if (_inverse == null)
     {
         _inverse = new MercatorProjection(this._parameters, !_isInverse);
     }
     return(_inverse);
 }
示例#3
0
        /// <summary>
        /// Given a IProjection and a IEllipsoid, createa a IMathTransform with the required parameters.
        /// </summary>
        /// <param name="projection">The projection information.</param>
        /// <param name="ellipsoid">The ellipsoid to use.</param>
        /// <returns>An object that implements the IMathTransform interface.</returns>
        private IMathTransform CreateCoordinateOperation(IProjection projection, IEllipsoid ellipsoid)
        {
            ParameterList parameterList = new ParameterList();

            for (int i = 0; i < projection.NumParameters; i++)
            {
                ProjectionParameter param = projection.GetParameter(i);
                parameterList.Add(param.Name, param.Value);
            }
            parameterList.Add("semi_major", ellipsoid.SemiMajorAxis);
            parameterList.Add("semi_minor", ellipsoid.SemiMinorAxis);

            IMathTransform transform = null;

            switch (projection.AuthorityCode)
            {
            case "9804":
                //1SP
                transform = new MercatorProjection(parameterList);
                break;

            case "9805":
                //2SP
                transform = new MercatorProjection(parameterList);
                break;

            case "9807":
                transform = new TransverseMercatorProjection(parameterList);
                break;

            case "9633":
                // we should get these parameters from the file - but since we know them....
                ParameterList param = new ParameterList();
                parameterList.Add("latitude_of_natural_origin", 49.0);
                parameterList.Add("longitude_of_natural_origin", -2.0);
                parameterList.Add("scale_factor_at_natural_origin", 0.999601272);
                parameterList.Add("false_easting", 400000.0);
                parameterList.Add("false_northing", -100000.0);
                transform = new MercatorProjection(parameterList);
                break;

            default:
                throw new NotSupportedException(String.Format("Projection {0} is not supported.", projection.AuthorityCode));
            }
            return(transform);
        }
        public static IMathTransform CreateCoordinateOperation(IProjection projection, IEllipsoid ellipsoid)
        {
            ParameterList parameterList = new ParameterList();

            for (int i = 0; i < projection.NumParameters; i++)
            {
                ProjectionParameter param = projection.GetParameter(i);
                parameterList.Add(param.Name, param.Value);
            }
            parameterList.Add("semi_major", ellipsoid.SemiMajorAxis);
            parameterList.Add("semi_minor", ellipsoid.SemiMinorAxis);

            IMathTransform transform = null;

            switch (projection.Name.ToLower())
            {
            case "mercator":
                //1SP
                transform = new MercatorProjection(parameterList);
                break;

            case "transverse_mercator":
                transform = new TransverseMercatorProjection(parameterList);
                break;

            case "albers":
                transform = new AlbersProjection(parameterList);
                break;

            case "lambert":
                transform = new LambertConformalConic2SPProjection(parameterList);
                break;

            default:
                throw new NotSupportedException(String.Format("Projection {0} is not supported.", projection.AuthorityCode));
            }
            return(transform);
        }
		/// <summary>
		/// Returns the inverse of this projection.
		/// </summary>
		/// <returns>IMathTransform that is the reverse of the current projection.</returns>
		public IMathTransform Inverse()
		{
			if (_inverse==null)
			{
				_inverse = new MercatorProjection(this._parameters, ! _isInverse);
			}
			return _inverse;
		}
        /// <summary>
        /// Given a IProjection and a IEllipsoid, createa a IMathTransform with the required parameters.
        /// </summary>
        /// <param name="projection">The projection information.</param>
        /// <param name="ellipsoid">The ellipsoid to use.</param>
        /// <returns>An object that implements the IMathTransform interface.</returns>
        private IMathTransform CreateCoordinateOperation(IProjection projection, IEllipsoid ellipsoid)
        {
            ParameterList parameterList = new ParameterList();
            for(int i=0; i< projection.NumParameters; i++)
            {
                ProjectionParameter param = projection.GetParameter(i);
                parameterList.Add(param.Name,param.Value);
            }
            parameterList.Add("semi_major",ellipsoid.SemiMajorAxis);
            parameterList.Add("semi_minor",ellipsoid.SemiMinorAxis);

            IMathTransform transform = null;
            switch(projection.AuthorityCode)
            {
                case "9804":
                    //1SP
                    transform = new MercatorProjection(parameterList);
                    break;
                case "9805":
                    //2SP
                    transform = new MercatorProjection(parameterList);
                    break;
                case "9807":
                    transform = new TransverseMercatorProjection(parameterList);
                    break;
                case "9633":
                    // we should get these parameters from the file - but since we know them....
                    ParameterList param = new ParameterList();
                    parameterList.Add("latitude_of_natural_origin",49.0);
                    parameterList.Add("longitude_of_natural_origin",-2.0);
                    parameterList.Add("scale_factor_at_natural_origin",0.999601272);
                    parameterList.Add("false_easting",400000.0);
                    parameterList.Add("false_northing",-100000.0);
                    transform = new MercatorProjection(parameterList);
                    break;
                default:
                    throw new NotSupportedException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Projection {0} is not supported.",projection.AuthorityCode));
            }
            return transform;
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="name">Name to give new object.</param>
		/// <param name="wktProjectionClass">Classification string for projection (e.g. "Transverse_Mercator").</param>
		/// <param name="parameters">Parameters to use for projection. A default set of parameters can
		/// be constructed using classification and initialized
		/// using a chain of SetParameter(...) calls.</param>
		/// <returns>A projection.</returns>
		public IProjection CreateProjection(string name, string wktProjectionClass,  ProjectionParameter[] parameters)
		{	
			if (name==null)
			{
				throw new ArgumentNullException("name");
			}

			ParameterList parameterList = new ParameterList();
			for(int i=0; i< parameters.Length; i++)
			{
				ProjectionParameter param = parameters[i];
				parameterList.Add(param.Name,param.Value);
			}

			IProjection projection= null;
			switch (wktProjectionClass.ToLower())
			{
				case  "transverse_mercator":
					projection = new TransverseMercatorProjection(parameterList);
					break;
				case "mercator":
					projection = new MercatorProjection(parameterList);
					break;
				case "lambert_conformal_conic_2sp":
					projection = new LambertConformalConic2SPProjection(parameterList);
					break;
				case "albers":
					projection = new AlbersProjection(parameterList);
					break;
				default:
					throw new NotImplementedException(String.Format("The {0} projection is not supported",wktProjectionClass));
			}
			return projection;
		}