예제 #1
0
        static void Main(string[] args)
        {
            double[] maxLatMargin  = new double[] { 0, 0, 0 }; //{Max Deviation Recorded, @Lat, @Long}
            double[] maxLongMargin = new double[] { 0, 0, 0 }; //{Max Deviation Recorded, @Lat, @Long}

            //Deviations Neglagible between 85th parallels. Beyond thats, Lat deviations can occur up to 3 degrees.
            //This forumala should not be used for calculations above/below -85/85 parallels.
            //Adjust parallels lat degrees in the below loop to guage deviations.

            for (double lat = -90.0; lat < 91; lat++)
            {
                for (double lng = -180.0; lng < 181; lng++)
                {
                    double     latMargin            = 0;
                    double     longMargin           = 0;
                    Coordinate c                    = new Coordinate(lat, lng);
                    UniversalTransverseMercator utm = c.UTM;
                    Coordinate nc;

                    nc = UniversalTransverseMercator.ConvertUTMtoLatLong(utm);

                    double clat  = c.Latitude.ToDouble();
                    double nlat  = nc.Latitude.ToDouble();
                    double clong = c.Longitude.ToDouble();
                    double nlong = nc.Longitude.ToDouble();
                    if (clat < 0)
                    {
                        clat *= -1;
                    }
                    if (clong < 0)
                    {
                        clong *= -1;
                    }
                    if (nlat < 0)
                    {
                        nlat *= -1;
                    }
                    if (nlong < 0)
                    {
                        nlong *= -1;
                    }
                    latMargin = Math.Round(clat, 6) - Math.Round(nlat, 6);

                    longMargin = Math.Round(clong, 6) - Math.Round(nlong, 6);
                    if (latMargin < 0)
                    {
                        latMargin *= -1;
                    }

                    if (longMargin < 0)
                    {
                        longMargin *= -1;
                    }
                    Console.WriteLine(c.Latitude.ToDouble() + " " + c.Longitude.ToDouble() + " : " +
                                      nc.Latitude.ToDouble() + " " + nc.Longitude.ToDouble() + " : "
                                      + latMargin.ToString() + " " + longMargin.ToString());
                    if (latMargin > maxLatMargin[0])
                    {
                        maxLatMargin[0] = latMargin; maxLatMargin[1] = c.Latitude.ToDouble(); maxLatMargin[2] = c.Longitude.ToDouble();
                    }
                    if (longMargin > maxLongMargin[0])
                    {
                        maxLongMargin[0] = longMargin; maxLongMargin[1] = c.Latitude.ToDouble(); maxLatMargin[2] = c.Longitude.ToDouble();
                    }
                }
            }
            Console.WriteLine("MAX LAT DEVIATIONS - " + maxLatMargin[0].ToString() + " @ " + maxLatMargin[1].ToString() + " " + maxLatMargin[2].ToString());
            Console.WriteLine("MAX LONG DEVIATIONS - " + maxLongMargin[0].ToString() + " @ " + maxLongMargin[1].ToString() + " " + maxLongMargin[2].ToString());
            Console.ReadKey();
        }
        private static void Load_Call_Tests(Coordinate c)
        {
            //Check Load_Calls
            bool pass = true;

            c.LoadCelestialInfo();
            if (c.CelestialInfo == null)
            {
                pass = false;
            }
            c.LoadUTM_MGRS_Info();
            if (c.UTM == null)
            {
                pass = false;
            }
            if (c.MGRS == null)
            {
                pass = false;
            }
            c.LoadCartesianInfo();
            if (c.Cartesian == null)
            {
                pass = false;
            }
            c.LoadECEFInfo();
            if (c.ECEF == null)
            {
                pass = false;
            }
            Pass.Write("Load Calls (Celestial, UTM, MGRS, Cartesian, ECEF)", pass);
            if (pass)
            {
                Celestial cel = c.CelestialInfo;
                MilitaryGridReferenceSystem mgrs = c.MGRS;
                UniversalTransverseMercator utm  = c.UTM;
                Cartesian cart = c.Cartesian;
                ECEF      ecef = c.ECEF;

                c.Latitude.DecimalDegree  = -45;
                c.Longitude.DecimalDegree = -75;

                //Properties should not change.
                if (!ReflectiveEquals(c.CelestialInfo, cel))
                {
                    pass = false;
                }
                if (!ReflectiveEquals(c.MGRS, mgrs))
                {
                    pass = false;
                }
                if (!ReflectiveEquals(c.UTM, utm))
                {
                    pass = false;
                }
                if (!ReflectiveEquals(c.Cartesian, cart))
                {
                    pass = false;
                }
                if (!ReflectiveEquals(c.ECEF, ecef))
                {
                    pass = false;
                }
                //Properties should remain equal as no load calls were made
                Pass.Write("Property State Hold (Celestial, UTM, MGRS, Cartesian, ECEF)", pass);

                //Properties should change
                pass = true;
                c.LoadCelestialInfo();
                c.LoadCartesianInfo();
                c.LoadUTM_MGRS_Info();
                c.LoadECEFInfo();
                if (ReflectiveEquals(c.CelestialInfo, cel))
                {
                    pass = false;
                }
                if (ReflectiveEquals(c.MGRS, mgrs))
                {
                    pass = false;
                }
                if (ReflectiveEquals(c.UTM, utm))
                {
                    pass = false;
                }
                if (ReflectiveEquals(c.Cartesian, cart))
                {
                    pass = false;
                }
                if (ReflectiveEquals(c.ECEF, ecef))
                {
                    pass = false;
                }
                //Properties should not be equal as chages have been made
                Pass.Write("Property State Change (Celestial, UTM, MGRS, Cartesian, ECEF)", pass);
            }
            else
            {
                //Passes auto fail has properties didn't load when called.

                Pass.Write("Property State Hold (Celestial, UTM, MGRS, Cartesian, ECEF)", false);
                Pass.Write("Property State Change (Celestial, UTM, MGRS, Cartesian, ECEF)", false);
            }
        }
