Пример #1
0
        public static string ToDisplayString(ISpatialReference spatialRef)
        {
            if (spatialRef == null)
            {
                return("");
            }

            if (spatialRef is IUnknownCoordinateSystem)
            {
                return("未知坐标系");
            }

            string strDisplay = "";
            IGeographicCoordinateSystem geoCoord = spatialRef as IGeographicCoordinateSystem;
            IProjectedCoordinateSystem  prjCood  = spatialRef as IProjectedCoordinateSystem;

            if (prjCood != null)
            {
                geoCoord = prjCood.GeographicCoordinateSystem;

                strDisplay += string.Format("投影:     {0}\r\n", prjCood.Projection.Name);
                strDisplay += string.Format("东移假定值(X0):{0}\r\n", prjCood.FalseEasting);
                strDisplay += string.Format("北移假定值(Y0):{0}\r\n", prjCood.FalseNorthing);
                strDisplay += string.Format("中心轴:    {0}\r\n", prjCood.get_CentralMeridian(true));
                strDisplay += string.Format("比例系数:   {0}\r\n", prjCood.ScaleFactor);
                //strDisplay += string.Format("源点经度:   {0}\r\n", prjCood.LongitudeOfOrigin);
                strDisplay += string.Format("线性单位:   {0}\r\n", prjCood.CoordinateUnit.Name);
                strDisplay += "\r\n";
            }

            if (geoCoord != null)
            {
                strDisplay += string.Format("地理坐标系:  {0}\r\n", geoCoord.Name);
                strDisplay += string.Format("角单位:    {0}({1})\r\n", geoCoord.CoordinateUnit.Name, geoCoord.CoordinateUnit.RadiansPerUnit);
                strDisplay += string.Format("本初子午线:  {0}({1})\r\n", geoCoord.PrimeMeridian.Name, geoCoord.PrimeMeridian.Longitude);
                strDisplay += string.Format("基准面:    {0}\r\n", geoCoord.Datum.Name);
                strDisplay += string.Format("  椭球:   {0}\r\n", geoCoord.Datum.Spheroid.Name);
                strDisplay += string.Format("    长半轴:{0}\r\n", geoCoord.Datum.Spheroid.SemiMajorAxis);
                strDisplay += string.Format("    短半轴:{0}\r\n", geoCoord.Datum.Spheroid.SemiMinorAxis);
            }

            return(strDisplay);
        }
Пример #2
0
 public void Init(ISpatialReference spatialRef)
 {
     this.lblCoordSysName.Text = spatialRef.Name;
     if (spatialRef is IProjectedCoordinateSystem)
     {
         IProjectedCoordinateSystem projectedCoordinateSystem = spatialRef as IProjectedCoordinateSystem;
         this.lblProjection.Text = projectedCoordinateSystem.Projection.Name;
         this.lblCentral.Text    = projectedCoordinateSystem.get_CentralMeridian(true).ToString();
         this.lblEast.Text       = projectedCoordinateSystem.FalseEasting.ToString();
         this.lblNorth.Text      = projectedCoordinateSystem.FalseNorthing.ToString();
         try
         {
             this.lblFactor.Text = projectedCoordinateSystem.ScaleFactor.ToString();
         }
         catch (Exception var_1_B2)
         {
             this.lblFactor.Text = "1";
         }
         this.ctrlGeographicCoordinateInfo1.Init(projectedCoordinateSystem.GeographicCoordinateSystem);
     }
 }
