private void  createProjectedCoordinateSystem()
        {
            ISpatialReferenceFactory2   spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
            IProjectionGEN              projection = spatialReferenceFactory.CreateProjection((int)esriSRProjectionType.esriSRProjection_Sinusoidal) as IProjectionGEN;
            IGeographicCoordinateSystem geographicCoordinateSystem = spatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
            ILinearUnit unit = spatialReferenceFactory.CreateUnit((int)esriSRUnitType.esriSRUnit_Meter) as ILinearUnit;

            IParameter[] parameters = projection.GetDefaultParameters();
            IProjectedCoordinateSystemEdit projectedCoordinateSystemEdit = new ProjectedCoordinateSystemClass();

            object name = "Newfoundland"; object alias = "NF_LAB";
            object abbreviation = "NF";
            object remarks      = "Most Eastern Province in Canada";
            object usage        = "When making maps of Newfoundland";
            object geographicCoordinateSystemObject = geographicCoordinateSystem as object;
            object unitObject       = unit as object;
            object projectionObject = projection as object;
            object parametersObject = parameters as object;

            projectedCoordinateSystemEdit.Define(ref name, ref alias, ref abbreviation, ref remarks, ref usage, ref geographicCoordinateSystemObject, ref unitObject, ref projectionObject, ref parametersObject);
            IProjectedCoordinateSystem userDefinedProjectedCoordinateSystem = projectedCoordinateSystemEdit as IProjectedCoordinateSystem;

            m_map.SpatialReference = userDefinedProjectedCoordinateSystem;
            m_activeView.Refresh();
            MessageBox.Show("自定义ProjectedCoordinateSystem完成!");
        }
 /// <summary>
 /// Initializes a new instance of an Ellipsoid
 /// </summary>
 /// <param name="semiMajorAxis">Semi major axis</param>
 /// <param name="semiMinorAxis">Semi minor axis</param>
 /// <param name="inverseFlattening">Inverse flattening</param>
 /// <param name="isIvfDefinitive">Inverse Flattening is definitive for this ellipsoid (Semi-minor axis will be overridden)</param>
 /// <param name="axisUnit">Axis unit</param>
 /// <param name="name">Name</param>
 /// <param name="authority">Authority name</param>
 /// <param name="code">Authority-specific identification code.</param>
 /// <param name="alias">Alias</param>
 /// <param name="abbreviation">Abbreviation</param>
 /// <param name="remarks">Provider-supplied remarks</param>
 internal Ellipsoid(
     double semiMajorAxis,
     double semiMinorAxis,
     double inverseFlattening,
     bool isIvfDefinitive,
     ILinearUnit axisUnit, string name, string authority, long code, string alias,
     string abbreviation, string remarks)
     : base(name, authority, code, alias, abbreviation, remarks)
 {
     SemiMajorAxis     = semiMajorAxis;
     InverseFlattening = inverseFlattening;
     AxisUnit          = axisUnit;
     IsIvfDefinitive   = isIvfDefinitive;
     if (isIvfDefinitive && (inverseFlattening == 0 || double.IsInfinity(inverseFlattening)))
     {
         SemiMinorAxis = semiMajorAxis;
     }
     else if (isIvfDefinitive)
     {
         SemiMinorAxis = (1.0 - (1.0 / InverseFlattening)) * semiMajorAxis;
     }
     else
     {
         SemiMinorAxis = semiMinorAxis;
     }
 }
 /// <summary>
 /// Initializes a new instance of the ProjectedCoordinateSystem class.
 /// </summary>
 /// <param name="horizontalDatum">The horizontal datum to use.</param>
 /// <param name="axisInfoArray">An array of IAxisInfo representing the axis information.</param>
 /// <param name="geographicCoordSystem">The geographic coordinate system.</param>
 /// <param name="linearUnit">The linear units to use.</param>
 /// <param name="projection">The projection to use.</param>
 /// <param name="remarks">Remarks about this object.</param>
 /// <param name="authority">The name of the authority.</param>
 /// <param name="authorityCode">The code the authority uses to identidy this object.</param>
 /// <param name="name">The name of the object.</param>
 /// <param name="alias">The alias of the object.</param>
 /// <param name="abbreviation">The abbreviated name of this object.</param>
 internal ProjectedCoordinateSystem(
     IHorizontalDatum horizontalDatum,
     IAxisInfo[] axisInfoArray,
     IGeographicCoordinateSystem geographicCoordSystem,
     ILinearUnit linearUnit,
     IProjection projection,
     string remarks, string authority, string authorityCode, string name, string alias, string abbreviation)
     : base(remarks, authority, authorityCode, name, alias, abbreviation)
 {
     if (axisInfoArray == null)
     {
         throw new ArgumentNullException("axisInfoArray");
     }
     if (geographicCoordSystem == null)
     {
         throw new ArgumentNullException("geographicCoordSystem");
     }
     if (projection == null)
     {
         throw new ArgumentNullException("projection");
     }
     if (linearUnit == null)
     {
         throw new ArgumentNullException("linearUnit");
     }
     _horizontalDatum       = horizontalDatum;
     _axisInfoArray         = axisInfoArray;
     _geographicCoordSystem = geographicCoordSystem;
     _projection            = projection;
     _linearUnit            = linearUnit;
 }
Пример #4
0
        private static IProjectedCoordinateSystem ReadProjectedCoordinateSystem(XmlTextReader reader)
        {
            if (!(reader.NodeType == XmlNodeType.Element && reader.Name == "CS_ProjectedCoordinateSystem"))
            {
                throw new ParseException(String.Format("Expected a IProjectedCoordinateSystem but got a {0} at line {1} col {2}", reader.Name, reader.LineNumber, reader.LinePosition));
            }
            string authority = "", authorityCode = "", abbreviation = "", name = "";

            reader.Read();
            ReadInfo(reader, ref authority, ref authorityCode, ref abbreviation, ref name);
            ArrayList list = new ArrayList();

            while (reader.NodeType == XmlNodeType.Element && reader.Name == "CS_AxisInfo")
            {
                IAxisInfo axis = ReadAxisInfo(reader);
                list.Add(axis);
                reader.Read();
            }
            IAxisInfo[] axisInfos = new IAxisInfo[list.Count];
            axisInfos = (IAxisInfo[])list.ToArray(typeof(IAxisInfo));
            IGeographicCoordinateSystem geographicCoordinateSystem = ReadGeographicCoordinateSystem(reader);
            ILinearUnit linearUnit = ReadLinearUnit(reader);
            IProjection projection = ReadProjection(reader);

            reader.Read();
            //IPrimeMeridian primeMeridian = null;
            IHorizontalDatum          horizontalDatum = null;
            ProjectedCoordinateSystem projectedCS     = new ProjectedCoordinateSystem(horizontalDatum,
                                                                                      axisInfos, geographicCoordinateSystem, linearUnit, projection, "", authority, authorityCode,
                                                                                      name, "", abbreviation);

            return(projectedCS);
        }
        private void createVerticalCoordinateSystem()
        {
            ISpatialReferenceFactory3 spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
            IVerticalDatum            verticalDatum           = spatialReferenceFactory.CreateVerticalDatum((int)esriSRVerticalDatumType.esriSRVertDatum_Taranaki);
            IHVDatum    hvDatum    = verticalDatum as IHVDatum;
            ILinearUnit linearUnit = spatialReferenceFactory.CreateUnit((int)esriSRUnitType.esriSRUnit_Meter) as ILinearUnit;
            IVerticalCoordinateSystemEdit verticalCoordinateSystemEdit = new VerticalCoordinateSystemClass();
            object name              = "New VCoordinateSystem";
            object alias             = "VCoordinateSystem alias";
            object abbreviation      = "abbr";
            object remarks           = "Test for options";
            object usage             = "New Zealand";
            object hvDatumObject     = hvDatum as object;
            object unitObject        = linearUnit as object;
            object verticalShift     = 40 as object;
            object positiveDirection = -1 as object;

            verticalCoordinateSystemEdit.Define(ref name, ref alias, ref abbreviation, ref remarks, ref usage, ref hvDatumObject, ref unitObject, ref verticalShift, ref positiveDirection);
            IVerticalCoordinateSystem verticalCoordinateSystem = verticalCoordinateSystemEdit as IVerticalCoordinateSystem;


            m_map.SpatialReference = verticalCoordinateSystem as ISpatialReference;
            m_activeView.Refresh();
            MessageBox.Show("自定义verticalCoordinateSystem完成!");
        }