예제 #3
0
        private static void Run_Conversion_Passes(List <List <string> > Conversions)
        {
            //List of coordinates to test conversions against.
            List <double[]> coords = new List <double[]>();

            coords.Add(new double[] { 39.5768, 72.4859 });
            coords.Add(new double[] { -15.5768, 100.4859 });
            coords.Add(new double[] { 65.25, -15.1859 });
            coords.Add(new double[] { -80.6586, -152.49 });
            for (int x = 0; x < Conversions.Count; x++)
            {
                List <string> coordList = Conversions[x];
                double        lat       = coords[x][0];
                double        lng       = coords[x][1];
                //0 = Decimal / Signed
                //1 = Decimal Degree
                //2 = Degree Decimal Minute
                //3 = Degree Minutes Seconds
                //4 = UTM
                //5 = MGRS
                //6 = Cartesian
                //7 = ECEF
                Coordinate c    = new Coordinate(lat, lng);
                bool       pass = true;
                Coordinate rc   = new Coordinate();
                for (int y = 0; y < 8; y++)
                {
                    switch (y)
                    {
                    case 0:
                        c.FormatOptions.Format = CoordinateFormatType.Decimal;
                        if (c.ToString() != coordList[y])
                        {
                            pass = false;
                        }
                        break;

                    case 1:
                        c.FormatOptions.Format = CoordinateFormatType.Decimal_Degree;
                        if (c.ToString() != coordList[y])
                        {
                            pass = false;
                        }
                        break;

                    case 2:
                        c.FormatOptions.Format = CoordinateFormatType.Degree_Decimal_Minutes;
                        if (c.ToString() != coordList[y])
                        {
                            pass = false;
                        }
                        rc           = new Coordinate();
                        rc.Latitude  = new CoordinatePart(c.Latitude.Degrees, c.Latitude.DecimalMinute, c.Latitude.Position);
                        rc.Longitude = new CoordinatePart(c.Longitude.Degrees, c.Longitude.DecimalMinute, c.Longitude.Position);
                        if (rc.Latitude.ToDouble() != c.Latitude.ToDouble())
                        {
                            pass = false; Debug.WriteLine("...Conversion Outside Limits: " + rc.Latitude.ToDouble() + " - " + c.Latitude.ToDouble());
                        }
                        if (rc.Longitude.ToDouble() != c.Longitude.ToDouble())
                        {
                            pass = false; Debug.WriteLine("...Conversion Outside Limits: " + rc.Longitude.ToDouble() + " - " + c.Longitude.ToDouble());
                        }
                        break;

                    case 3:
                        c.FormatOptions.Format = CoordinateFormatType.Degree_Minutes_Seconds;
                        if (c.ToString() != coordList[y])
                        {
                            pass = false;
                        }
                        rc           = new Coordinate();
                        rc.Latitude  = new CoordinatePart(c.Latitude.Degrees, c.Latitude.Minutes, c.Latitude.Seconds, c.Latitude.Position);
                        rc.Longitude = new CoordinatePart(c.Longitude.Degrees, c.Longitude.Minutes, c.Longitude.Seconds, c.Longitude.Position);
                        if (rc.Latitude.ToDouble() != c.Latitude.ToDouble())
                        {
                            pass = false; Debug.WriteLine("...Conversion Outside Limits: " + rc.Latitude.ToDouble() + " - " + c.Latitude.ToDouble());
                        }
                        if (rc.Longitude.ToDouble() != c.Longitude.ToDouble())
                        {
                            pass = false; Debug.WriteLine("...Conversion Outside Limits: " + rc.Longitude.ToDouble() + " - " + c.Longitude.ToDouble());
                        }
                        break;

                    case 4:
                        if (c.UTM.ToString() != coordList[y] && c.UTM.WithinCoordinateSystemBounds)
                        {
                            pass = false;
                        }
                        UniversalTransverseMercator utm = new UniversalTransverseMercator(c.UTM.LatZone, c.UTM.LongZone, c.UTM.Easting, c.UTM.Northing);
                        rc = UniversalTransverseMercator.ConvertUTMtoLatLong(utm);

                        if (Math.Abs(rc.Latitude.ToDouble() - c.Latitude.ToDouble()) >= .00001 && c.UTM.WithinCoordinateSystemBounds)
                        {
                            pass = false; Debug.WriteLine("...UTM Conversion Outside Limits: " + rc.Latitude.ToDouble() + " - " + c.Latitude.ToDouble());
                        }
                        if (Math.Abs(rc.Longitude.ToDouble() - c.Longitude.ToDouble()) >= .00001 && c.UTM.WithinCoordinateSystemBounds)
                        {
                            pass = false; Debug.WriteLine("...UTM Conversion Outside Limits: " + rc.Longitude.ToDouble() + " - " + c.Longitude.ToDouble());
                        }

                        //SIGNED DEGREE METHOD
                        double[] sd = UniversalTransverseMercator.ConvertUTMtoSignedDegree(utm);
                        if (Math.Abs(sd[0] - c.Latitude.ToDouble()) >= .00001 && c.UTM.WithinCoordinateSystemBounds)
                        {
                            pass = false; Debug.WriteLine("...UTM Conversion Outside Limits: " + rc.Latitude.ToDouble() + " - " + c.Latitude.ToDouble());
                        }
                        if (Math.Abs(sd[1] - c.Longitude.ToDouble()) >= .00001 && c.UTM.WithinCoordinateSystemBounds)
                        {
                            pass = false; Debug.WriteLine("...UTM Conversion Outside Limits: " + rc.Longitude.ToDouble() + " - " + c.Longitude.ToDouble());
                        }


                        //OVERLOAD METHOD
                        utm = new UniversalTransverseMercator(c.UTM.LongZone + c.UTM.LatZone.ToString(), c.UTM.Easting, c.UTM.Northing);
                        rc  = UniversalTransverseMercator.ConvertUTMtoLatLong(utm);
                        if (Math.Abs(rc.Latitude.ToDouble() - c.Latitude.ToDouble()) >= .00001 && c.UTM.WithinCoordinateSystemBounds)
                        {
                            pass = false; Debug.WriteLine("...UTM Conversion Outside Limits: " + rc.Latitude.ToDouble() + " - " + c.Latitude.ToDouble());
                        }
                        if (Math.Abs(rc.Longitude.ToDouble() - c.Longitude.ToDouble()) >= .00001 && c.UTM.WithinCoordinateSystemBounds)
                        {
                            pass = false; Debug.WriteLine("...UTM Conversion Outside Limits: " + rc.Longitude.ToDouble() + " - " + c.Longitude.ToDouble());
                        }



                        break;

                    case 5:
                        if (c.MGRS.ToString() != coordList[y] && c.MGRS.WithinCoordinateSystemBounds)
                        {
                            pass = false;
                        }
                        MilitaryGridReferenceSystem mgrs = new MilitaryGridReferenceSystem(c.MGRS.LatZone, c.MGRS.LongZone, c.MGRS.Digraph, c.MGRS.Easting, c.MGRS.Northing);
                        rc = MilitaryGridReferenceSystem.MGRStoLatLong(mgrs);
                        if (Math.Abs(rc.Latitude.ToDouble() - c.Latitude.ToDouble()) >= .0001 && c.MGRS.WithinCoordinateSystemBounds)
                        {
                            pass = false; Debug.WriteLine("...MGRS Conversion Outside Limits: " + rc.Latitude.ToDouble() + " - " + c.Latitude.ToDouble());
                        }
                        if (Math.Abs(rc.Longitude.ToDouble() - c.Longitude.ToDouble()) >= .0001 && c.MGRS.WithinCoordinateSystemBounds)
                        {
                            pass = false; Debug.WriteLine("...MGRS Conversion Outside Limits: " + rc.Longitude.ToDouble() + " - " + c.Longitude.ToDouble());
                        }

                        //SIGNED DEGREE METHOD
                        double[] sdM = MilitaryGridReferenceSystem.MGRStoSignedDegree(mgrs);
                        if (Math.Abs(sdM[0] - c.Latitude.ToDouble()) >= .0001 && c.MGRS.WithinCoordinateSystemBounds)
                        {
                            pass = false; Debug.WriteLine("...MGRS Conversion Outside Limits: " + rc.Latitude.ToDouble() + " - " + c.Latitude.ToDouble());
                        }
                        if (Math.Abs(sdM[1] - c.Longitude.ToDouble()) >= .0001 && c.MGRS.WithinCoordinateSystemBounds)
                        {
                            pass = false; Debug.WriteLine("...MGRS Conversion Outside Limits: " + rc.Longitude.ToDouble() + " - " + c.Longitude.ToDouble());
                        }


                        //OVERLOAD METHOD
                        mgrs = new MilitaryGridReferenceSystem(c.MGRS.LongZone + c.MGRS.LatZone.ToString(), c.MGRS.Digraph, c.MGRS.Easting, c.MGRS.Northing);
                        rc   = MilitaryGridReferenceSystem.MGRStoLatLong(mgrs);
                        if (Math.Abs(rc.Latitude.ToDouble() - c.Latitude.ToDouble()) >= .0001 && c.MGRS.WithinCoordinateSystemBounds)
                        {
                            pass = false; Debug.WriteLine("...MGRS Conversion Outside Limits: " + rc.Latitude.ToDouble() + " - " + c.Latitude.ToDouble());
                        }
                        if (Math.Abs(rc.Longitude.ToDouble() - c.Longitude.ToDouble()) >= .0001 && c.MGRS.WithinCoordinateSystemBounds)
                        {
                            pass = false; Debug.WriteLine("...MGRS Conversion Outside Limits: " + rc.Longitude.ToDouble() + " - " + c.Longitude.ToDouble());
                        }

                        break;

                    case 6:
                        if (c.Cartesian.ToString() != coordList[y])
                        {
                            pass = false;
                        }
                        Cartesian cart = new Cartesian(c.Cartesian.X, c.Cartesian.Y, c.Cartesian.Z);
                        rc = Cartesian.CartesianToLatLong(cart);
                        if (Math.Abs(rc.Latitude.ToDouble() - c.Latitude.ToDouble()) >= .00001)
                        {
                            pass = false; Debug.WriteLine("...Cartesian Conversion Outside Limits: " + rc.Latitude.ToDouble() + " - " + c.Latitude.ToDouble());
                        }
                        if (Math.Abs(rc.Longitude.ToDouble() - c.Longitude.ToDouble()) >= .00001)
                        {
                            pass = false; Debug.WriteLine("...Cartesian Conversion Outside Limits: " + rc.Longitude.ToDouble() + " - " + c.Longitude.ToDouble());
                        }
                        break;

                    case 7:
                        string ec = c.ECEF.ToString().Replace(" km", "").Replace(",", "");
                        if (ec != coordList[y])
                        {
                            pass = false;
                        }
                        ECEF ecef = new ECEF(c.ECEF.X, c.ECEF.Y, c.ECEF.Z);
                        rc = ECEF.ECEFToLatLong(ecef);
                        if (Math.Abs(rc.Latitude.ToDouble() - c.Latitude.ToDouble()) >= .00001)
                        {
                            pass = false; Debug.WriteLine("...ECEF Conversion Outside Limits: " + rc.Latitude.ToDouble() + " - " + c.Latitude.ToDouble());
                        }
                        if (Math.Abs(rc.Longitude.ToDouble() - c.Longitude.ToDouble()) >= .00001)
                        {
                            pass = false; Debug.WriteLine("...ECEF Conversion Outside Limits: " + rc.Longitude.ToDouble() + " - " + c.Longitude.ToDouble());
                        }
                        if (Math.Abs(rc.ECEF.GeoDetic_Height.Meters - c.ECEF.GeoDetic_Height.Meters) >= .00001)
                        {
                            pass = false; Debug.WriteLine("...ECEF Conversion Outside Limits: " + rc.Longitude.ToDouble() + " - " + c.Longitude.ToDouble());
                        }
                        break;

                    default:
                        break;
                    }
                }
                Pass.Write("Conversion Pass " + ((int)(x + 1)).ToString() + ": ", pass);
            }
        }
