Example #1
0
 protected OgcUnitBase(string name, double factor, IAuthorityTag authority)
     : base(name, authority)
 {
     Contract.Requires(name != null);
     Factor = factor;
     _referenceConversionMap = new Lazy <IUnitConversionMap <double> >(CreateReferenceConversionMap, LazyThreadSafetyMode.ExecutionAndPublication);
 }
 public OgcCoordinateOperationMethodInfo(string name, IAuthorityTag authorityTag = null)
 {
     if(name == null) throw new ArgumentNullException("name");
     Contract.EndContractBlock();
     Name = name;
     Authority = authorityTag;
 }
Example #3
0
        private ICoordinateOperationMethodInfo ReadCoordinateOperationMethodFromParams()
        {
            Contract.Ensures(Contract.Result <ICoordinateOperationMethodInfo>() != null);
            IAuthorityTag authority = null;
            var           name      = String.Empty;

            foreach (var parameter in ReadParams())
            {
                if (parameter is string)
                {
                    name = (string)parameter;
                }
                else if (parameter is IAuthorityTag)
                {
                    authority = (IAuthorityTag)parameter; // NOTE: this is in the spec for PROJECTION but does not appear to be used in practice
                }
            }

            if (null != authority)
            {
                var methodInfo = Options.GetCoordinateOperationMethod(authority);
                if (null != methodInfo)
                {
                    return(methodInfo);
                }
            }

            return(new OgcCoordinateOperationMethodInfo(
                       name,
                       authority
                       ));
        }
Example #4
0
 /// <summary>
 /// Constructs a prime meridian.
 /// </summary>
 /// <param name="name">The name of the prime meridian.</param>
 /// <param name="longitude">The longitude location of the meridian.</param>
 /// <param name="angularUnit">The angular unit of the longitude value.</param>
 /// <param name="authority">The authority.</param>
 public OgcPrimeMeridian(string name, double longitude, IUnit angularUnit, IAuthorityTag authority = null)
     : base(name, authority)
 {
     Contract.Requires(name != null);
     Longitude = longitude;
     Unit = angularUnit ?? OgcAngularUnit.DefaultDegrees;
 }
Example #5
0
 /// <summary>
 /// Constructs a new vertical CRS.
 /// </summary>
 /// <param name="name">The name of the CRS.</param>
 /// <param name="datum">The datum the CRS is based on.</param>
 /// <param name="linearUnit">The linear unit for the CRS.</param>
 /// <param name="axis">The axis for the linear CRS.</param>
 /// <param name="authority">The authority.</param>
 public OgcCrsVertical(
     string name,
     IDatum datum,
     IUnit linearUnit,
     IAxis axis,
     IAuthorityTag authority
     )
     : base(name, authority)
 {
     if (datum == null)
     {
         throw new ArgumentNullException("datum");
     }
     if (linearUnit == null)
     {
         throw new ArgumentNullException("linearUnit");
     }
     if (axis == null)
     {
         throw new ArgumentNullException("axis");
     }
     Contract.Requires(name != null);
     Datum = datum;
     Unit  = linearUnit;
     Axis  = axis;
 }
Example #6
0
        /// <summary>
        /// Constructs a new projected CRS.
        /// </summary>
        /// <param name="name">The name of the CRS.</param>
        /// <param name="baseCrs">The CRS this CRS is based on.</param>
        /// <param name="projection">The projection operation.</param>
        /// <param name="linearUnit">The linear unit of the projection.</param>
        /// <param name="axes">The axes of the projected CRS.</param>
        /// <param name="authority">The authority.</param>
        public OgcCrsProjected(
            string name,
            ICrsGeodetic baseCrs,
            ICoordinateOperationInfo projection,
            IUnit linearUnit,
            IEnumerable <IAxis> axes,
            IAuthorityTag authority = null
            )
            : base(name, authority)
        {
            if (null == baseCrs)
            {
                throw new ArgumentNullException("baseCrs");
            }
            if (null == projection)
            {
                throw new ArgumentNullException("projection");
            }
            if (null == linearUnit)
            {
                throw new ArgumentNullException("linearUnit");
            }
            if (null == axes)
            {
                throw new ArgumentNullException("axes");
            }
            Contract.Requires(name != null);

            BaseCrs    = baseCrs;
            Projection = projection;
            Unit       = linearUnit;
            Axes       = Array.AsReadOnly(null == axes ? new IAxis[0] : axes.ToArray());
        }
