コード例 #1
0
		/// <summary>
		/// Creates an instance of a Geographic Coordinate System
		/// </summary>
		/// <param name="angularUnit">Angular units</param>
		/// <param name="horizontalDatum">Horizontal datum</param>
		/// <param name="primeMeridian">Prime meridian</param>
		/// <param name="axisInfo">Axis info</param>
		/// <param name="name">Name</param>
		/// <param name="authority">Authority name</param>
		/// <param name="authorityCode">Authority-specific identification code.</param>
		/// <param name="alias">Alias</param>
		/// <param name="abbreviation">Abbreviation</param>
		/// <param name="remarks">Provider-supplied remarks</param>
		internal GeographicCoordinateSystem(IAngularUnit angularUnit, IHorizontalDatum horizontalDatum, IPrimeMeridian primeMeridian, List<AxisInfo> axisInfo, string name, string authority, long authorityCode, string alias, string abbreviation, string remarks)
			:
			base(horizontalDatum, axisInfo, name, authority, authorityCode, alias, abbreviation, remarks)
		{
			_AngularUnit = angularUnit;
			_PrimeMeridian = primeMeridian;
		}
コード例 #2
0
		internal GeographicCoordinateSystem( 
			IAngularUnit angularUnit, 
			IHorizontalDatum horizontalDatum, 
			IPrimeMeridian primeMeridian, 
			IAxisInfo axis0, 
			IAxisInfo axis1,
			string remarks, string authority, string authorityCode, string name, string alias, string abbreviation)
			: base(remarks, authority, authorityCode, name, alias, abbreviation)
		{
			_angularUnit = angularUnit;
			_horizontalDatum = horizontalDatum;
			_primeMeridian = primeMeridian;
			_axisInfo = new IAxisInfo[]{axis0,axis1};

			
			CoordinatePoint minPt = new CoordinatePoint();
			minPt.Ord= new Double[2];
			minPt.Ord.SetValue(-180,0);
			minPt.Ord.SetValue(-90,1);

			CoordinatePoint maxPt = new CoordinatePoint();
			maxPt.Ord= new Double[2];
			maxPt.Ord.SetValue(-180,0);
			maxPt.Ord.SetValue(-90,1);

			// define the envelope.
			_defaultEnvelope = new Positioning.Envelope();
			_defaultEnvelope.MinCP = minPt;
			_defaultEnvelope.MaxCP = maxPt;
		

	
		}
コード例 #3
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;
        }
コード例 #4
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, "", "", "", "", "", "")
        {
        }
コード例 #5
0
        internal GeographicCoordinateSystem(string name,
			IAngularUnit angularUnit, 
			IHorizontalDatum horizontalDatum, 
			IPrimeMeridian primeMeridian, 
			IAxisInfo axis0, 
			IAxisInfo axis1)
            : this(angularUnit,horizontalDatum,primeMeridian, axis0,  axis1,"","","",name,"","")
        {
        }
コード例 #6
0
        /// <summary>
        /// Creates an instance of HorizontalCoordinateSystem
        /// </summary>
        /// <param name="datum">Horizontal datum</param>
        /// <param name="axisInfo">Axis information</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 HorizontalCoordinateSystem(IHorizontalDatum datum, List<AxisInfo> axisInfo, 
			string name, string authority, long code, string alias,
			string remarks, string abbreviation)
            : base(name, authority, code, alias, abbreviation, remarks)
        {
            _HorizontalDatum = datum;
            if (axisInfo.Count != 2)
                throw new ArgumentException("Axis info should contain two axes for horizontal coordinate systems");
            base.AxisInfo = axisInfo;
        }
コード例 #7
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;
 }
コード例 #8
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;
 }
コード例 #9
0
        /// <summary>
        /// Initializes a new instance of the HorizontalCoordinateSystem class with the specified parameters.
        /// </summary>
        /// <param name="horizontalDatum">The horizontal datum to use.</param>
        /// <param name="axisInfoArray">Array of axis information.</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 HorizontalCoordinateSystem(IHorizontalDatum horizontalDatum,IAxisInfo[] axisInfoArray,
			string remarks, string authority, string authorityCode, string name, string alias, string abbreviation)
            : base(remarks, authority, authorityCode, name, alias, abbreviation)
        {
            if (horizontalDatum==null)
            {
                throw new ArgumentNullException("horizontalDatum");
            }
            if (axisInfoArray==null)
            {
                throw new ArgumentNullException("axisInfoArray");
            }
            _horizontalDatum = horizontalDatum;
            _axisInfoArray = axisInfoArray;
        }
コード例 #10
0
        public IHorizontalDatum CreateDatum(int datumType)
        {
            IHorizontalDatum datum = null;

            switch (datumType)
            {
            case (int)RgSRDatumType.RgSRDatum_WGS1984:
                IEllipsoid ellipsoid = this.CreateSpheroid((int)RgSRSpheroidType.RgSRSpheroid_WGS1984);
                datum = new HorizontalDatum(ellipsoid, null, DatumType.HD_Geocentric, "World Geodetic System 1984", "EPSG", 6326, String.Empty, "EPSG's WGS 84 datum has been the then current realisation. No distinction is made between the original WGS 84 frame, WGS 84 (G730), WGS 84 (G873) and WGS 84 (G1150). Since 1997, WGS 84 has been maintained within 10cm of the then current ITRF.", String.Empty);
                break;

            case (int)RgSRDatumType.RgSRDatum_Beijing1954:
                IEllipsoid ellipsoid2 = this.CreateSpheroid((int)RgSRSpheroidType.RgSRSpheroid_Krasovsky1940);
                datum = new HorizontalDatum(ellipsoid2, null, DatumType.HD_Geocentric, "D_Beijing1954", "EPSG", 6214, String.Empty, "", String.Empty);
                break;

            case (int)RgSRDatumType.RgSRDatum_Xian1980:
                IEllipsoid ellipsoid3 = this.CreateSpheroid((int)RgSRSpheroid2Type.RgSRSpheroid_Xian1980);
                datum = new HorizontalDatum(ellipsoid3, null, DatumType.HD_Geocentric, "D_Xian1980", "EPSG", 6610, String.Empty, "", String.Empty);
                break;
            }
            return(datum);
        }