예제 #4
0
        private static async Task ImportNestingBoxRecordAsync(NesteoDbContext dbContext, NestingBoxRecord nestingBoxRecord)
        {
            // Check id length
            if (nestingBoxRecord.Id.Length != 6)
            {
                throw new InvalidCsvRecordException("Id length is invalid. Expected 6 characters.");
            }

            // Ensure the nesting box doesn't exist yet
            if (await dbContext.NestingBoxes.FindAsync(nestingBoxRecord.Id).ConfigureAwait(false) != null)
            {
                throw new InvalidCsvRecordException("Nesting box exists and should not be overwritten.");
            }

            // Create collection for comments
            var comments = new List <string>();

            if (!string.IsNullOrWhiteSpace(nestingBoxRecord.Comments))
            {
                comments.AddRange(nestingBoxRecord.Comments.Split(',').Select(c => c.Trim()).Where(c => !string.IsNullOrEmpty(c)));
            }

            // Ensure the owner entity exists
            OwnerEntity ownerEntity = await GetOrCreateEntityAsync(dbContext, owner => owner.Name == nestingBoxRecord.OwnerName,
                                                                   () => new OwnerEntity { Name = nestingBoxRecord.OwnerName }).ConfigureAwait(false);

            // Ensure the region entity exists
            string regionName = $"{nestingBoxRecord.RegionCityName} - {nestingBoxRecord.RegionDetailedName}";

            string ExtractIdPrefix() => nestingBoxRecord.Id[0].ToString();

            RegionEntity regionEntity = await GetOrCreateEntityAsync(dbContext, region => region.Name == regionName,
                                                                     () => new RegionEntity { Name = regionName, NestingBoxIdPrefix = ExtractIdPrefix() }).ConfigureAwait(false);

            // Map material type
            var material = Material.Other;

            if (!string.IsNullOrWhiteSpace(nestingBoxRecord.Material))
            {
                material = GetMaterial(nestingBoxRecord.Material);
                if (material == Material.Other)
                {
                    comments.Add($"Material: {nestingBoxRecord.Material}");
                }
            }

            // Map hole size
            var holeSize = HoleSize.Other;

            if (!string.IsNullOrWhiteSpace(nestingBoxRecord.HoleSize))
            {
                holeSize = GetHoleSize(nestingBoxRecord.HoleSize);
                if (holeSize == HoleSize.Other)
                {
                    comments.Add($"Lochgröße: {nestingBoxRecord.HoleSize}");
                }
            }

            // Convert UTM to decimal coordinates
            Coordinate coordinate = null;

            if (!string.IsNullOrWhiteSpace(nestingBoxRecord.UtmEast) && !string.IsNullOrWhiteSpace(nestingBoxRecord.UtmNorth))
            {
                var utm = new UniversalTransverseMercator(UtmLatZ, UtmLongZ, double.Parse(nestingBoxRecord.UtmEast), double.Parse(nestingBoxRecord.UtmNorth));
                coordinate = UniversalTransverseMercator.ConvertUTMtoLatLong(utm);
            }

            // Analyze date info
            DateTime?hangUpDate = null;

            if (!string.IsNullOrWhiteSpace(nestingBoxRecord.HangUpDate))
            {
                hangUpDate = ParseDate(nestingBoxRecord.HangUpDate);
                if (hangUpDate.Value.Date == new DateTime(1999, 1, 1))
                {
                    hangUpDate = null;
                }
            }

            // Create nesting box
            dbContext.NestingBoxes.Add(new NestingBoxEntity {
                Id                  = nestingBoxRecord.Id,
                Region              = regionEntity,
                OldId               = null,
                ForeignId           = string.IsNullOrWhiteSpace(nestingBoxRecord.ForeignId) ? null : nestingBoxRecord.ForeignId,
                CoordinateLongitude = coordinate?.Longitude.DecimalDegree,
                CoordinateLatitude  = coordinate?.Latitude.DecimalDegree,
                HangUpDate          = hangUpDate,
                HangUpUser          = null,
                Owner               = ownerEntity,
                Material            = material,
                HoleSize            = holeSize,
                ImageFileName       = null,
                Comment             = comments.Any() ? string.Join(", ", comments) : null,
                LastUpdated         = string.IsNullOrWhiteSpace(nestingBoxRecord.DataUpdateDate)
                    ? hangUpDate ?? DateTime.UtcNow
                    : ParseDate(nestingBoxRecord.DataUpdateDate)
            });
        }
