コード例 #1
0
ファイル: VCSControlPage.cs プロジェクト: secondii/Yutai
        private void btnImport_Click(object sender, EventArgs e)
        {
            frmOpenFile file = new frmOpenFile();

            file.AddFilter(new MyGxFilterDatasets(), true);
            file.AllowMultiSelect = false;
            if (file.ShowDialog() == DialogResult.OK)
            {
                IGxDataset dataset = file.Items.get_Element(0) as IGxDataset;
                if (dataset != null)
                {
                    IGeoDataset dataset2 = dataset.Dataset as IGeoDataset;
                    if (dataset2 != null)
                    {
                        if (dataset2.SpatialReference is IUnknownCoordinateSystem)
                        {
                            this.ispatialReferenceInfo_0 = null;
                            this.textBoxName.Text        = "<NONE>";
                            this.textBoxName.Tag         = null;
                        }
                        else
                        {
                            this.ispatialReferenceInfo_0 =
                                (dataset2.SpatialReference as ISpatialReference3).VerticalCoordinateSystem;
                            this.textBoxName.Tag  = this.ispatialReferenceInfo_0;
                            this.textBoxName.Text = this.ispatialReferenceInfo_0.Name;
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: VCSControlPage.cs プロジェクト: secondii/Yutai
        private void btnNew_Click(object sender, EventArgs e)
        {
            frmNewVCS wvcs = new frmNewVCS();

            if (wvcs.ShowDialog() == DialogResult.OK)
            {
                this.ispatialReferenceInfo_0 = wvcs.VerticalCoordinateSystem;
                this.textBoxName.Tag         = this.ispatialReferenceInfo_0;
                this.textBoxName.Text        = this.ispatialReferenceInfo_0.Name;
            }
        }
コード例 #3
0
ファイル: VCSControlPage.cs プロジェクト: secondii/Yutai
 private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (e.Node.Tag is ISpatialReferenceInfo)
     {
         this.textBoxName.Text        = (e.Node.Tag as ISpatialReferenceInfo).Name;
         this.textBoxName.Tag         = e.Node.Tag;
         this.ispatialReferenceInfo_0 = this.textBoxName.Tag as ISpatialReferenceInfo;
     }
     else if (e.Node.Nodes.Count == 0)
     {
         this.textBoxName.Text        = "<NONE>";
         this.textBoxName.Tag         = null;
         this.ispatialReferenceInfo_0 = null;
     }
 }
コード例 #4
0
ファイル: RasterSet.cs プロジェクト: Mekeater/PSDS
        public void rasterSet(string Name, string Format, IPoint Origin, int columnCount, int RowCount, double cellSizeX, double cellSizeY, int numBands, rstPixelType PixelType, ISpatialReference SpatialReference = null)
        {
            this.Name        = Name;
            this.Format      = Format;
            this.Origin      = Origin;
            this.columnCount = columnCount;
            this.RowCount    = RowCount;
            this.cellSizeX   = cellSizeX;
            this.cellSizeY   = cellSizeY;
            this.numBands    = numBands;
            this.PixelType   = PixelType;
            if (SpatialReference != null)
            {
                this.SpatialReference = SpatialReference;
            }
            else
            {
                this.SpatialReference = spatialReference();
            }

            ISpatialReferenceInfo ptest = this.SpatialReference as ISpatialReferenceInfo;
            long t = ptest.FactoryCode;
        }
コード例 #5
0
        private string method_0(ISpatialReferenceInfo ispatialReferenceInfo_0)
        {
            IGeographicCoordinateSystem geographicCoordinateSystem;
            string str2;

            this.textBoxName.Text = ispatialReferenceInfo_0.Name;
            if (ispatialReferenceInfo_0 is IVerticalCoordinateSystem)
            {
                StringBuilder builder = new StringBuilder();
                builder.Append("线性单位:");
                builder.Append((ispatialReferenceInfo_0 as IVerticalCoordinateSystem).CoordinateUnit.Name);
                builder.Append("\r\n");
                if ((ispatialReferenceInfo_0 as IVerticalCoordinateSystem).PositiveDirection == -1)
                {
                    builder.Append("方向:正\r\n");
                }
                else
                {
                    builder.Append("方向:负\r\n");
                }
                builder.Append("垂直偏移:");
                builder.Append((ispatialReferenceInfo_0 as IVerticalCoordinateSystem).VerticalShift.ToString());
                builder.Append("\r\n");
                builder.Append("垂直坐标框架:");
                builder.Append(
                    ((ispatialReferenceInfo_0 as IVerticalCoordinateSystem).Datum as ISpatialReferenceInfo).Name);
                return(builder.ToString());
            }
            if (ispatialReferenceInfo_0 is IGeographicCoordinateSystem)
            {
                geographicCoordinateSystem = (IGeographicCoordinateSystem)ispatialReferenceInfo_0;
                str2 = ("别名: " + geographicCoordinateSystem.Alias + "\r\n") + "缩略名: " +
                       geographicCoordinateSystem.Abbreviation + "\r\n";
                string[] strArray = new string[]
                {
                    str2, "说明: ", geographicCoordinateSystem.Remarks, "\r\n角度单位: ",
                    geographicCoordinateSystem.CoordinateUnit.Name, " (",
                    geographicCoordinateSystem.CoordinateUnit.RadiansPerUnit.ToString(), ")\r\n本初子午线: ",
                    geographicCoordinateSystem.PrimeMeridian.Name, " (",
                    geographicCoordinateSystem.PrimeMeridian.Longitude.ToString(), ")\r\n数据: ",
                    geographicCoordinateSystem.Datum.Name, "\r\n  椭球体: ", geographicCoordinateSystem.Datum.Spheroid.Name,
                    "\r\n    长半轴: ",
                    geographicCoordinateSystem.Datum.Spheroid.SemiMajorAxis.ToString(), "\r\n    短半轴: ",
                    geographicCoordinateSystem.Datum.Spheroid.SemiMinorAxis.ToString(), "\r\n    扁率倒数: ",
                    (1.0 / geographicCoordinateSystem.Datum.Spheroid.Flattening).ToString()
                };
                return(string.Concat(strArray));
            }
            if (!(ispatialReferenceInfo_0 is IProjectedCoordinateSystem))
            {
                return("");
            }
            IProjectedCoordinateSystem system2 = (IProjectedCoordinateSystem)ispatialReferenceInfo_0;

            geographicCoordinateSystem = system2.GeographicCoordinateSystem;
            IProjection projection = system2.Projection;

            IParameter[] parameters = new IParameter[25];
            ((IProjectedCoordinateSystem4GEN)system2).GetParameters(ref parameters);
            string str3 = "  ";

            for (int i = 0; i < parameters.Length; i++)
            {
                if (parameters[i] == null)
                {
                    break;
                }
                str3 = str3 + parameters[i].Name + ": " + parameters[i].Value.ToString() + "\r\n ";
            }
            str2 = (((("别名: " + system2.Alias + "\r\n") + "缩略名: " + system2.Abbreviation + "\r\n") + "说明: " +
                     system2.Remarks + "\r\n") + "投影: " + system2.Projection.Name + "\r\n") + "参数:\r\n" + str3;
            str2 = ((((str2 + "线性单位: " + system2.CoordinateUnit.Name + " (" +
                       system2.CoordinateUnit.MetersPerUnit.ToString() + ")\r\n") + "地理坐标系:\r\n") + "  名称: " +
                     geographicCoordinateSystem.Name + "\r\n") + "  缩略名: " + geographicCoordinateSystem.Abbreviation +
                    "\r\n") + "  说明: " + geographicCoordinateSystem.Remarks + "\r\n";
            str2 = str2 + "  角度单位: " + geographicCoordinateSystem.CoordinateUnit.Name + " (" +
                   geographicCoordinateSystem.CoordinateUnit.RadiansPerUnit.ToString() + ")\r\n";
            double num = 1.0 / geographicCoordinateSystem.Datum.Spheroid.Flattening;

            return((((((str2 + "  本初子午线: " + geographicCoordinateSystem.PrimeMeridian.Name + " (" +
                        geographicCoordinateSystem.PrimeMeridian.Longitude.ToString() + ")\r\n") + "  数据: " +
                       geographicCoordinateSystem.Datum.Name + "\r\n") + "    椭球体: " +
                      geographicCoordinateSystem.Datum.Spheroid.Name + "\r\n") + "    长半轴: " +
                     geographicCoordinateSystem.Datum.Spheroid.SemiMajorAxis.ToString() + "\r\n") + "    短半轴: " +
                    geographicCoordinateSystem.Datum.Spheroid.SemiMinorAxis.ToString() + "\r\n") + "    扁率倒数: " +
                   num.ToString());
        }
コード例 #6
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            //
            if (context == null)
            {
                return(null);
            }
            if (context.Instance == null)
            {
                return(null);
            }
            if (provider == null)
            {
                return(null);
            }

            // Cannot handle multiple objects
            if (context.Instance is object[])
            {
                return(null);
            }

            //
            string wkt = null;

            if (value != null)
            {
                wkt = value.ToString();
            }

            // Do ArcGIS Desktop Test
            object dialog = null;

            try {
                dialog = new SpatialReferenceDialogClass();
            }
            catch { }
            if (dialog == null)
            {
                MessageBox.Show(
                    "You do not have ArcGIS Desktop Installed",
                    Resources.TEXT_APPLICATION,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxOptions.DefaultDesktopOnly);
                return(null);
            }

            // Variable to hold edited or created spatial reference
            ISpatialReference spatialReferenceOut = null;

            // Use DoModelCreate (if NULL) or DoModelEdit (if not NULL)
            if (string.IsNullOrEmpty(wkt))
            {
                ISpatialReferenceDialog2 spatialReferenceDialog = (ISpatialReferenceDialog2)dialog;
                spatialReferenceOut = spatialReferenceDialog.DoModalCreate(false, false, false, 0);
            }
            else
            {
                // Recreate ESRI Spatial Reference from String
                ISpatialReferenceFactory3 spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
                ISpatialReferenceInfo     spatialReferenceInfo    = null;
                int size;
                spatialReferenceFactory.CreateESRISpatialReferenceInfo(wkt, out spatialReferenceInfo, out size);
                ISpatialReference spatialReference = (ISpatialReference)spatialReferenceInfo;

                // Display Spatial Reference Dialog
                ISpatialReferenceDialog3 spatialReferenceDialog = (ISpatialReferenceDialog3)dialog;
                spatialReferenceOut = spatialReferenceDialog.DoModalEdit3(spatialReference, true, 0);
            }

            // Exit if Output SpatialReference is NULL
            if (spatialReferenceOut == null)
            {
                return(wkt);
            }

            // Convert ESRI Spatial Reference to a String
            IESRISpatialReferenceGEN spatialReferenceGEN = (IESRISpatialReferenceGEN)spatialReferenceOut;
            string projection;
            int    size2;

            spatialReferenceGEN.ExportToESRISpatialReference(out projection, out size2);
            if (string.IsNullOrEmpty(projection))
            {
                return(wkt);
            }

            // Return Result
            return(projection);
        }