コード例 #11
0
    private void TestMercator_2SP()
    {
        CoordinateSystemFactory cFac = new CoordinateSystemFactory();

        IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Krassowski 1940", 6378245.0, 298.3, LinearUnit.Metre);

        IHorizontalDatum            datum = cFac.CreateHorizontalDatum("Krassowski 1940", DatumType.HD_Geocentric, ellipsoid, null);
        IGeographicCoordinateSystem gcs   = cFac.CreateGeographicCoordinateSystem("Krassowski 1940", AngularUnit.Degrees,
                                                                                  datum,
                                                                                  PrimeMeridian.Greenwich,
                                                                                  new AxisInfo("Lon",
                                                                                               AxisOrientationEnum.East),
                                                                                  new AxisInfo("Lat",
                                                                                               AxisOrientationEnum.North));
        List <ProjectionParameter> parameters = new List <ProjectionParameter>();

        parameters.Add(new ProjectionParameter("latitude_of_origin", 42));
        parameters.Add(new ProjectionParameter("central_meridian", 51));
        parameters.Add(new ProjectionParameter("false_easting", 0));
        parameters.Add(new ProjectionParameter("false_northing", 0));
        IProjection projection = cFac.CreateProjection("Mercator_2SP", "Mercator_2SP", parameters);

        IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem(
            "Pulkovo 1942 / Mercator Caspian Sea", gcs, projection, LinearUnit.Metre,
            new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));

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

        Point pGeo  = new Point(53, 53);
        Point pUtm  = new Point(trans.MathTransform.Transform(pGeo.ToDoubleArray()));
        Point pGeo2 = new Point(trans.MathTransform.Inverse().Transform(pUtm.ToDoubleArray()));

        result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Point(165704.29, 5171848.07), pGeo2,
                                        "Mercator_2SP test");
    }
コード例 #12
0
        /// <summary>
        /// Creates the appropriate object given a string containing XML.
        /// </summary>
        /// <param name="wkt">String containing XML.</param>
        /// <returns>Object representation of the XML.</returns>
        /// <exception cref="ParseException">If a token is not recognised.</exception>
        public static object Create(string wkt)
        {
            object             returnObject = null;
            StringReader       reader       = new StringReader(wkt);
            WktStreamTokenizer tokenizer    = new WktStreamTokenizer(reader);

            tokenizer.NextToken();
            string objectName = tokenizer.GetStringValue();

            switch (objectName)
            {
            case "UNIT":
                IUnit unit = ReadUnit(tokenizer);
                returnObject = unit;
                break;

            case "VERT_DATUM":
                IVerticalDatum verticalDatum = ReadVerticalDatum(tokenizer);
                returnObject = verticalDatum;
                break;

            case "SPHEROID":
                IEllipsoid ellipsoid = ReadEllipsoid(tokenizer);
                returnObject = ellipsoid;
                break;

            case "TOWGS84":
                WGS84ConversionInfo wgsInfo = ReadWGS84ConversionInfo(tokenizer);
                returnObject = wgsInfo;
                break;

            case "DATUM":
                IHorizontalDatum horizontalDatum = ReadHorizontalDatum(tokenizer);
                returnObject = horizontalDatum;
                break;

            case "PRIMEM":
                IPrimeMeridian primeMeridian = ReadPrimeMeridian(tokenizer);
                returnObject = primeMeridian;
                break;

            case "VERT_CS":
                IVerticalCoordinateSystem verticalCS = ReadVerticalCoordinateSystem(tokenizer);
                returnObject = verticalCS;
                break;

            case "GEOGCS":
                IGeographicCoordinateSystem geographicCS = ReadGeographicCoordinateSystem(tokenizer);
                returnObject = geographicCS;
                break;

            case "PROJCS":
                IProjectedCoordinateSystem projectedCS = ReadProjectedCoordinateSystem(tokenizer);
                returnObject = projectedCS;
                break;

            case "COMPD_CS":
                ICompoundCoordinateSystem compoundCS = ReadCompoundCoordinateSystem(tokenizer);
                returnObject = compoundCS;
                break;

            case "GEOCCS":
            case "FITTED_CS":
            case "LOCAL_CS":
                throw new NotSupportedException(String.Format("{0} is not implemented.", objectName));

            default:
                throw new ParseException(String.Format("'{0'} is not recongnized.", objectName));
            }
            reader.Close();
            return(returnObject);
        }