예제 #5
0
        static void EagerLoading_Tests()
        {
            EagerLoad  e = new EagerLoad(false);
            Coordinate c = new Coordinate(45, 75, new DateTime(2008, 1, 2), e);
            //Check to make sure items don't initialize
            bool pass = true;

            if (c.CelestialInfo != null)
            {
                pass = false;
            }
            if (c.UTM != null)
            {
                pass = false;
            }
            if (c.MGRS != null)
            {
                pass = false;
            }
            if (c.Cartesian != null)
            {
                pass = false;
            }
            Write_Pass("Null Properties (Celestial, UTM, MGRS, Cartesian)", pass);

            //Check Load_Calls
            pass = true;
            c.LoadCelestialInfo();
            if (c.CelestialInfo == null)
            {
                pass = false;
            }
            c.LoadUTM_MGRS_Info();
            if (c.UTM == null)
            {
                pass = false;
            }
            if (c.MGRS == null)
            {
                pass = false;
            }
            c.LoadCartesianInfo();
            if (c.Cartesian == null)
            {
                pass = false;
            }
            Write_Pass("Load Calls (Celestial, UTM, MGRS, Cartesian)", pass);

            if (pass)
            {
                Celestial cel = c.CelestialInfo;
                MilitaryGridReferenceSystem mgrs = c.MGRS;
                UniversalTransverseMercator utm  = c.UTM;
                Cartesian cart = c.Cartesian;

                c.Latitude.DecimalDegree  = -45;
                c.Longitude.DecimalDegree = -75;

                //Properties should not change.
                if (!ReflectiveEquals(c.CelestialInfo, cel))
                {
                    pass = false;
                }
                if (!ReflectiveEquals(c.MGRS, mgrs))
                {
                    pass = false;
                }
                if (!ReflectiveEquals(c.UTM, utm))
                {
                    pass = false;
                }
                if (!ReflectiveEquals(c.Cartesian, cart))
                {
                    pass = false;
                }
                //Properties should remain equal as no load calls were made
                Write_Pass("Property State Hold (Celestial, UTM, MGRS, Cartesian)", pass);

                //Properties should change
                pass = true;
                c.LoadCelestialInfo();
                c.LoadCartesianInfo();
                c.LoadUTM_MGRS_Info();
                if (ReflectiveEquals(c.CelestialInfo, cel))
                {
                    pass = false;
                }
                if (ReflectiveEquals(c.MGRS, mgrs))
                {
                    pass = false;
                }
                if (ReflectiveEquals(c.UTM, utm))
                {
                    pass = false;
                }
                if (ReflectiveEquals(c.Cartesian, cart))
                {
                    pass = false;
                }
                //Properties should not be equal as chages have been made
                Write_Pass("Property State Change (Celestial, UTM, MGRS, Cartesian)", pass);
            }
            else
            {
                //Passes auto fail has properties didn't load when called.

                Write_Pass("Property State Hold (Celestial, UTM, MGRS, Cartesian)", false);
                Write_Pass("Property State Change (Celestial, UTM, MGRS, Cartesian)", false);
            }
        }