Example #7
0
 protected OgcUnitBase(string name, double factor, IAuthorityTag authority)
     : base(name, authority)
 {
     Contract.Requires(name != null);
     Factor = factor;
     _referenceConversionMap = new Lazy<IUnitConversionMap<double>>(CreateReferenceConversionMap, LazyThreadSafetyMode.ExecutionAndPublication);
 }
 protected OgcNamedAuthorityBoundEntity(string name, IAuthorityTag authorityTag)
 {
     if (name == null) throw new ArgumentNullException("name");
     Contract.EndContractBlock();
     Name = name;
     Authority = authorityTag;
 }
Example #9
0
 /// <summary>
 /// Constructs a prime meridian.
 /// </summary>
 /// <param name="name">The name of the prime meridian.</param>
 /// <param name="longitude">The longitude location of the meridian.</param>
 /// <param name="angularUnit">The angular unit of the longitude value.</param>
 /// <param name="authority">The authority.</param>
 public OgcPrimeMeridian(string name, double longitude, IUnit angularUnit, IAuthorityTag authority = null)
     : base(name, authority)
 {
     Contract.Requires(name != null);
     Longitude = longitude;
     Unit      = angularUnit ?? OgcAngularUnit.DefaultDegrees;
 }
Example #10
0
        public IDatumGeodetic ReadHorizontalDatumFromParams()
        {
            Contract.Ensures(Contract.Result <IDatumGeodetic>() != null);
            IAuthorityTag          authority     = null;
            var                    name          = String.Empty;
            ISpheroidInfo          spheroid      = null;
            Helmert7Transformation toWgs84       = null;
            IPrimeMeridianInfo     primeMeridian = null;

            foreach (var parameter in ReadParams())
            {
                if (parameter is IAuthorityTag)
                {
                    authority = (IAuthorityTag)parameter;
                }
                else if (parameter is string)
                {
                    name = (string)parameter;
                }
                else if (parameter is ISpheroidInfo)
                {
                    spheroid = (ISpheroidInfo)parameter;
                }
                else if (parameter is Helmert7Transformation)
                {
                    toWgs84 = (Helmert7Transformation)parameter;
                }
                else if (parameter is IPrimeMeridianInfo)
                {
                    primeMeridian = (IPrimeMeridianInfo)parameter; // NOTE: this may not happen due to the spec... but just in case?
                }
            }

            if (null != authority)
            {
                var datum = Options.GetDatum(authority) as IDatumGeodetic;
                if (null != datum)
                {
                    return(datum);
                }
            }

            if (spheroid == null)
            {
                if (Options.ThrowOnError)
                {
                    throw new WktParseExceptioncs("Horizontal Datum", "No spheroid.");
                }
                spheroid = OgcSpheroid.DefaultWgs84;
            }

            return(new OgcDatumHorizontal(
                       name,
                       spheroid,
                       primeMeridian,
                       toWgs84,
                       authority
                       ));
        }
Example #11
0
 public ICoordinateOperationMethodInfo GetCoordinateOperationMethod(IAuthorityTag tag)
 {
     if (tag == null)
     {
         throw new ArgumentNullException("tag");
     }
     Contract.EndContractBlock();
     return(GetAuthorityBoundObject(r => r.GetCoordinateOperationMethod(tag)));
 }
Example #12
0
 public IUnit GetUom(IAuthorityTag tag)
 {
     if (tag == null)
     {
         throw new ArgumentNullException("tag");
     }
     Contract.EndContractBlock();
     return(GetAuthorityBoundObject(r => r.GetUom(tag)));
 }
Example #13
0
 public IPrimeMeridianInfo GetPrimeMeridian(IAuthorityTag tag)
 {
     if (tag == null)
     {
         throw new ArgumentNullException("tag");
     }
     Contract.EndContractBlock();
     return(GetAuthorityBoundObject(r => r.GetPrimeMeridian(tag)));
 }
Example #14
0
 public OgcCoordinateOperationMethodInfo(string name, IAuthorityTag authorityTag = null)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     Contract.EndContractBlock();
     Name      = name;
     Authority = authorityTag;
 }
 protected OgcNamedAuthorityBoundEntity(string name, IAuthorityTag authorityTag)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     Contract.EndContractBlock();
     Name      = name;
     Authority = authorityTag;
 }
