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.
1429 lines
74 KiB
1429 lines
74 KiB
using ESRI.ArcGIS.Carto; |
|
using ESRI.ArcGIS.Controls; |
|
using ESRI.ArcGIS.DataSourcesGDB; |
|
using ESRI.ArcGIS.Geodatabase; |
|
using ESRI.ArcGIS.Geometry; |
|
using KGIS.Framework.AE; |
|
using KGIS.Framework.AE.ExtensionMethod; |
|
using KGIS.Framework.AE.GPHelper; |
|
using KGIS.Framework.Maps; |
|
using KGIS.Framework.Platform; |
|
using KGIS.Framework.Utils; |
|
using KGIS.Framework.Utils.ExtensionMethod; |
|
using KGIS.Framework.Utils.Helper; |
|
using Kingo.Plugin.CZC_IDG.Helper; |
|
using Kingo.PluginServiceInterface; |
|
using KUI.Windows; |
|
using System; |
|
using System.Collections.Generic; |
|
using System.Data; |
|
using System.IO; |
|
using System.Linq; |
|
using System.Runtime.InteropServices; |
|
using System.Windows; |
|
|
|
namespace Kingo.Plugin.CZC_IDG.View |
|
{ |
|
/// <summary> |
|
/// FrmCZCBG.xaml 的交互逻辑 |
|
/// </summary> |
|
public partial class FrmCZCBG : BaseWindow |
|
{ |
|
private IFeatureClass _CZCFc = null; |
|
private IFeatureLayer _DLTBFc = null; |
|
private List<string> _ComList { get; set; } |
|
public FrmCZCBG() |
|
{ |
|
InitializeComponent(); |
|
_ComList = new List<string>(); |
|
} |
|
private void BtnSelectCZCLayer_Click(object sender, RoutedEventArgs e) |
|
{ |
|
//OpenDataDialog pDialog = new OpenDataDialog(); |
|
//ISpatialDataObjectFilter pOFilter; |
|
//pOFilter = new FilterDatasetsAndLayers(); |
|
//pDialog.AddFilter(pOFilter, true); |
|
//pDialog.Title = "选择导入的数据"; |
|
//pDialog.AllowMultiSelect = false; |
|
//pDialog.RestoreLocation = true; |
|
//pDialog.StartLocation = pDialog.FinalLocation; |
|
//System.Windows.Forms.DialogResult dialogResult = pDialog.ShowDialog(); |
|
//if (dialogResult == System.Windows.Forms.DialogResult.OK && pDialog.Selection.Count != 0) |
|
//{ |
|
// foreach (ISpatialDataObject distObj in pDialog.Selection) |
|
// { |
|
// if (distObj.DatasetType == esriDatasetType.esriDTFeatureClass) |
|
// { |
|
// if (_ComList == null) |
|
// _ComList = new List<string>(); |
|
// if (!_ComList.Contains(pDialog.FinalLocation)) |
|
// _ComList.Add(pDialog.FinalLocation); |
|
// combCZCFW.ItemsSource = _ComList; |
|
// combCZCFW.SelectedItem = pDialog.FinalLocation; |
|
// //combCZCFW.Text = pDialog.FinalLocation; |
|
// _CZCFc = (distObj.DatasetName as IName).Open() as IFeatureClass; |
|
// } |
|
// } |
|
//} |
|
} |
|
|
|
IFeatureLayer _DLTBGXLayer_Mem = null; |
|
IFeatureLayer _DLTBGX201Layer_Mem = null; |
|
IFeatureLayer _DLTBGX202Layer_Mem = null; |
|
IFeatureLayer _DLTBGX203Layer_Mem = null; |
|
IFeatureLayer _DLTBGX204Layer_Mem = null; |
|
IFeatureLayer _DLTBGX205Layer_Mem = null; |
|
|
|
IFeatureLayer _CZC20XLayer_Mem = null; |
|
IFeatureLayer _CZC201Layer_Mem = null; |
|
IFeatureLayer _CZC202Layer_Mem = null; |
|
IFeatureLayer _CZC203Layer_Mem = null; |
|
IFeatureLayer _CZC204Layer_Mem = null; |
|
IFeatureLayer _CZC205Layer_Mem = null; |
|
string MaxBSM = string.Empty; |
|
private EngineEditorClass m_EngineEditor; |
|
private void BtnOK_Click(object sender, RoutedEventArgs e) |
|
{ |
|
try |
|
{ |
|
ProjectInfo projectInfo = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo); |
|
_CZCFc = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("城镇村等用地").FeatureClass; |
|
if (_CZCFc == null) |
|
{ |
|
MessageHelper.Show("未获取到工程下的基础城镇村等用地图层"); |
|
return; |
|
} |
|
if (m_EngineEditor == null) |
|
{ |
|
m_EngineEditor = new EngineEditorClass(); |
|
} |
|
if (m_EngineEditor.EditState != esriEngineEditState.esriEngineStateNotEditing) |
|
{ |
|
MessageHelper.Show("请先关闭编辑。"); |
|
return; |
|
} |
|
if (string.IsNullOrWhiteSpace((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE)) |
|
{ |
|
MessageHelper.Show("县行政区划代码不能为空,请在工程属性界面中填写6位县区划代码!"); |
|
return; |
|
} |
|
this.ShowLoading("正在进行城镇村范围变更...", 0, 0); |
|
CZCDYDHelper helper = new CZCDYDHelper(); |
|
helper.Implement(_CZCFc, ckbDelMinMJ.IsChecked == true, ckbXDM.IsChecked == true); |
|
this.CloseLoading(); |
|
MessageHelper.Show("完成"); |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw ex; |
|
} |
|
} |
|
|
|
|
|
|
|
private void CZCGXExe2(object param = null) |
|
{ |
|
try |
|
{ |
|
string gdbFolder = Directory.GetCurrentDirectory() + "\\Temp\\CZCGX"; |
|
if (!System.IO.Directory.Exists(gdbFolder)) |
|
{ |
|
System.IO.Directory.CreateDirectory(gdbFolder); |
|
} |
|
try |
|
{ |
|
DelectDir(gdbFolder);//能删除就删除 删除报错不处理 |
|
} |
|
catch |
|
{ } |
|
BasicDataModel[] dicXZQ = Platform.Instance.DicHelper.GetXZQDic(1); |
|
if (dicXZQ == null) |
|
dicXZQ = new BasicDataModel[] { }; |
|
List<DataDicTionary> dicQS = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.QSDM); |
|
if (dicQS == null) |
|
dicQS = new List<DataDicTionary>(); |
|
IWorkspaceFactory pFtWsFct = null; |
|
IWorkspaceName workspaceName = null; |
|
IWorkspace pWorkspace = null; |
|
pFtWsFct = new FileGDBWorkspaceFactory(); |
|
|
|
string gdbFileName = Guid.NewGuid().ToString() + ".gdb"; |
|
string path = System.IO.Path.Combine(gdbFolder, gdbFileName); |
|
|
|
workspaceName = pFtWsFct.Create(gdbFolder, gdbFileName, null, 0); |
|
GPParamClass gPParamClass = new GPParamClass(); |
|
|
|
IFeatureLayer new20Layer = null; |
|
gPParamClass.FirstFeatureClass = _DLTBGX201Layer_Mem.FeatureClass; |
|
gPParamClass.SecondFeatureClass = _CZC201Layer_Mem.FeatureClass; |
|
gPParamClass.OutFeatureClassPath = path + "\\" + "DLTBGX201"; |
|
gPParamClass.IsGetOutPutFeature = true; |
|
GeoprocessorHelper.EraseAnalysis(gPParamClass, ref new20Layer); |
|
InsertDataToMemeoryLayer(new20Layer.FeatureClass, _DLTBGXLayer_Mem.FeatureClass); |
|
Marshal.ReleaseComObject(new20Layer.FeatureClass); |
|
Marshal.ReleaseComObject(new20Layer); |
|
|
|
gPParamClass.FirstFeatureClass = _DLTBGX202Layer_Mem.FeatureClass; |
|
gPParamClass.SecondFeatureClass = _CZC202Layer_Mem.FeatureClass; |
|
gPParamClass.OutFeatureClassPath = path + "\\" + "DLTBGX202"; |
|
gPParamClass.IsGetOutPutFeature = true; |
|
GeoprocessorHelper.EraseAnalysis(gPParamClass, ref new20Layer); |
|
InsertDataToMemeoryLayer(new20Layer.FeatureClass, _DLTBGXLayer_Mem.FeatureClass); |
|
Marshal.ReleaseComObject(new20Layer.FeatureClass); |
|
Marshal.ReleaseComObject(new20Layer); |
|
|
|
gPParamClass.FirstFeatureClass = _DLTBGX203Layer_Mem.FeatureClass; |
|
gPParamClass.SecondFeatureClass = _CZC203Layer_Mem.FeatureClass; |
|
gPParamClass.OutFeatureClassPath = path + "\\" + "DLTBGX203"; |
|
gPParamClass.IsGetOutPutFeature = true; |
|
GeoprocessorHelper.EraseAnalysis(gPParamClass, ref new20Layer); |
|
InsertDataToMemeoryLayer(new20Layer.FeatureClass, _DLTBGXLayer_Mem.FeatureClass); |
|
Marshal.ReleaseComObject(new20Layer.FeatureClass); |
|
Marshal.ReleaseComObject(new20Layer); |
|
|
|
gPParamClass.FirstFeatureClass = _DLTBGX204Layer_Mem.FeatureClass; |
|
gPParamClass.SecondFeatureClass = _CZC204Layer_Mem.FeatureClass; |
|
gPParamClass.OutFeatureClassPath = path + "\\" + "DLTBGX204"; |
|
gPParamClass.IsGetOutPutFeature = true; |
|
GeoprocessorHelper.EraseAnalysis(gPParamClass, ref new20Layer); |
|
InsertDataToMemeoryLayer(new20Layer.FeatureClass, _DLTBGXLayer_Mem.FeatureClass); |
|
Marshal.ReleaseComObject(new20Layer.FeatureClass); |
|
Marshal.ReleaseComObject(new20Layer); |
|
|
|
gPParamClass.FirstFeatureClass = _DLTBGX205Layer_Mem.FeatureClass; |
|
gPParamClass.SecondFeatureClass = _CZC205Layer_Mem.FeatureClass; |
|
gPParamClass.OutFeatureClassPath = path + "\\" + "DLTBGX205"; |
|
gPParamClass.IsGetOutPutFeature = true; |
|
GeoprocessorHelper.EraseAnalysis(gPParamClass, ref new20Layer); |
|
InsertDataToMemeoryLayer(new20Layer.FeatureClass, _DLTBGXLayer_Mem.FeatureClass); |
|
Marshal.ReleaseComObject(new20Layer.FeatureClass); |
|
Marshal.ReleaseComObject(new20Layer); |
|
|
|
IQueryFilter filter = new QueryFilterClass(); |
|
filter.SubFields = "ZLDWDM,ZLDWMC,CZCSXM"; |
|
ICursor cur = (_DLTBGXLayer_Mem.FeatureClass as ITable).Update(filter, true); |
|
IRow _Row = null; |
|
int idxZLDWDM = _DLTBGXLayer_Mem.FeatureClass.FindField("ZLDWDM"); |
|
int idxZLDWMC = _DLTBGXLayer_Mem.FeatureClass.FindField("ZLDWMC"); |
|
int idxCZCSXM = _DLTBGXLayer_Mem.FeatureClass.FindField("CZCSXM"); |
|
while ((_Row = cur.NextRow()) != null) |
|
{ |
|
string strZLDWDM = _Row.Value[idxZLDWDM].ToTrim(); |
|
string strZLDWMC = _Row.Value[idxZLDWMC].ToTrim(); |
|
string strCZCSXM = _Row.Value[idxCZCSXM].ToTrim(); |
|
|
|
string newCZCDM = string.Empty; |
|
string newCZCMC = string.Empty; |
|
#region 获取城镇村代码与名称 |
|
|
|
if (!string.IsNullOrWhiteSpace(strZLDWDM)) |
|
{ |
|
if ("201,201A".Contains(strCZCSXM)) |
|
{ |
|
newCZCDM = strZLDWDM.Substring(0, 6).PadRight(19, '0'); |
|
var xzq = dicXZQ.ToList().Find(p => p.Code == newCZCDM.Substring(0, 6)); |
|
if (xzq != null) |
|
{ |
|
newCZCMC = xzq.Name; |
|
} |
|
_Row.Value[idxZLDWDM] = newCZCDM; |
|
_Row.Value[idxZLDWMC] = newCZCMC; |
|
} |
|
else if ("202,202A".Contains(strCZCSXM)) |
|
{ |
|
newCZCDM = strZLDWDM.Substring(0, 9).PadRight(19, '0'); |
|
var xzq = dicQS.Find(p => p.CODE == newCZCDM || p.CODE == newCZCDM.Substring(0, 9)); |
|
if (xzq != null) |
|
{ |
|
newCZCMC = xzq.NAME; |
|
} |
|
_Row.Value[idxZLDWDM] = newCZCDM; |
|
_Row.Value[idxZLDWMC] = newCZCMC; |
|
} |
|
cur.UpdateRow(_Row); |
|
} |
|
#endregion |
|
} |
|
|
|
IFeatureLayer newCZCLayer = null; |
|
gPParamClass.FirstFeatureClass = _DLTBGXLayer_Mem.FeatureClass; |
|
gPParamClass.OutFeatureClassPath = path + "\\" + "NewCZC"; |
|
gPParamClass.ListDissolveFiledName = new List<string>() { "ZLDWDM", "ZLDWMC", "CZCSXM" }; |
|
gPParamClass.IsGetOutPutFeature = true; |
|
GeoprocessorHelper.DissolveAnalysis(gPParamClass, ref newCZCLayer); |
|
|
|
IFeatureLayer czcUnionLayer = null; |
|
gPParamClass.FirstFeatureClass = newCZCLayer.FeatureClass; |
|
gPParamClass.SecondFeatureClass = _CZC20XLayer_Mem.FeatureClass; |
|
gPParamClass.OutFeatureClassPath = path + "\\" + "DLTBGX_Diss"; |
|
gPParamClass.IsGetOutPutFeature = true; |
|
GeoprocessorHelper.UnionAnalysis(gPParamClass, ref czcUnionLayer); |
|
|
|
IFeatureLayer czcUnionMToSLayer = null; |
|
gPParamClass.FirstFeatureClass = czcUnionLayer.FeatureClass; |
|
gPParamClass.OutFeatureClassPath = path + "\\" + "CZCUnionMToS"; |
|
gPParamClass.IsGetOutPutFeature = true; |
|
GeoprocessorHelper.MultipartToSinglePath(gPParamClass, ref czcUnionMToSLayer); |
|
//删除更新前后非20范围数据 |
|
(czcUnionMToSLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("DELETE from CZCUnionMToS where (CZCSXM is NULL or CZCSXM = '') and FID_CZC20X = -1")); |
|
//删除未变化数据 |
|
//(czcUnionMToSLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("Delete from CZCUnionMToS where FID_NewCZC = -1")); |
|
|
|
filter.WhereClause = " FID_NewCZC = -1"; |
|
filter.SubFields = "OBJECTID,FID_CZC20X"; |
|
ITable itb = czcUnionMToSLayer.FeatureClass as ITable; |
|
ICursor TbCursor = itb.Search(filter, true); |
|
IRow row = null; |
|
Dictionary<int, int> TempDic = new Dictionary<int, int>(); |
|
Dictionary<int, int> TempDelOids = new Dictionary<int, int>(); |
|
//List<int> delOids = new List<int>(); |
|
int idx = itb.FindField("FID_CZC20X"); |
|
while ((row = TbCursor.NextRow()) != null) |
|
{ |
|
int key = Convert.ToInt32(row.Value[idx]); |
|
if (TempDic.ContainsKey(key)) |
|
{ |
|
TempDic[key]++; |
|
} |
|
else |
|
{ |
|
TempDic.Add(key, 1); |
|
} |
|
TempDelOids.Add(row.OID, key); |
|
} |
|
foreach (var item in TempDelOids.Keys) |
|
{ |
|
if (TempDic[TempDelOids[item]] == 1) |
|
itb.GetRow(item).Delete(); |
|
} |
|
IFeatureClassAPI tempFcAPI = new FeatureClassAPI(czcUnionMToSLayer.FeatureClass); |
|
tempFcAPI.AddField("BGXW", esriFieldType.esriFieldTypeInteger, "变更行为"); |
|
(czcUnionMToSLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("Update CZCUnionMToS set BGXW=3 where FID_NewCZC <>-1 and FID_CZC20X = -1 ")); |
|
(czcUnionMToSLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("Update CZCUnionMToS set BGXW=0 where CZCSXM is null")); |
|
|
|
|
|
//IFeatureLayer newJCCZCLayer = null; |
|
//gPParamClass.FirstFeatureClass = _CZC20XLayer_Mem.FeatureClass; |
|
//gPParamClass.SecondFeatureClass = czcUnionMToSLayer.FeatureClass; |
|
//gPParamClass.OutFeatureClassPath = path + "\\" + "DLTBGX205"; |
|
//gPParamClass.IsGetOutPutFeature = true; |
|
//GeoprocessorHelper.EraseAnalysis(gPParamClass, ref newJCCZCLayer); |
|
//(_CZC20XLayer_Mem.FeatureClass as ITable).DeleteSearchedRows(null); |
|
//InsertDataToMemeoryLayer(newJCCZCLayer.FeatureClass, _CZC20XLayer_Mem.FeatureClass); |
|
//Marshal.ReleaseComObject(newJCCZCLayer.FeatureClass); |
|
//Marshal.ReleaseComObject(newJCCZCLayer); |
|
|
|
|
|
IFeatureLayer tempCZC203Layer = GeoDBAPI.CreateFeatureLayerInmemeory("CZC203", "城镇村203范围", (_CZCFc as IGeoDataset).SpatialReference, _CZCFc.ShapeType, _CZCFc.Fields); |
|
IFeatureClassAPI temp203FcAPI = new FeatureClassAPI(tempCZC203Layer.FeatureClass); |
|
temp203FcAPI.AddField("BGXW", esriFieldType.esriFieldTypeInteger, "变更行为"); |
|
filter.WhereClause = "BGXW = 3 or BGXW = 0"; |
|
IFeatureCursor cursor = czcUnionMToSLayer.FeatureClass.Search(null, true); |
|
IFeature feature = null; |
|
int idx_FID_NewCZC = czcUnionMToSLayer.FeatureClass.FindField("FID_NewCZC"); |
|
int idx_FID_CZC20X = czcUnionMToSLayer.FeatureClass.FindField("FID_CZC20X"); |
|
int idx_CZCSXM = czcUnionMToSLayer.FeatureClass.FindField("CZCSXM"); |
|
int idx_ZLDWDM = czcUnionMToSLayer.FeatureClass.FindField("ZLDWDM"); |
|
int idx_ZLDWMC = czcUnionMToSLayer.FeatureClass.FindField("ZLDWMC"); |
|
int idx_CZCLX = czcUnionMToSLayer.FeatureClass.FindField("CZCLX"); |
|
int idx_CZCDM = czcUnionMToSLayer.FeatureClass.FindField("CZCDM"); |
|
int idx_CZCMC = czcUnionMToSLayer.FeatureClass.FindField("CZCMC"); |
|
int idx_CZCMJ = czcUnionMToSLayer.FeatureClass.FindField("CZCMJ"); |
|
int idx_BGXW = czcUnionMToSLayer.FeatureClass.FindField("BGXW"); |
|
int idx_BSM = czcUnionMToSLayer.FeatureClass.FindField("BSM"); |
|
List<CZCGX> ListGX = new List<CZCGX>(); |
|
List<int> unionOldOIDs = new List<int>(); |
|
while ((feature = cursor.NextFeature()) != null) |
|
{ |
|
if (feature.OID == 12183)//|| feature.OID == 10432|| feature.OID == 10433 |
|
{ |
|
} |
|
//IFeatureBuffer buff = tempCZC203Layer.FeatureClass.CreateFeatureBuffer(); |
|
int FID_NewCZC = Convert.ToInt32(feature.Value[idx_FID_NewCZC]); |
|
int FID_CZC20X = Convert.ToInt32(feature.Value[idx_FID_CZC20X]); |
|
string CZCSXM = feature.Value[idx_CZCSXM].ToTrim(); |
|
string ZLDWDM = feature.Value[idx_ZLDWDM].ToTrim(); |
|
string ZLDWMC = feature.Value[idx_ZLDWMC].ToTrim(); |
|
string CZCLX = feature.Value[idx_CZCLX].ToTrim(); |
|
string CZCDM = feature.Value[idx_CZCDM].ToTrim(); |
|
string CZCMC = feature.Value[idx_CZCMC].ToTrim(); |
|
string CZCMJ = feature.Value[idx_CZCMJ].ToTrim(); |
|
string bgxw = feature.Value[idx_BGXW].ToTrim(); |
|
string bsm = feature.Value[idx_BSM].ToTrim(); |
|
string newCZCDM = ZLDWDM; |
|
string newCZCMC = ZLDWMC; |
|
CZCGX gx = new CZCGX(); |
|
if (bgxw == "3") |
|
{ |
|
ListGX.Add(gx); |
|
gx.CZCLX = CZCSXM; |
|
gx.CZCDM = newCZCDM; |
|
gx.CZCMC = newCZCMC; |
|
gx.Shape = feature.ShapeCopy; |
|
gx.GCList.Add(new CZCGXGC() |
|
{ |
|
Shape = feature.ShapeCopy, |
|
BGXW = bgxw, |
|
BGMJ = feature.ShapeCopy.GetEllipseArea(), |
|
BGHCZCDM = newCZCDM, |
|
BGHCZCMC = newCZCMC, |
|
BGHCZCLX = CZCSXM |
|
}); |
|
gx.BSM = "AddNew"; |
|
if (gx.CZCLX == "203" || gx.CZCLX == "203A") continue; |
|
List<IFeature> tempCzcs = FeatureAPI.Identify(gx.Shape, czcUnionMToSLayer); |
|
//int idxOldCzcOID = czcUnionMToSLayer; |
|
foreach (var item in tempCzcs) |
|
{ |
|
if (item.OID == feature.OID) continue; |
|
int tempBGHOID = Convert.ToInt32(item.Value[idx_FID_NewCZC]); |
|
string tempCZCLX = item.Value[idx_CZCLX].ToTrim(); |
|
string tempCZCDM = item.Value[idx_CZCDM].ToTrim(); |
|
string tempCZCMC = item.Value[idx_CZCMC].ToTrim(); |
|
if (tempBGHOID != -1) |
|
{ |
|
tempCZCLX = item.Value[idx_CZCSXM].ToTrim(); |
|
tempCZCDM = item.Value[idx_ZLDWDM].ToTrim(); |
|
tempCZCMC = item.Value[idx_ZLDWMC].ToTrim(); |
|
} |
|
string tempBGXW = item.Value[idx_BGXW].ToTrim(); |
|
if (tempCZCLX == gx.CZCLX && tempCZCDM == gx.CZCDM && tempCZCMC == gx.CZCMC && tempBGXW != "0" && FeatureAPI.IsAdjacent(item.ShapeCopy, gx.Shape)) |
|
{ |
|
int oldOID = Convert.ToInt32(item.Value[idx_FID_CZC20X]); |
|
if (oldOID == 25682) |
|
{ |
|
|
|
} |
|
if (oldOID != -1) |
|
{ |
|
unionOldOIDs.Add(oldOID); |
|
} |
|
gx.Shape = FeatureAPI.Union(item.ShapeCopy, gx.Shape); |
|
gx.GCList.Add(new CZCGXGC() |
|
{ |
|
Shape = item.ShapeCopy, |
|
BGXW = "2", |
|
BGMJ = item.ShapeCopy.GetEllipseArea(), |
|
BGQCZCLX = item.Value[idx_CZCLX].ToTrim(), |
|
BGQCZCDM = item.Value[idx_CZCDM].ToTrim(), |
|
BGQCZCMC = item.Value[idx_CZCMC].ToTrim(), |
|
BGQBSM = item.Value[idx_BSM].ToTrim(), |
|
BGHCZCDM = newCZCDM, |
|
BGHCZCMC = newCZCMC, |
|
BGHCZCLX = CZCSXM |
|
}); |
|
item.Delete(); |
|
} |
|
} |
|
List<IFeature> jcCzcs = FeatureAPI.Identify(gx.Shape, _CZC20XLayer_Mem); |
|
int idx_JCCZCLX = _CZC20XLayer_Mem.FeatureClass.FindField("CZCLX"); |
|
int idx_JCCZCDM = _CZC20XLayer_Mem.FeatureClass.FindField("CZCDM"); |
|
int idx_JCCZCMC = _CZC20XLayer_Mem.FeatureClass.FindField("CZCMC"); |
|
int idx_JCBSM = _CZC20XLayer_Mem.FeatureClass.FindField("BSM"); |
|
foreach (var item in jcCzcs) |
|
{ |
|
string jcCZCLX = item.Value[idx_JCCZCLX].ToTrim(); |
|
string jcCZCDM = item.Value[idx_JCCZCDM].ToTrim(); |
|
string jcCZCMC = item.Value[idx_JCCZCMC].ToTrim(); |
|
//string tempCZCLX = item.Value[idx_CZCLX].ToTrim(); |
|
string tempBSM = item.Value[idx_JCBSM].ToTrim(); |
|
if (jcCZCLX == gx.CZCLX && jcCZCDM == gx.CZCDM && jcCZCMC == gx.CZCMC && FeatureAPI.IsAdjacent(item.ShapeCopy, gx.Shape)) |
|
{ |
|
IGeometry tmpGeo = feature.ShapeCopy; |
|
CZCGX gx1 = ListGX.FirstOrDefault(f => f.UpdateOID.Contains(item.OID)); |
|
if (gx1 != null) |
|
{ |
|
gx1.Shape = FeatureAPI.Union(gx1.Shape, gx.Shape); |
|
gx1.GCList.AddRange(gx.GCList); |
|
ListGX.Remove(gx); |
|
gx = gx1; |
|
continue; |
|
} |
|
else |
|
{ |
|
gx.Shape = FeatureAPI.Union(item.ShapeCopy, gx.Shape); |
|
} |
|
//if (oldOID != -1) |
|
//{ |
|
// unionOldOIDs.Add(oldOID); |
|
//} |
|
gx.UpdateOID.Add(item.OID); |
|
//if (unionOldOIDs.Contains(item.OID)) continue; |
|
gx.GCList.Add(new CZCGXGC() |
|
{ |
|
Shape = item.ShapeCopy, |
|
BGXW = "2", |
|
BGMJ = item.ShapeCopy.GetEllipseArea(), |
|
BGQBSM = tempBSM, |
|
BGQCZCLX = jcCZCLX, |
|
BGQCZCDM = jcCZCDM, |
|
BGQCZCMC = jcCZCMC, |
|
BGHCZCDM = jcCZCDM, |
|
BGHCZCMC = jcCZCMC, |
|
BGHCZCLX = jcCZCLX |
|
}); |
|
} |
|
else if (unionOldOIDs.Contains(item.OID)) |
|
{ |
|
CZCGX gx1 = ListGX.FirstOrDefault(f => f.UpdateOID.Contains(item.OID)); |
|
if (gx1 != null) |
|
{ |
|
gx1.Shape = FeatureAPI.Difference(gx1.Shape, gx.Shape); |
|
gx1.GCList.ForEach(f => f.Shape = gx1.Shape); |
|
//gx1.GCList.AddRange(gx.GCList); |
|
//ListGX.Remove(gx); |
|
//gx = gx1; |
|
continue; |
|
} |
|
else |
|
{ |
|
gx1 = new CZCGX(); |
|
gx1.BSM = "AddNew"; |
|
gx1.CZCLX = item.Value[idx_JCCZCLX].ToTrim(); |
|
gx1.CZCDM = item.Value[idx_JCCZCDM].ToTrim(); |
|
gx1.CZCMC = item.Value[idx_JCCZCMC].ToTrim(); |
|
gx1.Shape = FeatureAPI.Difference(item.ShapeCopy, gx.Shape); |
|
gx1.UpdateOID.Add(item.OID); |
|
gx1.GCList.Add(new CZCGXGC() |
|
{ |
|
Shape = gx1.Shape, |
|
BGQBSM = tempBSM, |
|
BGQCZCLX = gx1.CZCLX, |
|
BGQCZCDM = gx1.CZCDM, |
|
BGQCZCMC = gx1.CZCMC, |
|
BGHCZCLX = gx1.CZCLX, |
|
BGHCZCDM = gx1.CZCDM, |
|
BGHCZCMC = gx1.CZCMC, |
|
BGMJ = item.ShapeCopy.GetEllipseArea(), |
|
BGXW = "2" |
|
}); |
|
ListGX.Add(gx1); |
|
continue; |
|
//gx.Shape = FeatureAPI.Union(item.ShapeCopy, gx.Shape); |
|
} |
|
//if (oldOID != -1) |
|
//{ |
|
// unionOldOIDs.Add(oldOID); |
|
//} |
|
gx.UpdateOID.Add(item.OID); |
|
//if (unionOldOIDs.Contains(item.OID)) continue; |
|
gx.GCList.Add(new CZCGXGC() |
|
{ |
|
Shape = item.ShapeCopy, |
|
BGXW = "2", |
|
BGMJ = item.ShapeCopy.GetEllipseArea(), |
|
BGQBSM = tempBSM, |
|
BGQCZCLX = jcCZCLX, |
|
BGQCZCDM = jcCZCDM, |
|
BGQCZCMC = jcCZCMC, |
|
BGHCZCDM = jcCZCDM, |
|
BGHCZCMC = jcCZCMC, |
|
BGHCZCLX = jcCZCLX |
|
}); |
|
} |
|
} |
|
} |
|
else if (bgxw == "0") |
|
{ |
|
ListGX.Add(gx); |
|
gx.Shape = feature.ShapeCopy; |
|
List<IFeature> jcCzcs = FeatureAPI.Identify(gx.Shape, _CZC20XLayer_Mem); |
|
foreach (var item in jcCzcs) |
|
{ |
|
CZCGX gx1 = ListGX.FirstOrDefault(f => f.UpdateOID.Contains(item.OID)); |
|
if (gx1 != null) |
|
{ |
|
if (FeatureAPI.IsInterSect(gx1.Shape, gx.Shape)) |
|
{ |
|
gx1.Shape = FeatureAPI.Difference(gx1.Shape, gx.Shape); |
|
foreach (var gc in gx1.GCList) |
|
{ |
|
if (FeatureAPI.IsInterSect(gc.Shape, gx.Shape)) |
|
gc.Shape = FeatureAPI.Difference(gc.Shape, gx.Shape); |
|
} |
|
} |
|
} |
|
else |
|
{ |
|
IGeometry upGeo = FeatureAPI.Difference(item.ShapeCopy, feature.ShapeCopy); |
|
if (upGeo == null || upGeo.IsEmpty) continue; |
|
int idx_JCCZCLX = _CZC20XLayer_Mem.FeatureClass.FindField("CZCLX"); |
|
int idx_JCCZCDM = _CZC20XLayer_Mem.FeatureClass.FindField("CZCDM"); |
|
int idx_JCCZCMC = _CZC20XLayer_Mem.FeatureClass.FindField("CZCMC"); |
|
int idx_JCBSM = _CZC20XLayer_Mem.FeatureClass.FindField("BSM"); |
|
string bgqbsm = item.Value[idx_JCBSM].ToTrim(); |
|
if (bgqbsm != bsm) |
|
{ |
|
continue; |
|
} |
|
gx1 = new CZCGX(); |
|
gx1.BSM = "AddNew"; |
|
gx1.CZCLX = item.Value[idx_JCCZCLX].ToTrim(); |
|
gx1.CZCDM = item.Value[idx_JCCZCDM].ToTrim(); |
|
gx1.CZCMC = item.Value[idx_JCCZCMC].ToTrim(); |
|
gx1.Shape = upGeo; |
|
gx1.UpdateOID.Add(item.OID); |
|
gx1.GCList.Add(new CZCGXGC() |
|
{ |
|
Shape = upGeo, |
|
BGQBSM = bsm, |
|
BGQCZCLX = CZCLX, |
|
BGQCZCDM = CZCDM, |
|
BGQCZCMC = CZCMC, |
|
BGHCZCLX = gx1.CZCLX, |
|
BGHCZCDM = gx1.CZCDM, |
|
BGHCZCMC = gx1.CZCMC, |
|
BGMJ = item.ShapeCopy.GetEllipseArea(), |
|
BGXW = "2" |
|
}); |
|
ListGX.Add(gx1); |
|
} |
|
} |
|
gx.CZCLX = ""; |
|
gx.CZCDM = ""; |
|
gx.CZCMC = ""; |
|
gx.Shape = null; |
|
gx.GCList.Add(new CZCGXGC() |
|
{ |
|
Shape = feature.ShapeCopy, |
|
BGQBSM = bsm, |
|
BGQCZCLX = CZCLX, |
|
BGQCZCDM = CZCDM, |
|
BGQCZCMC = CZCMC, |
|
BGMJ = feature.ShapeCopy.GetEllipseArea(), |
|
BGXW = bgxw |
|
}); |
|
} |
|
else |
|
{ |
|
ListGX.Add(gx); |
|
if (string.IsNullOrWhiteSpace(CZCSXM)) |
|
{ |
|
gx.CZCLX = CZCLX; |
|
gx.CZCDM = CZCDM; |
|
gx.CZCMC = CZCMC; |
|
gx.Shape = feature.ShapeCopy; |
|
bgxw = "2"; |
|
gx.BSM = "AddNew"; |
|
gx.GCList.Add(new CZCGXGC() |
|
{ |
|
Shape = feature.ShapeCopy, |
|
BGXW = bgxw, |
|
BGMJ = feature.ShapeCopy.GetEllipseArea(), |
|
BGQBSM = bsm, |
|
BGQCZCLX = CZCLX, |
|
BGQCZCDM = CZCDM, |
|
BGQCZCMC = CZCMC, |
|
BGHCZCDM = CZCDM, |
|
BGHCZCMC = CZCMC, |
|
BGHCZCLX = CZCLX |
|
}); |
|
gx.BSM = "AddNew"; |
|
if (gx.CZCLX == "203" || gx.CZCLX == "203A") |
|
{ |
|
ListGX.Remove(gx); |
|
continue; |
|
} |
|
List<IFeature> jcCzcs = FeatureAPI.Identify(gx.Shape, _CZC20XLayer_Mem); |
|
int idx_JCCZCLX = _CZC20XLayer_Mem.FeatureClass.FindField("CZCLX"); |
|
int idx_JCCZCDM = _CZC20XLayer_Mem.FeatureClass.FindField("CZCDM"); |
|
int idx_JCCZCMC = _CZC20XLayer_Mem.FeatureClass.FindField("CZCMC"); |
|
int idx_JCBSM = _CZC20XLayer_Mem.FeatureClass.FindField("BSM"); |
|
foreach (var item in jcCzcs) |
|
{ |
|
string jcCZCLX = item.Value[idx_JCCZCLX].ToTrim(); |
|
string jcCZCDM = item.Value[idx_JCCZCDM].ToTrim(); |
|
string jcCZCMC = item.Value[idx_JCCZCMC].ToTrim(); |
|
//string tempCZCLX = item.Value[idx_CZCLX].ToTrim(); |
|
string tempBSM = item.Value[idx_JCBSM].ToTrim(); |
|
if (jcCZCLX == CZCLX && jcCZCDM == CZCDM && jcCZCMC == CZCMC && FeatureAPI.IsAdjacent(item.ShapeCopy, gx.Shape)) |
|
{ |
|
gx.Shape = FeatureAPI.Union(item.ShapeCopy, gx.Shape); |
|
gx.GCList.Add(new CZCGXGC() |
|
{ |
|
Shape = item.ShapeCopy, |
|
BGXW = "2", |
|
BGMJ = item.ShapeCopy.GetEllipseArea(), |
|
BGQBSM = tempBSM, |
|
BGQCZCLX = jcCZCLX, |
|
BGQCZCDM = jcCZCDM, |
|
BGQCZCMC = jcCZCMC, |
|
BGHCZCDM = CZCDM, |
|
BGHCZCMC = CZCMC, |
|
BGHCZCLX = CZCLX |
|
}); |
|
} |
|
else if (FeatureAPI.IsInterSect(item.ShapeCopy, gx.Shape)) |
|
{ |
|
CZCGX gx1 = ListGX.FirstOrDefault(f => f.UpdateOID.Contains(item.OID)); |
|
if (gx1 != null) |
|
{ |
|
gx1.Shape = FeatureAPI.Difference(gx1.Shape, gx.Shape); |
|
gx1.GCList.ForEach(f => f.Shape = gx1.Shape); |
|
//gx1.GCList.AddRange(gx.GCList); |
|
//ListGX.Remove(gx); |
|
//gx = gx1; |
|
continue; |
|
} |
|
else |
|
{ |
|
gx1 = new CZCGX(); |
|
gx1.BSM = "AddNew"; |
|
gx1.CZCLX = item.Value[idx_JCCZCLX].ToTrim(); |
|
gx1.CZCDM = item.Value[idx_JCCZCDM].ToTrim(); |
|
gx1.CZCMC = item.Value[idx_JCCZCMC].ToTrim(); |
|
gx1.Shape = FeatureAPI.Difference(item.ShapeCopy, gx.Shape); |
|
gx1.UpdateOID.Add(item.OID); |
|
gx1.GCList.Add(new CZCGXGC() |
|
{ |
|
Shape = gx1.Shape, |
|
BGQBSM = tempBSM, |
|
BGQCZCLX = gx1.CZCLX, |
|
BGQCZCDM = gx1.CZCDM, |
|
BGQCZCMC = gx1.CZCMC, |
|
BGHCZCLX = gx1.CZCLX, |
|
BGHCZCDM = gx1.CZCDM, |
|
BGHCZCMC = gx1.CZCMC, |
|
BGMJ = feature.ShapeCopy.GetEllipseArea(), |
|
BGXW = "2" |
|
}); |
|
ListGX.Add(gx1); |
|
continue; |
|
//gx.Shape = FeatureAPI.Union(item.ShapeCopy, gx.Shape); |
|
} |
|
} |
|
} |
|
} |
|
else |
|
{ |
|
bgxw = "2"; |
|
gx.CZCLX = CZCSXM; |
|
gx.CZCDM = newCZCDM; |
|
gx.CZCMC = newCZCMC; |
|
gx.Shape = feature.ShapeCopy; |
|
gx.GCList.Add(new CZCGXGC() |
|
{ |
|
Shape = feature.ShapeCopy, |
|
BGXW = bgxw, |
|
BGMJ = feature.ShapeCopy.GetEllipseArea(), |
|
BGQBSM = bsm, |
|
BGQCZCLX = CZCLX, |
|
BGQCZCDM = CZCDM, |
|
BGQCZCMC = CZCMC, |
|
BGHCZCDM = gx.CZCDM, |
|
BGHCZCMC = gx.CZCMC, |
|
BGHCZCLX = gx.CZCLX |
|
}); |
|
gx.BSM = "AddNew"; |
|
int idx_JCCZCLX = _CZC20XLayer_Mem.FeatureClass.FindField("CZCLX"); |
|
int idx_JCCZCDM = _CZC20XLayer_Mem.FeatureClass.FindField("CZCDM"); |
|
int idx_JCCZCMC = _CZC20XLayer_Mem.FeatureClass.FindField("CZCMC"); |
|
int idx_JCBSM = _CZC20XLayer_Mem.FeatureClass.FindField("BSM"); |
|
if (gx.CZCLX == "203" || gx.CZCLX == "203A") |
|
{ |
|
List<IFeature> jcCzcs2 = FeatureAPI.Identify(gx.Shape, _CZC20XLayer_Mem); |
|
foreach (var item in jcCzcs2) |
|
{ |
|
string jcCZCLX = item.Value[idx_JCCZCLX].ToTrim(); |
|
string jcCZCDM = item.Value[idx_JCCZCDM].ToTrim(); |
|
string jcCZCMC = item.Value[idx_JCCZCMC].ToTrim(); |
|
//string tempCZCLX = item.Value[idx_CZCLX].ToTrim(); |
|
string tempBSM = item.Value[idx_JCBSM].ToTrim(); |
|
CZCGX gx1 = ListGX.FirstOrDefault(f => f.UpdateOID.Contains(item.OID)); |
|
if (gx1 != null) |
|
{ |
|
gx1.Shape = FeatureAPI.Difference(gx1.Shape, gx.Shape); |
|
foreach (var tempGC in gx1.GCList) |
|
{ |
|
tempGC.Shape = FeatureAPI.Difference(tempGC.Shape, gx.Shape); |
|
} |
|
} |
|
} |
|
continue; |
|
} |
|
List<IFeature> tempCzcs = FeatureAPI.Identify(gx.Shape, czcUnionMToSLayer); |
|
//int idxOldCzcOID = czcUnionMToSLayer; |
|
foreach (var item in tempCzcs) |
|
{ |
|
if (item.OID == feature.OID) continue; |
|
string tempBGXW = item.Value[idx_BGXW].ToTrim(); |
|
string tempCZCLX = tempBGXW == "3" ? item.Value[idx_CZCSXM].ToTrim() : item.Value[idx_CZCLX].ToTrim(); |
|
string tempCZCDM = tempBGXW == "3" ? item.Value[idx_ZLDWDM].ToTrim() : item.Value[idx_CZCDM].ToTrim(); |
|
string tempCZCMC = tempBGXW == "3" ? item.Value[idx_ZLDWMC].ToTrim() : item.Value[idx_CZCMC].ToTrim(); |
|
if (tempCZCLX == gx.CZCLX && tempCZCDM == gx.CZCDM && tempCZCMC == gx.CZCMC && tempBGXW != "0" && FeatureAPI.IsAdjacent(item.ShapeCopy, gx.Shape)) |
|
{ |
|
int oldOID = item.OID;// Convert.ToInt32(item.Value[idx_FID_CZC20X]); |
|
CZCGX gx1 = ListGX.FirstOrDefault(f => f.UpdateOID.Contains(oldOID)); |
|
if (gx1 != null) |
|
{ |
|
ListGX.Remove(gx); |
|
gx = gx1; |
|
} |
|
if (oldOID != -1) |
|
{ |
|
unionOldOIDs.Add(oldOID); |
|
} |
|
gx.UpdateOID.Add(oldOID); |
|
gx.Shape = FeatureAPI.Union(item.ShapeCopy, gx.Shape); |
|
gx.GCList.Add(new CZCGXGC() |
|
{ |
|
Shape = item.ShapeCopy, |
|
BGXW = "2", |
|
BGMJ = item.ShapeCopy.GetEllipseArea(), |
|
BGQCZCLX = CZCLX, |
|
BGQCZCDM = CZCDM, |
|
BGQCZCMC = CZCMC, |
|
BGHCZCDM = newCZCDM, |
|
BGHCZCMC = newCZCMC, |
|
BGHCZCLX = CZCSXM |
|
}); |
|
item.Delete(); |
|
} |
|
} |
|
List<IFeature> jcCzcs = FeatureAPI.Identify(gx.Shape, _CZC20XLayer_Mem); |
|
//int idx_JCCZCLX = _CZC20XLayer_Mem.FeatureClass.FindField("CZCLX"); |
|
//int idx_JCCZCDM = _CZC20XLayer_Mem.FeatureClass.FindField("CZCDM"); |
|
//int idx_JCCZCMC = _CZC20XLayer_Mem.FeatureClass.FindField("CZCMC"); |
|
//int idx_JCBSM = _CZC20XLayer_Mem.FeatureClass.FindField("BSM"); |
|
foreach (var item in jcCzcs) |
|
{ |
|
if (item.OID == 15) |
|
{ |
|
} |
|
string jcCZCLX = item.Value[idx_JCCZCLX].ToTrim(); |
|
string jcCZCDM = item.Value[idx_JCCZCDM].ToTrim(); |
|
string jcCZCMC = item.Value[idx_JCCZCMC].ToTrim(); |
|
string tempBSM = item.Value[idx_JCBSM].ToTrim(); |
|
if (jcCZCLX == gx.CZCLX && jcCZCDM == gx.CZCDM && jcCZCMC == gx.CZCMC && FeatureAPI.IsAdjacent(item.ShapeCopy, gx.Shape)) |
|
{ |
|
IGeometry tmpGeo = feature.ShapeCopy; |
|
CZCGX gx1 = ListGX.FirstOrDefault(f => f.UpdateOID.Contains(item.OID)); |
|
if (gx1 != null && gx1.CZCLX == gx.CZCLX && gx1.CZCDM == gx.CZCDM) |
|
{ |
|
if (FeatureAPI.IsContains(gx1.Shape, gx.Shape)) |
|
{ |
|
ListGX.Remove(gx); |
|
gx = gx1; |
|
} |
|
else |
|
{ |
|
gx1.Shape = FeatureAPI.Union(gx1.Shape, gx.Shape); |
|
gx1.GCList.AddRange(gx.GCList); |
|
ListGX.Remove(gx); |
|
gx = gx1; |
|
} |
|
continue; |
|
} |
|
else |
|
{ |
|
gx.Shape = FeatureAPI.Union(item.ShapeCopy, gx.Shape); |
|
} |
|
gx.UpdateOID.Add(item.OID); |
|
gx.GCList.Add(new CZCGXGC() |
|
{ |
|
Shape = item.ShapeCopy, |
|
BGXW = "2", |
|
BGMJ = item.ShapeCopy.GetEllipseArea(), |
|
BGQBSM = tempBSM, |
|
BGQCZCLX = jcCZCLX, |
|
BGQCZCDM = jcCZCDM, |
|
BGQCZCMC = jcCZCMC, |
|
BGHCZCDM = CZCDM, |
|
BGHCZCMC = CZCMC, |
|
BGHCZCLX = CZCLX |
|
}); |
|
} |
|
else |
|
{ |
|
bool isUpdata = false; |
|
IGeometry tmpGeo = gx.Shape; |
|
foreach (var gc in gx.GCList) |
|
{ |
|
if (gc.BGQBSM == tempBSM) |
|
{ |
|
tmpGeo = gc.Shape; |
|
isUpdata = true; |
|
} |
|
} |
|
if (isUpdata) |
|
{ |
|
//IGeometry tmpGeo = gx.Shape; |
|
CZCGX gx1 = ListGX.FirstOrDefault(f => f.UpdateOID.Contains(item.OID)); |
|
if (gx1 != null && gx1.CZCLX == gx.CZCLX && gx1.CZCDM == gx.CZCDM) |
|
{ |
|
gx1.Shape = FeatureAPI.Difference(gx1.Shape, gx.Shape); |
|
if (gx1.CZCDM == gx.CZCDM && gx1.CZCLX == gx.CZCLX && gx1.CZCMC == gx.CZCMC) |
|
{ |
|
ListGX.Remove(gx); |
|
gx1.GCList.AddRange(gx.GCList); |
|
|
|
gx = gx1; |
|
} |
|
else |
|
{ |
|
ListGX.Remove(gx); |
|
gx1 = new CZCGX(); |
|
gx1.BSM = "AddNew"; |
|
gx1.CZCDM = jcCZCDM; |
|
gx1.CZCLX = jcCZCLX; |
|
gx1.CZCMC = jcCZCMC; |
|
gx1.Shape = gx.Shape;// FeatureAPI.Difference(item.ShapeCopy, gx.Shape); |
|
gx1.GCList.Add(new CZCGXGC() |
|
{ |
|
Shape = gx.Shape, |
|
BGXW = "2", |
|
BGMJ = gx.Shape.GetEllipseArea(), |
|
BGQBSM = tempBSM, |
|
BGQCZCLX = jcCZCLX, |
|
BGQCZCDM = jcCZCDM, |
|
BGQCZCMC = jcCZCMC, |
|
BGHCZCDM = jcCZCDM, |
|
BGHCZCMC = jcCZCMC, |
|
BGHCZCLX = jcCZCLX |
|
}); |
|
ListGX.Add(gx1); |
|
} |
|
continue; |
|
//gx = gx1; |
|
} |
|
else |
|
{ |
|
if (gx1 != null) |
|
{ |
|
gx1.Shape = FeatureAPI.Difference(gx1.Shape, item.ShapeCopy); |
|
foreach (var tempGC in gx1.GCList) |
|
{ |
|
tempGC.Shape = FeatureAPI.Difference(tempGC.Shape, item.ShapeCopy); |
|
} |
|
if (isUpdata) |
|
continue; |
|
} |
|
else |
|
{ |
|
gx1 = new CZCGX(); |
|
gx1.BSM = "AddNew"; |
|
gx1.CZCDM = jcCZCDM; |
|
gx1.CZCLX = jcCZCLX; |
|
gx1.CZCMC = jcCZCMC; |
|
gx1.UpdateOID.Add(item.OID); |
|
gx1.Shape = FeatureAPI.Difference(item.ShapeCopy, gx.Shape); |
|
ListGX.Add(gx1); |
|
} |
|
} |
|
gx1.GCList.Add(new CZCGXGC() |
|
{ |
|
Shape = gx1.Shape, |
|
BGXW = "2", |
|
BGMJ = gx1.Shape.GetEllipseArea(), |
|
BGQBSM = tempBSM, |
|
BGQCZCLX = jcCZCLX, |
|
BGQCZCDM = jcCZCDM, |
|
BGQCZCMC = jcCZCMC, |
|
BGHCZCDM = jcCZCDM, |
|
BGHCZCMC = jcCZCMC, |
|
BGHCZCLX = jcCZCLX |
|
}); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
List<CZCGX> tempList = new List<CZCGX>(); |
|
foreach (var item in ListGX) |
|
{ |
|
if (item.Shape == null) continue; |
|
List<IGeometry> geos = FeatureAPI.DissolveGeometryByRing(item.Shape); |
|
if (geos != null && geos.Count > 1) |
|
{ |
|
item.Shape = geos[0]; |
|
for (int i = 1; i < geos.Count; i++) |
|
{ |
|
CZCGX tempGx = new CZCGX() |
|
{ |
|
BSM = "AddNew", |
|
CZCDM = item.CZCDM, |
|
CZCLX = item.CZCLX, |
|
CZCMC = item.CZCMC, |
|
Shape = geos[i] |
|
}; |
|
List<CZCGXGC> gcList = new List<CZCGXGC>(); |
|
foreach (var gc in item.GCList) |
|
{ |
|
if (FeatureAPI.GetEqual(gc.Shape, geos[i])) |
|
{ |
|
gcList.Add(gc); |
|
tempGx.GCList.Add(gc); |
|
} |
|
else |
|
if (FeatureAPI.IsContains(gc.Shape, geos[i])) |
|
{ |
|
CZCGXGC tempgc1 = new CZCGXGC() |
|
{ |
|
Shape = FeatureAPI.InterSect(gc.Shape, geos[i]), |
|
BGHBSM = gc.BGHBSM, |
|
BGHBZ = gc.BGHBZ, |
|
BGHCZCDM = gc.BGHCZCDM, |
|
BGHCZCLX = gc.BGHCZCLX, |
|
BGHCZCMC = gc.BGHCZCMC, |
|
BGMJ = 0, |
|
BGQBSM = gc.BGQBSM, |
|
BGQBZ = gc.BGQBZ, |
|
BGQCZCDM = gc.BGQCZCDM, |
|
BGQCZCLX = gc.BGQCZCLX, |
|
BGQCZCMC = gc.BGQCZCMC, |
|
BGXW = "2" |
|
}; |
|
gc.Shape = FeatureAPI.Difference(gc.Shape, geos[i]); |
|
tempgc1.BGMJ = tempgc1.Shape.GetEllipseArea(); |
|
tempGx.GCList.Add(tempgc1); |
|
} |
|
} |
|
foreach (var gc in gcList) |
|
{ |
|
item.GCList.Remove(gc); |
|
} |
|
tempList.Add(tempGx); |
|
} |
|
} |
|
} |
|
ListGX.AddRange(tempList); |
|
InsertData(ListGX); |
|
} |
|
catch (Exception ex) |
|
{ |
|
//MessageHelper.Show("城镇村范围变更失败!"); |
|
//LogAPI.Debug(ex); |
|
throw ex; |
|
} |
|
} |
|
public static void DelectDir(string srcPath) |
|
{ |
|
try |
|
{ |
|
DirectoryInfo dir = new DirectoryInfo(srcPath); |
|
FileSystemInfo[] fileinfo = dir.GetFileSystemInfos(); //返回目录中所有文件和子目录 |
|
foreach (FileSystemInfo i in fileinfo) |
|
{ |
|
if (i is DirectoryInfo) //判断是否文件夹 |
|
{ |
|
DirectoryInfo subdir = new DirectoryInfo(i.FullName); |
|
subdir.Delete(true); //删除子目录和文件 |
|
} |
|
else |
|
{ |
|
File.Delete(i.FullName); //删除指定文件 |
|
} |
|
} |
|
} |
|
catch (Exception e) |
|
{ |
|
throw; |
|
} |
|
} |
|
private void InsertData(List<CZCGX> pData) |
|
{ |
|
IFeatureClass _CZCGX_Fc = null; |
|
IFeatureClass _CZCGXGC_Fc = null; |
|
try |
|
{ |
|
if (pData == null || pData.Count == 0) return; |
|
_CZCGX_Fc = MapsManager.Instance.MapService.GetFeatureClassByName("CZCDYDGX"); |
|
_CZCGXGC_Fc = MapsManager.Instance.MapService.GetFeatureClassByName("CZCDYDGXGC"); |
|
if (_CZCGX_Fc == null) |
|
{ |
|
MessageHelper.Show("未找到城镇村更新层"); |
|
return; |
|
} |
|
if (_CZCGXGC_Fc == null) |
|
{ |
|
MessageHelper.Show("未找到城镇村更新过程层"); |
|
return; |
|
} |
|
(_CZCGX_Fc as ITable).DeleteSearchedRows(null); |
|
(_CZCGXGC_Fc as ITable).DeleteSearchedRows(null); |
|
IFeatureCursor _GXInsertCursor = _CZCGX_Fc.Insert(true); |
|
IFeatureCursor _GCInsertCursor = _CZCGXGC_Fc.Insert(true); |
|
IFeatureBuffer _GxBuffer = _CZCGX_Fc.CreateFeatureBuffer(); |
|
IFeatureBuffer _GcBuffer = _CZCGXGC_Fc.CreateFeatureBuffer(); |
|
int idxBSM = _CZCGX_Fc.FindField("BSM"); |
|
int idxCZCLX = _CZCGX_Fc.FindField("CZCLX"); |
|
int idxCZCDM = _CZCGX_Fc.FindField("CZCDM"); |
|
int idxCZCMC = _CZCGX_Fc.FindField("CZCMC"); |
|
int idxGXSJ = _CZCGX_Fc.FindField("GXSJ"); |
|
int idxBGQBSM = _CZCGXGC_Fc.FindField("BGQBSM"); |
|
int idxBGHBSM = _CZCGXGC_Fc.FindField("BGHBSM"); |
|
int idxBGQCZCLX = _CZCGXGC_Fc.FindField("BGQCZCLX"); |
|
int idxBGHCZCLX = _CZCGXGC_Fc.FindField("BGHCZCLX"); |
|
int idxBGQCZCDM = _CZCGXGC_Fc.FindField("BGQCZCDM"); |
|
int idxBGHCZCDM = _CZCGXGC_Fc.FindField("BGHCZCDM"); |
|
int idxBGQCZCMC = _CZCGXGC_Fc.FindField("BGQCZCMC"); |
|
int idxBGHCZCMC = _CZCGXGC_Fc.FindField("BGHCZCMC"); |
|
int idxBGXW = _CZCGXGC_Fc.FindField("BGXW"); |
|
int idxBGMJ = _CZCGXGC_Fc.FindField("BGMJ"); |
|
int idxGCGXSJ = _CZCGXGC_Fc.FindField("GXSJ"); |
|
int i = 0; |
|
Dictionary<string, List<PCModel>> gcMJs = new Dictionary<string, List<PCModel>>(); |
|
Dictionary<string, int> bghOIDs = new Dictionary<string, int>(); |
|
Dictionary<string, double> bghMJs = new Dictionary<string, double>(); |
|
List<SetBGXWModel> ListBGXWModel = new List<SetBGXWModel>(); |
|
foreach (var gx in pData) |
|
{ |
|
if (gx.GCList.Count == 0) |
|
{ |
|
} |
|
i++; |
|
if (!string.IsNullOrWhiteSpace(gx.CZCLX)) |
|
{ |
|
if (gx.Shape.IsEmpty) |
|
{ |
|
continue; |
|
} |
|
IArea area = gx.Shape as IArea; |
|
if (area.Area < 0.01) |
|
{ |
|
continue; |
|
} |
|
_GxBuffer.Shape = gx.Shape; |
|
if (idxBSM != -1) |
|
{ |
|
if (gx.BSM == "AddNew") |
|
{ |
|
string bsmPrefix = MaxBSM.Substring(0, 10); |
|
int MaxNum = Convert.ToInt32(MaxBSM.Substring(10)); |
|
if (MaxNum == 1171) |
|
{ |
|
} |
|
MaxBSM = bsmPrefix + (MaxNum + 1).ToString().PadLeft(8, '0'); |
|
gx.BSM = MaxBSM; |
|
} |
|
_GxBuffer.Value[idxBSM] = gx.BSM; |
|
} |
|
if (idxCZCLX != -1) |
|
_GxBuffer.Value[idxCZCLX] = gx.CZCLX; |
|
if (idxCZCDM != -1) |
|
_GxBuffer.Value[idxCZCDM] = gx.CZCDM; |
|
if (idxCZCMC != -1) |
|
_GxBuffer.Value[idxCZCMC] = gx.CZCMC; |
|
if (idxGXSJ != -1) |
|
_GxBuffer.Value[idxGXSJ] = new DateTime(DateTime.Now.Year - 1, 12, 31); |
|
object oid = _GXInsertCursor.InsertFeature(_GxBuffer); |
|
if (!bghOIDs.ContainsKey(gx.BSM)) |
|
{ |
|
bghOIDs.Add(gx.BSM, Convert.ToInt32(oid)); |
|
} |
|
} |
|
foreach (var gc in gx.GCList) |
|
{ |
|
gc.BGMJ = gc.Shape.GetEllipseArea().ToDouble(2); |
|
if (gc.Shape == null || gc.Shape.IsEmpty || gc.BGMJ == 0) |
|
{ |
|
continue; |
|
} |
|
List<IGeometry> gcList = FeatureAPI.DissolveGeometryByRing(gc.Shape); |
|
if (gcList == null) continue; |
|
foreach (var shp in gcList) |
|
{ |
|
double bgmj = shp.GetEllipseArea(); |
|
if (bgmj == 0) |
|
{ |
|
continue; |
|
} |
|
_GcBuffer.Shape = shp; |
|
if (idxBGXW != -1) |
|
_GcBuffer.Value[idxBGXW] = gc.BGXW; |
|
if (idxBGMJ != -1) |
|
_GcBuffer.Value[idxBGMJ] = bgmj.ToDouble(2); |
|
if (idxBGQBSM != -1) |
|
_GcBuffer.Value[idxBGQBSM] = gc.BGQBSM; |
|
if (idxBGHBSM != -1) |
|
_GcBuffer.Value[idxBGHBSM] = gx.BSM; |
|
if (idxBGQCZCLX != -1) |
|
_GcBuffer.Value[idxBGQCZCLX] = gc.BGQCZCLX; |
|
if (idxBGHCZCLX != -1) |
|
_GcBuffer.Value[idxBGHCZCLX] = gc.BGHCZCLX; |
|
if (idxBGQCZCDM != -1) |
|
_GcBuffer.Value[idxBGQCZCDM] = gc.BGQCZCDM; |
|
if (idxBGHCZCDM != -1) |
|
_GcBuffer.Value[idxBGHCZCDM] = gc.BGHCZCDM; |
|
if (idxBGQCZCMC != -1) |
|
_GcBuffer.Value[idxBGQCZCMC] = gc.BGQCZCMC; |
|
if (idxBGHCZCMC != -1) |
|
_GcBuffer.Value[idxBGHCZCMC] = gc.BGHCZCMC; |
|
if (idxGCGXSJ != -1) |
|
_GcBuffer.Value[idxGCGXSJ] = new DateTime(DateTime.Now.Year - 1, 12, 31); |
|
object oid = _GCInsertCursor.InsertFeature(_GcBuffer); |
|
if (!string.IsNullOrWhiteSpace(gc.BGQBSM)) |
|
{ |
|
if (gcMJs.ContainsKey(gc.BGQBSM)) |
|
{ |
|
gcMJs[gc.BGQBSM].Add(new PCModel() { OID = Convert.ToInt32(oid), MJ = gc.BGMJ }); |
|
} |
|
else |
|
{ |
|
gcMJs.Add(gc.BGQBSM, new List<PCModel>()); |
|
gcMJs[gc.BGQBSM].Add(new PCModel() { OID = Convert.ToInt32(oid), MJ = gc.BGMJ }); |
|
} |
|
} |
|
ListBGXWModel.Add(new SetBGXWModel { OID = Convert.ToInt32(oid), BGQBSM = gc.BGQBSM, BGHBSM = gc.BGHBSM }); |
|
} |
|
} |
|
} |
|
_GXInsertCursor.Flush(); |
|
_GCInsertCursor.Flush(); |
|
ICursor curor = (_CZCFc as ITable).Search(null, true); |
|
IRow row = null; |
|
Dictionary<string, double> jcMJs = new Dictionary<string, double>(); |
|
int idxJCBSM = -1, idxJCMJ = -1; |
|
while ((row = curor.NextRow()) != null) |
|
{ |
|
if (idxJCBSM == -1) |
|
idxJCBSM = row.Fields.FindField("BSM"); |
|
if (idxJCMJ == -1) |
|
idxJCMJ = row.Fields.FindField("CZCMJ"); |
|
jcMJs.Add(row.Value[idxJCBSM].ToTrim(), row.Value[idxJCMJ].ToDouble()); |
|
} |
|
foreach (var key in jcMJs.Keys) |
|
{ |
|
if (!gcMJs.ContainsKey(key)) |
|
{ |
|
continue; |
|
} |
|
List<PCModel> shpList = gcMJs[key]; |
|
double pKZMJ = jcMJs[key]; |
|
shpList = shpList.OrderByDescending(o => o.MJ).ToList(); |
|
double mjc = Math.Round(shpList.Sum(s => s.MJ) - pKZMJ, 2); |
|
if (Math.Round(mjc, 2) == 0) |
|
{ |
|
continue; |
|
} |
|
int num = 0; |
|
//平差 |
|
while (Math.Round(mjc, 2) != 0 && num < 10) |
|
{ |
|
num++; |
|
int tpsm = (int)(Math.Abs(Math.Round(mjc, 2)) / 0.01); |
|
int e = tpsm / shpList.Count; |
|
int f = tpsm % shpList.Count; |
|
if (f != 0) |
|
{ |
|
double tpmj = (e + 1) * 0.01; |
|
for (int j = 0; j < f; j++) |
|
{ |
|
if (mjc < 0) |
|
shpList[j].MJ = shpList[j].MJ + tpmj; |
|
else |
|
shpList[j].MJ = shpList[j].MJ - tpmj; |
|
} |
|
} |
|
if (e != 0) |
|
{ |
|
double tpmj = e * 0.01; |
|
for (int j = f; j < shpList.Count; j++) |
|
{ |
|
if (mjc < 0) |
|
shpList[j].MJ = shpList[j].MJ + tpmj; |
|
else |
|
shpList[j].MJ = shpList[j].MJ - tpmj; |
|
} |
|
} |
|
mjc = Math.Round(shpList.Sum(s => s.MJ), 2) - pKZMJ; |
|
} |
|
foreach (var item in shpList) |
|
{ |
|
IFeature fet = _CZCGXGC_Fc.GetFeature(item.OID); |
|
fet.Value[idxBGMJ] = item.MJ; |
|
fet.Store(); |
|
Marshal.ReleaseComObject(fet); |
|
} |
|
} |
|
curor = (_CZCGXGC_Fc as ITable).Search(null, true); |
|
row = null; |
|
bghMJs.Clear(); |
|
List<int> ListSXBG = new List<int>(); |
|
while ((row = curor.NextRow()) != null) |
|
{ |
|
string bgqBSM = row.Value[idxBGQBSM].ToTrim(); |
|
string bghBSM = row.Value[idxBGHBSM].ToTrim(); |
|
double bgmj = row.Value[idxBGMJ].ToDouble(); |
|
if (!string.IsNullOrWhiteSpace(bghBSM)) |
|
{ |
|
if (!bghMJs.ContainsKey(bghBSM)) |
|
{ |
|
bghMJs.Add(bghBSM, bgmj); |
|
} |
|
else |
|
{ |
|
bghMJs[bghBSM] += bgmj; |
|
} |
|
} |
|
int bgqNum = ListBGXWModel.Count(c => c.BGQBSM == bgqBSM); |
|
int bghnum = ListBGXWModel.Count(c => c.BGHBSM == bghBSM); |
|
if (bgqNum == 1 && bghnum == 1) |
|
{ |
|
ListSXBG.Add(row.OID); |
|
} |
|
} |
|
int idxCZCMJ = _CZCGX_Fc.FindField("CZCMJ"); |
|
foreach (var item in bghMJs.Keys) |
|
{ |
|
if (bghOIDs.ContainsKey(item)) |
|
{ |
|
if (bghOIDs[item] != -1) |
|
{ |
|
IFeature fet = _CZCGX_Fc.GetFeature(bghOIDs[item]); |
|
fet.Value[idxCZCMJ] = bghMJs[item].ToDouble(2); |
|
fet.Store(); |
|
Marshal.ReleaseComObject(fet); |
|
} |
|
} |
|
} |
|
foreach (var gcoid in ListSXBG) |
|
{ |
|
IFeature GCfeature = _CZCGXGC_Fc.GetFeature(gcoid); |
|
GCfeature.Value[idxBGXW] = "1"; |
|
string BGHBSM = GCfeature.Value[idxBGHBSM].ToTrim(); |
|
GCfeature.Value[idxBGHBSM] = GCfeature.Value[idxBGQBSM]; |
|
GCfeature.Store(); |
|
(_CZCGX_Fc as FeatureClass).Workspace.ExecuteSQL(string.Format("Update CZCDYDGX set BSM='{0}' where BSM='{1}'", GCfeature.Value[idxBGQBSM], BGHBSM)); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
MessageHelper.Show("写入数据失败!错误原因请查看系统日志"); |
|
LogAPI.Debug("城镇村范围变更失败:"); |
|
LogAPI.Debug(ex); |
|
} |
|
} |
|
private string GetMaxBSM(List<IFeatureClass> fcList) |
|
{ |
|
//System.Windows.Forms.Application.DoEvents(); |
|
int xh = 0; |
|
string MaxBSM = ""; |
|
string leftStr = string.Empty; |
|
foreach (var fc in fcList) |
|
{ |
|
string BSM = string.Empty; |
|
int BSMIndex = fc.FindField("BSM"); |
|
if (BSMIndex == -1) return BSM; |
|
|
|
ITable table = (ITable)fc; |
|
// 创建一个ITableSort接口对象 |
|
ITableSort tableSort = new TableSortClass(); |
|
tableSort.Table = table; |
|
tableSort.Fields = "BSM"; |
|
tableSort.set_Ascending("BSM", false); |
|
tableSort.Sort(null); |
|
ICursor cursor = tableSort.Rows; |
|
IRow row = cursor.NextRow(); |
|
if (row != null) |
|
{ |
|
int maxBSM = 0; |
|
int currBSM = 0; |
|
string BSMStr = row.Value[BSMIndex].ToString(); |
|
if (BSMStr.Length != 18) return BSM; |
|
string subBSMStr = BSMStr.Substring(9); |
|
try |
|
{ |
|
currBSM = Convert.ToInt32(subBSMStr); |
|
} |
|
catch (Exception) |
|
{ |
|
return BSM; |
|
} |
|
if (currBSM > maxBSM) maxBSM = currBSM; |
|
|
|
if (BSMStr.Length != 18) return BSM; |
|
string maxStr = maxBSM.ToString(); |
|
int zeroNum = 9 - maxStr.Length; |
|
for (int i = 0; i < zeroNum; i++) |
|
{ |
|
maxStr = 0 + maxStr; |
|
} |
|
BSM = BSMStr.Substring(0, 9) + maxStr; |
|
} |
|
if (BSM.Length != 18) |
|
continue; |
|
int xh2 = Convert.ToInt32(BSM.Substring(10)); |
|
leftStr = BSM.Substring(0, 10); |
|
if (xh < xh2) |
|
{ |
|
xh = xh2; |
|
MaxBSM = BSM; |
|
} |
|
} |
|
return MaxBSM; |
|
|
|
} |
|
private void InsertDataToMemeoryLayer(IFeatureClass pSource, IFeatureClass pTarget, IQueryFilter pFilter = null) |
|
{ |
|
try |
|
{ |
|
if (pSource == null || pTarget == null) return; |
|
IFeatureClassAPI fcAPI = new FeatureClassAPI(pSource); |
|
if (pTarget != null) |
|
fcAPI.FcToFc(pTarget, pFilter, false); |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("获取城镇村范围数据失败:"); |
|
LogAPI.Debug(ex); |
|
} |
|
} |
|
|
|
private void BtnCancel_Click(object sender, RoutedEventArgs e) |
|
{ |
|
this.Close(); |
|
} |
|
|
|
|
|
} |
|
public class PCModel |
|
{ |
|
public int OID { get; set; } |
|
public double MJ { get; set; } |
|
} |
|
public class SetBGXWModel |
|
{ |
|
public int OID { get; set; } |
|
public string BGQBSM { get; set; } |
|
public int BGQBSMNum { get; set; } |
|
public string BGHBSM { get; set; } |
|
public int BGHBSMNum { get; set; } |
|
} |
|
public class CZCGXGC |
|
{ |
|
public string BGXW { get; set; } |
|
public double BGMJ { get; set; } |
|
public string BGQBSM { get; set; } |
|
public string BGHBSM { get; set; } |
|
public string BGQCZCDM { get; set; } |
|
public string BGHCZCDM { get; set; } |
|
public string BGQCZCMC { get; set; } |
|
public string BGHCZCMC { get; set; } |
|
public string BGQBZ { get; set; } |
|
public string BGHBZ { get; set; } |
|
public string BGQCZCLX { get; set; } |
|
public string BGHCZCLX { get; set; } |
|
public IGeometry Shape { get; set; } |
|
} |
|
public class CZCGX |
|
{ |
|
public bool IsNewAdd203 { get; set; } |
|
public List<int> UpdateOID { get; set; } |
|
public int OID { get; set; } |
|
public string CZCLX { get; set; } |
|
public string BSM { get; set; } |
|
public string CZCDM { get; set; } |
|
public string CZCMC { get; set; } |
|
public double CZCMJ { get; set; } |
|
public List<CZCGXGC> GCList { get; set; } = new List<CZCGXGC>(); |
|
public IGeometry Shape { get; set; } |
|
public string BGXW { get; set; } |
|
public CZCGX() |
|
{ |
|
UpdateOID = new List<int>(); |
|
} |
|
} |
|
}
|
|
|