예제 #6
0
        static void Coordinate_Initialization_Tests()
        {
            //Check for errors with initialization as most calculations occur on load
            bool pass = true;

            try
            {
                Coordinate c = new Coordinate();
                c = new Coordinate(25, 25);
                c = new Coordinate(25, 25, new DateTime(2018, 8, 5, 10, 10, 0));

                EagerLoad eg = new EagerLoad();
                eg.Cartesian = false;
                eg.Celestial = false;
                eg.UTM_MGRS  = false;

                c = new Coordinate(eg);
                c = new Coordinate(25, 25, eg);
                c = new Coordinate(25, 25, new DateTime(2018, 8, 5, 10, 10, 0), eg);
            }
            catch { pass = false; }
            Write_Pass("Coordinate Initialization Error Checks", pass);

            try
            {
                pass = true;
                Coordinate     c  = new Coordinate();
                CoordinatePart cp = new CoordinatePart(CoordinateType.Lat, c);
                cp = new CoordinatePart(CoordinateType.Long, c);
                cp = new CoordinatePart(25, CoordinateType.Lat, c);
                cp = new CoordinatePart(25, CoordinateType.Long, c);
                cp = new CoordinatePart(25, 25, CoordinatesPosition.N, c);
                cp = new CoordinatePart(25, 25, CoordinatesPosition.E, c);
                cp = new CoordinatePart(25, 25, CoordinatesPosition.S, c);
                cp = new CoordinatePart(25, 25, CoordinatesPosition.W, c);
                cp = new CoordinatePart(25, 25, 25, CoordinatesPosition.N, c);
                cp = new CoordinatePart(25, 25, 25, CoordinatesPosition.E, c);
                cp = new CoordinatePart(25, 25, 25, CoordinatesPosition.S, c);
                cp = new CoordinatePart(25, 25, 25, CoordinatesPosition.W, c);
            }
            catch { pass = false; }
            Write_Pass("CoordinatePart Initialization Error Checks", pass);
            try
            {
                pass = true;
                UniversalTransverseMercator utm = new UniversalTransverseMercator("Q", 14, 581943.5, 2111989.8);
                utm = new UniversalTransverseMercator("Q", 14, 581943.5, 2111989.8, 6378160.000, 298.25);
            }
            catch { pass = false; }
            Write_Pass("UniversalTransverseMercator Initialization Error Checks", pass);
            try
            {
                pass = true;
                //Outputs 19T CE 51307 93264
                MilitaryGridReferenceSystem mgrs = new MilitaryGridReferenceSystem("T", 19, "CE", 51307, 93264);
                mgrs = new MilitaryGridReferenceSystem("T", 19, "CE", 51307, 93264, 6378160.000, 298.25);
            }
            catch { pass = false; }
            Write_Pass("UniversalTransverseMercator Initialization Error Checks", pass);
            try
            {
                pass = true;
                Coordinate c    = new Coordinate();
                Cartesian  cart = new Cartesian(c);
                cart = new Cartesian(345, -123, 2839);
            }
            catch { pass = false; }
            Write_Pass("Cartesian Initialization Error Checks", pass);
            Console.WriteLine();

            //Init Range Checks
            try
            {
                pass = true;
                EagerLoad eg = new EagerLoad();

                Coordinate c = new Coordinate(90, 180);
                c = new Coordinate(-90, -180);
                c = new Coordinate(90, 180, new DateTime());
                c = new Coordinate(-90, -180, new DateTime());
                c = new Coordinate(90, 180, eg);
                c = new Coordinate(-90, -180, eg);
                c = new Coordinate(90, 180, new DateTime(), eg);
                c = new Coordinate(-90, -180, new DateTime(), eg);

                //Should fail as arguments are out of range.
                try { c = new Coordinate(91, 180); pass = false; }
                catch { }
                //Should fail as arguments are out of range.
                try { c = new Coordinate(90, 181); pass = false; }
                catch { }
                //Should fail as arguments are out of range.
                try { c = new Coordinate(-91, -180); pass = false; }
                catch { }
                //Should fail as arguments are out of range.
                try { c = new Coordinate(-90, -181); pass = false; }
                catch { }

                //Should fail as arguments are out of range.
                try { c = new Coordinate(91, 180, new DateTime()); pass = false; }
                catch { }
                //Should fail as arguments are out of range.
                try { c = new Coordinate(90, 181, new DateTime()); pass = false; }
                catch { }
                //Should fail as arguments are out of range.
                try { c = new Coordinate(-91, -180, new DateTime()); pass = false; }
                catch { }
                //Should fail as arguments are out of range.
                try { c = new Coordinate(-90, -181, new DateTime()); pass = false; }
                catch {  }

                //Should fail as arguments are out of range.
                try { c = new Coordinate(91, 180, new DateTime(), eg); pass = false; }
                catch { }
                //Should fail as arguments are out of range.
                try { c = new Coordinate(90, 181, new DateTime(), eg); pass = false; }
                catch { }
                //Should fail as arguments are out of range.
                try { c = new Coordinate(-91, -180, new DateTime(), eg); pass = false; }
                catch { }
                //Should fail as arguments are out of range.
                try { c = new Coordinate(-90, -181, new DateTime(), eg); pass = false; }
                catch { }
            }
            catch { pass = false; }
            Write_Pass("Cordinate Initialization Range Checks", pass);

            pass = true;
            try
            {
                Coordinate     c  = new Coordinate();
                CoordinatePart cp = new CoordinatePart(90, CoordinateType.Lat, c);
                cp = new CoordinatePart(-90, CoordinateType.Lat, c);
                cp = new CoordinatePart(89, 59, CoordinatesPosition.N, c);
                cp = new CoordinatePart(89, 59, CoordinatesPosition.S, c);
                cp = new CoordinatePart(89, 59, 59, CoordinatesPosition.N, c);
                cp = new CoordinatePart(89, 59, 59, CoordinatesPosition.S, c);
                cp = new CoordinatePart(180, CoordinateType.Long, c);
                cp = new CoordinatePart(-180, CoordinateType.Long, c);
                cp = new CoordinatePart(179, 59, CoordinatesPosition.E, c);
                cp = new CoordinatePart(179, 59, CoordinatesPosition.W, c);
                cp = new CoordinatePart(179, 59, 59, CoordinatesPosition.E, c);
                cp = new CoordinatePart(179, 59, 59, CoordinatesPosition.W, c);

                //Should fail
                try { cp = new CoordinatePart(91, CoordinateType.Lat, c); pass = false; } catch { }
                try { cp = new CoordinatePart(-91, CoordinateType.Lat, c); pass = false; } catch { }
                try { cp = new CoordinatePart(181, CoordinateType.Long, c); pass = false; } catch { }
                try { cp = new CoordinatePart(-181, CoordinateType.Long, c); pass = false; } catch { }

                try { cp = new CoordinatePart(91, 0, CoordinatesPosition.N, c); pass = false; } catch { }
                try { cp = new CoordinatePart(90, 1, CoordinatesPosition.N, c); pass = false; } catch { }
                try { cp = new CoordinatePart(89, 60, CoordinatesPosition.N, c); pass = false; } catch { }
                try { cp = new CoordinatePart(91, 0, CoordinatesPosition.N, c); pass = false; } catch { }
                try { cp = new CoordinatePart(90, 1, CoordinatesPosition.N, c); pass = false; } catch { }
                try { cp = new CoordinatePart(89, 60, CoordinatesPosition.N, c); pass = false; } catch { }
                try { cp = new CoordinatePart(-90, 1, CoordinatesPosition.N, c); pass = false; } catch { }
                try { cp = new CoordinatePart(89, -1, CoordinatesPosition.N, c); pass = false; } catch { }

                try { cp = new CoordinatePart(91, 0, CoordinatesPosition.S, c); pass = false; } catch { }
                try { cp = new CoordinatePart(90, 1, CoordinatesPosition.S, c); pass = false; } catch { }
                try { cp = new CoordinatePart(89, 60, CoordinatesPosition.S, c); pass = false; } catch { }
                try { cp = new CoordinatePart(91, 0, CoordinatesPosition.S, c); pass = false; } catch { }
                try { cp = new CoordinatePart(90, 1, CoordinatesPosition.S, c); pass = false; } catch { }
                try { cp = new CoordinatePart(89, 60, CoordinatesPosition.S, c); pass = false; } catch { }
                try { cp = new CoordinatePart(-90, 1, CoordinatesPosition.S, c); pass = false; } catch { }
                try { cp = new CoordinatePart(89, -1, CoordinatesPosition.S, c); pass = false; } catch { }

                try { cp = new CoordinatePart(91, 0, 0, CoordinatesPosition.N, c); pass = false; } catch { }
                try { cp = new CoordinatePart(90, 0, 1, CoordinatesPosition.N, c); pass = false; } catch { }
                try { cp = new CoordinatePart(89, 59, 60, CoordinatesPosition.N, c); pass = false; } catch { }
                try { cp = new CoordinatePart(90, 0, 1, CoordinatesPosition.N, c); pass = false; } catch { }
                try { cp = new CoordinatePart(89, 59, 60, CoordinatesPosition.N, c); pass = false; } catch { }
                try { cp = new CoordinatePart(-90, 0, 0, CoordinatesPosition.N, c); pass = false; } catch { }
                try { cp = new CoordinatePart(89, -1, 0, CoordinatesPosition.N, c); pass = false; } catch { }
                try { cp = new CoordinatePart(89, 1, -1, CoordinatesPosition.N, c); pass = false; } catch { }

                try { cp = new CoordinatePart(91, 0, 0, CoordinatesPosition.S, c); pass = false; } catch { }
                try { cp = new CoordinatePart(90, 0, 1, CoordinatesPosition.S, c); pass = false; } catch { }
                try { cp = new CoordinatePart(89, 59, 60, CoordinatesPosition.S, c); pass = false; } catch { }
                try { cp = new CoordinatePart(90, 0, 1, CoordinatesPosition.S, c); pass = false; } catch { }
                try { cp = new CoordinatePart(89, 59, 60, CoordinatesPosition.S, c); pass = false; } catch { }
                try { cp = new CoordinatePart(-90, 0, 0, CoordinatesPosition.S, c); pass = false; } catch { }
                try { cp = new CoordinatePart(89, -1, 0, CoordinatesPosition.S, c); pass = false; } catch { }
                try { cp = new CoordinatePart(89, 1, -1, CoordinatesPosition.S, c); pass = false; } catch { }


                try { cp = new CoordinatePart(181, 0, CoordinatesPosition.E, c); pass = false; } catch { }
                try { cp = new CoordinatePart(180, 1, CoordinatesPosition.E, c); pass = false; } catch { }
                try { cp = new CoordinatePart(179, 60, CoordinatesPosition.E, c); pass = false; } catch { }
                try { cp = new CoordinatePart(181, 0, CoordinatesPosition.E, c); pass = false; } catch { }
                try { cp = new CoordinatePart(180, 1, CoordinatesPosition.E, c); pass = false; } catch { }
                try { cp = new CoordinatePart(179, 60, CoordinatesPosition.E, c); pass = false; } catch { }
                try { cp = new CoordinatePart(-180, 1, CoordinatesPosition.E, c); pass = false; } catch { }
                try { cp = new CoordinatePart(179, -1, CoordinatesPosition.E, c); pass = false; } catch { }

                try { cp = new CoordinatePart(181, 0, CoordinatesPosition.W, c); pass = false; } catch { }
                try { cp = new CoordinatePart(180, 1, CoordinatesPosition.W, c); pass = false; } catch { }
                try { cp = new CoordinatePart(179, 60, CoordinatesPosition.W, c); pass = false; } catch { }
                try { cp = new CoordinatePart(181, 0, CoordinatesPosition.W, c); pass = false; } catch { }
                try { cp = new CoordinatePart(180, 1, CoordinatesPosition.W, c); pass = false; } catch { }
                try { cp = new CoordinatePart(179, 60, CoordinatesPosition.W, c); pass = false; } catch { }
                try { cp = new CoordinatePart(-180, 1, CoordinatesPosition.W, c); pass = false; } catch { }
                try { cp = new CoordinatePart(179, -1, CoordinatesPosition.W, c); pass = false; } catch { }

                try { cp = new CoordinatePart(181, 0, 0, CoordinatesPosition.E, c); pass = false; } catch { }
                try { cp = new CoordinatePart(180, 0, 1, CoordinatesPosition.E, c); pass = false; } catch { }
                try { cp = new CoordinatePart(179, 59, 60, CoordinatesPosition.E, c); pass = false; } catch { }
                try { cp = new CoordinatePart(180, 0, 1, CoordinatesPosition.E, c); pass = false; } catch { }
                try { cp = new CoordinatePart(179, 59, 60, CoordinatesPosition.E, c); pass = false; } catch { }
                try { cp = new CoordinatePart(-180, 0, 0, CoordinatesPosition.E, c); pass = false; } catch { }
                try { cp = new CoordinatePart(179, -1, 0, CoordinatesPosition.E, c); pass = false; } catch { }
                try { cp = new CoordinatePart(179, 1, -1, CoordinatesPosition.E, c); pass = false; } catch { }

                try { cp = new CoordinatePart(181, 0, 0, CoordinatesPosition.W, c); pass = false; } catch { }
                try { cp = new CoordinatePart(180, 0, 1, CoordinatesPosition.W, c); pass = false; } catch { }
                try { cp = new CoordinatePart(179, 59, 60, CoordinatesPosition.W, c); pass = false; } catch { }
                try { cp = new CoordinatePart(180, 0, 1, CoordinatesPosition.W, c); pass = false; } catch { }
                try { cp = new CoordinatePart(179, 59, 60, CoordinatesPosition.W, c); pass = false; } catch { }
                try { cp = new CoordinatePart(-180, 0, 0, CoordinatesPosition.W, c); pass = false; } catch { }
                try { cp = new CoordinatePart(179, -1, 0, CoordinatesPosition.W, c); pass = false; } catch { }
                try { cp = new CoordinatePart(179, 1, -1, CoordinatesPosition.W, c); pass = false; } catch { }
            }
            catch
            {
                pass = false;
            }
            Write_Pass("CordinatePart Initialization Range Checks", pass);
        }