コード例 #13
0
        /// <summary>
        /// Returns a GeographicCoordinateSystem object from a code.
        /// </summary>
        /// <param name="code">The EPSG code.</param>
        /// <returns>An object that implements the IGeographicCoordinateSystem interface.</returns>
        public IGeographicCoordinateSystem CreateGeographicCoordinateSystem(string code)
        {
            if (code == null)
            {
                throw new ArgumentNullException("code");
            }
            string sqlQuery = "SELECT COORD_REF_SYS_NAME, COORD_REF_SYS_CODE, AREA_OF_USE_CODE, " +
                              "	COORD_REF_SYS_KIND, DATUM_CODE, COORD_SYS_CODE, " +
                              "	SOURCE_GEOGCRS_CODE, PROJECTION_CONV_CODE, CMPD_VERTCRS_CODE, CRS_SCOPE, CMPD_HORIZCRS_CODE, REMARKS, DATA_SOURCE " +
                              "FROM  [Coordinate Reference System] " +
                              "WHERE COORD_REF_SYS_CODE = {0}";


            sqlQuery = String.Format(System.Globalization.CultureInfo.InvariantCulture, sqlQuery, code);
            IDataReader reader = Database.ExecuteQuery(_databaseConnection, sqlQuery);

            if (!reader.Read())
            {
                throw new ArgumentException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Geographic Coordinate System with a code {0} not found in the CRS table in the EPSG database.", code));
            }
            ;

            string coordSysCode        = reader["COORD_SYS_CODE"].ToString().ToLower();
            string coordSysName        = reader["COORD_REF_SYS_NAME"].ToString();
            string name                = reader["COORD_REF_SYS_NAME"].ToString();
            string horizontalDatumCode = reader["DATUM_CODE"].ToString();
            string coordRefKind        = reader["COORD_REF_SYS_KIND"].ToString();
            string datasource          = reader["DATA_SOURCE"].ToString();    // should always be EPSG??
            string remarks             = reader["REMARKS"].ToString();

            if (coordRefKind.ToLower() != "geographic 2d")
            {
                throw new ArgumentException(String.Format("CRS code {0} is not a geographic coordinate system but a {1}.", code, coordRefKind));
            }

            Database.CheckOneRow(reader, code, "Geographic CRC code");

            string           primeMeridianCode = "";
            IPrimeMeridian   primeMeridian     = null;
            IHorizontalDatum horizontalDatum   = null;

            if (horizontalDatumCode == "")
            {
                horizontalDatum   = HorizontalDatum.WGS84;              //this.CreateHorizontalDatum( horizontalDatumCode );
                primeMeridianCode = this.CreatePrimeMeridianCodeFromDatum(horizontalDatumCode);
                primeMeridian     = this.CreatePrimeMeridian(primeMeridianCode);
            }
            else
            {
                horizontalDatum   = this.CreateHorizontalDatum(horizontalDatumCode);
                primeMeridianCode = this.CreatePrimeMeridianCodeFromDatum(horizontalDatumCode);
                primeMeridian     = this.CreatePrimeMeridian(primeMeridianCode);
            }

            // we get the information for the axis
            IAxisInfo[]  axisInfos   = GetAxisInfo(coordSysCode);
            IAngularUnit angularUnit = new AngularUnit(1);


            IAxisInfo axisInfo1 = axisInfos[0];
            IAxisInfo axisInfo2 = axisInfos[1];
            IGeographicCoordinateSystem geographicCoordSys = new GeographicCoordinateSystem(angularUnit, horizontalDatum, primeMeridian, axisInfo1, axisInfo2, remarks, datasource, code, name, "", "");

            return(geographicCoordSys);
        }
コード例 #14
0
        /// <summary>
        /// Creates a projected coordinate system using the given code.
        /// </summary>
        /// <param name="code">The EPSG code.</param>
        /// <returns>A IProjectedCoordinateSystem object.</returns>
        public IProjectedCoordinateSystem CreateProjectedCoordinateSystem(string code)
        {
            if (code == null)
            {
                throw new ArgumentNullException("code");
            }
            string sqlQuery = "SELECT COORD_REF_SYS_NAME, COORD_REF_SYS_CODE, AREA_OF_USE_CODE, " +
                              "	COORD_REF_SYS_KIND, DATUM_CODE, COORD_SYS_CODE, " +
                              "	SOURCE_GEOGCRS_CODE, PROJECTION_CONV_CODE, CMPD_VERTCRS_CODE, CRS_SCOPE, CMPD_HORIZCRS_CODE, DATA_SOURCE, REMARKS " +
                              "FROM  [Coordinate Reference System] " +
                              "WHERE COORD_REF_SYS_CODE = {0}";


            sqlQuery = String.Format(System.Globalization.CultureInfo.InvariantCulture, sqlQuery, code);
            IDataReader reader = Database.ExecuteQuery(_databaseConnection, sqlQuery);

            if (!reader.Read())
            {
                throw new ArgumentException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Geographic Coordinate System with a code {0} not found in the CRS table in the EPSG database.", code));
            }


            string coordSysCode        = reader["COORD_SYS_CODE"].ToString().ToLower();
            string coordSysName        = reader["COORD_REF_SYS_NAME"].ToString();
            string name                = reader["COORD_REF_SYS_NAME"].ToString();
            string horizontalDatumCode = reader["DATUM_CODE"].ToString();
            string geographicCRSCode   = reader["SOURCE_GEOGCRS_CODE"].ToString();
            string projectionCode      = reader["PROJECTION_CONV_CODE"].ToString();
            string coordRefKind        = reader["COORD_REF_SYS_KIND"].ToString();
            string remarks             = reader["REMARKS"].ToString();
            string datasource          = reader["DATA_SOURCE"].ToString();    // should always be EPSG??


            Database.CheckOneRow(reader, code, "Geographic CRC code");
            if (coordRefKind.ToLower() != "projected")
            {
                throw new ArgumentException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "CRS code {0} is not a projected coordinate system but a {1}.", code, coordRefKind));
            }

            string           primeMeridianCode = "";
            IPrimeMeridian   primeMeridian     = null;
            IHorizontalDatum horizontalDatum   = null;

            if (horizontalDatumCode != "")
            {
                horizontalDatum   = HorizontalDatum.WGS84;              //this.CreateHorizontalDatum( horizontalDatumCode );
                primeMeridianCode = this.CreatePrimeMeridianCodeFromDatum(horizontalDatumCode);
                primeMeridian     = this.CreatePrimeMeridian(primeMeridianCode);
            }

            // we get the information for the axis
            IAxisInfo[] axisInfos = GetAxisInfo(coordSysCode);

            ICoordinateTransformationAuthorityFactory factory = new CoordinateTransformationEPSGFactory(_databaseConnection);

            ICoordinateTransformation mathtransform = factory.CreateFromCoordinateSystemCodes(geographicCRSCode, "");
            string      methodOperation             = this.GetMethodOperationCodeFromProjectionCode(projectionCode);
            IProjection projection = this.CreateProjection(methodOperation, projectionCode);
            IGeographicCoordinateSystem geographicCoordSystem = this.CreateGeographicCoordinateSystem(geographicCRSCode);
            ILinearUnit linearUnit = LinearUnit.Meters;
            IProjectedCoordinateSystem projectedCoordSys = new ProjectedCoordinateSystem(horizontalDatum, axisInfos, geographicCoordSystem, linearUnit, projection, remarks, datasource, code, coordSysName, "", "");

            return(projectedCoordSys);
        }
コード例 #15
0
 public IGeographicCoordinateSystem CreateGeographicCoordinateSystem(string name, IAngularUnit angularUnit,
     IHorizontalDatum datum, IPrimeMeridian primeMeridian, AxisInfo axis0, AxisInfo axis1)
 {
     throw new NotImplementedException();
 }