Пример #3
0
 public static string FormatSpatialReference(ISpatialReference sr)
 {
     try
     {
         if (sr == null)
         {
             return("");
         }
         StringBuilder builder = new StringBuilder();
         if (sr is UnknownCoordinateSystemClass)
         {
             builder.Append("UnknownCoordinateSystem");
         }
         else
         {
             if (sr.Name == "Unknown")
             {
                 builder.Append("UnknownCoordinateSystem");
             }
             else
             {
                 IGeographicCoordinateSystem system2;
                 if (sr is IProjectedCoordinateSystem)
                 {
                     Exception exception;
                     IProjectedCoordinateSystem system = sr as IProjectedCoordinateSystem;
                     builder.Append("投影坐标系:\n");
                     builder.Append("  Name:").Append(system.Name).Append("\n");
                     builder.Append("  Alias:").Append(system.Alias).Append("\n");
                     builder.Append("  Abbreviation:").Append(system.Abbreviation).Append("\n");
                     builder.Append("  Remarks:").Append(system.Remarks).Append("\n");
                     builder.Append("投影:").Append(system.Projection.Name).Append("\n");
                     builder.Append("投影参数:\n");
                     builder.Append("   False_Easting:").Append(system.FalseEasting).Append("\n");
                     builder.Append("   False_Northing:").Append(system.FalseNorthing).Append("\n");
                     builder.Append("   Central_Meridian:").Append(system.get_CentralMeridian(true)).Append("\n");
                     try
                     {
                         builder.Append("   Scale_Factor:").Append(system.ScaleFactor).Append("\n");
                     }
                     catch { }
                     builder.Append("   Latitude_Of_Origin:0\n");
                     builder.Append("Linear Unit:").Append(system.CoordinateUnit.Name).Append("(").Append(system.CoordinateUnit.MetersPerUnit).Append(")\n");
                     builder.Append("Geographic Coordinate System:\n");
                     system2 = system.GeographicCoordinateSystem;
                     builder.Append("  Name:").Append(system2.Name).Append("\n");
                     builder.Append("  Alias:").Append(system2.Alias).Append("\n");
                     builder.Append("  Abbreviation:").Append(system2.Abbreviation).Append("\n");
                     builder.Append("  Remarks:").Append(system2.Remarks).Append("\n");
                     builder.Append("  Angular Unit:").Append(system2.CoordinateUnit.Name).Append("(").Append(system2.CoordinateUnit.RadiansPerUnit).Append(")\n");
                     builder.Append("  Prime Meridian:").Append(system2.PrimeMeridian.Name).Append("(").Append(system2.PrimeMeridian.Longitude).Append(")\n");
                     builder.Append("  Datum:").Append(system2.Datum.Name).Append("\n");
                     builder.Append("    Spheroid:").Append(system2.Datum.Spheroid.Name).Append("\n");
                     builder.Append("      Semimajor Axis:").Append(system2.Datum.Spheroid.SemiMajorAxis).Append("\n");
                     builder.Append("      Semiminor Axis:").Append(system2.Datum.Spheroid.SemiMinorAxis).Append("\n");
                     builder.Append("      Inverse Flattening:").Append((double)(1.0 / system2.Datum.Spheroid.Flattening)).Append("\n");
                     builder.Append("X/Y Domain:\n");
                     try
                     {
                         double num  = 0.0;
                         double num2 = 0.0;
                         double num3 = 0.0;
                         double num4 = 0.0;
                         double num5 = 0.0;
                         sr.GetDomain(out num, out num3, out num2, out num4);
                         sr.GetFalseOriginAndUnits(out num, out num2, out num5);
                         builder.Append(" Min X:").Append(num).Append("\n");
                         builder.Append(" Min Y:").Append(num2).Append("\n");
                         builder.Append(" Max X:").Append(num3).Append("\n");
                         builder.Append(" Max Y:").Append(num4).Append("\n");
                         builder.Append(" XYScale:").Append(num5).Append("\n");
                         builder.Append("\n");
                     }
                     catch (Exception exception1)
                     {
                         exception = exception1;
                     }
                     builder.Append("Z Domain:\n");
                     try
                     {
                         double num6;
                         double num7;
                         double num8 = 0.0;
                         sr.GetZDomain(out num6, out num7);
                         sr.GetZFalseOriginAndUnits(out num6, out num8);
                         builder.Append("  Min Z:").Append(num6).Append("\n");
                         builder.Append("  Max Z:").Append(num7).Append("\n");
                         builder.Append("  ZScale:").Append(num8).Append("\n");
                         builder.Append("\n");
                     }
                     catch (Exception exception2)
                     {
                         exception = exception2;
                     }
                     try
                     {
                         double num9;
                         double num10;
                         builder.Append("M Domain:\n");
                         double num11 = 0.0;
                         sr.GetMDomain(out num9, out num10);
                         sr.GetMFalseOriginAndUnits(out num9, out num11);
                         builder.Append("  Min M:").Append(num9).Append("\n");
                         builder.Append("  Max M:").Append(num10).Append("\n");
                         builder.Append("  MScale:").Append(num11).Append("\n");
                     }
                     catch (Exception exception3)
                     {
                         exception = exception3;
                     }
                 }
                 else if (sr is IGeographicCoordinateSystem)
                 {
                     builder.Append("Geographic Coordinate System:\n");
                     system2 = sr as IGeographicCoordinateSystem;
                     builder.Append("  Name:").Append(system2.Name).Append("\n");
                     builder.Append("  Alias:").Append(system2.Alias).Append("\n");
                     builder.Append("  Abbreviation:").Append(system2.Abbreviation).Append("\n");
                     builder.Append("  Remarks:").Append(system2.Remarks).Append("\n");
                     builder.Append("  Angular Unit:").Append(system2.CoordinateUnit.Name).Append("(").Append(system2.CoordinateUnit.RadiansPerUnit).Append(")\n");
                     builder.Append("  Prime Meridian:").Append(system2.PrimeMeridian.Name).Append("(").Append(system2.PrimeMeridian.Longitude).Append(")\n");
                     builder.Append("  Datum:").Append(system2.Datum.Name).Append("\n");
                     builder.Append("    Spheroid:").Append(system2.Datum.Spheroid.Name).Append("\n");
                     builder.Append("      Semimajor Axis:").Append(system2.Datum.Spheroid.SemiMajorAxis).Append("\n");
                     builder.Append("      Semiminor Axis:").Append(system2.Datum.Spheroid.SemiMinorAxis).Append("\n");
                     builder.Append("      Inverse Flattening:").Append((double)(1.0 / system2.Datum.Spheroid.Flattening)).Append("\n");
                 }
             }
         }
         return(builder.ToString());
     }
     catch (Exception ex)
     { return(""); }
 }