Пример #6
0
        public static bool ValideFeatureClass(IGeoDataset igeoDataset_0)
        {
            IEnvelope extent = igeoDataset_0.Extent;
            bool      result;

            if (extent.IsEmpty)
            {
                result = true;
            }
            else
            {
                if (igeoDataset_0 is IFeatureClass)
                {
                    if (!CommonHelper.FeatureClassHasData(igeoDataset_0 as IFeatureClass))
                    {
                        result = true;
                        return(result);
                    }
                }
                else if (igeoDataset_0 is IFeatureLayer && !CommonHelper.LayerHasData(igeoDataset_0 as IFeatureLayer))
                {
                    result = true;
                    return(result);
                }
                ISpatialReference spatialReference = igeoDataset_0.SpatialReference;
                if (spatialReference is IProjectedCoordinateSystem)
                {
                    double falseEasting  = (spatialReference as IProjectedCoordinateSystem).FalseEasting;
                    double falseNorthing = (spatialReference as IProjectedCoordinateSystem).FalseNorthing;
                    if (falseEasting > 0.0 && extent.XMin < falseEasting - 500000.0)
                    {
                        result = false;
                        return(result);
                    }
                    ILinearUnit coordinateUnit = (spatialReference as IProjectedCoordinateSystem).CoordinateUnit;
                    double      num            = -10001858.0 / coordinateUnit.MetersPerUnit + falseNorthing;
                    double      num2           = 10001858.0 / coordinateUnit.MetersPerUnit + falseNorthing;
                    if (extent.YMin < num || extent.YMax > num2)
                    {
                        result = false;
                        return(result);
                    }
                }
                else if (spatialReference is IGeographicCoordinateSystem)
                {
                    if (extent.XMin < -360.0 || extent.XMax > 360.0)
                    {
                        result = false;
                        return(result);
                    }
                    if (extent.YMin < -100.0 || extent.YMax > 100.0)
                    {
                        result = false;
                        return(result);
                    }
                }
                result = true;
            }
            return(result);
        }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the Ellipsoid class with the specified parameters.
 /// </summary>
 /// <param name="semiMajorAxis">Double representing semi major axis.</param>
 /// <param name="semiMinorAxis">Double representing semi minor axis.</param>
 /// <param name="inverseFlattening">The inverse flattening.</param>
 /// <param name="isIvfDefinitive">Flag indicating wether the inverse flattening shoul be used to determine the semi-minor axis.</param>
 /// <param name="linearUnit">The linar units to measure the ellipsoid.</param>
 /// <param name="remarks">Remarks about this object.</param>
 /// <param name="authority">The name of the authority.</param>
 /// <param name="authorityCode">The code the authority uses to identidy this object.</param>
 /// <param name="name">The name of the object.</param>
 /// <param name="alias">The alias of the object.</param>
 /// <param name="abbreviation">The abbreviated name of this object.</param>
 internal Ellipsoid(
     double semiMajorAxis,
     double semiMinorAxis,
     double inverseFlattening,
     bool isIvfDefinitive,
     ILinearUnit linearUnit,
     string remarks, string authority, string authorityCode, string name, string alias, string abbreviation)
     : base(remarks, authority, authorityCode, name, alias, abbreviation)
 {
     if (linearUnit == null)
     {
         throw new ArgumentNullException("linearUnit");
     }
     _name              = name;
     _linearUnit        = linearUnit;
     _semiMajorAxis     = semiMajorAxis;
     _inverseFlattening = inverseFlattening;
     _isIvfDefinitive   = isIvfDefinitive;
     if (_isIvfDefinitive)
     {
         _semiMinorAxis = (1.0 - (1.0 / _inverseFlattening)) * semiMajorAxis;
     }
     else
     {
         _semiMinorAxis = semiMinorAxis;
     }
     _semiMajorAxis     = semiMajorAxis;
     _inverseFlattening = inverseFlattening;
 }
Пример #8
0
 /// <summary>
 /// Creates an <see cref="Ellipsoid"/> from radius values.
 /// </summary>
 /// <seealso cref="CreateFlattenedSphere"/>
 /// <param name="name">Name of ellipsoid</param>
 /// <param name="semiMajorAxis"></param>
 /// <param name="semiMinorAxis"></param>
 /// <param name="linearUnit"></param>
 /// <returns>Ellipsoid</returns>
 public IEllipsoid CreateEllipsoid(string name, double semiMajorAxis, double semiMinorAxis, ILinearUnit linearUnit)
 {
     double ivf = 0;
     if (semiMajorAxis != semiMinorAxis)
         ivf = semiMajorAxis / (semiMajorAxis - semiMinorAxis);
     return new Ellipsoid(semiMajorAxis, semiMinorAxis, ivf, false, linearUnit, name, String.Empty, -1, String.Empty, string.Empty, string.Empty);
 }
 private static void WriteLinearUnit(ILinearUnit linearUnit, XmlTextWriter writer)
 {
     writer.WriteStartElement("CS_LinearUnit");
     writer.WriteAttributeString("MetersPerUnit", linearUnit.MetersPerUnit.ToString());
     WriteCSInfo(linearUnit, writer);
     writer.WriteEndElement();
 }
Пример #10
0
        /// <summary>
        /// Initializes a new instance of the ProjectedCoordinateSystem class.
        /// </summary>
        /// <param name="horizontalDatum">The horizontal datum to use.</param>
        /// <param name="axisInfoArray">An array of IAxisInfo representing the axis information.</param>
        /// <param name="geographicCoordSystem">The geographic coordinate system.</param>
        /// <param name="linearUnit">The linear units to use.</param>
        /// <param name="projection">The projection to use.</param>
        /// <param name="remarks">Remarks about this object.</param>
        /// <param name="authority">The name of the authority.</param>
        /// <param name="authorityCode">The code the authority uses to identidy this object.</param>
        /// <param name="name">The name of the object.</param>
        /// <param name="alias">The alias of the object.</param>
        /// <param name="abbreviation">The abbreviated name of this object.</param>
        internal ProjectedCoordinateSystem(
			IHorizontalDatum horizontalDatum,
			IAxisInfo[] axisInfoArray,
			IGeographicCoordinateSystem geographicCoordSystem,
			ILinearUnit linearUnit,
			IProjection projection,
			string remarks, string authority, string authorityCode, string name, string alias, string abbreviation)
            : base(remarks, authority, authorityCode, name, alias, abbreviation)
        {
            if (axisInfoArray==null)
            {
                throw new ArgumentNullException("axisInfoArray");
            }
            if (geographicCoordSystem==null)
            {
                throw new ArgumentNullException("geographicCoordSystem");
            }
            if (projection==null)
            {
                throw new ArgumentNullException("projection");
            }
            if (linearUnit==null)
            {
                throw new ArgumentNullException("linearUnit");
            }
            _horizontalDatum=horizontalDatum;
            _axisInfoArray=  axisInfoArray;
            _geographicCoordSystem = geographicCoordSystem;
            _projection=	 projection;
            _linearUnit = linearUnit;
        }
Пример #11
0
 /// <summary>
 /// Creates an <see cref="T:Topology.CoordinateSystems.Ellipsoid" /> from an major radius, and inverse flattening.
 /// </summary>
 /// <seealso cref="M:Topology.CoordinateSystems.CoordinateSystemFactory.CreateEllipsoid(System.String,System.Double,System.Double,Topology.CoordinateSystems.ILinearUnit)" />
 /// <param name="name">Name of ellipsoid</param>
 /// <param name="semiMajorAxis">Semi major-axis</param>
 /// <param name="inverseFlattening">Inverse flattening</param>
 /// <param name="linearUnit">Linear unit</param>
 /// <returns>Ellipsoid</returns>
 public IEllipsoid CreateFlattenedSphere(string name, double semiMajorAxis, double inverseFlattening, ILinearUnit linearUnit)
 {
     if (string.IsNullOrEmpty(name))
     {
         throw new ArgumentException("Invalid name");
     }
     return new Ellipsoid(semiMajorAxis, -1, inverseFlattening, true, linearUnit, name, string.Empty, -1L, string.Empty, string.Empty, string.Empty);
 }
 /// <summary>
 /// Initializes a new instance of the ProjectedCoordinateSystem class.
 /// </summary>
 /// <param name="horizontalDatum">The horizontal datum to use.</param>
 /// <param name="axisInfoArray">An array of IAxisInfo representing the axis information.</param>
 /// <param name="geographicCoordSystem">The geographic coordinate system.</param>
 /// <param name="linearUnit">The linear units to use.</param>
 /// <param name="projection">The projection to use.</param>
 internal ProjectedCoordinateSystem(
     IHorizontalDatum horizontalDatum,
     IAxisInfo[] axisInfoArray,
     IGeographicCoordinateSystem geographicCoordSystem,
     ILinearUnit linearUnit,
     IProjection projection) : this(horizontalDatum, axisInfoArray, geographicCoordSystem, linearUnit, projection, "", "", "", "", "", "")
 {
 }
