Пример #1
0
        private static ICrs CreateTMerc(GeoTransGoldDataReader reader)
        {
            var datum      = GenerateDatum(reader["DATUM"]);
            var linearUnit = OgcLinearUnit.DefaultMeter;

            return(new OgcCrsProjected(
                       reader["PROJECTION"],
                       new OgcCrsGeographic(
                           datum.Name,
                           datum,
                           datum.PrimeMeridian.Unit,
                           new[] {
                new OgcAxis("Latitude", OgcOrientationType.East),
                new OgcAxis("Longitude", OgcOrientationType.North)
            }
                           ),
                       new CoordinateOperationInfo(
                           "Transverse Mercator",
                           new INamedParameter[] {
                new NamedParameter <double>("latitude_of_origin", Double.Parse(reader["ORIGIN LATITUDE"]), OgcAngularUnit.DefaultDegrees),
                new NamedParameter <double>("central_meridian", Double.Parse(reader["CENTRAL MERIDIAN"]), OgcAngularUnit.DefaultDegrees),
                new NamedParameter <double>("scale_factor", Double.Parse(reader["SCALE FACTOR"]), ScaleUnitUnity.Value),
                new NamedParameter <double>("false_easting", Double.Parse(reader["FALSE EASTING"]), linearUnit),
                new NamedParameter <double>("false_northing", Double.Parse(reader["FALSE NORTHING"]), linearUnit)
            }
                           ),
                       linearUnit,
                       new IAxis[] {
                new OgcAxis("Easting", OgcOrientationType.East),
                new OgcAxis("Northing", OgcOrientationType.North)
            }
                       ));
        }
Пример #2
0
        private static ICrs CreateLcc2Sp(GeoTransGoldDataReader reader)
        {
            var datum      = GenerateDatum(reader["DATUM"]);
            var linearUnit = OgcLinearUnit.DefaultMeter;

            return(new OgcCrsProjected(
                       reader["PROJECTION"],
                       new OgcCrsGeographic(
                           datum.Name,
                           datum,
                           datum.PrimeMeridian.Unit,
                           new[] {
                new OgcAxis("Latitude", OgcOrientationType.East),
                new OgcAxis("Longitude", OgcOrientationType.North)
            }
                           ),
                       new CoordinateOperationInfo(
                           "Lambert_Conformal_Conic_2SP",
                           new INamedParameter[] {
                new NamedParameter <double>("latitude_of_origin", Double.Parse(reader["ORIGIN LATITUDE"]), OgcAngularUnit.DefaultDegrees),
                new NamedParameter <double>("central_meridian", Double.Parse(reader["CENTRAL MERIDIAN"]), OgcAngularUnit.DefaultDegrees),
                new NamedParameter <double>("parallel_1", Double.Parse(reader["STANDARD PARALLEL ONE"]), OgcAngularUnit.DefaultDegrees),
                new NamedParameter <double>("parallel_2", Double.Parse(reader["STANDARD PARALLEL TWO"]), OgcAngularUnit.DefaultDegrees),
                new NamedParameter <double>("false_easting", Double.Parse(reader["FALSE EASTING"]), linearUnit),
                new NamedParameter <double>("false_northing", Double.Parse(reader["FALSE NORTHING"]), linearUnit)
            }
                           ),
                       linearUnit,
                       new IAxis[] {
                new OgcAxis("Easting", OgcOrientationType.East),
                new OgcAxis("Northing", OgcOrientationType.North)
            }
                       ));
        }
Пример #3
0
        public static ICrs GetCrs(GeoTransGoldDataReader reader)
        {
            var coordinatesName = reader["COORDINATES"];

            if (String.IsNullOrEmpty(coordinatesName))
            {
                coordinatesName = reader["PROJECTION"];
            }

            switch (coordinatesName)
            {
            case "Geodetic":
                return(CreateGeographicCrs(reader));

            case "Lambert Conformal Conic (1 parallel)":
                return(CreateLcc1Sp(reader));

            case "Lambert Conformal Conic (2 parallel)":
                return(CreateLcc2Sp(reader));

            case "Mercator":
                return(CreateMercator(reader));

            case "Polar Stereographic":
                return(CreatePolarStereographic(reader));

            case "Transverse Mercator":
                return(CreateTMerc(reader));

            default:
                throw new NotSupportedException("Not supported: " + coordinatesName);
            }
        }
