Beispiel #1
0
        private void btnSHP_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.Filter      = "*.shp|*.shp";
            openFile.Title       = "选择shp文件";
            openFile.Multiselect = true;

            ESRI.ArcGIS.Geometry.ISpatialReference pSpa = null;

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                string[] strs = openFile.FileNames;
                this.lstLyrFile.Items.Clear();
                for (int i = 0; i < strs.GetLength(0); i++)
                {
                    string str = strs[i];
                    this.lstLyrFile.Items.Add(System.IO.Path.GetFileNameWithoutExtension(str));

                    //获得一个源数据的空间参考
                    //获得空间参看 源的

                    if (pSpa == null)
                    {
                        IWorkspaceFactory pFac = new ShapefileWorkspaceFactory();
                        IWorkspace        pWks = pFac.OpenFromFile(System.IO.Path.GetDirectoryName(str), 0);
                        if (pWks == null)
                        {
                            continue;
                        }
                        IFeatureWorkspace pFeaWks = pWks as IFeatureWorkspace;
                        IFeatureClass     pFeaCls = pFeaWks.OpenFeatureClass(System.IO.Path.GetFileNameWithoutExtension(str));
                        if (pFeaCls == null)
                        {
                            continue;
                        }
                        IGeoDataset pGeoData = pFeaCls as IGeoDataset;

                        pSpa = pGeoData.SpatialReference;
                        if (pSpa == null)
                        {
                            continue;
                        }
                        m_strInPrj = ExportToESRISpatialReference(pSpa);
                        pFeaWks    = null;
                    }
                }

                for (int i = 0; i < this.lstLyrFile.Items.Count; i++)
                {
                    this.lstLyrFile.Items[i].Checked = true;
                }

                this.txtSource.Text = System.IO.Path.GetDirectoryName(strs[0]);
            }
        }
Beispiel #2
0
        public override bool SelectSpatialReference()
        {
            // get dialog handle
            ESRI.ArcGIS.CatalogUI.ISpatialReferenceDialog2 spatialReferenceDialog = new ESRI.ArcGIS.CatalogUI.SpatialReferenceDialogClass();
            ESRI.ArcGIS.Geometry.ISpatialReference         spatialReference       = spatialReferenceDialog.DoModalCreate(true, false, false, (int)System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle);

            if (spatialReference != null)
            {
                Mediator.NotifyColleagues(CoordinateToolLibrary.Constants.SpatialReferenceSelected, string.Format("{0}::{1}", spatialReference.FactoryCode, spatialReference.Name));
                return(true);
            }

            return(false);
        }
Beispiel #3
0
        private void btnPrjFile_Click(object sender, EventArgs e)
        {
            string sInstall = ReadRegistry("SOFTWARE\\ESRI\\CoreRuntime");

            if (sInstall == "") //added by chulili 2012-11-13 平台由ArcGIS9.3换成ArcGIS10,相应的注册表路径要修改
            {
                sInstall = ReadRegistry("SOFTWARE\\ESRI\\Engine10.0\\CoreRuntime");
            }
            if (sInstall == "")
            {
                sInstall = ReadRegistry("SOFTWARE\\ESRI\\Desktop10.0\\CoreRuntime");
            }   //added by chulili 2012-11-13  end
            sInstall = sInstall + "\\Coordinate Systems";

            OpenFileDialog filedialog = new OpenFileDialog();

            filedialog.Multiselect      = false;
            filedialog.InitialDirectory = sInstall;
            filedialog.Filter           = "*.prj|*.prj";
            filedialog.Title            = "选择prj文件";
            if (filedialog.ShowDialog() == DialogResult.OK)
            {
                string str = filedialog.FileName;
                this.txtPrjFile.Text = str;

                //直接读取坐标系统
                try
                {
                    ESRI.ArcGIS.Geometry.ISpatialReferenceFactory pPrjFac = new ESRI.ArcGIS.Geometry.SpatialReferenceEnvironmentClass();
                    ESRI.ArcGIS.Geometry.ISpatialReference        pSpa    = pPrjFac.CreateESRISpatialReferenceFromPRJFile(str);

                    m_strOutPrj = ExportToESRISpatialReference(pSpa);
                }
                catch
                {
                }
            }
        }
Beispiel #4
0
        private void LstAllLyrFile(IWorkspace pWks)
        {
            try
            {
                IFeatureWorkspace pFeaWks = pWks as IFeatureWorkspace;
                if (pFeaWks == null)
                {
                    return;
                }

                ESRI.ArcGIS.Geometry.ISpatialReference pSpa = null;

                IEnumDatasetName pEnumFeaCls = pWks.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
                IDatasetName     pFeaClsName = pEnumFeaCls.Next();
                while (pFeaClsName != null)
                {
                    if (pSpa == null)
                    {
                        IName         pPrjName    = pFeaClsName as IName;
                        IFeatureClass pFeaCls     = pPrjName.Open() as IFeatureClass;
                        IGeoDataset   pGeodataset = pFeaCls as IGeoDataset;

                        //获得空间参看 源的
                        pSpa       = pGeodataset.SpatialReference;
                        m_strInPrj = ExportToESRISpatialReference(pSpa);
                    }

                    this.lstLyrFile.Items.Add(pFeaClsName.Name);
                    pFeaClsName = pEnumFeaCls.Next();
                }

                IEnumDatasetName pEnumDataNames = pWks.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
                IDatasetName     pDatasetName   = pEnumDataNames.Next();
                while (pDatasetName != null)
                {
                    IEnumDatasetName pSubNames = pDatasetName.SubsetNames;
                    IDatasetName     pSubName  = pSubNames.Next();
                    while (pSubName != null)
                    {
                        if (pSpa == null)
                        {
                            IName         pPrjName    = pSubName as IName;
                            IFeatureClass pFeaCls     = pPrjName.Open() as IFeatureClass;
                            IGeoDataset   pGeodataset = pFeaCls as IGeoDataset;

                            //获得空间参看 源的
                            pSpa       = pGeodataset.SpatialReference;
                            m_strInPrj = ExportToESRISpatialReference(pSpa);
                        }

                        this.lstLyrFile.Items.Add(pSubName.Name);
                        pSubName = pSubNames.Next();
                    }

                    pDatasetName = pEnumDataNames.Next();
                }

                for (int i = 0; i < this.lstLyrFile.Items.Count; i++)
                {
                    this.lstLyrFile.Items[i].Checked = true;
                }
            }
            catch
            {
            }
        }