Пример #13
0
        public double getLinearConversion(IProjectedCoordinateSystem prjSys)
        {
            IUnitConverter converter  = new UnitConverterClass();
            ILinearUnit    linearUnit = prjSys.CoordinateUnit;
            double         meter      = linearUnit.MetersPerUnit;
            double         unitToFoot = converter.ConvertUnits(meter, esriUnits.esriMeters, esriUnits.esriFeet);

            return(unitToFoot);
        }
Пример #14
0
        /// <summary>
        /// Initializes a new instance of the ProjectedCoordinateSystem class.
        /// </summary>
        /// <param name="horizontalDatum">The horizontal datum to use.</param>
        /// <param name="axisInfoArray">An array of IAxisInfo representing the axis information.</param>
        /// <param name="geographicCoordSystem">The geographic coordinate system.</param>
        /// <param name="linearUnit">The linear units to use.</param>
        /// <param name="projection">The projection to use.</param>
        internal ProjectedCoordinateSystem(
			IHorizontalDatum horizontalDatum,
			IAxisInfo[] axisInfoArray,
			IGeographicCoordinateSystem geographicCoordSystem,
			ILinearUnit linearUnit,
			IProjection projection)
            : this(horizontalDatum, axisInfoArray, geographicCoordSystem, linearUnit, projection, "", "", "", "", "", "")
        {
        }
Пример #15
0
 /// <summary>
 /// Initializes a new instance of the Ellipsoid class with the specified parameters.
 /// </summary>
 /// <param name="semiMajorAxis">Double representing semi major axis.</param>
 /// <param name="semiMinorAxis">Double representing semi minor axis.</param>
 /// <param name="inverseFlattening">The inverse flattening.</param>
 /// <param name="isIvfDefinitive">Flag indicating wether the inverse flattening shoul be used to determine the semi-minor axis.</param>
 /// <param name="linearUnit">The linar units to measure the ellipsoid.</param>
 internal Ellipsoid(double semiMajorAxis,
                    double semiMinorAxis,
                    double inverseFlattening,
                    bool isIvfDefinitive,
                    ILinearUnit linearUnit)
     : this(semiMajorAxis, semiMinorAxis, inverseFlattening, isIvfDefinitive, linearUnit,
            "", "", "", "", "", "")
 {
 }
Пример #16
0
 private static void WriteLinearUnit(ILinearUnit linearUnit, IndentedTextWriter writer)
 {
     writer.WriteLine("UNIT[");
     writer.Indent = writer.Indent + 1;
     writer.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "\"{0}\",{1},", linearUnit.Name, linearUnit.MetersPerUnit));
     writer.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "AUTHORITY[\"{0}\",\"{1}\"]", linearUnit.Authority, linearUnit.AuthorityCode));
     writer.Indent = writer.Indent - 1;
     writer.WriteLine("]");
 }
Пример #17
0
 private static void WriteLinearUnit(ILinearUnit linearUnit, IndentedTextWriter writer)
 {
     writer.WriteLine("UNIT[");
     writer.Indent = writer.Indent + 1;
     writer.WriteLine(String.Format("\"{0}\",{1},", linearUnit.Name, linearUnit.MetersPerUnit));
     writer.WriteLine(String.Format("AUTHORITY[\"{0}\",\"{1}\"]", linearUnit.Authority, linearUnit.AuthorityCode));
     writer.Indent = writer.Indent - 1;
     writer.WriteLine("]");
 }
Пример #18
0
        /// <summary>
        /// Initializes a new instance of the Ellipsoid class with the specified parameters.
        /// </summary>
        /// <param name="semiMajorAxis">Double representing semi major axis.</param>
        /// <param name="semiMinorAxis">Double representing semi minor axis.</param>
        /// <param name="inverseFlattening">The inverse flattening.</param>
        /// <param name="isIvfDefinitive">Flag indicating wether the inverse flattening shoul be used to determine the semi-minor axis.</param>
        /// <param name="linearUnit">The linar units to measure the ellipsoid.</param>
        internal Ellipsoid(	double semiMajorAxis,
			double semiMinorAxis,
			double inverseFlattening,
			bool isIvfDefinitive,
			ILinearUnit linearUnit)
            : this(semiMajorAxis, semiMinorAxis, inverseFlattening,  isIvfDefinitive, linearUnit,
			"","","", "","","")
        {
        }
 /// <summary>
 /// Initializes a new instance of a projected coordinate system
 /// </summary>
 /// <param name="datum">Horizontal datum</param>
 /// <param name="geographicCoordinateSystem">Geographic coordinate system</param>
 /// <param name="linearUnit">Linear unit</param>
 /// <param name="projection">Projection</param>
 /// <param name="axisInfo">Axis info</param>
 /// <param name="name">Name</param>
 /// <param name="authority">Authority name</param>
 /// <param name="code">Authority-specific identification code.</param>
 /// <param name="alias">Alias</param>
 /// <param name="abbreviation">Abbreviation</param>
 /// <param name="remarks">Provider-supplied remarks</param>
 internal ProjectedCoordinateSystem(IHorizontalDatum datum, IGeographicCoordinateSystem geographicCoordinateSystem,
                                    ILinearUnit linearUnit, IProjection projection, List <AxisInfo> axisInfo,
                                    string name, string authority, long code, string alias,
                                    string remarks, string abbreviation)
     : base(datum, axisInfo, name, authority, code, alias, abbreviation, remarks)
 {
     _GeographicCoordinateSystem = geographicCoordinateSystem;
     _LinearUnit = linearUnit;
     _Projection = projection;
 }
Пример #20
0
 /// <summary>
 /// Initializes a new instance of a projected coordinate system
 /// </summary>
 /// <param name="datum">Horizontal datum</param>
 /// <param name="geographicCoordinateSystem">Geographic coordinate system</param>
 /// <param name="linearUnit">Linear unit</param>
 /// <param name="projection">Projection</param>
 /// <param name="axisInfo">Axis info</param>
 /// <param name="name">Name</param>
 /// <param name="authority">Authority name</param>
 /// <param name="code">Authority-specific identification code.</param>
 /// <param name="alias">Alias</param>
 /// <param name="abbreviation">Abbreviation</param>
 /// <param name="remarks">Provider-supplied remarks</param>
 internal ProjectedCoordinateSystem(IHorizontalDatum datum, IGeographicCoordinateSystem geographicCoordinateSystem,
     ILinearUnit linearUnit, IProjection projection, List<AxisInfo> axisInfo,
     string name, string authority, long code, string alias,
     string remarks, string abbreviation)
     : base(datum, axisInfo, name, authority, code, alias, abbreviation, remarks)
 {
     _GeographicCoordinateSystem = geographicCoordinateSystem;
     _LinearUnit = linearUnit;
     _Projection = projection;
 }