Пример #4
0
        /// <summary>
        /// ��������ϵͳ
        /// </summary>
        /// <param name="isFile">�Ƿ��ļ���ʽ����</param>
        private void LoadProCoord(bool isFile, IProjectedCoordinateSystem pProCoord)
        {
            this.txtName.Text = pProCoord.Name;
            this.rtxDetail.Text = "ͶӰ����ϵͳ��\n";
            this.rtxDetail.Text += " Name :" + pProCoord.Name + "\n";

            this.rtxDetail.Text += "Projection: " + pProCoord.Projection.Name + "\n";
            this.rtxDetail.Text += "Parameters:\n";
            this.rtxDetail.Text += " False_Easting: " + pProCoord.FalseEasting.ToString() + "\n";
            this.rtxDetail.Text += " False_Northing: " + pProCoord.FalseNorthing.ToString() + "\n";
            this.rtxDetail.Text += " Central_Meridian: " + pProCoord.get_CentralMeridian(true).ToString() + "\n";
            this.rtxDetail.Text += " Scale_Factor: " + pProCoord.ScaleFactor.ToString() + "\n";
            this.rtxDetail.Text += " Latitude_Of_Origin: 0.000000\n";
            this.rtxDetail.Text += " Linear Unit: Meter (1.000000)\n";

            this.rtxDetail.Text += "��������ϵͳ��\n";
            this.rtxDetail.Text += " Name: " + pProCoord.GeographicCoordinateSystem.Name + "\n";
            this.rtxDetail.Text += " Alias: " + pProCoord.GeographicCoordinateSystem.Alias + "\n";
            this.rtxDetail.Text += " Abbreviation: " + pProCoord.GeographicCoordinateSystem.Abbreviation + "\n";
            this.rtxDetail.Text += " Remarks: " + pProCoord.GeographicCoordinateSystem.Remarks + "\n";
            this.rtxDetail.Text += " Angular Unit: Degree (0.017453292519943299)\n";
            this.rtxDetail.Text += " Prime Meridian: " + pProCoord.GeographicCoordinateSystem.PrimeMeridian.Name + "\n";
            this.rtxDetail.Text += " Datum: " + pProCoord.GeographicCoordinateSystem.Datum.Name + "\n";
            this.rtxDetail.Text += "   Spheroid: " + pProCoord.GeographicCoordinateSystem.Datum.Spheroid.Name + "\n";
            this.rtxDetail.Text += "   Semimajor Axis: " + pProCoord.GeographicCoordinateSystem.Datum.Spheroid.SemiMajorAxis.ToString() + "\n";
            this.rtxDetail.Text += "   Semiminor Axis: " + pProCoord.GeographicCoordinateSystem.Datum.Spheroid.SemiMinorAxis.ToString() + "\n";
            this.rtxDetail.Text += "   Inverse Flattening: " + pProCoord.GeographicCoordinateSystem.Datum.Spheroid.Flattening.ToString() + "\n";

            this.rtxDetail.Text += "X/Y Domain: \n";
            double xMin = 0, xMax = 90000000, yMin = 0, yMax = 90000000, zMin = 0, zMax = 20000;
            pProCoord.SetDomain(xMin, xMax, yMin, yMax);

            this.rtxDetail.Text += " Min X: " + xMin.ToString() + "\n";
            this.rtxDetail.Text += " Min Y: " + yMin.ToString() + "\n";
            this.rtxDetail.Text += " Max X: " + xMax.ToString() + "\n";
            this.rtxDetail.Text += " Max Y: " + yMax.ToString() + "\n";

            this.rtxDetail.Text += "Z Domain: \n";
            pProCoord.SetZDomain(zMin, zMax);

            this.rtxDetail.Text += " Min: " + zMin.ToString() + "\n";
            this.rtxDetail.Text += " Max: " + zMax.ToString() + "\n";
        }