예제 #7
0
        static void Coordinate_Convsersions_Tests()
        {
            Console.WriteLine();
            //GATHER CONVERSIONS
            //Conversion lists must end in //** to signify end of list
            List <List <string> > Conversions = new List <List <string> >();

            string[]      coordStrings = File.ReadAllLines("Conversions.txt");
            List <string> cList        = new List <string>();

            foreach (string c in coordStrings)
            {
                if (c == "//**")
                {
                    Conversions.Add(cList);
                    cList = new List <string>();
                }
                else
                {
                    cList.Add(c);
                }
            }
            //Conversion coords to test
            List <double[]> coords = new List <double[]>();

            coords.Add(new double[] { 39.5768, 72.4859 });
            coords.Add(new double[] { -15.5768, 100.4859 });
            coords.Add(new double[] { 65.25, -15.1859 });
            coords.Add(new double[] { -80.6586, -152.49 });

            for (int x = 0; x < Conversions.Count; x++)
            {
                List <string> coordList = Conversions[x];
                double        lat       = coords[x][0];
                double        lng       = coords[x][1];
                //0 = Decimal / Signed
                //1 = Decimal Degree
                //2 = Degree Decimal Minute
                //3 = Degree Minutes Seconds
                //4 = UTM
                //5 = MGRS
                //6 = Cartesian
                Coordinate c    = new Coordinate(lat, lng);
                bool       pass = true;
                Coordinate rc   = new Coordinate();
                for (int y = 0; y < 7; y++)
                {
                    switch (y)
                    {
                    case 0:
                        c.FormatOptions.Format = CoordinateFormatType.Decimal;
                        if (c.ToString() != coordList[y])
                        {
                            pass = false;
                        }
                        break;

                    case 1:
                        c.FormatOptions.Format = CoordinateFormatType.Decimal_Degree;
                        if (c.ToString() != coordList[y])
                        {
                            pass = false;
                        }
                        break;

                    case 2:
                        c.FormatOptions.Format = CoordinateFormatType.Degree_Decimal_Minutes;
                        if (c.ToString() != coordList[y])
                        {
                            pass = false;
                        }
                        rc           = new Coordinate();
                        rc.Latitude  = new CoordinatePart(c.Latitude.Degrees, c.Latitude.DecimalMinute, c.Latitude.Position, rc);
                        rc.Longitude = new CoordinatePart(c.Longitude.Degrees, c.Longitude.DecimalMinute, c.Longitude.Position, rc);
                        if (rc.Latitude.ToDouble() != c.Latitude.ToDouble())
                        {
                            pass = false; Debug.WriteLine("...Conversion Outside Limits: " + rc.Latitude.ToDouble() + " - " + c.Latitude.ToDouble());
                        }
                        if (rc.Longitude.ToDouble() != c.Longitude.ToDouble())
                        {
                            pass = false; Debug.WriteLine("...Conversion Outside Limits: " + rc.Longitude.ToDouble() + " - " + c.Longitude.ToDouble());
                        }
                        break;

                    case 3:
                        c.FormatOptions.Format = CoordinateFormatType.Degree_Minutes_Seconds;
                        if (c.ToString() != coordList[y])
                        {
                            pass = false;
                        }
                        rc           = new Coordinate();
                        rc.Latitude  = new CoordinatePart(c.Latitude.Degrees, c.Latitude.Minutes, c.Latitude.Seconds, c.Latitude.Position, rc);
                        rc.Longitude = new CoordinatePart(c.Longitude.Degrees, c.Longitude.Minutes, c.Longitude.Seconds, c.Longitude.Position, rc);
                        if (rc.Latitude.ToDouble() != c.Latitude.ToDouble())
                        {
                            pass = false; Debug.WriteLine("...Conversion Outside Limits: " + rc.Latitude.ToDouble() + " - " + c.Latitude.ToDouble());
                        }
                        if (rc.Longitude.ToDouble() != c.Longitude.ToDouble())
                        {
                            pass = false; Debug.WriteLine("...Conversion Outside Limits: " + rc.Longitude.ToDouble() + " - " + c.Longitude.ToDouble());
                        }
                        break;

                    case 4:
                        if (c.UTM.ToString() != coordList[y])
                        {
                            pass = false;
                        }
                        UniversalTransverseMercator utm = new UniversalTransverseMercator(c.UTM.LatZone, c.UTM.LongZone, c.UTM.Easting, c.UTM.Northing);
                        rc = UniversalTransverseMercator.ConvertUTMtoLatLong(utm);
                        if (Math.Abs(rc.Latitude.ToDouble() - c.Latitude.ToDouble()) >= .00001)
                        {
                            pass = false; Debug.WriteLine("...UTM Conversion Outside Limits: " + rc.Latitude.ToDouble() + " - " + c.Latitude.ToDouble());
                        }
                        if (Math.Abs(rc.Longitude.ToDouble() - c.Longitude.ToDouble()) >= .00001)
                        {
                            pass = false; Debug.WriteLine("...UTM Conversion Outside Limits: " + rc.Longitude.ToDouble() + " - " + c.Longitude.ToDouble());
                        }
                        break;

                    case 5:
                        if (c.MGRS.ToString() != coordList[y])
                        {
                            pass = false;
                        }
                        MilitaryGridReferenceSystem mgrs = new MilitaryGridReferenceSystem(c.MGRS.LatZone, c.MGRS.LongZone, c.MGRS.Digraph, c.MGRS.Easting, c.MGRS.Northing);
                        rc = MilitaryGridReferenceSystem.MGRStoLatLong(mgrs);
                        if (Math.Abs(rc.Latitude.ToDouble() - c.Latitude.ToDouble()) >= .0001)
                        {
                            pass = false; Debug.WriteLine("...MGRS Conversion Outside Limits: " + rc.Latitude.ToDouble() + " - " + c.Latitude.ToDouble());
                        }
                        if (Math.Abs(rc.Longitude.ToDouble() - c.Longitude.ToDouble()) >= .0001)
                        {
                            pass = false; Debug.WriteLine("...MGRS Conversion Outside Limits: " + rc.Longitude.ToDouble() + " - " + c.Longitude.ToDouble());
                        }

                        break;

                    case 6:
                        if (c.Cartesian.ToString() != coordList[y])
                        {
                            pass = false;
                        }
                        Cartesian cart = new Cartesian(c.Cartesian.X, c.Cartesian.Y, c.Cartesian.Z);
                        rc = Cartesian.CartesianToLatLong(cart);
                        if (Math.Abs(rc.Latitude.ToDouble() - c.Latitude.ToDouble()) >= .00001)
                        {
                            pass = false; Debug.WriteLine("...Cartesian Conversion Outside Limits: " + rc.Latitude.ToDouble() + " - " + c.Latitude.ToDouble());
                        }
                        if (Math.Abs(rc.Longitude.ToDouble() - c.Longitude.ToDouble()) >= .00001)
                        {
                            pass = false; Debug.WriteLine("...Cartesian Conversion Outside Limits: " + rc.Longitude.ToDouble() + " - " + c.Longitude.ToDouble());
                        }
                        break;

                    default:
                        break;
                    }
                }

                Write_Pass("Conversion Pass " + ((int)(x + 1)).ToString() + ": ", pass);
            }
        }