Example #16
0
 /// <summary>
 /// Constructs a new spheroid.
 /// </summary>
 /// <param name="spheroid">The spheroid this spheroid is based on.</param>
 /// <param name="name">The name of this spheroid.</param>
 /// <param name="axisUnit">The unit the axis is measured in.</param>
 /// <param name="authority">The authority.</param>
 public OgcSpheroid(ISpheroid <double> spheroid, string name, IUnit axisUnit, IAuthorityTag authority = null)
     : base(name, authority)
 {
     if (spheroid == null)
     {
         throw new ArgumentNullException("spheroid");
     }
     Contract.Requires(name != null);
     Spheroid = spheroid;
     AxisUnit = axisUnit;
 }
Example #17
0
 /// <summary>
 /// Constructs a new fitted CRS.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="toBaseOperation">The operation which converts to <paramref name="baseCrs"/>.</param>
 /// <param name="baseCrs">The base CRS.</param>
 /// <param name="authority">The authority code of the CRS.</param>
 public OgcCrsFitted(
     string name,
     ICoordinateOperationInfo toBaseOperation,
     ICrs baseCrs,
     IAuthorityTag authority = null
     )
     : base(name, authority)
 {
     if (null == toBaseOperation) throw new ArgumentNullException("toBaseOperation");
     if (null == baseCrs) throw new ArgumentNullException("baseCrs");
     Contract.Requires(name != null);
     ToBaseOperation = toBaseOperation;
     BaseCrs = baseCrs;
 }
Example #18
0
 /// <summary>
 /// Creates a new compound CRS.
 /// </summary>
 /// <param name="name">The name of the compound.</param>
 /// <param name="head">The head CRS.</param>
 /// <param name="tail">The tail CRS.</param>
 /// <param name="authority">The authority.</param>
 public OgcCrsCompound(
     string name,
     ICrs head,
     ICrs tail,
     IAuthorityTag authority
     )
     : base(name, authority)
 {
     if(null == head) throw new ArgumentNullException("head");
     if(null == tail) throw new ArgumentNullException("tail");
     Contract.Requires(name != null);
     Head = head;
     Tail = tail;
 }
Example #19
0
 public void Write(IAuthorityTag entity)
 {
     if (entity == null)
     {
         throw new ArgumentNullException("entity");
     }
     Contract.EndContractBlock();
     Write(WktKeyword.Authority);
     WriteOpenParenthesis();
     WriteQuoted(FixName(entity.Name));
     WriteComma();
     WriteQuoted(entity.Code);
     WriteCloseParenthesis();
 }
Example #20
0
 /// <summary>
 /// Constructs a horizontal datum.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="spheroid">The spheroid of the datum.</param>
 /// <param name="primeMeridian">The prime meridian of the datum.</param>
 /// <param name="transform">The transformation for conversions to WGS84.</param>
 /// <param name="authority">The authority.</param>
 public OgcDatumHorizontal(
     string name,
     ISpheroidInfo spheroid,
     IPrimeMeridianInfo primeMeridian,
     Helmert7Transformation transform,
     IAuthorityTag authority = null
     )
     : base(name, OgcDatumType.None, authority)
 {
     if (null == spheroid) throw new ArgumentNullException("spheroid");
     Contract.Requires(name != null);
     Spheroid = spheroid;
     PrimeMeridian = primeMeridian;
     BasicWgs84Transformation = transform;
 }
Example #21
0
 public CoordinateOperationInfo(
     string name,
     IEnumerable <INamedParameter> parameters = null,
     ICoordinateOperationMethodInfo method    = null,
     IAuthorityTag authority = null,
     bool hasInverse         = true
     )
 {
     Name       = name ?? String.Empty;
     Parameters = null == parameters
         ? EmptyParameterList
         : Array.AsReadOnly(parameters.ToArray());
     HasInverse = hasInverse;
     Method     = method;
     Authority  = authority;
 }
Example #22
0
 /// <summary>
 /// Constructs a new local CRS.
 /// </summary>
 /// <param name="name">The CRS name.</param>
 /// <param name="datum">The datum the CRS is based on.</param>
 /// <param name="unit">The unit for the CRS.</param>
 /// <param name="axes">The axes of the CRS.</param>
 /// <param name="authority">The authority.</param>
 public OgcCrsLocal(
     string name,
     IDatum datum,
     IUnit unit,
     IEnumerable<IAxis> axes,
     IAuthorityTag authority
     )
     : base(name, authority)
 {
     if (datum == null) throw new ArgumentNullException("datum");
     if (unit == null) throw new ArgumentNullException("unit");
     Contract.Requires(name != null);
     Datum = datum;
     Unit = unit;
     Axes = Array.AsReadOnly(null == axes ? new IAxis[0] : axes.ToArray());
 }