Пример #4
0
        public static GeoTransGoldDataReader GetReadyReader(string name)
        {
            var reader = new GeoTransGoldDataReader(GetEmbeddedStreamReader(name));
            if (!reader.Read())
                Assert.Inconclusive("Could not read header: " + name);

            return reader;
        }
Пример #5
0
        public static GeoTransGoldDataReader GetReadyReader(string name)
        {
            var reader = new GeoTransGoldDataReader(GetEmbeddedStreamReader(name));

            if (!reader.Read())
            {
                Assert.Inconclusive("Could not read header: " + name);
            }

            return(reader);
        }
Пример #6
0
 private static ICrs CreateGeographicCrs(GeoTransGoldDataReader reader)
 {
     var datum = GenerateDatum(reader["DATUM"]);
     return new OgcCrsGeographic(
         reader["COORDINATES"],
         datum,
         datum.PrimeMeridian.Unit,
         new[] {
             new OgcAxis("Latitude", OgcOrientationType.East),
             new OgcAxis("Longitude", OgcOrientationType.North)
         }
     );
 }
Пример #7
0
        private static ICrs CreateGeographicCrs(GeoTransGoldDataReader reader)
        {
            var datum = GenerateDatum(reader["DATUM"]);

            return(new OgcCrsGeographic(
                       reader["COORDINATES"],
                       datum,
                       datum.PrimeMeridian.Unit,
                       new[] {
                new OgcAxis("Latitude", OgcOrientationType.East),
                new OgcAxis("Longitude", OgcOrientationType.North)
            }
                       ));
        }
Пример #8
0
        private static ICrs CreatePolarStereographic(GeoTransGoldDataReader reader)
        {
            var datum       = GenerateDatum(reader["DATUM"]);
            var linearUnit  = OgcLinearUnit.DefaultMeter;
            var scaleFactor = reader["SCALE FACTOR"];
            var parameters  = new List <INamedParameter> {
                new NamedParameter <double>("longitude_down_from_pole", Double.Parse(reader["LONGITUDE DOWN FROM POLE"]), OgcAngularUnit.DefaultDegrees),
                new NamedParameter <double>("false_easting", Double.Parse(reader["FALSE EASTING"]), linearUnit),
                new NamedParameter <double>("false_northing", Double.Parse(reader["FALSE NORTHING"]), linearUnit)
            };

            if (null != scaleFactor)
            {
                parameters.Add(new NamedParameter <double>("latitude_of_true_scale", 90, OgcAngularUnit.DefaultDegrees));
                parameters.Add(new NamedParameter <double>("scale_factor", Double.Parse(scaleFactor), ScaleUnitUnity.Value));
            }
            else
            {
                var latSp = Double.Parse(reader["LATITUDE OF TRUE SCALE"]);
                parameters.Add(new NamedParameter <double>("standard_parallel", latSp, OgcAngularUnit.DefaultDegrees));
                parameters.Add(new NamedParameter <double>("latitude_of_true_scale", latSp < 0 ? -90 : 90, OgcAngularUnit.DefaultDegrees));
            }

            return(new OgcCrsProjected(
                       reader["PROJECTION"],
                       new OgcCrsGeographic(
                           datum.Name,
                           datum,
                           datum.PrimeMeridian.Unit,
                           new[] {
                new OgcAxis("Latitude", OgcOrientationType.East),
                new OgcAxis("Longitude", OgcOrientationType.North)
            }
                           ),
                       new CoordinateOperationInfo(
                           "Polar Stereographic",
                           parameters
                           ),
                       linearUnit,
                       new IAxis[] {
                new OgcAxis("Easting", OgcOrientationType.East),
                new OgcAxis("Northing", OgcOrientationType.North)
            }
                       ));
        }