Beispiel #5
0
        private void button_Import_Click(object sender, System.EventArgs e)
        {
            // point to the first selected feature:
            ESRI.ArcGIS.Animation.IAGImportPathOptions AGImportPathOptionsCls = new ESRI.ArcGIS.Animation.AGImportPathOptionsClass();

            // Set properties for AGImportPathOptions
            AGImportPathOptionsCls.BasicMap        = (ESRI.ArcGIS.Carto.IBasicMap)globe;              // Explicit Cast
            AGImportPathOptionsCls.AnimationTracks = (ESRI.ArcGIS.Animation.IAGAnimationTracks)globe; // Explicit Cast
            AGImportPathOptionsCls.AnimationType   = new ESRI.ArcGIS.GlobeCore.AnimationTypeGlobeCameraClass();
            AGImportPathOptionsCls.AnimatedObject  = globe.GlobeDisplay.ActiveViewer.Camera;

            if (this.radioButton_flyby.Checked == true)
            {
                AGImportPathOptionsCls.ConversionType = esriFlyFromPathType.esriFlyFromPathObsAndTarget;
                AGImportPathOptionsCls.PutAngleCalculationMethods(esriPathAngleCalculation.esriAngleAddRelative, esriPathAngleCalculation.esriAngleAddRelative, esriPathAngleCalculation.esriAngleAddRelative);
                AGImportPathOptionsCls.PutAngleCalculationValues(0.0, 0.0, 0.0);
            }
            else if (this.radioButton_currentTarget.Checked == true)
            {
                AGImportPathOptionsCls.ConversionType = esriFlyFromPathType.esriFlyFromPathObserver;
            }
            else if (this.radioButton_currentObserver.Checked == true)
            {
                AGImportPathOptionsCls.ConversionType = esriFlyFromPathType.esriFlyFromPathTarget;
            }

            double pAzimuth, pInclination, pRollVal;

            AGImportPathOptionsCls.GetAngleCalculationValues(out pAzimuth, out pInclination, out pRollVal);

            AGImportPathOptionsCls.LookaheadFactor   = this.trackBarSimplificationFactor.Value / 100;
            AGImportPathOptionsCls.TrackName         = this.textBox_TrackName.Text;
            AGImportPathOptionsCls.OverwriteExisting = Convert.ToBoolean(this.checkBox_Overwrite.CheckState);
            AGImportPathOptionsCls.VerticalOffset    = Convert.ToDouble(this.textBox_VertOffset.Text);
            AGImportPathOptionsCls.ReversePath       = Convert.ToBoolean(this.checkBox_ReverseOrder.CheckState);

            // get the layer selected in the combo box
            if (this.comboBoxLayers.SelectedIndex == -1)
            {
                MessageBox.Show("Please select a layer before you proceed");
            }
            else
            {
                //set the layer based on the item selected in the combo box
                ESRI.ArcGIS.Carto.ILayer layer = (ESRI.ArcGIS.Carto.ILayer)layerArray.get_Element(this.comboBoxLayers.SelectedIndex);                  // Explicit Cast

                // Get the line feature selected in the layer
                ESRI.ArcGIS.Carto.IFeatureLayer       featureLayer     = (ESRI.ArcGIS.Carto.IFeatureLayer)layer;       // Explicit Cast
                ESRI.ArcGIS.Carto.IFeatureSelection   featureSelection = (ESRI.ArcGIS.Carto.IFeatureSelection)layer;   // Explicit Cast
                ESRI.ArcGIS.Geodatabase.ISelectionSet selectionSet     = featureSelection.SelectionSet;
                ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass     = featureLayer.FeatureClass;
                string shapeField = featureClass.ShapeFieldName;
                ESRI.ArcGIS.Geodatabase.ISpatialFilter spatialFilterCls = new ESRI.ArcGIS.Geodatabase.SpatialFilterClass();

                IScene scene = globe.GlobeDisplay.Scene;

                ESRI.ArcGIS.Geometry.ISpatialReference spatialReference = scene.SpatialReference;
                spatialFilterCls.GeometryField = shapeField;
                spatialFilterCls.set_OutputSpatialReference(shapeField, spatialReference);
                ESRI.ArcGIS.Geodatabase.ICursor cursor;
                selectionSet.Search(spatialFilterCls, true, out cursor);
                ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = (ESRI.ArcGIS.Geodatabase.IFeatureCursor)cursor;                 // Explicit Cast

                ESRI.ArcGIS.Geodatabase.IFeature lineFeature;
                lineFeature = featureCursor.NextFeature();
                if (lineFeature == null)
                {
                    MessageBox.Show("Please select a feature in the feature layer selected");
                }
                else
                {
                    CreateFlybyFromPathAnimation(globe, lineFeature, AGImportPathOptionsCls);
                }
            }
            this.Close();
        }