Example #1
0
 public Proj4DatumWrapper(Datum datum, Proj4MeridianWrapper meridian)
 {
     if (datum == null) throw new ArgumentNullException("datum");
     if (meridian == null) throw new ArgumentNullException("meridian");
     if (datum.Spheroid == null) throw new ArgumentException("Datum has no spheroid.", "datum");
     Contract.EndContractBlock();
     Core = datum;
     PrimeMeridian = meridian;
 }
Example #2
0
 /// <summary>
 /// Compares two datums to see if they are actually describing the same thing and
 /// therefore don't need to be transformed.
 /// </summary>
 /// <param name="otherDatum">The other datum to compare against</param>
 /// <returns>The boolean result of the operation.</returns>
 public bool Matches(Datum otherDatum)
 {
     if (_datumtype != otherDatum.DatumType) return false;
     if (_datumtype == DatumType.WGS84) return true;
     if (_spheroid.EquatorialRadius != otherDatum.Spheroid.EquatorialRadius) return false;
     if (_spheroid.PolarRadius != otherDatum.Spheroid.PolarRadius) return false;
     if (_datumtype == DatumType.Param3)
     {
         if (_toWgs84[0] != otherDatum.ToWGS84[0]) return false;
         if (_toWgs84[1] != otherDatum.ToWGS84[1]) return false;
         if (_toWgs84[2] != otherDatum.ToWGS84[2]) return false;
         return true;
     }
     if (_datumtype == DatumType.Param7)
     {
         if (_toWgs84[0] != otherDatum.ToWGS84[0]) return false;
         if (_toWgs84[1] != otherDatum.ToWGS84[1]) return false;
         if (_toWgs84[2] != otherDatum.ToWGS84[2]) return false;
         if (_toWgs84[3] != otherDatum.ToWGS84[3]) return false;
         if (_toWgs84[4] != otherDatum.ToWGS84[4]) return false;
         if (_toWgs84[5] != otherDatum.ToWGS84[5]) return false;
         if (_toWgs84[6] != otherDatum.ToWGS84[6]) return false;
         return true;
     }
     if (_datumtype == DatumType.GridShift)
     {
         if (_nadGrids.Length != otherDatum.NadGrids.Length) return false;
         return !_nadGrids.Where((t, i) => t != otherDatum.NadGrids[i]).Any();
     }
     return false;
 }
Example #3
0
 /// <summary>
 /// Creates a new instance of GeographicInfo
 /// </summary>
 public GeographicInfo()
 {
     _datum = new Datum();
     _meridian = new Meridian();
     _unit = new AngularUnit();
 }
Example #4
0
        public static Datum Create(IDatumGeodetic datum)
        {
            if(datum == null) throw new ArgumentNullException("datum");
            Contract.Ensures(Contract.Result<Datum>() != null);

            var result = new Datum {
                Name = datum.Name
            };

            result.Spheroid = Proj4SpheroidWrapper.Create(datum.Spheroid);

            if (datum.IsTransformableToWgs84) {
                var helmert = datum.BasicWgs84Transformation;
                if (helmert.ScaleDeltaPartsPerMillion == 0 && Vector3.Zero.Equals(helmert.RotationArcSeconds)) {
                    if (Vector3.Zero.Equals(helmert.Delta)) {
                        if (result.Spheroid.Name == "WE")
                            result.Proj4DatumName = "wgs84";
                        else
                            result.DatumType = DatumType.WGS84;
                    }
                    else{
                        result.ToWGS84 = new[] {
                            helmert.Delta.X, helmert.Delta.Y, helmert.Delta.Z
                        };
                        result.DatumType = DatumType.Param3;
                    }
                }
                else {
                    result.ToWGS84 = new[] {
                        helmert.Delta.X, helmert.Delta.Y, helmert.Delta.Z,
                        helmert.RotationArcSeconds.X, helmert.RotationArcSeconds.Y, helmert.RotationArcSeconds.Z,
                        helmert.ScaleDeltaPartsPerMillion
                    };
                    result.DatumType = DatumType.Param7;
                }
            }
            else {
                result.DatumType = DatumType.Unknown;
            }

            return result;
        }