Example #23
0
 /// <summary>
 /// Constructs a new geocentric CRS.
 /// </summary>
 /// <param name="name">The name of the CRS.</param>
 /// <param name="datum">The datum the CRS is based on.</param>
 /// <param name="linearUnit">The linear UoM to use for the CRS.</param>
 /// <param name="axes">The axes which define the space.</param>
 /// <param name="authority">The authority.</param>
 public OgcCrsGeocentric(
     string name,
     IDatumGeodetic datum,
     IUnit linearUnit,
     IEnumerable<IAxis> axes,
     IAuthorityTag authority
     )
     : base(name, authority)
 {
     if (null == datum) throw new ArgumentNullException("datum");
     if (null == linearUnit) throw new ArgumentNullException("linearUnit");
     Contract.Requires(name != null);
     Datum = datum;
     Unit = linearUnit;
     Axes = Array.AsReadOnly(null == axes ? new IAxis[0] : axes.ToArray());
 }
 public CoordinateOperationInfo(
     string name,
     IEnumerable<INamedParameter> parameters = null,
     ICoordinateOperationMethodInfo method = null,
     IAuthorityTag authority = null,
     bool hasInverse = true
 )
 {
     Name = name ?? String.Empty;
     Parameters = null == parameters
         ? EmptyParameterList
         : Array.AsReadOnly(parameters.ToArray());
     HasInverse = hasInverse;
     Method = method;
     Authority = authority;
 }
Example #25
0
 /// <summary>
 /// Constructs a new vertical CRS.
 /// </summary>
 /// <param name="name">The name of the CRS.</param>
 /// <param name="datum">The datum the CRS is based on.</param>
 /// <param name="linearUnit">The linear unit for the CRS.</param>
 /// <param name="axis">The axis for the linear CRS.</param>
 /// <param name="authority">The authority.</param>
 public OgcCrsVertical(
     string name,
     IDatum datum,
     IUnit linearUnit,
     IAxis axis,
     IAuthorityTag authority
     )
     : base(name, authority)
 {
     if(datum == null) throw new ArgumentNullException("datum");
     if(linearUnit == null) throw new ArgumentNullException("linearUnit");
     if(axis == null) throw new ArgumentNullException("axis");
     Contract.Requires(name != null);
     Datum = datum;
     Unit = linearUnit;
     Axis = axis;
 }
Example #26
0
        public IUnit ReadUnitFromParams(bool isLength = true)
        {
            Contract.Ensures(Contract.Result <IUnit>() != null);
            IAuthorityTag authority = null;
            var           name      = String.Empty;
            double?       factor    = null;

            foreach (var parameter in ReadParams())
            {
                if (parameter is IAuthorityTag)
                {
                    authority = (IAuthorityTag)parameter;
                }
                else if (parameter is string)
                {
                    name = (string)parameter;
                }
                else if (parameter is double)
                {
                    factor = (double)parameter;
                }
            }

            if (null != authority)
            {
                var unit = Options.GetUom(authority);
                if (null != unit)
                {
                    return(unit);
                }
            }

            if (!factor.HasValue)
            {
                if (Options.ThrowOnError)
                {
                    throw new WktParseExceptioncs("Unit", "No base conversion factor.");
                }
                factor = 1.0;
            }

            return(isLength
                ? (IUnit) new OgcLinearUnit(name, factor.GetValueOrDefault(), authority)
                : new OgcAngularUnit(name, factor.GetValueOrDefault(), authority));
        }
Example #27
0
 /// <summary>
 /// Constructs a horizontal datum.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="spheroid">The spheroid of the datum.</param>
 /// <param name="primeMeridian">The prime meridian of the datum.</param>
 /// <param name="transform">The transformation for conversions to WGS84.</param>
 /// <param name="authority">The authority.</param>
 public OgcDatumHorizontal(
     string name,
     ISpheroidInfo spheroid,
     IPrimeMeridianInfo primeMeridian,
     Helmert7Transformation transform,
     IAuthorityTag authority = null
     )
     : base(name, OgcDatumType.None, authority)
 {
     if (null == spheroid)
     {
         throw new ArgumentNullException("spheroid");
     }
     Contract.Requires(name != null);
     Spheroid                 = spheroid;
     PrimeMeridian            = primeMeridian;
     BasicWgs84Transformation = transform;
 }