Пример #21
0
        public void TestReadUnit3()
        {
            string      testFile   = Global.GetUnitTestRootDirectory() + @"\IO\LinearUnit.txt";
            string      wkt1       = FileToString(testFile);
            ILinearUnit linearUnit = CoordinateSystemWktReader.Create(wkt1) as ILinearUnit;
            string      wkt2       = linearUnit.WKT;
            bool        same       = Compare.CompareAgainstString(testFile, wkt2);

            Assertion.AssertEquals("Unit 3", true, same);
        }
 internal GeocentricCoordinateSystem(IHorizontalDatum datum, ILinearUnit linearUnit, IPrimeMeridian primeMeridian, List <AxisInfo> axisinfo, string name, string authority, long code, string alias, string remarks, string abbreviation) : base(name, authority, code, alias, abbreviation, remarks)
 {
     this._HorizontalDatum = datum;
     this._LinearUnit      = linearUnit;
     this._Primemeridan    = primeMeridian;
     if (axisinfo.Count != 3)
     {
         throw new ArgumentException("Axis info should contain three axes for geocentric coordinate systems");
     }
     base.AxisInfo = axisinfo;
 }
 public void Test_LinearUnit2()
 {
     try
     {
         ILinearUnit linearUnit = _factory.CreateLinearUnit("9101");
         Assertion.Fail("Linear Unit - Exception should be thrown because 9101 is an angular unit.");
     }
     catch (ArgumentException)
     {
     }
 }
        /*
         * public void Test_TestSqlServer()
         * {
         *      string connectionString = @"initial catalog=EPSG;data source=localhost;Integrated Security=SSPI;";
         *      SqlConnection connection = new SqlConnection(connectionString);
         *
         *      CoordinateSystemEPSGFactory factory = new CoordinateSystemEPSGFactory(connection);
         *      ILinearUnit linearUnit = factory.CreateLinearUnit("9001");
         *      Assertion.AssertEquals("LinearUnit - untis per meter ",1.0,linearUnit.MetersPerUnit);
         *      Assertion.AssertEquals("LinearUnit - Authority","EPSG",linearUnit.Authority);
         *      Assertion.AssertEquals("LinearUnit - Remarks","Also known as International metre.",linearUnit.Remarks);
         *      connection.Close();
         * }
         */
        #endregion

        #region LinearUnit
        public void Test_LinearUnit()
        {
            try
            {
                ILinearUnit linearUnit = _factory.CreateLinearUnit("1");
                Assertion.Fail("Linear Unit - Exception should be thrown.");
            }
            catch (ArgumentOutOfRangeException)
            {
            }
        }
        public void TestWriteUnit1()
        {
            ILinearUnit        linearUnit         = _factory.CreateLinearUnit("9001");
            TextWriter         textwriter         = new StringWriter();
            IndentedTextWriter indentedTextWriter = new IndentedTextWriter(textwriter);

            CoordinateSystemWktWriter.Write(linearUnit, indentedTextWriter);
            bool same = Compare.CompareAgainstString(Global.GetUnitTestRootDirectory() + @"\IO\LinearUnit.txt", textwriter.ToString());

            Assertion.AssertEquals("test 1", true, same);
        }
        /*
         * [Ignore("EPSG is not in the bin directory, so will fail")]
         * public void Test_Constructor2()
         * {
         *      CoordinateSystemEPSGFactory factory = CoordinateSystemEPSGFactory.UseDefaultDatabase();
         *      ILinearUnit linearUnit = factory.CreateLinearUnit("9001");
         *      Assertion.AssertEquals("LinearUnit - untis per meter ",1.0,linearUnit.MetersPerUnit);
         *      Assertion.AssertEquals("LinearUnit - Authority","EPSG",linearUnit.Authority);
         *      Assertion.AssertEquals("LinearUnit - Remarks","Also known as International metre.",linearUnit.Remarks);
         * }*/


        public void Test_TestAccessDB()
        {
            IDbConnection connection            = Global.GetEPSGDatabaseConnection();
            CoordinateSystemEPSGFactory factory = new CoordinateSystemEPSGFactory(connection);
            ILinearUnit linearUnit = factory.CreateLinearUnit("9001");

            Assertion.AssertEquals("LinearUnit - untis per meter ", 1.0, linearUnit.MetersPerUnit);
            Assertion.AssertEquals("LinearUnit - Authority", "EPSG", linearUnit.Authority);
            Assertion.AssertEquals("LinearUnit - Remarks", "Also known as International metre.", linearUnit.Remarks);
            connection.Close();
        }
Пример #27
0
        public void TestCreateVerticalCoordinateSystem1()
        {
            IAxisInfo                 axis          = AxisInfo.Altitude;
            ILinearUnit               unit          = LinearUnit.Meters;
            IVerticalDatum            verticalDatum = _csFactory.CreateVerticalDatum("vertdatum", DatumType.IVD_Ellipsoidal);
            IVerticalCoordinateSystem verticalCS    = _csFactory.CreateVerticalCoordinateSystem("test", verticalDatum, unit, axis);

            Assertion.AssertEquals("ctor. 1", "test", verticalCS.Name);
            Assertion.AssertEquals("ctor. 2", verticalDatum, verticalCS.VerticalDatum);
            Assertion.AssertEquals("ctor. 3", unit, verticalCS.VerticalUnit);
            Assertion.AssertEquals("ctor. 4", axis, verticalCS.GetAxis(0));
        }
 internal GeocentricCoordinateSystem(IHorizontalDatum datum, ILinearUnit linearUnit, IPrimeMeridian primeMeridian, List<AxisInfo> axisinfo,
     string name, string authority, long code, string alias,
     string remarks, string abbreviation)
     : base(name, authority, code, alias, abbreviation, remarks)
 {
     _HorizontalDatum = datum;
     _LinearUnit = linearUnit;
     _Primemeridan = primeMeridian;
     if (axisinfo.Count != 3)
         throw new ArgumentException("Axis info should contain three axes for geocentric coordinate systems");
     base.AxisInfo = axisinfo;
 }
        private static IProjectedCoordinateSystem ReadProjectedCoordinateSystem(WktStreamTokenizer tokenizer)
        {
            /*			PROJCS[
             *      "OSGB 1936 / British National Grid",
             *      GEOGCS[
             *              "OSGB 1936",
             *              DATUM[...]
             *              PRIMEM[...]
             *              AXIS["Geodetic latitude","NORTH"]
             *              AXIS["Geodetic longitude","EAST"]
             *              AUTHORITY["EPSG","4277"]
             *      ],
             *      PROJECTION["Transverse Mercator"],
             *      PARAMETER["latitude_of_natural_origin",49],
             *      PARAMETER["longitude_of_natural_origin",-2],
             *      PARAMETER["scale_factor_at_natural_origin",0.999601272],
             *      PARAMETER["false_easting",400000],
             *      PARAMETER["false_northing",-100000],
             *      AXIS["Easting","EAST"],
             *      AXIS["Northing","NORTH"],
             *      AUTHORITY["EPSG","27700"]
             * ]
             */
            tokenizer.ReadToken("[");
            string name = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("GEOGCS");
            IGeographicCoordinateSystem geographicCS = ReadGeographicCoordinateSystem(tokenizer);

            tokenizer.ReadToken(",");
            IProjection projection = ReadProjection(tokenizer);
            IAxisInfo   axis0      = ReadAxisInfo(tokenizer);

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("AXIS");
            IAxisInfo axis1 = ReadAxisInfo(tokenizer);

            tokenizer.ReadToken(",");
            string authority     = "";
            string authorityCode = "";

            tokenizer.ReadAuthority(ref authority, ref authorityCode);
            tokenizer.ReadToken("]");
            IAxisInfo[] axisArray = new IAxisInfo[2];
            axisArray[0] = axis0;
            axisArray[1] = axis1;
            ILinearUnit linearUnit = LinearUnit.Meters;
            IProjectedCoordinateSystem projectedCS = new ProjectedCoordinateSystem(null, axisArray, geographicCS, linearUnit, projection, "", authority, authorityCode, name, "", "");

            return(projectedCS);
        }
        public void TestAlbersProjection()
        {
            ICoordinateSystemFactory cFac = new CoordinateSystemFactory();
            ILinearUnit usSurveyFoot      = cFac.CreateLinearUnit();

            IEllipsoid ellipsoid = cFac.CreateFlattenedSphere(
                6378206.4, 294.9786982138982, LinearUnit.USSurveyFoot, "Clarke 1866");

            IHorizontalDatum datum = cFac.CreateHorizontalDatum(
                DatumType.HorizontalGeocentric, ellipsoid, null, "Clarke 1866");

            IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem(
                "Clarke 1866", AngularUnit.Degrees, datum,
                PrimeMeridian.Greenwich,
                new AxisInfo("Lon", AxisOrientation.East),
                new AxisInfo("Lat", AxisOrientation.North));

            //Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5);
            Collection <ProjectionParameter> parameters = new Collection <ProjectionParameter>();

            parameters.Add(new ProjectionParameter("central_meridian", -96));
            parameters.Add(new ProjectionParameter("latitude_of_origin", 23));
            parameters.Add(new ProjectionParameter("standard_parallel_1", 29.5));
            parameters.Add(new ProjectionParameter("standard_parallel_2", 45.5));
            parameters.Add(new ProjectionParameter("false_easting", 0));
            parameters.Add(new ProjectionParameter("false_northing", 0));

            IProjection projection = cFac.CreateProjection("Albers Conical Equal Area", "albers", parameters);

            IProjectedCoordinateSystem coordsys =
                cFac.CreateProjectedCoordinateSystem(
                    gcs, projection, LinearUnit.Metre,
                    new AxisInfo("East", AxisOrientation.East),
                    new AxisInfo("North", AxisOrientation.North));

            ICoordinateTransformation trans = new CoordinateTransformationFactory()
                                              .CreateFromCoordinateSystems(gcs, coordsys);

            IPoint pGeo  = new Point(-75, 35);
            IPoint pUtm  = trans.MathTransform.Transform(pGeo);
            IPoint pGeo2 = trans.MathTransform.Inverse().Transform(pUtm);

            IPoint expected = new IPoint(1885472.7, 1535925);

            Assert.IsTrue(toleranceLessThan(pUtm, expected, 0.05),
                          String.Format("Albers forward transformation outside tolerance, Expected {0}, got {1}",
                                        expected, pUtm));

            Assert.IsTrue(toleranceLessThan(pGeo, pGeo2, 0.0000001),
                          String.Format("Albers reverse transformation outside tolerance, Expected {0}, got {1}",
                                        pGeo.ToString(), pGeo2.ToString()));
        }
        public void Test_Constructor()
        {
            VerticalDatum datum = VerticalDatum.Ellipsoidal;
            IAxisInfo     axis  = AxisInfo.Altitude;
            ILinearUnit   unit  = LinearUnit.Meters;

            VerticalCoordinateSystem vcs = new VerticalCoordinateSystem("test1", datum, axis, unit);

            Assertion.AssertEquals("Test1", datum, vcs.VerticalDatum);
            Assertion.AssertEquals("Test2", 1.0, vcs.VerticalUnit.MetersPerUnit);
            Assertion.AssertEquals("ctor. 3", unit, vcs.VerticalUnit);
            Assertion.AssertEquals("ctor. 4", axis, vcs.GetAxis(0));
        }
        public void Test_TestSqlServer()
        {
            string        connectionString = @"initial catalog=EPSG;data source=localhost;Integrated Security=SSPI;";
            SqlConnection connection       = new SqlConnection(connectionString);

            CoordinateSystemEPSGFactory factory = new CoordinateSystemEPSGFactory(connection);
            ILinearUnit linearUnit = factory.CreateLinearUnit("9001");

            Assertion.AssertEquals("LinearUnit - untis per meter ", 1.0, linearUnit.MetersPerUnit);
            Assertion.AssertEquals("LinearUnit - Authority", "EPSG", linearUnit.Authority);
            Assertion.AssertEquals("LinearUnit - Remarks", "Also known as International metre.", linearUnit.Remarks);
            connection.Close();
        }