Пример #9
0
        private static ICrs CreateMercator(GeoTransGoldDataReader reader)
        {
            var datum        = GenerateDatum(reader["DATUM"]);
            var linearUnit   = OgcLinearUnit.DefaultMeter;
            var latTrueScale = reader["LATITUDE OF TRUE SCALE"];
            var parameters   = new List <INamedParameter> {
                new NamedParameter <double>("central_meridian", Double.Parse(reader["CENTRAL MERIDIAN"]), OgcAngularUnit.DefaultDegrees),
                new NamedParameter <double>("false_easting", Double.Parse(reader["FALSE EASTING"]), linearUnit),
                new NamedParameter <double>("false_northing", Double.Parse(reader["FALSE NORTHING"]), linearUnit)
            };

            if (null == latTrueScale)
            {
                parameters.Add(new NamedParameter <double>("scale_factor", Double.Parse(reader["SCALE FACTOR"]), ScaleUnitUnity.Value));
            }
            else
            {
                parameters.Add(new NamedParameter <double>("latitude_of_true_scale", Double.Parse(latTrueScale), OgcAngularUnit.DefaultDegrees));
            }

            return(new OgcCrsProjected(
                       reader["PROJECTION"],
                       new OgcCrsGeographic(
                           datum.Name,
                           datum,
                           datum.PrimeMeridian.Unit,
                           new[] {
                new OgcAxis("Latitude", OgcOrientationType.East),
                new OgcAxis("Longitude", OgcOrientationType.North)
            }
                           ),
                       new CoordinateOperationInfo(
                           "Mercator",
                           parameters
                           ),
                       linearUnit,
                       new IAxis[] {
                new OgcAxis("Easting", OgcOrientationType.East),
                new OgcAxis("Northing", OgcOrientationType.North)
            }
                       ));
        }
Пример #10
0
        public static ICrs GetCrs(GeoTransGoldDataReader reader)
        {
            var coordinatesName = reader["COORDINATES"];
            if (String.IsNullOrEmpty(coordinatesName))
                coordinatesName = reader["PROJECTION"];

            switch (coordinatesName) {
            case "Geodetic":
                return CreateGeographicCrs(reader);
            case "Lambert Conformal Conic (1 parallel)":
                return CreateLcc1Sp(reader);
            case "Lambert Conformal Conic (2 parallel)":
                return CreateLcc2Sp(reader);
            case "Mercator":
                return CreateMercator(reader);
            case "Polar Stereographic":
                return CreatePolarStereographic(reader);
            case "Transverse Mercator":
                return CreateTMerc(reader);
            default:
                throw new NotSupportedException("Not supported: " + coordinatesName);
            }
        }
Пример #11
0
 private static ICrs CreateLcc1Sp(GeoTransGoldDataReader reader)
 {
     var datum = GenerateDatum(reader["DATUM"]);
     var linearUnit = OgcLinearUnit.DefaultMeter;
     return new OgcCrsProjected(
         reader["PROJECTION"],
         new OgcCrsGeographic(
             datum.Name,
             datum,
             datum.PrimeMeridian.Unit,
             new[] {
                 new OgcAxis("Latitude", OgcOrientationType.East),
                 new OgcAxis("Longitude", OgcOrientationType.North)
             }
         ),
         new CoordinateOperationInfo(
             "Lambert_Conformal_Conic_1SP",
             new INamedParameter[] {
                 new NamedParameter<double>("latitude_of_origin",Double.Parse(reader["ORIGIN LATITUDE"]), OgcAngularUnit.DefaultDegrees),
                 new NamedParameter<double>("central_meridian", Double.Parse(reader["CENTRAL MERIDIAN"]), OgcAngularUnit.DefaultDegrees),
                 new NamedParameter<double>("scale_factor", Double.Parse(reader["SCALE FACTOR"]), ScaleUnitUnity.Value),
                 new NamedParameter<double>("false_easting", Double.Parse(reader["FALSE EASTING"]),linearUnit),
                 new NamedParameter<double>("false_northing", Double.Parse(reader["FALSE NORTHING"]),linearUnit)
             }
         ),
         linearUnit,
         new IAxis[] {
             new OgcAxis("Easting", OgcOrientationType.East),
             new OgcAxis("Northing", OgcOrientationType.North)
         }
     );
 }