コード例 #16
0
 public GeographicCoordinateSystem(string name, string authority, string authorityCode, string alias, string info, IAngularUnit angularUnit, IHorizontalDatum horizontalDatum, IPrimeMeridian primeMeridian, AxisInfo[] ejes, IUnit[] unidades) => throw null;
コード例 #17
0
		/// <summary>
		/// Creates a GCS, which could be Lat/Lon or Lon/Lat.
		/// </summary>
		/// <param name="name">The name of the coordinae system.</param>
		/// <param name="angularUnit">The angular units to use.</param>
		/// <param name="horizontalDatum">Ghe horizontal datum to use.</param>
		/// <param name="primeMeridian">The prime meridian to use.</param>
		/// <param name="axis0">Information about the x axis.</param>
		/// <param name="axis1">Information about the y axis.</param>
		/// <returns>an object that implements the IGeographicCoordinateSystem interface.</returns>
		public IGeographicCoordinateSystem CreateGeographicCoordinateSystem(string name, IAngularUnit angularUnit, IHorizontalDatum horizontalDatum, IPrimeMeridian primeMeridian,  IAxisInfo axis0, IAxisInfo axis1)
		{
			return new GeographicCoordinateSystem(name, angularUnit, horizontalDatum, primeMeridian, axis0, axis1);
		}
コード例 #18
0
        public override FeatureList process(FeatureList input, FilterEnv env)
        {
            FeatureList output = new FeatureList();

            // HACER ALGO DEL ESTILO:

            if (transform == null)
            {
                //Create zone UTM 32N projection
                IProjectedCoordinateSystem utmProj = CreateUtmProjection(32);

                //Create geographic coordinate system (lets just reuse the CS from the projection)
                IGeographicCoordinateSystem geoCS = utmProj.GeographicCoordinateSystem;

                //Create transformation
                CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory();

                // TODO DANI Mirar de donde viene este source y target
                ICoordinateTransformation Coordinatetransform = null;// TODO = ctFac.CreateFromCoordinateSystems(source, target);

                //cs
                string wkt = "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.0174532925199433]]";
                //ICoordinateSystem cs = SharpMap.Converters.WellKnownText.CoordinateSystemWktReader.Parse(wkt) as ICoordinateSystem;
                ICoordinateSystem cs = ProjNet.Converters.WellKnownText.CoordinateSystemWktReader.Parse(wkt) as ICoordinateSystem;
                //wgs84
                GeographicCoordinateSystem wgs84 = GeographicCoordinateSystem.WGS84;

                //gcs
                CoordinateSystemFactory cFac = new ProjNet.CoordinateSystems.CoordinateSystemFactory();
                //CoordinateSystemFactory cFac = new SharpMap.CoordinateSystems.CoordinateSystemFactory();
                //Create Bessel 1840 geographic coordinate system
                IEllipsoid                  ellipsoid = cFac.CreateFlattenedSphere("Bessel 1840", 6377397.155, 299.15281, LinearUnit.Metre);
                IHorizontalDatum            datum     = cFac.CreateHorizontalDatum("Bessel 1840", DatumType.HD_Geocentric, ellipsoid, null);
                IGeographicCoordinateSystem gcs       = cFac.CreateGeographicCoordinateSystem("Bessel 1840", AngularUnit.Degrees, datum,
                                                                                              PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East),
                                                                                              new AxisInfo("Lat", AxisOrientationEnum.North));

                //coordsys
                //Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5);
                List <ProjectionParameter> parameters = new List <ProjectionParameter>();
                parameters.Add(new ProjectionParameter("latitude_of_origin", 0));
                parameters.Add(new ProjectionParameter("central_meridian", 110));
                parameters.Add(new ProjectionParameter("scale_factor", 0.997));
                parameters.Add(new ProjectionParameter("false_easting", 3900000));
                parameters.Add(new ProjectionParameter("false_northing", 900000));
                IProjection projection = cFac.CreateProjection("Mercator_1SP", "Mercator_1SP", parameters);
                IProjectedCoordinateSystem coordsys =
                    cFac.CreateProjectedCoordinateSystem("Makassar / NEIEZ", gcs, projection, LinearUnit.Metre,
                                                         new AxisInfo("East", AxisOrientationEnum.East),
                                                         new AxisInfo("North", AxisOrientationEnum.North));

                Coordinatetransform = ctFac.CreateFromCoordinateSystems(gcs, coordsys);//gcsWGS84 -> gcenCsWGS84

                //Apply transformation
                transform = Coordinatetransform.MathTransform;
            }

            SharpMap.Geometries.Point p = new SharpMap.Geometries.Point(30.0, 20.0);

            p = GeometryTransform.TransformPoint(p, transform);

/*IMPORTANTE
*           foreach (Feature feature in input)
*           {
*               feature.row.Geometry = GeometryTransform.TransformGeometry(feature.row.Geometry, transform);
*               //feature.row.Geometry = GeometryTransform.TransformMultiPolygon(feature.row.Geometry, transform);
*           }
*  IMPORTANTE*/
            foreach (Feature f in input)
            {
                output.Add(f);//output = input
            }

            // Cosas a cambiar:
            // Primero, la construccion del transform está siguiendo el ejemplo, pero hay que tener en cuenta los datos del xml y construirlo en consecuencia
            // Segundo, el filtro debe retornar una NUEVA lista, y no modificar la inicial. Ahora modifica los valores de la lista inicial
            // IMPORTANTE RETORNAR NUEVA LISTA OUTPUT <----------- FALTA POR HACER