Пример #33
0
 /// <summary>
 /// 获取分析图层及Surfer
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void comboBoxOpen_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBoxOpen.Items.Count > 0)
     {
         string LayerName = comboBoxOpen.SelectedItem.ToString();
         m_Layer = GetLayerByName(ref LayerName);
         if (m_Layer is IRasterLayer)//读取Raster数据的ISurface
         {
             IRasterLayer   pRasterLayer   = m_Layer as IRasterLayer;
             IRasterSurface pRasterSurface = new RasterSurfaceClass();
             pRasterSurface.PutRaster(pRasterLayer.Raster, 0);
             m_Surface = pRasterSurface as ISurface;
         }
         else if (m_Layer is ITinLayer)//读取TIN数据的ISurface
         {
             ITinLayer pTinLayer = m_Layer as ITinLayer;
             m_Surface = pTinLayer.Dataset as ISurface;
         }
         if (m_Surface == null)
         {
             MessageBox.Show("请选择需要进行分析的DEM数据", "提示!");
             return;
         }
         pTool3DLineOfSight.m_Layer   = m_Layer;   //将当前选中的图层传给通视分析工具
         pTool3DLineOfSight.m_SurFace = m_Surface; //将当前获取的Surface传给通视分析工具
         //下面是根据获取的Surface来自动判断是否应用曲率和折射校正
         bool bCurvEnabled;
         bCurvEnabled = false;
         ISurface    pSurface = m_Surface;
         IGeoDataset pGeoDataset;
         if (pSurface is ITin)
         {
             pGeoDataset = pSurface as IGeoDataset;
         }
         else
         {
             IRasterSurface pRasterSurf = pSurface as IRasterSurface;
             pGeoDataset = pRasterSurf.RasterBand.RasterDataset as IGeoDataset;
         }
         ISpatialReference pSpatialReference = pGeoDataset.SpatialReference;
         ILinearUnit       pLinearUnit       = pSpatialReference.ZCoordinateUnit;
         if (pLinearUnit != null)
         {
             if (pSpatialReference is IProjectedCoordinateSystem)//当投影ProjectedCoordinateSystem时使用应用曲率和折射校正
             {
                 bCurvEnabled = true;
             }
         }
         checkBoxCurv.Checked = bCurvEnabled;
     }
 }
Пример #34
0
 /// <summary>
 /// Initializes a new instance of an Ellipsoid
 /// </summary>
 /// <param name="semiMajorAxis">Semi major axis</param>
 /// <param name="semiMinorAxis">Semi minor axis</param>
 /// <param name="inverseFlattening">Inverse flattening</param>
 /// <param name="isIvfDefinitive">Inverse Flattening is definitive for this ellipsoid (Semi-minor axis will be overridden)</param>
 /// <param name="axisUnit">Axis unit</param>
 /// <param name="name">Name</param>
 /// <param name="authority">Authority name</param>
 /// <param name="code">Authority-specific identification code.</param>
 /// <param name="alias">Alias</param>
 /// <param name="abbreviation">Abbreviation</param>
 /// <param name="remarks">Provider-supplied remarks</param>
 internal Ellipsoid(double semiMajorAxis, double semiMinorAxis, double inverseFlattening, bool isIvfDefinitive, ILinearUnit axisUnit, string name, string authority, long code, string alias, string abbreviation, string remarks) : base(name, authority, code, alias, abbreviation, remarks)
 {
     this._SemiMajorAxis     = semiMajorAxis;
     this._InverseFlattening = inverseFlattening;
     this._AxisUnit          = axisUnit;
     this._IsIvfDefinitive   = isIvfDefinitive;
     if (isIvfDefinitive)
     {
         this._SemiMinorAxis = (1 - (1 / this._InverseFlattening)) * semiMajorAxis;
     }
     else
     {
         this._SemiMinorAxis = semiMinorAxis;
     }
 }
        private double GetAreas(IEnumerable <IPolygon> polygons,
                                esriGeodeticType geodeticType)
        {
            double area = 0;

            ILinearUnit linearUnit = ((IProjectedCoordinateSystem)_lv95).CoordinateUnit;

            foreach (IPolygon clone in polygons)
            {
                // NOTE uncomment to run on 10.1+
                //area = ((IAreaGeodetic) clone).AreaGeodetic[geodeticType, linearUnit];
            }

            return(area);
        }
        /// <summary>
        /// Creates an ellipsoid given a code.
        /// </summary>
        /// <param name="code">The EPSG code.</param>
        /// <returns>An object that implements the IEllipsoid interface.</returns>
        public IEllipsoid CreateEllipsoid(string code)
        {
            if (code == null)
            {
                throw new ArgumentNullException("code");
            }
            string sqlQuery = "SELECT " +
                              "	ELLIPSOID_CODE, ELLIPSOID_NAME, SEMI_MAJOR_AXIS, UOM_CODE, " +
                              "	SEMI_MINOR_AXIS, INV_FLATTENING, ELLIPSOID_SHAPE, DATA_SOURCE,  " +
                              "	REMARKS " +
                              "FROM Ellipsoid " +
                              "WHERE ELLIPSOID_CODE={0}";

            sqlQuery = String.Format(System.Globalization.CultureInfo.InvariantCulture, sqlQuery, code);
            IDataReader reader      = Database.ExecuteQuery(_databaseConnection, sqlQuery);
            IEllipsoid  ellipsoid   = null;
            bool        recordFound = reader.Read();

            if (!recordFound)
            {
                throw new ArgumentOutOfRangeException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Ellipsoid with a code of '{0}' was not found in the database.", code));
            }

            int    semiMinorAxisIndex     = reader.GetOrdinal("SEMI_MINOR_AXIS");
            int    inverseFlatteningIndex = reader.GetOrdinal("INV_FLATTENING");
            string ellipsoidName          = reader["ELLIPSOID_NAME"].ToString();
            double semiMajorAxis          = (double)reader["SEMI_MAJOR_AXIS"];
            string unitsOfMearureCode     = reader["UOM_CODE"].ToString();
            string datasource             = reader["DATA_SOURCE"].ToString();
            bool   ellipsoidShape         = (bool)reader["ELLIPSOID_SHAPE"];
            string remarks = reader["REMARKS"].ToString();

            if (reader.IsDBNull(semiMinorAxisIndex))
            {
                double inverseFlattening = (double)reader["INV_FLATTENING"];
                Database.CheckOneRow(reader, code, "Ellipsoid");
                ILinearUnit linearUnit = CreateLinearUnit(unitsOfMearureCode);
                ellipsoid = new Ellipsoid(semiMajorAxis, 0.0, inverseFlattening, true, linearUnit, remarks, datasource, code, ellipsoidName, "", "");
            }
            else if (reader.IsDBNull(inverseFlatteningIndex))
            {
                double semiMinorAxis = (double)reader["SEMI_MINOR_AXIS"];
                Database.CheckOneRow(reader, code, "Ellipsoid");
                ILinearUnit linearUnit = CreateLinearUnit(unitsOfMearureCode);
                ellipsoid = new Ellipsoid(semiMajorAxis, semiMinorAxis, 0.0, false, linearUnit, remarks, datasource, code, ellipsoidName, "", "");
            }
            return(ellipsoid);
        }