Пример #5
0
        /// <summary>
        /// 初始化form element
        /// </summary>
        private void Initialize()
        {
            IFeatureLayer           featureLayer    = (IFeatureLayer)m_layer;
            IGeoFeatureLayer        geoLayer        = (IGeoFeatureLayer)m_layer;
            IFeatureClass           featureClass    = featureLayer.FeatureClass;
            ILayerGeneralProperties layerProperties = (ILayerGeneralProperties)featureLayer;

            // 图层属性页
            this.textBoxLayerName.Text        = m_layer.Name;
            this.textBoxLayerDescription.Text = layerProperties.LayerDescription;
            this.checkBoxVisibility.Checked   = m_layer.Visible;

            String scaleMin = geoLayer.MinimumScale.ToString();
            String sacleMax = geoLayer.MaximumScale.ToString();

            if ("0" == scaleMin && "0" == sacleMax)
            {
                this.radioButtonScaleAll.Checked  = true;
                this.radioButtonScaleZoom.Checked = false;
            }
            else
            {
                this.radioButtonScaleAll.Checked  = false;
                this.radioButtonScaleZoom.Checked = true;
                this.comboBoxScaleMax.Text        = sacleMax;
                this.comboBoxScaleMin.Text        = scaleMin;
            }

            // 字段定义页
            IFields fields     = featureClass.Fields;
            int     fieldCount = fields.FieldCount;

            for (int i = 0; i < fieldCount; i++)
            {
                IField       field = fields.get_Field(i);
                ListViewItem item  = new ListViewItem(field.Name);
                item.SubItems.Add(field.AliasName);
                item.SubItems.Add(field.Editable ? "允许编辑" : "不允许编辑");
                item.SubItems.Add(field.IsNullable ? "允许为空" : "不允许为空");
                item.SubItems.Add(field.Length.ToString());
                item.SubItems.Add(field.Precision.ToString());
                item.SubItems.Add(field.Scale.ToString());
                item.SubItems.Add(GetFieldType(field.Type));
                listViewFields.Items.Add(item);
            }

            // 数据源及四至范围
            IEnvelope envelope = m_layer.AreaOfInterest;

            textBoxLeft.Text   = envelope.XMin.ToString();
            textBoxRight.Text  = envelope.XMax.ToString();
            textBoxTop.Text    = envelope.YMin.ToString();
            textBoxBottom.Text = envelope.YMax.ToString();

            IDataset dataset = (IDataset)featureLayer;

            textBoxDataSource.AppendText("数据源类型:           ");
            textBoxDataSource.AppendText(featureLayer.DataSourceType);
            textBoxDataSource.AppendText("\r\n数据集:               ");
            textBoxDataSource.AppendText(dataset.BrowseName);
            textBoxDataSource.AppendText("\r\n数据源名称:           ");
            textBoxDataSource.AppendText(dataset.Workspace.PathName);

            textBoxDataSource.AppendText("\r\n要素类:               ");
            textBoxDataSource.AppendText(featureClass.AliasName);
            textBoxDataSource.AppendText("\r\n要素类类型:           ");
            textBoxDataSource.AppendText(GetFeatureType(featureClass.FeatureType));
            textBoxDataSource.AppendText("\r\n几何类型:             ");
            textBoxDataSource.AppendText(GetGeometryType(featureClass.ShapeType));

            IGeoDataset geoDataset = (IGeoDataset)featureClass;
            // 通过IGeoDataset接口获取FeatureClass坐标系统
            ISpatialReference          spatialReference   = geoDataset.SpatialReference;
            IProjectedCoordinateSystem projectCoordSystem = null;

            if (spatialReference is IProjectedCoordinateSystem)
            {
                projectCoordSystem = (IProjectedCoordinateSystem)spatialReference;

                if (projectCoordSystem == null)
                {
                    return;
                }

                textBoxDataSource.AppendText("\r\n");

                IProjection project = projectCoordSystem.Projection;
                textBoxDataSource.AppendText("\r\n投影坐标系:           ");
                textBoxDataSource.AppendText(projectCoordSystem.Name);
                textBoxDataSource.AppendText("\r\n投影:                 ");
                textBoxDataSource.AppendText(project.Name);
                textBoxDataSource.AppendText("\r\nFalseEasting:         ");
                textBoxDataSource.AppendText(projectCoordSystem.FalseEasting.ToString());
                textBoxDataSource.AppendText("\r\nFalseNorthing:        ");
                textBoxDataSource.AppendText(projectCoordSystem.FalseNorthing.ToString());
                textBoxDataSource.AppendText("\r\n中央经线:             ");
                textBoxDataSource.AppendText(projectCoordSystem.get_CentralMeridian(true).ToString());
                textBoxDataSource.AppendText("\r\n缩放比例:             ");
                textBoxDataSource.AppendText(projectCoordSystem.ScaleFactor.ToString());
                textBoxDataSource.AppendText("\r\n高度原点:             ");
                try
                {
                    textBoxDataSource.AppendText(projectCoordSystem.LongitudeOfOrigin.ToString());
                }
                catch (Exception e)
                {
                    textBoxDataSource.AppendText("0");
                }

                textBoxDataSource.AppendText("\r\n单位:                 ");
                textBoxDataSource.AppendText(projectCoordSystem.CoordinateUnit.Name);

                textBoxDataSource.AppendText("\r\n");

                IGeographicCoordinateSystem geographCoordinateSystem = projectCoordSystem.GeographicCoordinateSystem;
                if (geographCoordinateSystem != null)
                {
                    textBoxDataSource.AppendText("\r\n地理坐标系:           ");
                    textBoxDataSource.AppendText(geographCoordinateSystem.Name);
                    textBoxDataSource.AppendText("\r\n基准面:               ");
                    textBoxDataSource.AppendText(geographCoordinateSystem.Datum.Name);
                    textBoxDataSource.AppendText("\r\n本初子午线:           ");
                    textBoxDataSource.AppendText(geographCoordinateSystem.PrimeMeridian.Name);
                    textBoxDataSource.AppendText("\r\n单位:                 ");
                    textBoxDataSource.AppendText(geographCoordinateSystem.CoordinateUnit.Name);
                }
            }
            else if (spatialReference is IGeographicCoordinateSystem)
            {
                IGeographicCoordinateSystem geographCoordinateSystem = spatialReference as IGeographicCoordinateSystem;
                if (geographCoordinateSystem != null)
                {
                    textBoxDataSource.AppendText("\r\n地理坐标系:           ");
                    textBoxDataSource.AppendText(geographCoordinateSystem.Name);
                    textBoxDataSource.AppendText("\r\n基准面:               ");
                    textBoxDataSource.AppendText(geographCoordinateSystem.Datum.Name);
                    textBoxDataSource.AppendText("\r\n本初子午线:           ");
                    textBoxDataSource.AppendText(geographCoordinateSystem.PrimeMeridian.Name);
                    textBoxDataSource.AppendText("\r\n单位:                 ");
                    textBoxDataSource.AppendText(geographCoordinateSystem.CoordinateUnit.Name);
                }
            }



            // filter

            IDisplayString displayString = (IDisplayString)featureLayer;

            textBoxFilter.AppendText(displayString.ExpressionProperties.Expression);

            // 标注
            IAnnotateLayerPropertiesCollection annoLayerPropsColl = geoLayer.AnnotationProperties;
            IAnnotateLayerProperties           annoLayerProps     = null;
            IElementCollection placedElements   = null;
            IElementCollection unplacedElements = null;

            annoLayerPropsColl.QueryItem(0, out annoLayerProps, out placedElements, out unplacedElements);
            ILabelEngineLayerProperties aLELayerProps = annoLayerProps as ILabelEngineLayerProperties;

            // annoLayerProps.DisplayAnnotation;
            checkBoxLabelVisibility.Checked = annoLayerProps.DisplayAnnotation;

            //初始化字体大小下拉框
            for (int k = 5; k <= 11; k++)
            {
                cmbFontSize.Items.Add(k);
            }
            for (int k = 12; k <= 72; k = k + 2)
            {
                cmbFontSize.Items.Add(k);
            }
            // cmbFontSize.Text = "8";

            //初始化字体下拉框
            foreach (FontFamily onefontfamily in FontFamily.Families)
            {
                //去掉名称头个字为@的字体
                if (onefontfamily.Name.Substring(0, 1) != "@")
                {
                    cmbFontName.Items.Add(onefontfamily.Name);
                }
            }
            // cmbFontName.Text = "宋体";
            ITextSymbol pTextSymbol = aLELayerProps.Symbol;

            stdole.IFontDisp pFontDisp = pTextSymbol.Font;
            cmbFontSize.Text = pFontDisp.Size.ToString();
            toolBarStyle.Buttons[0].Pushed = pFontDisp.Bold;
            toolBarStyle.Buttons[1].Pushed = pFontDisp.Italic;
            toolBarStyle.Buttons[2].Pushed = pFontDisp.Underline;
            cmbFontName.Text = pFontDisp.Name;
            IRgbColor rgbColor = (IRgbColor)pTextSymbol.Color;

            colorButtonFont.Color = Color.FromArgb(rgbColor.Transparency,
                                                   rgbColor.Red,
                                                   rgbColor.Green,
                                                   rgbColor.Blue);
            colorButtonFont.Refresh();
            for (int i = 0; i < fields.FieldCount; i++)
            {
                IField field = fields.get_Field(i);
                cmbFieldName.Items.Add(field.Name);
            }

            cmbFieldName.Enabled = aLELayerProps.IsExpressionSimple;
            String expr = aLELayerProps.Expression.Trim('[').Trim(']');

            cmbFieldName.SelectedIndex = cmbFieldName.FindString(expr);

            cmbMaxScale.Text = annoLayerProps.AnnotationMaximumScale.ToString();
            cmbMinScale.Text = annoLayerProps.AnnotationMinimumScale.ToString();

            if (cmbMaxScale.Text == "0" && cmbMinScale.Text == "0")
            {
                rbScaleWithLayer.Checked    = true;
                this.rbScaleDefined.Checked = false;
            }
            else
            {
                rbScaleWithLayer.Checked    = false;
                this.rbScaleDefined.Checked = true;
            }

            //ITextSymbol pTextSymbol = aLELayerProps.Symbol;
            //stdole.IFontDisp pFontDisp = pTextSymbol.Font;
            //pFontDisp.Size = decimal.Parse(fontSize);
            //pFontDisp.Bold = boldBool;
            //pFontDisp.Italic = italicBool;
            //pFontDisp.Name = fontStyle;
            //IRgbColor pRgbColor = new RgbColorClass();
            //pRgbColor.Red = int.Parse(fontColor.R.ToString());
            //pRgbColor.Blue = int.Parse(fontColor.B.ToString());
            //pRgbColor.Green = int.Parse(fontColor.G.ToString());
            //pTextSymbol.Font = pFontDisp;
            //pTextSymbol.Color = pRgbColor;
            //aLELayerProps.Symbol = pTextSymbol;
            //annoLayerProps = aLELayerProps as IAnnotateLayerProperties;
            //annoLayerProps.FeatureLayer = geoLayer;
            //annoLayerProps.LabelWhichFeatures = esriLabelWhichFeatures.esriAllFeatures;
            //annoLayerPropsColl.Add(annoLayerProps);

            // 符号
            checkBoxCostomSymbol.Checked = EPSUtils.IsLayerRenderer(featureLayer);
        }