Example #28
0
        public IDatum ReadBasicDatumFromParams(OgcDatumType defaultDatumType)
        {
            Contract.Ensures(Contract.Result <IDatum>() != null);
            IAuthorityTag authority = null;
            var           name      = String.Empty;
            var           datumType = OgcDatumType.None;

            foreach (var parameter in ReadParams())
            {
                if (parameter is string)
                {
                    name = (string)parameter;
                }
                else if (parameter is IAuthorityTag)
                {
                    authority = (IAuthorityTag)parameter;
                }
                else if (parameter is double)
                {
                    datumType = (OgcDatumType)(int)(double)parameter;
                }
                else if (parameter is int)
                {
                    datumType = (OgcDatumType)(int)parameter;
                }
            }

            if (null != authority)
            {
                var datum = Options.GetDatum(authority);
                if (null != datum)
                {
                    return(datum);
                }
            }

            return(new OgcDatum(
                       name,
                       datumType,
                       authority
                       ));
        }
Example #29
0
 /// <summary>
 /// Constructs a new fitted CRS.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="toBaseOperation">The operation which converts to <paramref name="baseCrs"/>.</param>
 /// <param name="baseCrs">The base CRS.</param>
 /// <param name="authority">The authority code of the CRS.</param>
 public OgcCrsFitted(
     string name,
     ICoordinateOperationInfo toBaseOperation,
     ICrs baseCrs,
     IAuthorityTag authority = null
     )
     : base(name, authority)
 {
     if (null == toBaseOperation)
     {
         throw new ArgumentNullException("toBaseOperation");
     }
     if (null == baseCrs)
     {
         throw new ArgumentNullException("baseCrs");
     }
     Contract.Requires(name != null);
     ToBaseOperation = toBaseOperation;
     BaseCrs         = baseCrs;
 }
Example #30
0
        public IAuthorityTag ReadAuthorityFromParams()
        {
            var names = Array.ConvertAll(ReadParams(), x => null == x ? String.Empty : x.ToString());

            if (names.Length == 0)
            {
                return(null);
            }

            var authorityName = names[0] ?? String.Empty;
            var authorityCode = (names.Length > 1 ? names[1] : null) ?? String.Empty;

            IAuthorityTag tag = null;

            if (Options.ResolveAuthorities)
            {
                tag = Options.GetAuthorityTag(authorityName, authorityCode);
            }
            return(tag ?? new AuthorityTag(authorityName, authorityCode));
        }
Example #31
0
 /// <summary>
 /// Creates a new compound CRS.
 /// </summary>
 /// <param name="name">The name of the compound.</param>
 /// <param name="head">The head CRS.</param>
 /// <param name="tail">The tail CRS.</param>
 /// <param name="authority">The authority.</param>
 public OgcCrsCompound(
     string name,
     ICrs head,
     ICrs tail,
     IAuthorityTag authority
     )
     : base(name, authority)
 {
     if (null == head)
     {
         throw new ArgumentNullException("head");
     }
     if (null == tail)
     {
         throw new ArgumentNullException("tail");
     }
     Contract.Requires(name != null);
     Head = head;
     Tail = tail;
 }
Example #32
0
 /// <summary>
 /// Constructs a new geographic CRS.
 /// </summary>
 /// <param name="name">The name of the CRS.</param>
 /// <param name="datum">The datum the CRS is based on.</param>
 /// <param name="angularUnit">The angular unit of measure for the CRS.</param>
 /// <param name="axes">The axes defining the space.</param>
 /// <param name="authority">The authority.</param>
 public OgcCrsGeographic(
     string name,
     IDatumGeodetic datum,
     IUnit angularUnit,
     IEnumerable <IAxis> axes,
     IAuthorityTag authority = null
     )
     : base(name, authority)
 {
     if (null == datum)
     {
         throw new ArgumentNullException("datum");
     }
     if (null == angularUnit)
     {
         throw new ArgumentNullException("angularUnit");
     }
     Contract.Requires(name != null);
     Datum = datum;
     Unit  = angularUnit;
     Axes  = Array.AsReadOnly(null == axes ? new IAxis[0] : axes.ToArray());
 }