Пример #37
0
 /// <summary>
 /// Initializes a new instance of an Ellipsoid
 /// </summary>
 /// <param name="semiMajorAxis">Semi major axis</param>
 /// <param name="semiMinorAxis">Semi minor axis</param>
 /// <param name="inverseFlattening">Inverse flattening</param>
 /// <param name="isIvfDefinitive">Inverse Flattening is definitive for this ellipsoid (Semi-minor axis will be overridden)</param>
 /// <param name="axisUnit">Axis unit</param>
 /// <param name="name">Name</param>
 /// <param name="authority">Authority name</param>
 /// <param name="code">Authority-specific identification code.</param>
 /// <param name="alias">Alias</param>
 /// <param name="abbreviation">Abbreviation</param>
 /// <param name="remarks">Provider-supplied remarks</param>
 internal Ellipsoid(double semiMajorAxis, double semiMinorAxis, double inverseFlattening, bool isIvfDefinitive, ILinearUnit axisUnit, string name, string authority, long code, string alias, string abbreviation, string remarks)
     : base(name, authority, code, alias, abbreviation, remarks)
 {
     this._SemiMajorAxis = semiMajorAxis;
     this._InverseFlattening = inverseFlattening;
     this._AxisUnit = axisUnit;
     this._IsIvfDefinitive = isIvfDefinitive;
     if (isIvfDefinitive)
     {
         this._SemiMinorAxis = (1 - (1 / this._InverseFlattening)) * semiMajorAxis;
     }
     else
     {
         this._SemiMinorAxis = semiMinorAxis;
     }
 }
Пример #38
0
        /// <summary>
        /// Initializes a new instance of the Projection class.
        /// </summary>
        /// <param name="verticaldatum">The vertical datum the coordiniate system is to use.</param>
        /// <param name="axisinfo">Axis information.</param>
        /// <param name="linearUnit">The units this coordinate system uses.</param>
        /// <param name="remarks">Remarks about this object.</param>
        /// <param name="authority">The name of the authority.</param>
        /// <param name="authorityCode">The code the authority uses to identidy this object.</param>
        /// <param name="name">The name of the object.</param>
        /// <param name="alias">The alias of the object.</param>
        /// <param name="abbreviation">The abbreviated name of this object.</param>
        public VerticalCoordinateSystem(	string name,
			IVerticalDatum verticaldatum,
			IAxisInfo axisinfo,
			ILinearUnit linearUnit,
			string remarks, string authority, string authorityCode, string alias, string abbreviation)
            : base(remarks, authority,  authorityCode,name, alias, abbreviation)
        {
            if (verticaldatum==null)
            {
                throw new ArgumentNullException("verticaldatum");
            }

            _verticaldatum = verticaldatum;
            _axisinfo = new IAxisInfo[1]{axisinfo};
            _units = linearUnit;
        }
        /// <summary>
        /// Gets native units to meters conversion factor
        /// </summary>
        /// <param name="ipSpatialReference">The spatial reference</param>
        /// <returns>The meters conversion factor</returns>
        private static double GetConversionFactor(ISpatialReference ipSpatialReference)
        {
            double dConversionFactor = 0.0;

            if (ipSpatialReference is IGeographicCoordinateSystem)
            {
                IAngularUnit ipAngularUnit = ((IGeographicCoordinateSystem)ipSpatialReference).CoordinateUnit;
                dConversionFactor = ipAngularUnit.ConversionFactor;
            }
            else
            {
                ILinearUnit ipLinearUnit = ((IProjectedCoordinateSystem)ipSpatialReference).CoordinateUnit;
                dConversionFactor = ipLinearUnit.ConversionFactor;
            }
            return(dConversionFactor);
        }
Пример #40
0
        /// <summary>
        /// Initializes a new instance of the Projection class.
        /// </summary>
        /// <param name="name">The name of the coordinate system.</param>
        /// <param name="verticaldatum">The vertical datum the coordiniate system is to use.</param>
        /// <param name="axisinfo">Axis information.</param>
        /// <param name="units">The units this coordinae system uses.</param>
        internal VerticalCoordinateSystem(string name, IVerticalDatum verticaldatum, IAxisInfo axisinfo, ILinearUnit units)
            : base(name,"","","","","")
        {
            if (verticaldatum==null)
            {
                throw new ArgumentNullException("verticaldatum");
            }
            if (units==null)
            {
                throw new ArgumentNullException("units");
            }

            _name = name;
            _verticaldatum = verticaldatum;
            _axisinfo= new IAxisInfo[1]{axisinfo};
            _units = units;
        }
Пример #41
0
		/// <summary>
		/// Initializes a new instance of an Ellipsoid
		/// </summary>
		/// <param name="semiMajorAxis">Semi major axis</param>
		/// <param name="semiMinorAxis">Semi minor axis</param>
		/// <param name="inverseFlattening">Inverse flattening</param>
		/// <param name="isIvfDefinitive">Inverse Flattening is definitive for this ellipsoid (Semi-minor axis will be overridden)</param>
		/// <param name="axisUnit">Axis unit</param>
		/// <param name="name">Name</param>
		/// <param name="authority">Authority name</param>
		/// <param name="code">Authority-specific identification code.</param>
		/// <param name="alias">Alias</param>
		/// <param name="abbreviation">Abbreviation</param>
		/// <param name="remarks">Provider-supplied remarks</param>
		internal Ellipsoid(
			double semiMajorAxis, 
			double semiMinorAxis, 
			double inverseFlattening,
			bool isIvfDefinitive,
			ILinearUnit axisUnit, string name, string authority, long code, string alias, 
			string abbreviation, string remarks)
			: base(name, authority, code, alias, abbreviation, remarks)
		{
			_SemiMajorAxis = semiMajorAxis;
			_InverseFlattening = inverseFlattening;
			_AxisUnit = axisUnit;
			_IsIvfDefinitive = isIvfDefinitive;
			if (isIvfDefinitive && (inverseFlattening == 0 || double.IsInfinity(inverseFlattening)))
				_SemiMinorAxis = semiMajorAxis;
			else if (isIvfDefinitive)
				_SemiMinorAxis = (1.0 - (1.0 / _InverseFlattening)) * semiMajorAxis;
			else
				_SemiMinorAxis = semiMinorAxis;
		}