#if TODO
            // first time through, establish a working SRS for output data.
            if (working_srs == null)
            {
                // first try to use the terrain SRS if so directed:
                SpatialReference new_out_srs = getUseTerrainSRS() ? env.getTerrainSRS() : null;
                if (new_out_srs == null)
                {
                    // failing that, see if we have an SRS in a resource:
                    if (getSRS() == null && getSRSScript() != null)
                    {
                        ScriptResult r = env.getScriptEngine().run(getSRSScript(), env);
                        if (r.isValid())
                        {
                            setSRS(env.getSession().getResources().getSRS(r.ToString()));
                        }
                        else
                        {
                            env.getReport().error(r.ToString());
                        }
                    }

                    new_out_srs = srs;
                }

                // set the "working" SRS that will be used for all features passing though this filter:
                working_srs = new_out_srs != null ? new_out_srs : env.getInputSRS();

                // LOCALIZE points around a local origin (the working extent's centroid)
                if (working_srs != null && getLocalize()) //&& env.getExtent().getArea() > 0.0 )
                {
                    if (env.getCellExtent().getSRS().isGeographic() && env.getCellExtent().getWidth() > 179.0)
                    {
                        //NOP - no localization for big geog extent ... needs more thought perhaps
                    }
                    else
                    {
                        GeoPoint centroid0 = new_out_srs != null?
                                             new_out_srs.transform(env.getCellExtent().getCentroid()) :
                                                 env.getCellExtent().getCentroid();

                        // we do want the localizer point on the surface if possible:
                        GeoPoint centroid = clampToTerrain(centroid0, env);
                        if (centroid == null)
                        {
                            centroid = centroid0;
                        }

                        Matrixd localizer;

                        // For geocentric datasets, we need a special localizer matrix:
                        if (working_srs.isGeocentric())
                        {
                            localizer = working_srs.getEllipsoid().createGeocentricInvRefFrame(centroid);
                            localizer.invert(localizer);
                        }

                        // For projected datasets, just a simple translation:
                        else
                        {
                            localizer = osg.Matrixd.translate(-centroid);
                        }

                        working_srs = working_srs.cloneWithNewReferenceFrame(localizer);
                    }
                }
            }

            // we have to assign the output SRS on each pass
            if (working_srs != null)
            {
                env.setOutputSRS(working_srs);
            }

            return(base.process(input, env));
#endif
            //throw new NotImplementedException();

            if (successor != null)
            {
                if (successor is FeatureFilter)
                {
                    FeatureFilter filter = (FeatureFilter)successor;
                    FeatureList   l      = filter.process(output, env);
                }
                else if (successor is FragmentFilter)
                {
                    FragmentFilter filter = (FragmentFilter)successor;
                    FragmentList   l      = filter.process(output, env);
                }
            }

            return(output);
        }
コード例 #19
0
        private static void WriteHorizontalDatum(IHorizontalDatum horizontalDatum, IndentedTextWriter writer)
        {
            writer.WriteLine("DATUM[");
            writer.Indent=writer.Indent+1;
            writer.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "\"{0}\",", horizontalDatum.Name));

            WriteEllipsoid(horizontalDatum.Ellipsoid, writer);
            WriteWGS84ConversionInfo(horizontalDatum.WGS84Parameters, writer);
            writer.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "AUTHORITY[\"{0}\",\"{1}\"]", horizontalDatum.Authority, horizontalDatum.AuthorityCode));
            writer.Indent=writer.Indent-1;
            writer.WriteLine("]");
        }
コード例 #20
0
        private void btnCalculate_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            string str = txtLon.Text.Trim();

            if (str == string.Empty)
            {
                errorProvider1.SetError(txtLon, "请输入经度!");
            }
            double lon = 0;

            try
            {
                lon = Convert.ToDouble(str);
            }
            catch
            {
                errorProvider1.SetError(txtLon, "请输入度为单位的经度!");
            }
            string str2 = txtLat.Text.Trim();

            if (str2 == string.Empty)
            {
                errorProvider1.SetError(txtLat, "请输入纬度!");
            }
            double lat = 0;

            try
            {
                lat = Convert.ToDouble(str2);
            }
            catch
            {
                errorProvider1.SetError(txtLat, "请输入度为单位的纬度!");
            }

            string str3 = txtCentre.Text.Trim();

            if (str3 == string.Empty)
            {
                errorProvider1.SetError(txtLat, "请输入中央经线!");
            }
            double longitude0 = 0;

            try
            {
                longitude0 = Convert.ToDouble(str3);
            }
            catch
            {
                errorProvider1.SetError(txtCentre, "请输入度为单位的中央经线!");
            }
            List <ProjectionParameter> pInfo = new List <ProjectionParameter>();

            pInfo.Add(new ProjectionParameter("latitude_of_origin", 0));
            pInfo.Add(new ProjectionParameter("central_meridian", longitude0));
            pInfo.Add(new ProjectionParameter("scale_factor", 1));
            pInfo.Add(new ProjectionParameter("false_easting", 500000));
            pInfo.Add(new ProjectionParameter("false_northing", 0));

            Projection proj = new Projection("Gauss_Kruger", pInfo, "", "EPSG", 0, String.Empty, String.Empty, String.Empty);

            System.Collections.Generic.List <AxisInfo> axes = new List <AxisInfo>();
            axes.Add(new AxisInfo("East", AxisOrientationEnum.East));
            axes.Add(new AxisInfo("North", AxisOrientationEnum.North));
            ISpatialReferenceFactory        srf    = new SpatialReferenceEnvironmentClass();
            IHorizontalDatum                dataum = srf.CreateDatum((int)RgSRDatumType.RgSRDatum_Beijing1954);
            ICoordinateSystem               gauss  = new ProjectedCoordinateSystem(dataum, coord, ProjNet.CoordinateSystems.LinearUnit.Metre, proj, axes, "CustomGauss", "EPSG", 0, String.Empty, "", string.Empty);
            CoordinateTransformationFactory ctfac  = new CoordinateTransformationFactory();
            ICoordinateTransformation       trans  = ctfac.CreateFromCoordinateSystems(coord, gauss);

            double[] pGauss = trans.MathTransform.Transform(new double[] { lon, lat });
            txtX.Text = string.Format("{0}", pGauss[0]);
            txtY.Text = string.Format("{0}", pGauss[1]);
        }
コード例 #21
0
 /// <summary>
 ///  Initializes a new instance of the HorizontalCoordinateSystem class with the specified parameters.
 /// </summary>
 /// <param name="horizontalDatum">The horizontal datum to use.</param>
 /// <param name="axisInfoArray">Array of axis information.</param>
 public HorizontalCoordinateSystem(IHorizontalDatum horizontalDatum, IAxisInfo[] axisInfoArray)
     : this(horizontalDatum, axisInfoArray, "", "", "", "", "", "")
 {
 }