Example #33
0
 /// <summary>
 /// Constructs a new local CRS.
 /// </summary>
 /// <param name="name">The CRS name.</param>
 /// <param name="datum">The datum the CRS is based on.</param>
 /// <param name="unit">The unit for the CRS.</param>
 /// <param name="axes">The axes of the CRS.</param>
 /// <param name="authority">The authority.</param>
 public OgcCrsLocal(
     string name,
     IDatum datum,
     IUnit unit,
     IEnumerable <IAxis> axes,
     IAuthorityTag authority
     )
     : base(name, authority)
 {
     if (datum == null)
     {
         throw new ArgumentNullException("datum");
     }
     if (unit == null)
     {
         throw new ArgumentNullException("unit");
     }
     Contract.Requires(name != null);
     Datum = datum;
     Unit  = unit;
     Axes  = Array.AsReadOnly(null == axes ? new IAxis[0] : axes.ToArray());
 }
Example #34
0
 public static bool TryConvert(IAuthorityTag authorityTag, out EpsgAuthorityTag epsgTag)
 {
     if (authorityTag != null)
     {
         if (authorityTag is EpsgAuthorityTag)
         {
             epsgTag = (EpsgAuthorityTag)authorityTag;
             return(true);
         }
         if (EpsgName.Equals(authorityTag.Name, StringComparison.OrdinalIgnoreCase))
         {
             int codeNumber;
             if (Int32.TryParse(authorityTag.Code, out codeNumber))
             {
                 epsgTag = new EpsgAuthorityTag(codeNumber);
                 return(true);
             }
         }
     }
     epsgTag = new EpsgAuthorityTag();
     return(false);
 }
Example #35
0
        public IPrimeMeridianInfo ReadPrimeMeridianFromParams()
        {
            Contract.Ensures(Contract.Result <IPrimeMeridianInfo>() != null);
            IAuthorityTag authority = null;
            var           name      = String.Empty;
            double        longitude = 0;

            foreach (var parameter in ReadParams())
            {
                if (parameter is string)
                {
                    name = (string)parameter;
                }
                else if (parameter is IAuthorityTag)
                {
                    authority = (IAuthorityTag)parameter;
                }
                else if (parameter is double)
                {
                    longitude = (double)parameter;
                }
            }

            if (null != authority)
            {
                var primeMeridian = Options.GetPrimeMeridian(authority);
                if (null != primeMeridian)
                {
                    return(primeMeridian);
                }
            }

            return(new OgcPrimeMeridian(
                       name,
                       longitude,
                       OgcAngularUnit.DefaultDegrees,// TODO: from options?
                       authority
                       ));
        }
Example #36
0
        private ICrsGeographic ReadGeographicCsFromParams()
        {
            Contract.Ensures(Contract.Result <ICrsGeographic>() != null);
            IAuthorityTag      authority     = null;
            var                name          = String.Empty;
            IDatumGeodetic     datum         = null;
            IPrimeMeridianInfo primeMeridian = null;
            IUnit              unit          = OgcAngularUnit.DefaultDegrees;
            var                axes          = new List <IAxis>();

            foreach (var parameter in ReadParams())
            {
                if (parameter is string)
                {
                    name = (string)parameter;
                }
                else if (parameter is IAuthorityTag)
                {
                    authority = (IAuthorityTag)parameter;
                }
                else if (parameter is IDatumGeodetic)
                {
                    datum = (IDatumGeodetic)parameter;
                }
                else if (parameter is IPrimeMeridianInfo)
                {
                    primeMeridian = (IPrimeMeridianInfo)parameter;
                }
                else if (parameter is IUnit)
                {
                    unit = (IUnit)parameter;
                }
                else if (parameter is IAxis)
                {
                    axes.Add((IAxis)parameter);
                }
            }

            if (null != authority)
            {
                var crs = Options.GetCrs(authority) as ICrsGeographic;
                if (null != crs)
                {
                    return(crs);
                }
            }

            if (null != datum && datum.PrimeMeridian == null && null != primeMeridian)
            {
                // in this case the datum must have NOT been created from an authority source so we should remake it with a prime meridian
                datum = new OgcDatumHorizontal(
                    datum.Name,
                    datum.Spheroid,
                    primeMeridian,
                    datum.BasicWgs84Transformation,
                    datum.Authority
                    );
            }

            if (datum == null)
            {
                if (Options.ThrowOnError)
                {
                    throw new WktParseExceptioncs("Geographic CRS", "No datum.");
                }
                datum = OgcDatumHorizontal.DefaultWgs84;
            }

            return(new OgcCrsGeographic(
                       name,
                       datum,
                       unit,
                       axes,
                       authority
                       ));
        }
