年度变更建库软件5.0版本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

91 lines
3.2 KiB

using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using KGIS.Framework.AE.ExtensionMethod;
using KGIS.Framework.Platform.Helper;
using KGIS.Framework.Utils;
using KGIS.Framework.Utils.ExtensionMethod;
using KGIS.Framework.Utils.Helper;
using System;
using System.Runtime.InteropServices;
using System.Windows;
using KUI.Windows;
namespace Kingo.Plugin.MapView.Views
{
/// <summary>
/// UcClaculationMJView.xaml 的交互逻辑
/// </summary>
public partial class UcClaculationMJView : BaseWindow
{
IFeatureLayer _TarLayer = null;
public UcClaculationMJView(object pLayer)
{
InitializeComponent();
if (pLayer is IFeatureLayer)
{
_TarLayer = pLayer as IFeatureLayer;
IFields fields = _TarLayer.FeatureClass.Fields;
for (int i = 0; i < fields.FieldCount; i++)
{
IField field = fields.Field[i];
if (!field.Name.EndsWith("MJ"))
continue;
if (field.Type != esriFieldType.esriFieldTypeDouble)
continue;
combField.Items.Add(string.Format("{0}({1})", field.AliasName, field.Name));
}
}
}
private void BtnOK_Click(object sender, RoutedEventArgs e)
{
IFeatureCursor cursor = null;
IFeature f = null;
try
{
if (combField.SelectedItem == null) return;
this.ShowLoading("正在进行椭球面积计算......", 0, 0);
string FieldInfo = combField.SelectedItem.ToTrim();
FieldInfo = FieldInfo.Substring(FieldInfo.IndexOf("(") + 1, FieldInfo.IndexOf(")") - FieldInfo.IndexOf("(") - 1);
cursor = _TarLayer.FeatureClass.Update(null, false);
int count = _TarLayer.FeatureClass.FeatureCount(null);
ProgressHelper.CountProgress = count;
int num = 0;
int idx = _TarLayer.FeatureClass.FindField(FieldInfo);
while ((f = cursor.NextFeature()) != null)
{
if (num % 100 == 0 || num == count)
{
ProgressHelper.CurrentProgress = num;
}
if (idx == -1) continue;
double mj = f.ShapeCopy.GetEllipseArea();
f.Value[idx] = mj.ToDouble(2);
cursor.UpdateFeature(f);
Marshal.ReleaseComObject(f);
}
this.CloseLoading();
MessageHelper.ShowTips("椭球面积计算成功!");
this.Close();
}
catch (Exception ex)
{
this.CloseLoading();
MessageHelper.Show("椭球面积计算失败!");
LogAPI.Debug("椭球面积计算时发生异常:");
LogAPI.Debug(ex);
}
finally
{
if (cursor != null)
Marshal.ReleaseComObject(cursor);
}
}
private void BtnCancel_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}