Пример #1
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);
            }
        }
 /// <summary>
 /// Sets the output projection for the transform to the one chosen here.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void comboBoxCoordSys_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         ISpatialReference         sr        = null;
         ISpatialReferenceFactory3 srFactory = new SpatialReferenceEnvironmentClass();
         if (comboBoxCoordSys.SelectedIndex == 4)
         {
             if (_map != null && _map.SpatialReference != null)
             {
                 sr           = _map.SpatialReference;
                 labelSR.Text = sr.Name;
             }
             else
             {
                 labelSR.Text = "";
             }
             buttonSR.Enabled = true;
             _transform.SetGeoTransform(null);
         }
         else
         {
             if (comboBoxCoordSys.SelectedIndex == 0)
             {
                 sr = srFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
                 _transform.SetGeoTransform(null);
             }
             else
             {
                 if (comboBoxCoordSys.SelectedIndex == 1)
                 {
                     sr = srFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_NAD1983UTM_10N);
                 }
                 else if (comboBoxCoordSys.SelectedIndex == 2)
                 {
                     sr = srFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_NAD1983UTM_11N);
                 }
                 else if (comboBoxCoordSys.SelectedIndex == 3)
                 {
                     sr = srFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_NAD1983UTM_12N);
                 }
                 IGeoTransformation trans = null;
                 trans = (IGeoTransformation)srFactory.CreateGeoTransformation(
                     (int)esriSRGeoTransformationType.esriSRGeoTransformation_NAD1983_To_WGS1984_1);
                 _transform.SetGeoTransform(trans);
             }
             labelSR.Text     = "";
             buttonSR.Enabled = false;
         }
         _transform.SetSpatialReference(sr);
         if ((_map.SpatialReference == null) || !((IClone)_map.SpatialReference).IsEqual((IClone)sr))
         {
             _map.SpatialReference = sr;
             ArcMap.Document.ActiveView.Refresh();
         }
         FillDatumTransform();
         EnableSelectInputs();
     }
     catch (Exception ex)
     {
         ShowError(ex.Message);
     }
 }