Example #37
0
 /// <summary>
 /// Constructs a prime meridian.
 /// </summary>
 /// <param name="name">The name of the prime meridian.</param>
 /// <param name="longitude">The longitude location of the meridian.</param>
 /// <param name="authority">The authority.</param>
 public OgcPrimeMeridian(string name, double longitude, IAuthorityTag authority = null)
     : this(name, longitude, null, authority)
 {
     Contract.Requires(name != null);
 }
Example #38
0
 public bool Equals(IAuthorityTag other)
 {
     return(null != other &&
            String.Equals(Name, other.Name) &&
            String.Equals(Code, other.Code));
 }
Example #39
0
 protected Proj4Crs(string name, IAuthorityTag tag)
     : base(name, tag)
 {
     Contract.Requires(name != null);
 }
Example #40
0
 /// <summary>
 /// Constructs a local datum.
 /// </summary>
 /// <param name="name">The datum name.</param>
 /// <param name="type">The datum type code.</param>
 /// <param name="authority">The authority.</param>
 public OgcDatum(string name, OgcDatumType type, IAuthorityTag authority)
     : base(name, authority)
 {
     Contract.Requires(name != null);
     OgcType = type;
 }
Example #41
0
 /// <summary>
 /// Constructs a new unit.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="factor">The conversion factor to the base unit.</param>
 /// <param name="authority">The authority.</param>
 public OgcLinearUnit(string name, double factor, IAuthorityTag authority)
     : base(name, factor, authority)
 {
     Contract.Requires(name != null);
 }
Example #42
0
        public ISpheroidInfo ReadSpheroidFromParams()
        {
            Contract.Ensures(Contract.Result <ISpheroidInfo>() != null);
            var           name      = String.Empty;
            double?       majorAxis = null;
            double?       inverseF  = null;
            IAuthorityTag authority = null;

            foreach (var parameter in ReadParams())
            {
                if (parameter is string)
                {
                    name = (string)parameter;
                }
                else if (parameter is IAuthorityTag)
                {
                    authority = (IAuthorityTag)parameter;
                }
                else if (parameter is double)
                {
                    var value = (double)parameter;
                    if (!majorAxis.HasValue)
                    {
                        majorAxis = value;
                    }
                    else if (!inverseF.HasValue)
                    {
                        inverseF = value;
                    }
                }
            }

            if (null != authority)
            {
                var spheroid = Options.GetSpheroid(authority);
                if (null != spheroid)
                {
                    return(spheroid);
                }
            }

            if (!majorAxis.HasValue)
            {
                if (Options.ThrowOnError)
                {
                    throw new WktParseExceptioncs("Spheroid", "No major axis.");
                }
                majorAxis = Double.NaN;
            }
            if (!inverseF.HasValue)
            {
                if (Options.ThrowOnError)
                {
                    throw new WktParseExceptioncs("Spheroid", "No inverse flattening.");
                }
                inverseF = Double.NaN;
            }

            return(new OgcSpheroid(
                       new SpheroidEquatorialInvF(
                           majorAxis.GetValueOrDefault(),
                           inverseF.GetValueOrDefault()
                           ),
                       name,
                       OgcLinearUnit.DefaultMeter,
                       authority
                       ));
        }
Example #43
0
        private ICrsLocal ReadLocalCsFromParams()
        {
            Contract.Ensures(Contract.Result <ICrsLocal>() != null);
            IAuthorityTag authority = null;
            var           name      = String.Empty;
            IDatum        datum     = null;
            IUnit         unit      = null;
            var           axes      = new List <IAxis>();

            foreach (var parameter in ReadParams())
            {
                if (parameter is IAuthorityTag)
                {
                    authority = (IAuthorityTag)parameter;
                }
                else if (parameter is string)
                {
                    name = (string)parameter;
                }
                else if (parameter is IDatum)
                {
                    datum = (IDatum)parameter;
                }
                else if (parameter is IUnit)
                {
                    unit = (IUnit)parameter;
                }
                else if (parameter is IAxis)
                {
                    axes.Add((IAxis)parameter);
                }
            }

            if (null != authority)
            {
                var crs = Options.GetCrs(authority) as ICrsLocal;
                if (null != crs)
                {
                    return(crs);
                }
            }

            if (datum == null)
            {
                if (Options.ThrowOnError)
                {
                    throw new WktParseExceptioncs("Local CRS", "No datum.");
                }
                datum = OgcDatumHorizontal.DefaultWgs84;
            }
            if (unit == null)
            {
                if (Options.ThrowOnError)
                {
                    throw new WktParseExceptioncs("Local CRS", "No unit.");
                }
                unit = OgcLinearUnit.DefaultMeter;
            }

            return(new OgcCrsLocal(
                       name,
                       datum,
                       unit,
                       axes,
                       authority
                       ));
        }