Пример #6
0
		/// <summary>
		/// 获取VCT头节点
		/// </summary>
		public HeadNode GetHeadNode()
        {
            m_HeadNode = new HeadNode();
            ///头文件数据标识、版本号、坐标系统类型,维数
            m_HeadNode.Datamark =Metadata.MetaDataFile.HeadConfig.DataMark.Value;
            m_HeadNode.Version = Metadata.MetaDataFile.HeadConfig.Version.Defualt;// "1.0";
            m_HeadNode.CoordinateSystemType = Metadata.MetaDataFile.HeadConfig.CoordSystemType.Defualt;//"C";
            m_HeadNode.Dim =Convert.ToInt32( Metadata.MetaDataFile.HeadConfig.CoordinateDim.Defualt);

            ///投影类型
            m_HeadNode.Projection = Metadata.MetaDataFile.HeadConfig.Projection.Value;

            ///头文件X、Y坐标方向
            m_HeadNode.XaxisDirection = Metadata.MetaDataFile.HeadConfig.XAxisDirection.Defualt;
            m_HeadNode.YAxisDirection = Metadata.MetaDataFile.HeadConfig.YAxisDirection.Defualt;

            //获取投影参数
           // m_HeadNode.Parametetor = Metadata.MetaDataFile.HeadConfig.ProjectionParator.Value;//ipSpheroid.SemiMajorAxis.ToString("f6") + "," + ipSpheroid.SemiMinorAxis.ToString("f6");

            ///参考椭球,长半轴,扁率的倒数
            m_HeadNode.Spheroid = Metadata.MetaDataFile.HeadConfig.Spheroid.Value; //pSpatialReference.Name + "," + ipSpheroid.SemiMajorAxis.ToString("f6") + "," + flater.ToString("f6");

            //首子午线
            m_HeadNode.PrimeMeridian = Metadata.MetaDataFile.HeadConfig.PrimeMeridian.Value;// ipProjCoordSys.get_CentralMeridian(true).ToString();

            ///比例尺
            m_HeadNode.Scale = Metadata.MetaDataFile.HeadConfig.Scale.Value;

            ///坐标单位
            m_HeadNode.Unit = Metadata.MetaDataFile.HeadConfig.CoordinateUnit.Defualt;

            ///偏移量
            m_HeadNode.Excursion = Metadata.MetaDataFile.HeadConfig.Excurtion.Value;

            //if("3_Degree")


            //获取空间参考参数
            ISpatialReference pSpatialReference = m_pSpatialReference;
            ISpheroid ipSpheroid=null;
            IProjection ipProjection;

            ///投影坐标系
            if (m_pSpatialReference is IProjectedCoordinateSystem)
            {
                //获取空间参考参数
                IProjectedCoordinateSystem ipProjCoordSys = m_pSpatialReference as IProjectedCoordinateSystem;//投影参考信息
                ipProjection = ipProjCoordSys.Projection;

                IGeographicCoordinateSystem ipGeoCoordSys = ipProjCoordSys.GeographicCoordinateSystem;
                ipSpheroid = ipGeoCoordSys.Datum.Spheroid;

                //m_HeadNode.Excursion = ipProjCoordSys.FalseEasting.ToString();///坐标偏移量

                //m_HeadNode.Scale = ipProjCoordSys.ScaleFactor.ToString("6f");//比例尺

                ///获取最小、大坐标
                double xMin = 10000000, xMax = 10000000, yMin = -10000000, yMax = -10000000;
                ipProjCoordSys.GetDomain(out xMin, out xMax, out yMin, out yMax);
                //GetXyDomain(m_pWorkspace, ref xMin, ref yMin, ref xMax, ref yMax);
                m_HeadNode.MajorMax = new PointInfoNode(xMax, yMax);
                m_HeadNode.MajorMin = new PointInfoNode(xMin, yMin);

                m_HeadNode.CoordinateSystemType = "P";

                ///投影参数(东偏、北偏、原点经度、第一标准纬线,第二标准纬线、方位角)
                m_HeadNode.Parametetor.EastOffset = ipProjCoordSys.FalseEasting.ToString();
                m_HeadNode.Parametetor.NorthOffset = ipProjCoordSys.FalseNorthing.ToString();
                m_HeadNode.Parametetor.OriginLongtitude = ipProjCoordSys.get_CentralMeridian(true).ToString();
                try
                {
                    m_HeadNode.Parametetor.FirstStandard = ipProjCoordSys.LatitudeOf1st.ToString();
                    m_HeadNode.Parametetor.SecondStandard = ipProjCoordSys.LatitudeOf2nd.ToString();
                    m_HeadNode.Parametetor.Angle = ipProjCoordSys.Azimuth.ToString();
                }
                catch
                { }
                //m_HeadNode.Parametetor.Angle = ipProjCoordSys.Azimuth.ToString();
               // m_HeadNode.Parametetor.OriginLatitude= ipProjCoordSys.

                /////根据投影名称来判断带号,带宽
                if (ipProjCoordSys.Name.Contains("3_Degree"))
                {
                    m_HeadNode.Parametetor.With = "3";
                }
                else
                {
                    m_HeadNode.Parametetor.With = "6";
                }


                ////包含Zone的表示可能带带号
                if (ipProjCoordSys.Name.Contains("Zone"))
                {
                    int index = ipProjCoordSys.Name.LastIndexOf("Zone_");
                    int nTolLen = ipProjCoordSys.Name.Length;

                    string strSubName = ipProjCoordSys.Name.Substring(index+5, nTolLen - index-5);

                    ////带号中不存在n则表示有带号
                    if (!strSubName.Contains("N"))
                        m_HeadNode.Parametetor.Num = m_HeadNode.Parametetor.Num;
                }
                else
                {
                    ///不存在带号
                }
            }
            else if (m_pSpatialReference is IGeographicCoordinateSystem)
            {
                IGeographicCoordinateSystem ipGeoCoordSys = m_pSpatialReference as IGeographicCoordinateSystem;
                ipSpheroid = ipGeoCoordSys.Datum.Spheroid;

                ///获取最小、大坐标
                double xMin = 10000000, xMax = 10000000, yMin = -10000000, yMax = -10000000;
                ipGeoCoordSys.GetDomain(out xMin, out xMax, out yMin, out yMax);
                //GetXyDomain(m_pWorkspace, ref xMin, ref yMin, ref xMax, ref yMax);
                m_HeadNode.MajorMax = new PointInfoNode(xMax, yMax);
                m_HeadNode.MajorMin = new PointInfoNode(xMin, yMin);
                m_HeadNode.CoordinateSystemType = "D";

                //中央经线
                m_HeadNode.Parametetor.OriginLongtitude = ipGeoCoordSys.PrimeMeridian.Longitude.ToString();
            }


            ///高程基准 时间参考系
            m_HeadNode.Vertical = Metadata.MetaDataFile.HeadConfig.Vertical.Value;
            m_HeadNode.TemporalReferenceSystem = Metadata.MetaDataFile.HeadConfig.TemporalReferenceSystem.Value;

            ///获取日期
            string dataTime = DateTime.Now.Year.ToString();

            ///计算月份部分不足两位加0
            if (DateTime.Now.Month < 10)
                dataTime = dataTime + "0" + DateTime.Now.Month.ToString();
            else
                dataTime += DateTime.Now.Month.ToString();
            ///计算日期部分不足两位加0
            if (DateTime.Now.Day < 10)
                dataTime = dataTime + "0" + DateTime.Now.Day.ToString();
            else
                dataTime += DateTime.Now.Day.ToString();

            m_HeadNode.Date= dataTime;
            HeadNode.Separator = Metadata.MetaDataFile.HeadConfig.Sparator.Value.ToCharArray()[0];
            return m_HeadNode;
		}