Пример #42
0
        /// <summary>
        /// Initializes a new instance of the Projection class. The units are set to meters and the axis is set to represent altitude.
        /// </summary>
        /// <param name="verticaldatum"></param>
        /// <param name="remarks">Remarks about this object.</param>
        /// <param name="authority">The name of the authority.</param>
        /// <param name="authorityCode">The code the authority uses to identidy this object.</param>
        /// <param name="name">The name of the object.</param>
        /// <param name="alias">The alias of the object.</param>
        /// <param name="abbreviation">The abbreviated name of this object.</param>
        internal VerticalCoordinateSystem(
			string name,
			IVerticalDatum verticaldatum,
			string remarks, string authority, string authorityCode, string alias, string abbreviation)
            : base(remarks, authority,  authorityCode,name, alias, abbreviation)
        {
            if (verticaldatum==null)
            {
                throw new ArgumentNullException("verticaldatum");
            }
            _verticaldatum = verticaldatum;
            _units = LinearUnit.Meters;
            _axisinfo= new IAxisInfo[1]{AxisInfo.Altitude};
        }
		private static IMathTransform CreateCoordinateOperation(IProjection projection, IEllipsoid ellipsoid, ILinearUnit unit)
		{
			var parameterList = new List<ProjectionParameter>(projection.NumParameters);
			for (var i = 0; i < projection.NumParameters; i++)
				parameterList.Add(projection.GetParameter(i));

		    //var toMeter = 1d/ellipsoid.AxisUnit.MetersPerUnit;
            if (parameterList.Find((p) => p.Name.ToLowerInvariant().Replace(' ', '_').Equals("semi_major")) == null)
			    parameterList.Add(new ProjectionParameter("semi_major", /*toMeter * */ellipsoid.SemiMajorAxis));
            if (parameterList.Find((p) => p.Name.ToLowerInvariant().Replace(' ', '_').Equals("semi_minor")) == null)
                parameterList.Add(new ProjectionParameter("semi_minor", /*toMeter * */ellipsoid.SemiMinorAxis));
            if (parameterList.Find((p) => p.Name.ToLowerInvariant().Replace(' ', '_').Equals("unit")) == null)
                parameterList.Add(new ProjectionParameter("unit", unit.MetersPerUnit));

            var operation = ProjectionsRegistry.CreateProjection(projection.ClassName, parameterList);
		    /*
            var mpOperation = operation as MapProjection;
            if (mpOperation != null && projection.AuthorityCode !=-1)
            {
                mpOperation.Authority = projection.Authority;
                mpOperation.AuthorityCode = projection.AuthorityCode;
            }
             */

		    return operation;
		    /*
            switch (projection.ClassName.ToLower(CultureInfo.InvariantCulture).Replace(' ', '_'))
			{
				case "mercator":
				case "mercator_1sp":
				case "mercator_2sp":
					//1SP
					transform = new Mercator(parameterList);
					break;
				case "transverse_mercator":
					transform = new TransverseMercator(parameterList);
					break;
				case "albers":
				case "albers_conic_equal_area":
					transform = new AlbersProjection(parameterList);
					break;
				case "krovak":
					transform = new KrovakProjection(parameterList);
					break;
                case "polyconic":
                    transform = new PolyconicProjection(parameterList);
                    break;
                case "lambert_conformal_conic":
				case "lambert_conformal_conic_2sp":
				case "lambert_conic_conformal_(2sp)":
					transform = new LambertConformalConic2SP(parameterList);
					break;
				default:
					throw new NotSupportedException(String.Format("Projection {0} is not supported.", projection.ClassName));
			}
			return transform;
             */
		}
Пример #44
0
        /// <summary>
        /// Initializes a new instance of the Ellipsoid class with the specified parameters.
        /// </summary>
        /// <param name="semiMajorAxis">Double representing semi major axis.</param>
        /// <param name="semiMinorAxis">Double representing semi minor axis.</param>
        /// <param name="inverseFlattening">The inverse flattening.</param>
        /// <param name="isIvfDefinitive">Flag indicating wether the inverse flattening shoul be used to determine the semi-minor axis.</param>
        /// <param name="linearUnit">The linar units to measure the ellipsoid.</param>
        /// <param name="remarks">Remarks about this object.</param>
        /// <param name="authority">The name of the authority.</param>
        /// <param name="authorityCode">The code the authority uses to identidy this object.</param>
        /// <param name="name">The name of the object.</param>
        /// <param name="alias">The alias of the object.</param>
        /// <param name="abbreviation">The abbreviated name of this object.</param>
        internal Ellipsoid(
			double semiMajorAxis,
			double semiMinorAxis,
			double inverseFlattening,
			bool isIvfDefinitive,
			ILinearUnit linearUnit,
			string remarks, string authority, string authorityCode, string name, string alias, string abbreviation)
            : base(remarks, authority, authorityCode, name, alias, abbreviation)
        {
            if (linearUnit==null)
            {
                throw new ArgumentNullException("linearUnit");
            }
            _name= name;
            _linearUnit = linearUnit;
            _semiMajorAxis = semiMajorAxis;
            _inverseFlattening = inverseFlattening;
            _isIvfDefinitive = isIvfDefinitive;
            if (_isIvfDefinitive)
            {
                _semiMinorAxis = (1.0-(1.0/_inverseFlattening))* semiMajorAxis;
            }
            else
            {
                _semiMinorAxis  = semiMinorAxis;
            }
            _semiMajorAxis = semiMajorAxis;
            _inverseFlattening = inverseFlattening;
        }
Пример #45
0
 public IEllipsoid CreateFlattenedSphere(string name, double semiMajorAxis, double inverseFlattening, ILinearUnit linearUnit)
 {
     throw new NotImplementedException();
 }
		private static void WriteLinearUnit(ILinearUnit linearUnit, IndentedTextWriter writer)
		{
			writer.WriteLine("UNIT[");
			writer.Indent=writer.Indent+1;
			writer.WriteLine(String.Format("\"{0}\",{1},", linearUnit.Name, linearUnit.MetersPerUnit));
			writer.WriteLine(String.Format("AUTHORITY[\"{0}\",\"{1}\"]", linearUnit.Authority, linearUnit.AuthorityCode));
			writer.Indent=writer.Indent-1;
			writer.WriteLine("]");
		}
Пример #47
0
 /// <summary>
 /// Creates a <see cref="ProjectedCoordinateSystem"/> using a projection object.
 /// </summary>
 /// <param name="name">Name of projected coordinate system</param>
 /// <param name="gcs">Geographic coordinate system</param>
 /// <param name="projection">Projection</param>
 /// <param name="linearUnit">Linear unit</param>
 /// <param name="axis0">Primary axis</param>
 /// <param name="axis1">Secondary axis</param>
 /// <returns>Projected coordinate system</returns>
 public IProjectedCoordinateSystem CreateProjectedCoordinateSystem(string name, IGeographicCoordinateSystem gcs, IProjection projection, ILinearUnit linearUnit, AxisInfo axis0, AxisInfo axis1)
 {
     if (string.IsNullOrEmpty(name))
         throw new ArgumentException("Invalid name");
     if (gcs == null)
         throw new ArgumentException("Geographic coordinate system was null");
     if (projection == null)
         throw new ArgumentException("Projection was null");
     if (linearUnit == null)
         throw new ArgumentException("Linear unit was null");
     List<AxisInfo> info = new List<AxisInfo>(2);
     info.Add(axis0);
     info.Add(axis1);
     return new ProjectedCoordinateSystem(null, gcs, linearUnit, projection, info, name, String.Empty, -1, String.Empty, String.Empty, String.Empty);
 }
		/// <summary>
		/// Creates a projected coordinate system using a projection object.
		/// </summary>
		/// <param name="name">The name of the projected coordinate system.</param>
		/// <param name="geographicCoordinateSystem">The geographic coordinate system to base this coordinate system on.</param>
		/// <param name="projection">The projection details.</param>
		/// <param name="linearUnit">The linear units to use.</param>
		/// <param name="axis0">The X axis.</param>
		/// <param name="axis1">The Y aixs.</param>
		/// <returns>An object the implements the IProjectedCoordinateSystem interface.</returns>
		public IProjectedCoordinateSystem CreateProjectedCoordinateSystem(string name, IGeographicCoordinateSystem geographicCoordinateSystem, IProjection projection, ILinearUnit linearUnit,  IAxisInfo axis0,  IAxisInfo axis1)
		{
			if (name==null)
			{
				throw new ArgumentNullException("name");
			}
			if (geographicCoordinateSystem==null)
			{
				throw new ArgumentNullException("geographicCoordinateSystem");
			}
			if (projection==null)
			{
				throw new ArgumentNullException("projection");
			}
			if (linearUnit==null)
			{
				throw new ArgumentNullException("linearUnit");
			}
			IAxisInfo[] axisInfo = new IAxisInfo[2];
			axisInfo[0]=axis0;
			axisInfo[1]=axis1;
			ProjectedCoordinateSystem projectedCS = new ProjectedCoordinateSystem(null,axisInfo,geographicCoordinateSystem,linearUnit, projection);
			return projectedCS;
		}
		/// <summary>
		/// Creates an <see cref="Ellipsoid"/> from radius values.
		/// </summary>
		/// <seealso cref="CreateFlattenedSphere"/>
		/// <param name="name">Name of ellipsoid</param>
		/// <param name="semiMajorAxis"></param>
		/// <param name="semiMinorAxis"></param>
		/// <param name="linearUnit"></param>
		/// <returns>Ellipsoid</returns>
		public IEllipsoid CreateEllipsoid(string name, double semiMajorAxis, double semiMinorAxis, ILinearUnit linearUnit)
		{
			return new Ellipsoid(semiMajorAxis, semiMinorAxis, 1.0, false, linearUnit, name, String.Empty, -1, String.Empty, string.Empty, string.Empty);
		}
		/// <summary>
		/// Creates an ellipsoid from an major radius, and inverse flattening.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="semiMajorAxis">Double representing the equatorial radius.</param>
		/// <param name="inverseFlattening">Double representing the inverse of the flattening constant.</param>
		/// <param name="linearUnit">The linear units the radius are specified in.</param>
		/// <returns>An ellipsoid created with the specified parameters.</returns>
		public IEllipsoid CreateFlattenedSphere(string name, double semiMajorAxis, double inverseFlattening, ILinearUnit linearUnit)
		{
			if (name==null)
			{
				throw new ArgumentNullException("name");
			}
			if (linearUnit==null)
			{
				throw new ArgumentNullException("linearUnit");
			}
			return new Ellipsoid(semiMajorAxis, -1.0, inverseFlattening,true,linearUnit,"","","",name,"","");
		}
		/// <summary>
		/// Creates an ellipsoid from radius values.
		/// </summary>
		/// <param name="name">The name of the ellipsoid.</param>
		/// <param name="semiMajorAxis">Double representing the equatorial radius.</param>
		/// <param name="semiMinorAxis">Double representing the polar radius.</param>
		/// <param name="linearUnit">The linear units the radius are specified in.</param>
		/// <returns>An ellipsoid created with the specified parameters.</returns>
		public IEllipsoid CreateEllipsoid(string name, double semiMajorAxis, double semiMinorAxis, ILinearUnit linearUnit)
		{
			if (name==null)
			{
				throw new ArgumentNullException("name");
			}
			if (linearUnit==null)
			{
				throw new ArgumentNullException("linearUnit");
			}
			return new Ellipsoid(semiMajorAxis, semiMinorAxis,1.0,false,linearUnit,"","","",name,"","");
		}