Example #44
0
        public ICrsVertical ReadVerticalCsFromParams()
        {
            IAuthorityTag authority = null;
            var           name      = String.Empty;
            IDatum        datum     = null;
            IUnit         unit      = null;
            IAxis         axis      = null;

            foreach (var parameter in ReadParams())
            {
                if (parameter is string)
                {
                    name = (string)parameter;
                }
                else if (parameter is IAuthorityTag)
                {
                    authority = (IAuthorityTag)parameter;
                }
                else if (parameter is IDatum)
                {
                    datum = (IDatum)parameter;
                }
                else if (parameter is IUnit)
                {
                    unit = (IUnit)parameter;
                }
                else if (parameter is IAxis)
                {
                    axis = (IAxis)parameter;
                }
            }

            if (null != authority)
            {
                var crs = Options.GetCrs(authority) as ICrsVertical;
                if (null != crs)
                {
                    return(crs);
                }
            }

            if (null == datum)
            {
                if (Options.ThrowOnError)
                {
                    throw new WktParseExceptioncs("Vertical CRS", "No datum.");
                }
                datum = OgcDatumHorizontal.DefaultWgs84;
            }
            if (null == unit)
            {
                if (Options.ThrowOnError)
                {
                    throw new WktParseExceptioncs("Vertical CRS", "No unit.");
                }
                unit = OgcLinearUnit.DefaultMeter;
            }
            if (null == axis)
            {
                if (Options.ThrowOnError)
                {
                    throw new WktParseExceptioncs("Vertical CRS", "No axis.");
                }
                return(null);
            }

            return(new OgcCrsVertical(
                       name,
                       datum,
                       unit,
                       axis,
                       authority
                       ));
        }
Example #45
0
        public ICrsProjected ReadProjectedCsFromParams()
        {
            IAuthorityTag authority = null;
            string        name      = null;
            ICrsGeodetic  baseCrs   = null;
            ICoordinateOperationMethodInfo operationMethodInfo = null;
            var   operationParameters = new List <INamedParameter>();
            IUnit linearUnit          = null;
            var   axes = new List <IAxis>();

            foreach (var parameter in ReadParams())
            {
                if (parameter is string)
                {
                    name = (string)parameter;
                }
                else if (parameter is ICrsGeodetic)
                {
                    baseCrs = (ICrsGeodetic)parameter;
                }
                else if (parameter is ICoordinateOperationMethodInfo)
                {
                    operationMethodInfo = (ICoordinateOperationMethodInfo)parameter;
                }
                else if (parameter is INamedParameter)
                {
                    operationParameters.Add((INamedParameter)parameter);
                }
                else if (parameter is IUnit)
                {
                    linearUnit = (IUnit)parameter;
                }
                else if (parameter is IAxis)
                {
                    axes.Add((IAxis)parameter);
                }
                else if (parameter is IAuthorityTag)
                {
                    authority = (IAuthorityTag)parameter;
                }
            }

            if (null != authority)
            {
                var crs = Options.GetCrs(authority) as ICrsProjected;
                if (null != crs)
                {
                    return(crs);
                }
            }

            if (null == baseCrs)
            {
                if (Options.ThrowOnError)
                {
                    throw new WktParseExceptioncs("Project CRS", "No base CRS.");
                }
                return(null);
            }

            return(new OgcCrsProjected(
                       name ?? String.Empty,
                       baseCrs,
                       new CoordinateOperationInfo(
                           null == operationMethodInfo ? String.Empty : FixName(operationMethodInfo.Name),
                           operationParameters,
                           operationMethodInfo
                           ),
                       linearUnit ?? OgcLinearUnit.DefaultMeter,
                       axes,
                       authority
                       ));
        }
Example #46
0
 public bool Equals(IAuthorityTag other)
 {
     return null != other
         && String.Equals(Name, other.Name)
         && String.Equals(Code, other.Code);
 }