Пример #12
0
        private static ICrs CreatePolarStereographic(GeoTransGoldDataReader reader)
        {
            var datum = GenerateDatum(reader["DATUM"]);
            var linearUnit = OgcLinearUnit.DefaultMeter;
            var scaleFactor = reader["SCALE FACTOR"];
            var parameters = new List<INamedParameter> {
                new NamedParameter<double>("longitude_down_from_pole", Double.Parse(reader["LONGITUDE DOWN FROM POLE"]), OgcAngularUnit.DefaultDegrees),
                new NamedParameter<double>("false_easting", Double.Parse(reader["FALSE EASTING"]),linearUnit),
                new NamedParameter<double>("false_northing", Double.Parse(reader["FALSE NORTHING"]),linearUnit)
            };

            if (null != scaleFactor) {
                parameters.Add(new NamedParameter<double>("latitude_of_true_scale", 90, OgcAngularUnit.DefaultDegrees));
                parameters.Add(new NamedParameter<double>("scale_factor", Double.Parse(scaleFactor), ScaleUnitUnity.Value));
            }
            else {
                var latSp = Double.Parse(reader["LATITUDE OF TRUE SCALE"]);
                parameters.Add(new NamedParameter<double>("standard_parallel", latSp, OgcAngularUnit.DefaultDegrees));
                parameters.Add(new NamedParameter<double>("latitude_of_true_scale", latSp < 0 ? -90 : 90, OgcAngularUnit.DefaultDegrees));
            }

            return new OgcCrsProjected(
                reader["PROJECTION"],
                new OgcCrsGeographic(
                    datum.Name,
                    datum,
                    datum.PrimeMeridian.Unit,
                    new[] {
                        new OgcAxis("Latitude", OgcOrientationType.East),
                        new OgcAxis("Longitude", OgcOrientationType.North)
                    }
                ),
                new CoordinateOperationInfo(
                    "Polar Stereographic",
                    parameters
                ),
                linearUnit,
                new IAxis[] {
                    new OgcAxis("Easting", OgcOrientationType.East),
                    new OgcAxis("Northing", OgcOrientationType.North)
                }
            );
        }