Пример #52
0
 public IEllipsoid CreateEllipsoid(string name, double semiMajorAxis, double semiMinorAxis, ILinearUnit linearUnit)
 {
     throw new NotImplementedException();
 }
Пример #53
0
 private static void WriteLinearUnit(ILinearUnit linearUnit, IndentedTextWriter writer)
 {
     writer.WriteLine("UNIT[");
     writer.Indent=writer.Indent+1;
     writer.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "\"{0}\",{1},", linearUnit.Name, linearUnit.MetersPerUnit));
     writer.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "AUTHORITY[\"{0}\",\"{1}\"]", linearUnit.Authority, linearUnit.AuthorityCode));
     writer.Indent=writer.Indent-1;
     writer.WriteLine("]");
 }
Пример #54
0
        /// <summary>
        /// Creates a <see cref="CreateGeocentricCoordinateSystem"/> from a <see cref="IHorizontalDatum">datum</see>, 
        /// <see cref="ILinearUnit">linear unit</see> and <see cref="IPrimeMeridian"/>.
        /// </summary>
        /// <param name="name">Name of geocentric coordinate system</param>
        /// <param name="datum">Horizontal datum</param>
        /// <param name="linearUnit">Linear unit</param>
        /// <param name="primeMeridian">Prime meridian</param>
        /// <returns>Geocentric Coordinate System</returns>
        public IGeocentricCoordinateSystem CreateGeocentricCoordinateSystem(string name, IHorizontalDatum datum, ILinearUnit linearUnit, IPrimeMeridian primeMeridian)
        {
            if (string.IsNullOrEmpty(name))
                throw new ArgumentException("Invalid name");
            List<AxisInfo> info = new List<AxisInfo>(3);

            info.Add(new AxisInfo("X", AxisOrientationEnum.Other));
            info.Add(new AxisInfo("Y", AxisOrientationEnum.Other));
            info.Add(new AxisInfo("Z", AxisOrientationEnum.Other));
            return new GeocentricCoordinateSystem(datum, linearUnit, primeMeridian, info, name,String.Empty,-1,String.Empty,String.Empty,String.Empty);
        }
		/// <summary>
		/// Creates a vertical coordinate system from a datum and linear units
		/// </summary>
		/// <param name="name">The name of the vertical coordinate system.</param>
		/// <param name="verticalDatum">The vertical datum to use.</param>
		/// <param name="verticalUnit">The units to use.</param>
		/// <param name="axis">The axis to use.</param>
		/// <returns>An an object that implements the IVerticalCoordinateSystem interface.</returns>
		public IVerticalCoordinateSystem CreateVerticalCoordinateSystem(string name, IVerticalDatum verticalDatum, ILinearUnit verticalUnit, IAxisInfo axis)
		{
			if (name==null)
			{
				throw new ArgumentNullException("name");
			}
			if (verticalDatum==null)
			{
				throw new ArgumentNullException("verticalDatum");
			}
			if (verticalUnit==null)
			{
				throw new ArgumentNullException("verticalUnit");
			}
			VerticalCoordinateSystem verticalCS = new VerticalCoordinateSystem(name, verticalDatum, axis, verticalUnit);
			return verticalCS; 
		}
Пример #56
0
 /// <summary>
 /// Creates a <see cref="IVerticalCoordinateSystem"/> from a <see cref="IVerticalDatum">datum</see> and <see cref="LinearUnit">linear units</see>.
 /// </summary>
 /// <param name="name">Name of vertical coordinate system</param>
 /// <param name="datum">Vertical datum</param>
 /// <param name="verticalUnit">Unit</param>
 /// <param name="axis">Axis info</param>
 /// <returns>Vertical coordinate system</returns>
 public IVerticalCoordinateSystem CreateVerticalCoordinateSystem(string name, IVerticalDatum datum, ILinearUnit verticalUnit, AxisInfo axis)
 {
     throw new NotImplementedException();
 }
Пример #57
0
        private static IMathTransform CreateCoordinateOperation(IProjection projection, IEllipsoid ellipsoid, ILinearUnit unit)
        {
            List<ProjectionParameter> parameterList = new List<ProjectionParameter>(projection.NumParameters);
            for (int i = 0; i < projection.NumParameters; i++)
                parameterList.Add(projection.GetParameter(i));

            parameterList.Add(new ProjectionParameter("semi_major", ellipsoid.SemiMajorAxis));
            parameterList.Add(new ProjectionParameter("semi_minor", ellipsoid.SemiMinorAxis));
            parameterList.Add(new ProjectionParameter("unit", unit.MetersPerUnit));
            IMathTransform transform = null;
            switch (projection.ClassName.ToLower(CultureInfo.InvariantCulture).Replace(' ', '_'))
            {
                case "mercator":
                case "mercator_1sp":
                case "mercator_2sp":
                    //1SP
                    transform = new Mercator(parameterList);
                    break;
                case "transverse_mercator":
                    transform = new TransverseMercator(parameterList);
                    break;
                case "albers":
                case "albers_conic_equal_area":
                    transform = new AlbersProjection(parameterList);
                    break;
                case "krovak":
                    transform = new KrovakProjection(parameterList);
                    break;
                case "lambert_conformal_conic":
                case "lambert_conformal_conic_2sp":
                case "lambert_conic_conformal_(2sp)":
                    transform = new LambertConformalConic2SP(parameterList);
                    break;
                default:
                    throw new NotSupportedException(String.Format("Projection {0} is not supported.", projection.ClassName));
            }
            return transform;
        }
 void AnadeParámetroAListaParámetros(List<ProjectionParameter> parámetros, string nombre, double valor, ILinearUnit unidad)
 {
     valor = unidad.MetersPerUnit * valor;
     parámetros.Add(new ProjectionParameter(nombre, valor));
 }
Пример #59
0
 public IProjectedCoordinateSystem CreateProjectedCoordinateSystem(string name, IGeographicCoordinateSystem gcs,
     IProjection projection, ILinearUnit linearUnit, AxisInfo axis0, AxisInfo axis1)
 {
     throw new NotImplementedException();
 }