コード例 #22
0
ファイル: CoordinateSystemFactory.cs プロジェクト: maxm/osmuy
 /// <summary>
 /// Creates a <see cref="GeographicCoordinateSystem"/>, which could be Lat/Lon or Lon/Lat.
 /// </summary>
 /// <param name="name">Name of geographical coordinate system</param>
 /// <param name="angularUnit">Angular units</param>
 /// <param name="datum">Horizontal datum</param>
 /// <param name="primeMeridian">Prime meridian</param>
 /// <param name="axis0">First axis</param>
 /// <param name="axis1">Second axis</param>
 /// <returns>Geographic coordinate system</returns>
 public IGeographicCoordinateSystem CreateGeographicCoordinateSystem(string name, IAngularUnit angularUnit, IHorizontalDatum datum, IPrimeMeridian primeMeridian, AxisInfo axis0, AxisInfo axis1)
 {
     if (string.IsNullOrEmpty(name))
         throw new ArgumentException("Invalid name");
     List<AxisInfo> info = new List<AxisInfo>(2);
     info.Add(axis0);
     info.Add(axis1);
     return new GeographicCoordinateSystem(angularUnit, datum, primeMeridian,info, name, String.Empty, -1, String.Empty, String.Empty, String.Empty);
 }
コード例 #23
0
 /// <summary>
 ///  Initializes a new instance of the HorizontalCoordinateSystem class with the specified parameters.
 /// </summary>
 /// <param name="horizontalDatum">The horizontal datum to use.</param>
 /// <param name="axisInfoArray">Array of axis information.</param>
 public HorizontalCoordinateSystem(IHorizontalDatum horizontalDatum,IAxisInfo[] axisInfoArray)
     : this(horizontalDatum,axisInfoArray, "","","","","","")
 {
 }
コード例 #24
0
 // Methods
 public GeocentricCoordinateSystem(string name, string authority, string authorityCode, string alias, string info, ILinearUnit linearUnit, IHorizontalDatum horizontalDatum, IPrimeMeridian primeMeridian, AxisInfo axis1, AxisInfo axis2, AxisInfo axis3) => throw null;
コード例 #25
0
        /// <summary>
        /// Creates a <see cref="GeographicCoordinateSystem"/>, which could be Lat/Lon or Lon/Lat.
        /// </summary>
        /// <param name="name">Name of geographical coordinate system</param>
        /// <param name="angularUnit">Angular units</param>
        /// <param name="datum">Horizontal datum</param>
        /// <param name="primeMeridian">Prime meridian</param>
        /// <param name="axis0">First axis</param>
        /// <param name="axis1">Second axis</param>
        /// <returns>Geographic coordinate system</returns>
        public IGeographicCoordinateSystem CreateGeographicCoordinateSystem(string name, IAngularUnit angularUnit, IHorizontalDatum datum, IPrimeMeridian primeMeridian, AxisInfo axis0, AxisInfo axis1)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Invalid name");
            }

            List <AxisInfo> info = new List <AxisInfo>(2);

            info.Add(axis0);
            info.Add(axis1);
            return(new GeographicCoordinateSystem(angularUnit, datum, primeMeridian, info, name, String.Empty, -1, String.Empty, String.Empty, String.Empty));
        }