Пример #7
0
        private void GetDataSource()
        {
            IFeatureLayer     pFeatureLayer   = (IFeatureLayer)m_pLayer;
            IFeatureClass     pFeatureClass   = pFeatureLayer.FeatureClass;
            IDataset          pFeatureDataset = pFeatureClass as IDataset;
            ISpatialReference pSpatialRef;

            pSpatialRef = (pFeatureClass as IGeoDataset).SpatialReference;

            //判断如果转换成投影坐标是否成功 xisheng 20111122
            IProjectedCoordinateSystem  pProjectedCoordinateSystem  = ((pFeatureClass as IGeoDataset).SpatialReference) as IProjectedCoordinateSystem;
            IGeographicCoordinateSystem pGeographicCoordinateSystem = null;

            if (pProjectedCoordinateSystem == null)
            {
                pGeographicCoordinateSystem = ((pFeatureClass as IGeoDataset).SpatialReference) as IGeographicCoordinateSystem;
            }
            else
            {
                pGeographicCoordinateSystem = pProjectedCoordinateSystem.GeographicCoordinateSystem;
            }
            //**************************************************end
            string strDataType      = pFeatureLayer.DataSourceType;
            string strLocation      = pFeatureDataset.Workspace.PathName;
            string strFeatureDSName = pFeatureDataset.Name;
            string strFCName        = pFeatureClass.AliasName;
            string strFeatureType   = pFeatureClass.FeatureType.ToString().Substring(6);
            string strGeometryType  = pFeatureClass.ShapeType.ToString().Substring(12);

            if (pProjectedCoordinateSystem != null)
            {
                string strPCSName         = pProjectedCoordinateSystem.Name;
                string strProjection      = pProjectedCoordinateSystem.Projection.Name;
                string strFalseEasting    = pProjectedCoordinateSystem.FalseEasting.ToString();
                string strFalseNorthing   = pProjectedCoordinateSystem.FalseNorthing.ToString();
                string strCentralMeridian = pProjectedCoordinateSystem.get_CentralMeridian(true).ToString();
                string strScaleFactor     = pProjectedCoordinateSystem.ScaleFactor.ToString();
                string strLinearUnit      = pProjectedCoordinateSystem.CoordinateUnit.Name;

                string strGCSName       = pGeographicCoordinateSystem.Name;
                string strDatum         = pGeographicCoordinateSystem.Datum.Name;
                string strPrimeMeridian = pGeographicCoordinateSystem.PrimeMeridian.Name;
                string strAngularUnit   = pGeographicCoordinateSystem.CoordinateUnit.Name;
                txtDataSource.Text =
                    "Data Type:\t\t\t" + strDataType +
                    "\r\n位置:\t\t\t" + strLocation +
                    "\r\n要素集:\t\t" + strFeatureDSName +
                    "\r\n要素类:\t\t\t" + strFCName +
                    "\r\n要素类型:\t\t\t" + strFeatureType +
                    "\r\n几何类型:\t\t\t" + strGeometryType +
                    "\r\n\r\n投影坐标系信息:\t" + strPCSName +
                    "\r\n投影:\t\t\t" + strProjection +
                    "\r\nFalse_Easting:\t\t\t" + strFalseEasting +
                    "\r\nFalse_Northing:\t\t\t" + strFalseNorthing +
                    "\r\nCentral_Meridian:\t\t" + strCentralMeridian +
                    "\r\nScale_Factor:\t\t\t" + strScaleFactor +
                    "\r\nLinear Unit:\t\t\t" + strLinearUnit +
                    "\r\n\r\nGeographic Coordinate System:\t" + strGCSName +
                    "\r\nDatum:\t\t\t\t" + strDatum +
                    "\r\nPrime Meridian:\t\t\t" + strPrimeMeridian +
                    "\r\nAngular Unit:\t\t\t" + strAngularUnit + "\r\n";
            }
            else
            {
                string strGCSName       = pGeographicCoordinateSystem.Name;
                string strDatum         = pGeographicCoordinateSystem.Datum.Name;
                string strPrimeMeridian = pGeographicCoordinateSystem.PrimeMeridian.Name;
                string strAngularUnit   = pGeographicCoordinateSystem.CoordinateUnit.Name;
                txtDataSource.Text =
                    "Data Type:\t\t\t" + strDataType +
                    "\r\nLocation:\t\t\t" + strLocation +
                    "\r\nFeature Dataset:\t\t" + strFeatureDSName +
                    "\r\nFeature Class:\t\t\t" + strFCName +
                    "\r\nFeature Type:\t\t\t" + strFeatureType +
                    "\r\nGeometry Type:\t\t\t" + strGeometryType +
                    "\r\n\r\nGeographic Coordinate System:\t" + strGCSName +
                    "\r\nDatum:\t\t\t\t" + strDatum +
                    "\r\nPrime Meridian:\t\t\t" + strPrimeMeridian +
                    "\r\nAngular Unit:\t\t\t" + strAngularUnit + "\r\n";
            }
        }