Пример #13
0
        private static ICrs CreateMercator(GeoTransGoldDataReader reader)
        {
            var datum = GenerateDatum(reader["DATUM"]);
            var linearUnit = OgcLinearUnit.DefaultMeter;
            var latTrueScale = reader["LATITUDE OF TRUE SCALE"];
            var parameters = new List<INamedParameter> {
                new NamedParameter<double>("central_meridian", Double.Parse(reader["CENTRAL MERIDIAN"]), OgcAngularUnit.DefaultDegrees),
                new NamedParameter<double>("false_easting", Double.Parse(reader["FALSE EASTING"]),linearUnit),
                new NamedParameter<double>("false_northing", Double.Parse(reader["FALSE NORTHING"]),linearUnit)
            };

            if (null == latTrueScale) {
                parameters.Add(new NamedParameter<double>("scale_factor", Double.Parse(reader["SCALE FACTOR"]), ScaleUnitUnity.Value));
            }
            else {
                parameters.Add(new NamedParameter<double>("latitude_of_true_scale", Double.Parse(latTrueScale), OgcAngularUnit.DefaultDegrees));
            }

            return new OgcCrsProjected(
                reader["PROJECTION"],
                new OgcCrsGeographic(
                    datum.Name,
                    datum,
                    datum.PrimeMeridian.Unit,
                    new[] {
                        new OgcAxis("Latitude", OgcOrientationType.East),
                        new OgcAxis("Longitude", OgcOrientationType.North)
                    }
                ),
                new CoordinateOperationInfo(
                    "Mercator",
                    parameters
                ),
                linearUnit,
                new IAxis[] {
                    new OgcAxis("Easting", OgcOrientationType.East),
                    new OgcAxis("Northing", OgcOrientationType.North)
                }
            );
        }
        public void BasicTest()
        {
            var reader = new StringReader(
            @"COORDINATES: Lambert Conformal Conic (2 parallel)
            DATUM: WGE
            # ELLIPSOID: WE
            CENTRAL MERIDIAN: 57.53847 #deg
            ORIGIN LATITUDE: -20.26430 #deg
            STANDARD PARALLEL ONE: -20.52861 #deg
            STANDARD PARALLEL TWO: -20.00000 #deg
            FALSE EASTING: 0 #m
            FALSE NORTHING: 0 #m
            # Easting (m), Northing (m)
            END OF HEADER

            # Mauritius
               392,  29260  #1
              1003,  29260  #2
              3241,  29260  #3
             11991,  29256  #4
             25373,  -3232  #5
             -2361, -29261  #6
            -25345, -22422  #7
               392,  29260  #8
            ");

            var parser = new GeoTransGoldDataReader(reader);
            Assert.IsTrue(parser.Read());
            Assert.AreEqual("Lambert Conformal Conic (2 parallel)", parser["COORDINATES"]);
            Assert.AreEqual("WGE", parser["DATUM"]);
            Assert.AreEqual("57.53847", parser["CENTRAL MERIDIAN"]);
            Assert.AreEqual("-20.26430", parser["ORIGIN LATITUDE"]);
            Assert.AreEqual("-20.52861", parser["STANDARD PARALLEL ONE"]);
            Assert.AreEqual("-20.00000", parser["STANDARD PARALLEL TWO"]);
            Assert.AreEqual("0", parser["FALSE EASTING"]);
            Assert.AreEqual("0", parser["FALSE NORTHING"]);
            Assert.IsTrue(parser.Read());
            Assert.AreEqual(
                new Point2(392, 29260),
                parser.CurrentPoint2D()
            );
            Assert.IsTrue(parser.Read());
            Assert.AreEqual(
                new Point2(1003, 29260),
                parser.CurrentPoint2D()
            );
            Assert.IsTrue(parser.Read());
            Assert.AreEqual(
                new Point2(3241, 29260),
                parser.CurrentPoint2D()
            );
            Assert.IsTrue(parser.Read());
            Assert.AreEqual(
                new Point2(11991, 29256),
                parser.CurrentPoint2D()
            );
            Assert.IsTrue(parser.Read());
            Assert.AreEqual(
                new Point2(25373, -3232),
                parser.CurrentPoint2D()
            );
            Assert.IsTrue(parser.Read());
            Assert.AreEqual(
                new Point2(-2361, -29261),
                parser.CurrentPoint2D()
            );
            Assert.IsTrue(parser.Read());
            Assert.AreEqual(
                new Point2(-25345, -22422),
                parser.CurrentPoint2D()
            );
            Assert.IsTrue(parser.Read());
            Assert.AreEqual(
                new Point2(392, 29260),
                parser.CurrentPoint2D()
            );
            Assert.IsFalse(parser.Read());
        }
Пример #15
0
        public void BasicTest()
        {
            var reader = new StringReader(
                @"COORDINATES: Lambert Conformal Conic (2 parallel)
DATUM: WGE
# ELLIPSOID: WE
CENTRAL MERIDIAN: 57.53847 #deg
ORIGIN LATITUDE: -20.26430 #deg
STANDARD PARALLEL ONE: -20.52861 #deg
STANDARD PARALLEL TWO: -20.00000 #deg
FALSE EASTING: 0 #m
FALSE NORTHING: 0 #m
# Easting (m), Northing (m)
END OF HEADER

# Mauritius
   392,  29260  #1
  1003,  29260  #2
  3241,  29260  #3
 11991,  29256  #4
 25373,  -3232  #5
 -2361, -29261  #6
-25345, -22422  #7
   392,  29260  #8
");

            var parser = new GeoTransGoldDataReader(reader);

            Assert.IsTrue(parser.Read());
            Assert.AreEqual("Lambert Conformal Conic (2 parallel)", parser["COORDINATES"]);
            Assert.AreEqual("WGE", parser["DATUM"]);
            Assert.AreEqual("57.53847", parser["CENTRAL MERIDIAN"]);
            Assert.AreEqual("-20.26430", parser["ORIGIN LATITUDE"]);
            Assert.AreEqual("-20.52861", parser["STANDARD PARALLEL ONE"]);
            Assert.AreEqual("-20.00000", parser["STANDARD PARALLEL TWO"]);
            Assert.AreEqual("0", parser["FALSE EASTING"]);
            Assert.AreEqual("0", parser["FALSE NORTHING"]);
            Assert.IsTrue(parser.Read());
            Assert.AreEqual(
                new Point2(392, 29260),
                parser.CurrentPoint2D()
                );
            Assert.IsTrue(parser.Read());
            Assert.AreEqual(
                new Point2(1003, 29260),
                parser.CurrentPoint2D()
                );
            Assert.IsTrue(parser.Read());
            Assert.AreEqual(
                new Point2(3241, 29260),
                parser.CurrentPoint2D()
                );
            Assert.IsTrue(parser.Read());
            Assert.AreEqual(
                new Point2(11991, 29256),
                parser.CurrentPoint2D()
                );
            Assert.IsTrue(parser.Read());
            Assert.AreEqual(
                new Point2(25373, -3232),
                parser.CurrentPoint2D()
                );
            Assert.IsTrue(parser.Read());
            Assert.AreEqual(
                new Point2(-2361, -29261),
                parser.CurrentPoint2D()
                );
            Assert.IsTrue(parser.Read());
            Assert.AreEqual(
                new Point2(-25345, -22422),
                parser.CurrentPoint2D()
                );
            Assert.IsTrue(parser.Read());
            Assert.AreEqual(
                new Point2(392, 29260),
                parser.CurrentPoint2D()
                );
            Assert.IsFalse(parser.Read());
        }