コード例 #26
0
        public void TestDatumTransform()
        {
            ICoordinateSystemFactory cFac = new ICoordinateSystemFactory();

            //Define datums
            IHorizontalDatum wgs72 = HorizontalDatum.WGS72;
            IHorizontalDatum ed50  = HorizontalDatum.ED50;

            //Define geographic coordinate systems
            IGeographicCoordinateSystem gcsWGS72 =
                cFac.CreateGeographicCoordinateSystem("WGS72 Geographic", AngularUnit.Degrees, wgs72,
                                                      PrimeMeridian.Greenwich,
                                                      new AxisInfo("East", AxisOrientation.East),
                                                      new AxisInfo("North", AxisOrientation.North));

            IGeographicCoordinateSystem gcsWGS84 =
                cFac.CreateGeographicCoordinateSystem("WGS84 Geographic", AngularUnit.Degrees, HorizontalDatum.WGS84,
                                                      PrimeMeridian.Greenwich,
                                                      new AxisInfo("East", AxisOrientation.East),
                                                      new AxisInfo("North", AxisOrientation.North));

            IGeographicCoordinateSystem gcsED50 =
                cFac.CreateGeographicCoordinateSystem("ED50 Geographic", AngularUnit.Degrees, ed50,
                                                      PrimeMeridian.Greenwich,
                                                      new AxisInfo("East", AxisOrientation.East),
                                                      new AxisInfo("North", AxisOrientation.North));

            //Define geocentric coordinate systems
            IGeocentricCoordinateSystem gcenCsWGS72 =
                cFac.CreateGeocentricCoordinateSystem("WGS72 Geocentric", wgs72, LinearUnit.Metre,
                                                      PrimeMeridian.Greenwich);
            IGeocentricCoordinateSystem gcenCsWGS84 =
                cFac.CreateGeocentricCoordinateSystem("WGS84 Geocentric", HorizontalDatum.WGS84, LinearUnit.Metre,
                                                      PrimeMeridian.Greenwich);
            IGeocentricCoordinateSystem gcenCsED50 =
                cFac.CreateGeocentricCoordinateSystem("ED50 Geocentric", ed50, LinearUnit.Metre, PrimeMeridian.Greenwich);

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

            parameters.Add(new ProjectionParameter("latitude_of_origin", 0));
            parameters.Add(new ProjectionParameter("central_meridian", 9));
            parameters.Add(new ProjectionParameter("scale_factor", 0.9996));
            parameters.Add(new ProjectionParameter("false_easting", 500000));
            parameters.Add(new ProjectionParameter("false_northing", 0));
            IProjection projection             = cFac.CreateProjection("Transverse Mercator", "Transverse_Mercator", parameters);
            IProjectedCoordinateSystem utmED50 =
                cFac.CreateProjectedCoordinateSystem("ED50 UTM Zone 32N", gcsED50, projection, LinearUnit.Metre,
                                                     new AxisInfo("East", AxisOrientation.East),
                                                     new AxisInfo("North", AxisOrientation.North));
            IProjectedCoordinateSystem utmWGS84 =
                cFac.CreateProjectedCoordinateSystem("WGS84 UTM Zone 32N", gcsWGS84, projection, LinearUnit.Metre,
                                                     new AxisInfo("East", AxisOrientation.East),
                                                     new AxisInfo("North", AxisOrientation.North));

            //Set TOWGS84 parameters
            wgs72.Wgs84Parameters = new Wgs84ConversionInfo(0, 0, 4.5, 0, 0, 0.554, 0.219);
            ed50.Wgs84Parameters  = new Wgs84ConversionInfo(-81.0703, -89.3603, -115.7526,
                                                            -0.48488, -0.02436, -0.41321,
                                                            -0.540645); //Parameters for Denmark

            //Set up coordinate transformations
            ICoordinateTransformationFactory ctFac  = new CoordinateTransformationFactory();
            ICoordinateTransformation        ctForw = ctFac.CreateFromCoordinateSystems(gcsWGS72, gcenCsWGS72);
            //Geographic->Geocentric (WGS72)
            ICoordinateTransformation ctWGS84_Gcen2Geo = ctFac.CreateFromCoordinateSystems(gcenCsWGS84, gcsWGS84);
            //Geocentric->Geographic (WGS84)
            ICoordinateTransformation ctWGS84_Geo2UTM = ctFac.CreateFromCoordinateSystems(gcsWGS84, utmWGS84);
            //UTM ->Geographic (WGS84)
            ICoordinateTransformation ctED50_UTM2Geo = ctFac.CreateFromCoordinateSystems(utmED50, gcsED50);
            //UTM ->Geographic (ED50)
            ICoordinateTransformation ctED50_Geo2Gcen = ctFac.CreateFromCoordinateSystems(gcsED50, gcenCsED50);
            //Geographic->Geocentric (ED50)

            //Test datum-shift from WGS72 to WGS84
            //Point3D pGeoCenWGS72 = ctForw.MathTransform.Transform(pLongLatWGS72) as Point3D;
            IPoint3D pGeoCenWGS72 = new IPoint3D(3657660.66, 255768.55, 5201382.11);
            ICoordinateTransformation geocen_ed50_2_Wgs84 = ctFac.CreateFromCoordinateSystems(gcenCsWGS72, gcenCsWGS84);
            IPoint3D pGeoCenWGS84 = geocen_ed50_2_Wgs84.MathTransform.Transform(pGeoCenWGS72) as IPoint3D;

            //Point3D pGeoCenWGS84 = wgs72.Wgs84Parameters.Apply(pGeoCenWGS72);

            Assert.IsTrue(toleranceLessThan(new IPoint3D(3657660.78, 255778.43, 5201387.75), pGeoCenWGS84, 0.01));

            ICoordinateTransformation utm_ed50_2_Wgs84 = ctFac.CreateFromCoordinateSystems(utmED50, utmWGS84);
            IPoint pUTMED50  = new IPoint(600000, 6100000);
            IPoint pUTMWGS84 = utm_ed50_2_Wgs84.MathTransform.Transform(pUTMED50);

            Assert.IsTrue(toleranceLessThan(new IPoint(599928.6, 6099790.2), pUTMWGS84, 0.1));
            //Perform reverse
            ICoordinateTransformation utm_Wgs84_2_Ed50 = ctFac.CreateFromCoordinateSystems(utmWGS84, utmED50);

            pUTMED50 = utm_Wgs84_2_Ed50.MathTransform.Transform(pUTMWGS84);
            Assert.IsTrue(toleranceLessThan(new IPoint(600000, 6100000), pUTMED50, 0.1));
            //Assert.IsTrue(Math.Abs((pUTMWGS84 as Point3D).Z - 36.35) < 0.5);
            //Point pExpected = Point.FromDMS(2, 7, 46.38, 53, 48, 33.82);
            //ED50_to_WGS84_Denmark: datum.Wgs84Parameters = new Wgs84ConversionInfo(-89.5, -93.8, 127.6, 0, 0, 4.5, 1.2);
        }
コード例 #27
0
ファイル: CoordinateSystemFactory.cs プロジェクト: maxm/osmuy
        /// <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);
        }
コード例 #28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tokenizer"></param>
        /// <returns></returns>
        private static IGeographicCoordinateSystem ReadGeographicCoordinateSystem(WktStreamTokenizer tokenizer)
        {
            /*
             * GEOGCS["OSGB 1936",
             * DATUM["OSGB 1936",SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6277"]]
             * PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]]
             * AXIS["Geodetic latitude","NORTH"]
             * AXIS["Geodetic longitude","EAST"]
             * AUTHORITY["EPSG","4277"]
             * ]
             */
            tokenizer.ReadToken("[");
            string name = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("DATUM");
            IHorizontalDatum horizontalDatum = ReadHorizontalDatum(tokenizer);

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("PRIMEM");
            IPrimeMeridian primeMeridian = ReadPrimeMeridian(tokenizer);

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("UNIT");
            IAngularUnit angularUnit = ReadAngularUnit(tokenizer);

            string authority     = String.Empty;
            long   authorityCode = -1;

            tokenizer.NextToken();
            List <AxisInfo> info = new List <AxisInfo>(2);

            if (tokenizer.GetStringValue() == ",")
            {
                tokenizer.NextToken();
                while (tokenizer.GetStringValue() == "AXIS")
                {
                    info.Add(ReadAxis(tokenizer));
                    tokenizer.NextToken();
                    if (tokenizer.GetStringValue() == ",")
                    {
                        tokenizer.NextToken();
                    }
                }
                if (tokenizer.GetStringValue() == ",")
                {
                    tokenizer.NextToken();
                }
                if (tokenizer.GetStringValue() == "AUTHORITY")
                {
                    tokenizer.ReadAuthority(ref authority, ref authorityCode);
                    tokenizer.ReadToken("]");
                }
            }
            //This is default axis values if not specified.
            if (info.Count == 0)
            {
                info.Add(new AxisInfo("Lon", AxisOrientationEnum.East));
                info.Add(new AxisInfo("Lat", AxisOrientationEnum.North));
            }
            IGeographicCoordinateSystem geographicCS = new GeographicCoordinateSystem(angularUnit, horizontalDatum,
                                                                                      primeMeridian, info, name, authority, authorityCode, String.Empty, String.Empty, String.Empty);

            return(geographicCS);
        }
