Пример #1
0
 /// <summary>
 /// Opens a dialog so the user can select a dataset containing the new data to be transformed.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void inputDatasetButton_Click(object sender, EventArgs e)
 {
     try
     {
         IGxObjectFilter           datasetFilter = new GxFilterFeatureDatasetsClass();
         IGxDialog                 dlg           = new GxDialogClass();
         IGxObjectFilterCollection filters       = (IGxObjectFilterCollection)dlg;
         filters.AddFilter(datasetFilter, true);
         dlg.Title         = "Select the feature dataset containing the data to be transformed";
         dlg.ButtonCaption = "Select";
         IEnumGxObject objects = null;
         if (dlg.DoModalOpen(0, out objects))
         {
             IGxObject obj = objects.Next();
             _inputDatasetName        = (IFeatureDatasetName2)obj.InternalObjectName;
             inputDatasetTextBox.Text = obj.Parent.Name + "/" + obj.Name;
             List <IDatasetName> fcNames =
                 EsriUtilities.GetFeatureClassNames(esriGeometryType.esriGeometryPoint,
                                                    _inputDatasetName);
             fcNames.Sort(_nameComparer);
             controlPointsComboBox.DataSource    = fcNames;
             controlPointsComboBox.DisplayMember = "Name";
             EnableSave();
         }
     }
     catch (Exception ex)
     {
         ShowError(ex.Message);
     }
 }
Пример #2
0
        /// <summary>
        /// Enables and disables the Select Inputs button based on values in the textboxes.
        /// </summary>
        private void EnableSelectInputs()
        {
            ISpatialReference sr = _transform.GetSpatialReference();

            buttonSelectInputs.Enabled = _bm1LongOK && _bm1LatOK && _bm1ElevOK && _bm2LongOK &&
                                         _bm2LatOK && _bm2ElevOK && _bm3LongOK && _bm3LatOK && _bm3ElevOK && _bearing12OK &&
                                         _bearing13OK && _bearing23OK && _workspaceOK && sr != null &&
                                         (EsriUtilities.IsWGS84(sr) || _transform.GetGeoTransform() != null);
        }
Пример #3
0
        /// <summary>
        /// Transforms and saves the data.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void saveButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Get spatial reference
                IFeatureClass benchmarks = (IFeatureClass)_benchmarkName.Open();
                _transform.SetSpatialReference(((IGeoDataset)benchmarks).SpatialReference);

                // Set benchmarks
                for (int i = 1; i < 4; i++)
                {
                    IFeature feature = benchmarks.GetFeature(i);
                    _transform.SetBenchmarkPoint(i, (IPoint)feature.ShapeCopy);
                }

                // Set total station benchmarks
                _transform.SetTSBenchmark(1, benchmark1ComboBox.Text);
                _transform.SetTSBenchmark(2, benchmark2ComboBox.Text);
                _transform.SetTSBenchmark(3, benchmark3ComboBox.Text);

                // Add data to be transformed
                foreach (IDatasetName dsName in EsriUtilities.GetFeatureClassNames(esriGeometryType.esriGeometryAny, _inputDatasetName))
                {
                    _transform.AddData((IFeatureClassName)dsName);
                }

                // Transform data
                IQueryFilter query = new QueryFilterClass();
                query.WhereClause = "\"Chosen\" = 1";
                ITable  table  = (ITable)_transformTableName.Open();
                ICursor cursor = table.Search(query, true);
                IRow    row    = cursor.NextRow();
                int     hinge  = Convert.ToInt32(((string)row.get_Value(table.FindField("Hinge"))).Split(' ')[1]);
                int     toBM   = Convert.ToInt32(((string)row.get_Value(table.FindField("Bearing"))).Split(' ')[2]);
                _transform.SaveData(hinge, toBM);

                // Close dialog
                Init();
                ChampExtension.GetExtension().GetApplyDockableWindow().Show(false);
                ArcMap.Document.ActiveView.Refresh();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
Пример #4
0
        /// <summary>
        /// Deletes any existing CHaMP graphics layers.
        /// </summary>
        private void DeleteGraphicsLayers()
        {
            string bearingId;

            for (int hingeIndex = 1; hingeIndex <= 3; hingeIndex++)
            {
                for (int bearingIndex = 1; bearingIndex <= 3; bearingIndex++)
                {
                    if (bearingIndex == hingeIndex)
                    {
                        continue;
                    }
                    bearingId = hingeIndex.ToString() + bearingIndex.ToString();
                    EsriUtilities.DeleteGraphicsLayer(_map, "gps" + bearingId);
                    EsriUtilities.DeleteGraphicsLayer(_map, "compass" + bearingId);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Fills the datum transformations comobo box with the transforms applicable to the
        /// selected projection and WGS84.
        /// </summary>
        private void FillDatumTransform()
        {
            ISpatialReference sr = _transform.GetSpatialReference();

            if (sr != null)
            {
                IGeoTransformation trans = _transform.GetGeoTransform();
                if (trans != null)
                {
                    List <IGeoTransformation> transList = EsriUtilities.GetTransformations(sr);
                    comboBoxGeoTrans.DataSource    = transList;
                    comboBoxGeoTrans.DisplayMember = "Name";
                    comboBoxGeoTrans.SelectedIndex = comboBoxGeoTrans.FindString(trans.Name);
                    comboBoxGeoTrans.Enabled       = true;
                }
                else
                {
                    if (EsriUtilities.IsWGS84(sr))
                    {
                        comboBoxGeoTrans.DataSource = null;
                        comboBoxGeoTrans.Enabled    = false;
                    }
                    else
                    {
                        List <IGeoTransformation> transList = EsriUtilities.GetTransformations(sr);
                        comboBoxGeoTrans.DataSource    = transList;
                        comboBoxGeoTrans.DisplayMember = "Name";
                        comboBoxGeoTrans.Enabled       = true;
                    }
                }
            }
            else
            {
                comboBoxGeoTrans.DataSource = null;
                comboBoxGeoTrans.Enabled    = false;
            }
        }