예제 #8
0
        /// <summary>
        /// Attempts to parse known parameters from the set of proj4 parameters
        /// </summary>
        /// <param name="proj4String">
        /// </param>
        private void ParseProj4String(string proj4String)
        {
            if (string.IsNullOrEmpty(proj4String))
            {
                return;
            }

            // If it has a zone, and the projection is tmerc, it actually needs the utm initialization
            bool tmercIsUtm = proj4String.Contains("zone=");

            string[] sections = proj4String.Split('+');
            foreach (string str in sections)
            {
                string s = str.Trim();
                if (string.IsNullOrEmpty(s))
                {
                    continue;
                }

                // single token commands
                if (s == "no_defs")
                {
                    NoDefs = true;
                    continue;
                }
                else if (s == "south")
                {
                    IsSouth = true;
                    continue;
                }
                else if (s == "R_A")
                {
                    //+R_A tells PROJ.4 to use a spherical radius that
                    //gives a sphere with the same surface area as the original ellipsoid.  I
                    //imagine I added this while trying to get the results to match PCI's GCTP
                    //based implementation though the history isn't clear on the details.
                    //the R_A parameter indicates that an authalic auxiliary sphere should be used.
                    //from http://pdl.perl.org/?docs=Transform/Proj4&title=PDL::Transform::Proj4#r_a
                    AuxiliarySphereType = AuxiliarySphereType.Authalic;
                }
                else if (s == "to")
                {
                    // some "+to" parameters exist... e.g., DutchRD. but I'm not sure what to do with them.
                    // they seem to specify a second projection
                    Trace.WriteLine(
                        "ProjectionInfo.ParseProj4String: command 'to' not supported and the portion of the string after 'to' will not be processed in '"
                        + proj4String + "'");
                    break;
                }

                // parameters
                string[] set = s.Split('=');
                if (set.Length != 2)
                {
                    Trace.WriteLine(
                        String.Format("ProjectionInfo.ParseProj4String: command '{0}' not understood in '{1}'", s, proj4String));
                    continue;
                }

                string name  = set[0].Trim();
                string value = set[1].Trim();

                switch (name)
                {
                case "lonc":
                    _longitudeOfCenter = double.Parse(value, CultureInfo.InvariantCulture);
                    break;

                case "alpha":
                    _azimuth = double.Parse(value, CultureInfo.InvariantCulture);
                    break;

                case "x_0":
                    FalseEasting = double.Parse(value, CultureInfo.InvariantCulture);
                    break;

                case "y_0":
                    FalseNorthing = double.Parse(value, CultureInfo.InvariantCulture);
                    break;

                case "k":
                case "k_0":
                    _scaleFactor = double.Parse(value, CultureInfo.InvariantCulture);
                    break;

                case "lat_0":
                    LatitudeOfOrigin = double.Parse(value, CultureInfo.InvariantCulture);
                    break;

                case "lat_1":
                    StandardParallel1 = double.Parse(value, CultureInfo.InvariantCulture);
                    break;

                case "lat_2":
                    StandardParallel2 = double.Parse(value, CultureInfo.InvariantCulture);
                    break;

                case "lon_0":
                    CentralMeridian = double.Parse(value, CultureInfo.InvariantCulture);
                    break;

                case "lat_ts":
                    StandardParallel1 = double.Parse(value, CultureInfo.InvariantCulture);
                    break;

                case "zone":
                    Zone = int.Parse(value, CultureInfo.InvariantCulture);
                    break;

                case "geoc":
                    Geoc = bool.Parse(value) && (GeographicInfo.Datum.Spheroid.EccentricitySquared() != 0);
                    break;

                case "over":
                    Over = bool.Parse(value);
                    break;

                case "proj":

                    if (value == "longlat")
                    {
                        this.IsLatLon = true;
                    }

                    if (tmercIsUtm)
                    {
                        Transform = new UniversalTransverseMercator();
                    }
                    else
                    {
                        Transform = TransformManager.DefaultTransformManager.GetProj4(value);
                    }

                    break;

                case "to_meter":

                    Unit.Meters = double.Parse(value, CultureInfo.InvariantCulture);
                    if (Unit.Meters == .3048)
                    {
                        Unit.Name = "Foot";     // International Foot
                    }
                    else if (Unit.Meters > .3048 && Unit.Meters < .305)
                    {
                        Unit.Name = "Foot_US";
                    }

                    break;

                case "units":
                    if (value == "m")
                    {
                        // do nothing, since the default is meter anyway.
                    }
                    else if (value == "ft" || value == "f")
                    {
                        Unit.Name   = "Foot";
                        Unit.Meters = .3048;
                    }
                    else if (value == "us-ft")
                    {
                        Unit.Name   = "Foot_US";
                        Unit.Meters = .304800609601219;
                    }

                    break;

                case "pm":
                    GeographicInfo.Meridian.pm = value;
                    //// added by Jiri Kadlec - pm should also specify the CentralMeridian
                    //if (value != null)
                    //{
                    //    CentralMeridian = GeographicInfo.Meridian.Longitude;
                    //}
                    break;

                case "datum":

                    // Even though th ellipsoid is set by its known definition, we permit overriding it with a specifically defined ellps parameter
                    GeographicInfo.Datum = new Datum(value);
                    break;

                case "nadgrids":
                    GeographicInfo.Datum.NadGrids = value.Split(',');

                    if (value != "@null")
                    {
                        GeographicInfo.Datum.DatumType = DatumType.GridShift;
                    }

                    break;

                case "towgs84":
                    GeographicInfo.Datum.InitializeToWgs84(value.Split(','));
                    break;

                case "ellps":

                    // Even though th ellipsoid is set by its known definition, we permit overriding it with a specifically defined ellps parameter
                    // generally ellps will not be used in the same string as a,b,rf,R.
                    GeographicInfo.Datum.Spheroid = new Spheroid(value);
                    break;

                case "a":
                case "R":
                    GeographicInfo.Datum.Spheroid.EquatorialRadius = double.Parse(
                        value, CultureInfo.InvariantCulture);
                    break;

                case "b":
                    GeographicInfo.Datum.Spheroid.PolarRadius = double.Parse(value, CultureInfo.InvariantCulture);
                    break;

                case "rf":
                    Debug.Assert(GeographicInfo.Datum.Spheroid.EquatorialRadius > 0, "a must appear before rf");
                    GeographicInfo.Datum.Spheroid.InverseFlattening = double.Parse(
                        value, CultureInfo.InvariantCulture);
                    break;

                default:
                    Trace.WriteLine(string.Format("Unrecognized parameter skipped {0}.", name));
                    break;
                }
            }

            if (Transform != null)
            {
                Transform.Init(this);
            }
        }