コード例 #29
0
 public IGeographicCoordinateSystem CreateGeographicCoordinateSystem(string name, IAngularUnit angularUnit,
                                                                     IHorizontalDatum datum, IPrimeMeridian primeMeridian, AxisInfo axis0, AxisInfo axis1)
 {
     throw new NotImplementedException();
 }
コード例 #30
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)
 {
     this._GeographicCoordinateSystem = geographicCoordinateSystem;
     this._LinearUnit = linearUnit;
     this._Projection = projection;
 }
コード例 #31
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));
        }
コード例 #32
0
        public static object Create(XmlTextReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            // we don't want to handle whitespace
            reader.WhitespaceHandling = WhitespaceHandling.None;
            object returnObject = null;

            reader.Read();


            // skip declarions and comments.
            while (reader.NodeType != XmlNodeType.Element)
            {
                reader.Read();
            }

            if (reader.NodeType == XmlNodeType.Element)
            {
                switch (reader.Name)
                {
                case "CS_LinearUnit":
                    ILinearUnit linearUnit = ReadLinearUnit(reader);
                    returnObject = linearUnit;
                    break;

                case "CS_AngularUnit":
                    IAngularUnit angularUnit = ReadAngularUnit(reader);
                    returnObject = angularUnit;
                    break;

                case "CS_VerticalDatum":
                    IVerticalDatum verticalDatum = ReadVerticalDatum(reader);
                    returnObject = verticalDatum;
                    break;

                case "CS_Ellipsoid":
                    IEllipsoid ellipsoid = ReadEllipsoid(reader);
                    returnObject = ellipsoid;
                    break;

                case "CS_WGS84ConversionInfo":
                    WGS84ConversionInfo wgsInfo = ReadWGS84ConversionInfo(reader);
                    returnObject = wgsInfo;
                    break;

                case "CS_HorizontalDatum":
                    IHorizontalDatum horizontalDatum = ReadHorizontalDatum(reader);
                    returnObject = horizontalDatum;
                    break;

                case "CS_PrimeMeridian":
                    IPrimeMeridian primeMeridian = ReadPrimeMeridian(reader);
                    returnObject = primeMeridian;
                    break;

                case "CS_VerticalCoordinateSystem":
                    IVerticalCoordinateSystem verticalCS = ReadVerticalCoordinateSystem(reader);
                    returnObject = verticalCS;
                    break;

                case "CS_GeographicCoordinateSystem":
                    IGeographicCoordinateSystem geographicCS = ReadGeographicCoordinateSystem(reader);
                    returnObject = geographicCS;
                    break;

                case "CS_ProjectedCoordinateSystem":
                    IProjectedCoordinateSystem projectedCS = ReadProjectedCoordinateSystem(reader);
                    returnObject = projectedCS;
                    break;

                case "CS_CompoundCoordinateSystem":
                    ICompoundCoordinateSystem compoundCS = ReadCompoundCoordinateSystem(reader);
                    returnObject = compoundCS;
                    break;

                case "CS_Projection":
                    IProjection projection = ReadProjection(reader);
                    returnObject = projection;
                    break;

                case "CS_CoordinateSystem":
                    // must be a compound coord sys since all other coord system should have been
                    // taken care of by now.
                    reader.Read();
                    ICoordinateSystem coordinateSystem = ReadCompoundCoordinateSystem(reader);
                    reader.Read();
                    returnObject = coordinateSystem;
                    break;

                case "CS_GEOCCS":
                case "CS_FITTED_CS":
                case "CS_LOCAL_CS":
                    throw new NotSupportedException(String.Format("{0} is not implemented.", reader.Name));

                default:
                    throw new ParseException(String.Format("Element type {0} was is not understoon.", reader.Name));
                }
            }

            return(returnObject);
        }
コード例 #33
0
 /// <summary>
 /// Creates a GCS, which could be Lat/Lon or Lon/Lat.
 /// </summary>
 /// <param name="name">The name of the coordinae system.</param>
 /// <param name="angularUnit">The angular units to use.</param>
 /// <param name="horizontalDatum">Ghe horizontal datum to use.</param>
 /// <param name="primeMeridian">The prime meridian to use.</param>
 /// <param name="axis0">Information about the x axis.</param>
 /// <param name="axis1">Information about the y axis.</param>
 /// <returns>an object that implements the IGeographicCoordinateSystem interface.</returns>
 public IGeographicCoordinateSystem CreateGeographicCoordinateSystem(string name, IAngularUnit angularUnit, IHorizontalDatum horizontalDatum, IPrimeMeridian primeMeridian, IAxisInfo axis0, IAxisInfo axis1)
 {
     return(new GeographicCoordinateSystem(name, angularUnit, horizontalDatum, primeMeridian, axis0, axis1));
 }
コード例 #34
0
 /// <summary>
 /// Creates an instance of a Geographic Coordinate System
 /// </summary>
 /// <param name="angularUnit">Angular units</param>
 /// <param name="horizontalDatum">Horizontal datum</param>
 /// <param name="primeMeridian">Prime meridian</param>
 /// <param name="axisInfo">Axis info</param>
 /// <param name="name">Name</param>
 /// <param name="authority">Authority name</param>
 /// <param name="authorityCode">Authority-specific identification code.</param>
 /// <param name="alias">Alias</param>
 /// <param name="abbreviation">Abbreviation</param>
 /// <param name="remarks">Provider-supplied remarks</param>
 internal GeographicCoordinateSystem(IAngularUnit angularUnit, IHorizontalDatum horizontalDatum, IPrimeMeridian primeMeridian, List <AxisInfo> axisInfo, string name, string authority, long authorityCode, string alias, string abbreviation, string remarks) : base(horizontalDatum, axisInfo, name, authority, authorityCode, alias, abbreviation, remarks)
 {
     this._AngularUnit   = angularUnit;
     this._PrimeMeridian = primeMeridian;
 }