|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using ESRI.ArcGIS.DataManagementTools;
|
|
|
|
|
using ESRI.ArcGIS.DataSourcesGDB;
|
|
|
|
|
using ESRI.ArcGIS.esriSystem;
|
|
|
|
|
using ESRI.ArcGIS.Geodatabase;
|
|
|
|
|
using ESRI.ArcGIS.Geometry;
|
|
|
|
|
using ESRI.ArcGIS.Geoprocessing;
|
|
|
|
|
using ESRI.ArcGIS.Geoprocessor;
|
|
|
|
|
//using IDEParameter;
|
|
|
|
|
using KGIS.Framework.AE;
|
|
|
|
|
using KGIS.Framework.AE.Enum;
|
|
|
|
|
using KGIS.Framework.AE.ExtensionMethod;
|
|
|
|
|
using KGIS.Framework.AE.GaussCalculate;
|
|
|
|
|
using KGIS.Framework.AE.GPHelper;
|
|
|
|
|
//using KGIS.Framework.AE.GPHelper;
|
|
|
|
|
using KGIS.Framework.DBOperator;
|
|
|
|
|
using KGIS.Framework.Platform;
|
|
|
|
|
using KGIS.Framework.ThreadManager;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using KGIS.Framework.Utils.Utility;
|
|
|
|
|
using Kingo.PluginServiceInterface;
|
|
|
|
|
using Kingo.PluginServiceInterface.Model;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
namespace IDGForNDBG
|
|
|
|
|
{
|
|
|
|
|
public class CZC_IDGHelper : BaseIDG
|
|
|
|
|
{
|
|
|
|
|
//private IFeatureLayer _DLTBFc = null;
|
|
|
|
|
public string IDataChangeName { get => "CZCDYDHelper"; }
|
|
|
|
|
private string TempGDBPath = string.Empty;
|
|
|
|
|
private string TempDBPath = string.Empty;
|
|
|
|
|
Dictionary<int, double> AreaList = new Dictionary<int, double>();
|
|
|
|
|
IDGParameter pParm = null;
|
|
|
|
|
#region ExecuteDataChange
|
|
|
|
|
public void Execute(IDGParameter pParm)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//ExtractExe(pParm);
|
|
|
|
|
ThreadManager.Instance.QueueUserWorkItem(new System.Threading.WaitCallback(ExtractExe), pParm);
|
|
|
|
|
|
|
|
|
|
//IFeatureClass _CZCFc = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("城镇村等用地").FeatureClass;
|
|
|
|
|
//Implement(_CZCFc, true, false);
|
|
|
|
|
//ExtractExe(pParm, bgParm);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public void OpenDB(IDGParameter parm)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
LayerCfg layerInfo = null;
|
|
|
|
|
if (parm.PrjInfo != null && !string.IsNullOrWhiteSpace(parm.PrjInfo.TempData))
|
|
|
|
|
{
|
|
|
|
|
byte[] contentArray = Convert.FromBase64String(parm.PrjInfo.TempData);
|
|
|
|
|
string LayerCfg = System.Text.Encoding.Default.GetString(contentArray);
|
|
|
|
|
layerInfo = KGIS.Framework.Utils.SerializeAPI.DeserializeToObject<LayerCfg>(LayerCfg);
|
|
|
|
|
}
|
|
|
|
|
if (layerInfo == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Err:获取图层信息失败!");
|
|
|
|
|
}
|
|
|
|
|
//FileInfo fileInfo = new FileInfo(parm.PrjInfo.BGDatabase);
|
|
|
|
|
string PathBgDB = parm.PrjInfo.BGDatabase;// Path.Combine(, "BGDB" + ".gdb");
|
|
|
|
|
string PathZLDB = parm.PrjInfo.ZLDatabase;
|
|
|
|
|
string PathNMDB = parm.PrjInfo.NMDatabase;// System.IO.Path.Combine(fileInfo.DirectoryName, "NMDB" + ".gdb");
|
|
|
|
|
BgWsAPI = new WorkspaceAPI(PathBgDB, WorkspaceTypeEnum.GDBFile);
|
|
|
|
|
if (BgWsAPI.CurrentWorkspace == null)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("打开变更数据库失败!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ZlWsAPI = new WorkspaceAPI(PathZLDB, WorkspaceTypeEnum.GDBFile);
|
|
|
|
|
if (ZlWsAPI.CurrentWorkspace == null)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("打开增量数据库失败!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
NmWsAPI = new WorkspaceAPI(PathNMDB, WorkspaceTypeEnum.GDBFile);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LayerCfg JCLayerInfo = layerInfo.Layers.FirstOrDefault(f => f.LayerName == "年初数据");
|
|
|
|
|
if (JCLayerInfo == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Err:获取年初数据库失败!");
|
|
|
|
|
}
|
|
|
|
|
List<LayerCfg> NcList = JCLayerInfo.GetAllItem();
|
|
|
|
|
//if (parm.ExeDLTB)
|
|
|
|
|
//{
|
|
|
|
|
LayerCfg _JcTBLayerInfo = NcList.FirstOrDefault(f => f.LayerName == "地类图斑");
|
|
|
|
|
|
|
|
|
|
_jcTbLayer = OpenLayer(_JcTBLayerInfo);
|
|
|
|
|
if (_jcTbLayer == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Err:获取年初地类图斑数据失败!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
LayerCfg _JcCzcLayerInfo = NcList.FirstOrDefault(f => f.LayerName == "城镇村等用地");
|
|
|
|
|
_jcCzcLayer = OpenLayer(_JcCzcLayerInfo);
|
|
|
|
|
if (_JcCzcLayerInfo == null)
|
|
|
|
|
throw new Exception("Err:获取年初城镇村等用地数据失败!");
|
|
|
|
|
//if (_nmTbLayer == null)
|
|
|
|
|
// _nmTbLayer = OpenLayer(NmWsAPI, "DLTB_NMK");
|
|
|
|
|
_gxCzcLayer = OpenLayer(ZlWsAPI, "CZCDYDGX");
|
|
|
|
|
_gxgcCzcLayer = OpenLayer(ZlWsAPI, "CZCDYDGXGC");
|
|
|
|
|
_gxTbLayer = OpenLayer(ZlWsAPI, "DLTBGX");
|
|
|
|
|
_gxgcTBLayer = OpenLayer(ZlWsAPI, "DLTBGXGC");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void ExtractExe(object parm)
|
|
|
|
|
{
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
List<DataDicTionary> qsDic = null;
|
|
|
|
|
DateTime StartTime = DateTime.Now;
|
|
|
|
|
Console.WriteLine("Log:正在提取城镇村更新数据,请稍候...");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Kingo.ThreadManager.TaskParameter taskParm = parm as Kingo.ThreadManager.TaskParameter;
|
|
|
|
|
pParm = taskParm.Data as IDGParameter;
|
|
|
|
|
//pParm = parm as IDGParameter;
|
|
|
|
|
OpenDB(pParm);
|
|
|
|
|
//Console.WriteLine("Log:1...");
|
|
|
|
|
string TempDir = CreateTempDB("CZC");
|
|
|
|
|
//Console.WriteLine("Log:2...");
|
|
|
|
|
TempGDBPath = System.IO.Path.Combine(TempDir, "TempGDB.gdb");
|
|
|
|
|
TempDBPath = TempDir + @"\Temp" + ".sqlite";
|
|
|
|
|
|
|
|
|
|
//FileInfo fileInfo = new FileInfo(pParm.PrjInfo.BGDatabase);
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper(System.IO.Path.Combine(pParm.PrjInfo.ProjDir, "BGTJ.sqlite"), DatabaseType.SQLite);
|
|
|
|
|
DataTable dicDt = rdbHelper.ExecuteDatatable("Dic", string.Format("SELECT * from Sys_Dicdetail where OWNERDIC=(select ID from Sys_DicManage WHERE NAME='权属代码')"), true);
|
|
|
|
|
qsDic = TBToList.ToList<DataDicTionary>(dicDt);
|
|
|
|
|
if (qsDic == null)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug($"Err:权属单位代码表获取失败。");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Console.WriteLine("Log:正在提取城镇村数据...");
|
|
|
|
|
IFeatureLayer tempjcCjdcqLayer = null;
|
|
|
|
|
//Console.WriteLine("Log:4...");
|
|
|
|
|
string HRCZC = pParm.PrjInfo.DR_CZCPath;
|
|
|
|
|
|
|
|
|
|
//Console.WriteLine("Log:5...");
|
|
|
|
|
if (!string.IsNullOrEmpty(HRCZC))
|
|
|
|
|
{
|
|
|
|
|
IWorkspaceAPI hrWsAPI = null;
|
|
|
|
|
IFeatureClassAPI hrFcAPI = null;
|
|
|
|
|
IFeatureLayer hrCZCLayer = null;
|
|
|
|
|
if (HRCZC.ToLower().Contains(".gdb"))
|
|
|
|
|
{
|
|
|
|
|
string hr_dbPath = HRCZC.Substring(0, HRCZC.ToLower().IndexOf(".gdb"));
|
|
|
|
|
hr_dbPath = hr_dbPath + ".gdb";
|
|
|
|
|
hrWsAPI = new WorkspaceAPI(hr_dbPath, WorkspaceTypeEnum.GDBFile);
|
|
|
|
|
FileInfo fInfo = new FileInfo(HRCZC);
|
|
|
|
|
hrFcAPI = hrWsAPI.OpenFeatureClass(fInfo.Name);
|
|
|
|
|
hrCZCLayer = new FeatureLayerClass() { FeatureClass = hrFcAPI.FeatureClass };
|
|
|
|
|
}
|
|
|
|
|
else if (HRCZC.ToLower().Contains(".shp"))
|
|
|
|
|
{
|
|
|
|
|
FileInfo fInfo = new FileInfo(HRCZC);
|
|
|
|
|
Console.WriteLine("Log:正在加载城镇村数据" + fInfo.Name);
|
|
|
|
|
IWorkspaceFactory pWorkspaceFactory = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass();
|
|
|
|
|
IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(fInfo.DirectoryName, 0);
|
|
|
|
|
hrWsAPI = new WorkspaceAPI(pWorkspace);
|
|
|
|
|
hrFcAPI = hrWsAPI.OpenFeatureClass2(fInfo.Name.Split('.')[0]);
|
|
|
|
|
hrCZCLayer = new FeatureLayerClass() { FeatureClass = hrFcAPI.FeatureClass };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPParamClass gPParamClass2 = new GPParamClass();
|
|
|
|
|
gPParamClass2.FirstFeatureLayer = JcCzcLayer;
|
|
|
|
|
gPParamClass2.SecondFeatureLayer = hrCZCLayer;
|
|
|
|
|
gPParamClass2.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass2.GPType = EnumGPType.Erase;
|
|
|
|
|
gPParamClass2.OutFeatureClassPath = System.IO.Path.Combine(TempGDBPath, "CZCDYD");
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass2, ref tempjcCjdcqLayer);
|
|
|
|
|
hrFcAPI.FcToFc(tempjcCjdcqLayer.FeatureClass, null, false);
|
|
|
|
|
tempjcCjdcqLayer.Name = "城镇村等用地";
|
|
|
|
|
SetJcCzcLayer(tempjcCjdcqLayer);
|
|
|
|
|
}
|
|
|
|
|
IFeatureLayer Union20XLayer = null;
|
|
|
|
|
IFeatureLayer Union203Layer = null;
|
|
|
|
|
|
|
|
|
|
//Console.WriteLine("Log:7...");
|
|
|
|
|
Get20XDLTB(JcTbLayer, GxTbLayer, JcCzcLayer, ref Union20XLayer, ref Union203Layer);
|
|
|
|
|
|
|
|
|
|
//Console.WriteLine("Log:8...");
|
|
|
|
|
Console.WriteLine("Log:正在写入城镇村更新过程数据...");
|
|
|
|
|
//(GxgcCzcLayer.FeatureClass as ITable).DeleteSearchedRows(null);
|
|
|
|
|
(GxgcCzcLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL("Delete From CZCDYDGXGC WHERE 1=1");
|
|
|
|
|
GenerateGXGC(GxgcCzcLayer, Union20XLayer, qsDic);
|
|
|
|
|
GenerateXz203GXGC(GxgcCzcLayer, Union203Layer, qsDic);
|
|
|
|
|
IFeatureLayer ptempLayer = null;
|
|
|
|
|
//GPParamClass gPParamClass = new GPParamClass();
|
|
|
|
|
//gPParamClass.FirstFeatureLayer = GxgcCzcLayer;
|
|
|
|
|
//gPParamClass.GPType = EnumGPType.Default;
|
|
|
|
|
//GPHelper.Instance.ExeGPForProces(gPParamClass, ref ptempLayer);
|
|
|
|
|
//ZLBGTBExt();
|
|
|
|
|
Console.WriteLine("Log:正在写入城镇村更新层数据...");
|
|
|
|
|
//(GxCzcLayer.FeatureClass as ITable).DeleteSearchedRows(null);
|
|
|
|
|
(GxCzcLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL("Delete From CZCDYDGX WHERE 1=1");
|
|
|
|
|
|
|
|
|
|
(GxgcCzcLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("update CZCDYDGXGC set BGHCZCDM='{1}' where BGHCZCDM='{0}'", "2205211002160000000", "2205022012070000000"));
|
|
|
|
|
(GxgcCzcLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("update CZCDYDGXGC set BGHCZCDM='{1}' where BGHCZCDM='{0}'", "2205211012000000000", "2205023002000000000"));
|
|
|
|
|
(GxgcCzcLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("update CZCDYDGXGC set BGHCZCDM='{1}' where BGHCZCDM='{0}'", "2205211012020000000", "2205023002020000000"));
|
|
|
|
|
(GxgcCzcLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("update CZCDYDGXGC set BGHCZCDM='{1}' where BGHCZCDM='{0}'", "2205211012100000000", "2205023002100000000"));
|
|
|
|
|
(GxgcCzcLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("update CZCDYDGXGC set BGHCZCDM='{1}' where BGHCZCDM='{0}'", "2205211012110000000", "2205023002110000000"));
|
|
|
|
|
(GxgcCzcLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("update CZCDYDGXGC set BGHCZCDM='{1}' where BGHCZCDM='{0}'", "2205211012120000000", "2205023002120000000"));
|
|
|
|
|
(GxgcCzcLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("update CZCDYDGXGC set BGHCZCDM='{1}' where BGHCZCDM='{0}'", "2205211012010000000", "2205023002010000000"));
|
|
|
|
|
(GxgcCzcLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(string.Format("update CZCDYDGXGC set BGHCZCDM='{1}' where BGHCZCDM='{0}'", "2205211012010000000", "2205023002010000000"));
|
|
|
|
|
GenerateGX(GxgcCzcLayer, GxCzcLayer);
|
|
|
|
|
Console.WriteLine("Log:正在写入城镇村更新层标识码、面积等属性...");
|
|
|
|
|
|
|
|
|
|
#region 划出/灭失城镇村写入更新过程层
|
|
|
|
|
int idxXZQTZLX = JcCzcLayer.FeatureClass.FindField("XZQTZLX");
|
|
|
|
|
if (idxXZQTZLX != -1)
|
|
|
|
|
{
|
|
|
|
|
IFeatureCursor jcCursor = JcCzcLayer.FeatureClass.Search(new QueryFilter() { WhereClause = "XZQTZLX='2' or XZQTZLX='4'" }, true);
|
|
|
|
|
IFeatureCursor gxgcCuroso = GxgcCzcLayer.FeatureClass.Insert(true);
|
|
|
|
|
IFeatureBuffer buff = null;
|
|
|
|
|
IFeature jcF = null;
|
|
|
|
|
int idxBGXW = GxgcCzcLayer.FeatureClass.FindField("BGXW");
|
|
|
|
|
int idxGXSJ = GxgcCzcLayer.FeatureClass.FindField("GXSJ");
|
|
|
|
|
int idxBGMJ = GxgcCzcLayer.FeatureClass.FindField("BGMJ");
|
|
|
|
|
int idxJCCZCMJ = JcCzcLayer.FeatureClass.FindField("CZCMJ");
|
|
|
|
|
while ((jcF = jcCursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
if (buff == null)
|
|
|
|
|
buff = GxgcCzcLayer.FeatureClass.CreateFeatureBuffer();
|
|
|
|
|
for (int i = 0; i < GxgcCzcLayer.FeatureClass.Fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = GxgcCzcLayer.FeatureClass.Fields.Field[i];
|
|
|
|
|
if (!field.Editable || field.Name.Contains("SHAPE")) continue;
|
|
|
|
|
if (field.Name.StartsWith("BGQ"))
|
|
|
|
|
{
|
|
|
|
|
string jcFName = field.Name.Replace("BGQ", "");
|
|
|
|
|
int idx = jcF.Fields.FindField(jcFName);
|
|
|
|
|
if (idx != -1)
|
|
|
|
|
buff.Value[i] = jcF.Value[idx];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
buff.Shape = jcF.ShapeCopy;
|
|
|
|
|
if (idxBGXW != -1)
|
|
|
|
|
buff.Value[idxBGXW] = "1";
|
|
|
|
|
if (idxGXSJ != -1)
|
|
|
|
|
buff.Value[idxGXSJ] = DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31);
|
|
|
|
|
if (idxBGMJ != -1 && idxJCCZCMJ != -1)
|
|
|
|
|
buff.Value[idxBGMJ] = jcF.Value[idxJCCZCMJ];
|
|
|
|
|
gxgcCuroso.InsertFeature(buff);
|
|
|
|
|
}
|
|
|
|
|
gxgcCuroso.Flush();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
SetAttribute(GxgcCzcLayer, GxCzcLayer, JcCzcLayer);
|
|
|
|
|
ResultPress(GxgcCzcLayer, GxCzcLayer);
|
|
|
|
|
|
|
|
|
|
//gPParamClass = new GPParamClass();
|
|
|
|
|
//gPParamClass.FirstFeatureLayer = GxgcCzcLayer;
|
|
|
|
|
//gPParamClass.GPType = EnumGPType.Default;
|
|
|
|
|
//GPHelper.Instance.ExeGPForProces(gPParamClass, ref ptempLayer);
|
|
|
|
|
|
|
|
|
|
//gPParamClass = new GPParamClass();
|
|
|
|
|
//gPParamClass.FirstFeatureLayer = GxCzcLayer;
|
|
|
|
|
//gPParamClass.GPType = EnumGPType.Default;
|
|
|
|
|
//GPHelper.Instance.ExeGPForProces(gPParamClass, ref ptempLayer);
|
|
|
|
|
|
|
|
|
|
#region 小于30平图斑是否灭失
|
|
|
|
|
if (pParm.PrjInfo.LessThan30Missing == true)
|
|
|
|
|
{
|
|
|
|
|
IFeatureCursor cursor = null;
|
|
|
|
|
IFeature feature = null;
|
|
|
|
|
IFeature czcgxgcfeature = null;
|
|
|
|
|
var gx_CZCMJ = _gxCzcLayer.FeatureClass.FindField("CZCMJ");
|
|
|
|
|
var jc_CZCMJ = _jcCzcLayer.FeatureClass.FindField("CZCMJ");
|
|
|
|
|
var jc_CZCSXM = _jcCzcLayer.FeatureClass.FindField("CZCLX");
|
|
|
|
|
var jc_CZCDM = _jcCzcLayer.FeatureClass.FindField("CZCDM");
|
|
|
|
|
var jc_CZCMC = _jcCzcLayer.FeatureClass.FindField("CZCMC");
|
|
|
|
|
var gx_GXSJ = _gxCzcLayer.FeatureClass.FindField("GXSJ");
|
|
|
|
|
var gx_CZCDM = _gxCzcLayer.FeatureClass.FindField("CZCDM");
|
|
|
|
|
var gx_CZCMC = _gxCzcLayer.FeatureClass.FindField("CZCMC");
|
|
|
|
|
int gc_GXSJ = _gxgcCzcLayer.FeatureClass.FindField("GXSJ");
|
|
|
|
|
var gx_YSDM = _gxCzcLayer.FeatureClass.FindField("YSDM");
|
|
|
|
|
int idxCZCBGMJ = _gxgcCzcLayer.FeatureClass.FindField("BGMJ");
|
|
|
|
|
var gxgc_bgxw = _gxgcCzcLayer.FeatureClass.FindField("BGXW");
|
|
|
|
|
var gx_BSM = _gxCzcLayer.FeatureClass.FindField("BSM");
|
|
|
|
|
var gx_CZCLX = _gxCzcLayer.FeatureClass.FindField("CZCLX");
|
|
|
|
|
var gxgc_BGHBSM = _gxgcCzcLayer.FeatureClass.FindField("BGHBSM");
|
|
|
|
|
var gxgc_BGHCZCDM = _gxgcCzcLayer.FeatureClass.FindField("BGHCZCDM");
|
|
|
|
|
var gxgc_BGHCZCMC = _gxgcCzcLayer.FeatureClass.FindField("BGHCZCMC");
|
|
|
|
|
var gxgc_BGHCZCLX = _gxgcCzcLayer.FeatureClass.FindField("BGHCZCLX");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Log:正在进行城镇村小于30平图斑灭失...");
|
|
|
|
|
string WhereClause = $" SHAPE_Area<30 and BGXW='2' and BGQCZCLX='203' and BGHCZCLX='203' ";
|
|
|
|
|
cursor = _gxgcCzcLayer.Search(new QueryFilter() { WhereClause = WhereClause }, true);
|
|
|
|
|
while ((czcgxgcfeature = cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
double bgmj = czcgxgcfeature.Value[idxCZCBGMJ].ToDecimal(2).ToDouble();
|
|
|
|
|
//与相邻更新层合并,继承最大图形的属性
|
|
|
|
|
List<IFeature> listFcCZC = FeatureAPI.Identify2(czcgxgcfeature.ShapeCopy, _gxCzcLayer);
|
|
|
|
|
if (listFcCZC.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
if (bgmj < 0.1) continue;
|
|
|
|
|
//提取地类图斑数据,作为无变化数据
|
|
|
|
|
List<IFeature> listFc = FeatureAPI.Identify2(czcgxgcfeature.ShapeCopy, _gxgcTBLayer);
|
|
|
|
|
if (listFc == null || listFc.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
czcgxgcfeature.Store();//城镇村小于30平灭失,需提取无变化地类图斑增量才可以灭失,否则做例外处理;
|
|
|
|
|
listFc = FeatureAPI.Identify2(czcgxgcfeature.ShapeCopy, _jcTbLayer);
|
|
|
|
|
if (listFc == null || listFc.Count == 0) continue;
|
|
|
|
|
//IFeature jctb_F = listFc[0];
|
|
|
|
|
bool IsMS = false;
|
|
|
|
|
foreach (IFeature jctb_F in listFc)
|
|
|
|
|
{
|
|
|
|
|
var listVs = FeatureAPI.Identify2(jctb_F.ShapeCopy, _jcCzcLayer);
|
|
|
|
|
if (listVs != null && listVs.Count > 0) continue;
|
|
|
|
|
else IsMS = true;//无变化地类图斑数据提取压盖到基础CZC不灭失
|
|
|
|
|
int idxTBMJ = jctb_F.Fields.FindField("TBMJ");
|
|
|
|
|
#region 地类图斑更新过程层
|
|
|
|
|
IFeatureCursor insertCur = _gxgcTBLayer.FeatureClass.Insert(true);
|
|
|
|
|
IFeatureBuffer gcBuf = _gxgcTBLayer.FeatureClass.CreateFeatureBuffer();
|
|
|
|
|
gcBuf.Shape = jctb_F.ShapeCopy;
|
|
|
|
|
for (int i = 0; i < _gxgcTBLayer.FeatureClass.Fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = _gxgcTBLayer.FeatureClass.Fields.Field[i];
|
|
|
|
|
if (!field.Editable || field.Name.Contains("SHAPE")) continue;
|
|
|
|
|
string sFieldName = field.Name.Replace("BGQ", "").Replace("BGH", "");
|
|
|
|
|
int idx = jctb_F.Fields.FindField(sFieldName);
|
|
|
|
|
if (idx == -1)
|
|
|
|
|
{
|
|
|
|
|
sFieldName = field.Name.Replace("BGQTB", "").Replace("BGHTB", "");
|
|
|
|
|
idx = jctb_F.Fields.FindField(sFieldName);
|
|
|
|
|
}
|
|
|
|
|
if (idx != -1)
|
|
|
|
|
gcBuf.Value[i] = jctb_F.Value[idx];
|
|
|
|
|
}
|
|
|
|
|
int idxBGXW = _gxgcTBLayer.FeatureClass.FindField("BGXW");
|
|
|
|
|
int idxBGMJ = _gxgcTBLayer.FeatureClass.FindField("TBBGMJ");
|
|
|
|
|
int iXZQTZLX = _gxgcTBLayer.FeatureClass.FindField("XZQTZLX");
|
|
|
|
|
int idxGXSJ = _gxgcTBLayer.FeatureClass.FindField("GXSJ");
|
|
|
|
|
gcBuf.Value[idxBGMJ] = jctb_F.Value[idxTBMJ];
|
|
|
|
|
gcBuf.Value[idxBGXW] = "4";
|
|
|
|
|
gcBuf.Value[iXZQTZLX] = "0";
|
|
|
|
|
gcBuf.Value[idxGXSJ] = DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31);
|
|
|
|
|
insertCur.InsertFeature(gcBuf);
|
|
|
|
|
insertCur.Flush();
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 地类图斑更新层
|
|
|
|
|
insertCur = _gxTbLayer.FeatureClass.Insert(true);
|
|
|
|
|
gcBuf = _gxTbLayer.FeatureClass.CreateFeatureBuffer();
|
|
|
|
|
gcBuf.Shape = jctb_F.ShapeCopy;
|
|
|
|
|
for (int i = 0; i < _gxTbLayer.FeatureClass.Fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = _gxTbLayer.FeatureClass.Fields.Field[i];
|
|
|
|
|
if (!field.Editable || field.Name.Contains("SHAPE")) continue;
|
|
|
|
|
string sFieldName = field.Name.Replace("BGQ", "").Replace("BGH", "");
|
|
|
|
|
int idx = jctb_F.Fields.FindField(sFieldName);
|
|
|
|
|
if (idx == -1)
|
|
|
|
|
{
|
|
|
|
|
sFieldName = field.Name.Replace("BGQTB", "").Replace("BGHTB", "");
|
|
|
|
|
idx = jctb_F.Fields.FindField(sFieldName);
|
|
|
|
|
}
|
|
|
|
|
if (idx != -1)
|
|
|
|
|
gcBuf.Value[i] = jctb_F.Value[idx];
|
|
|
|
|
}
|
|
|
|
|
idxGXSJ = _gxTbLayer.FeatureClass.FindField("GXSJ");
|
|
|
|
|
gcBuf.Value[idxGXSJ] = DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31);
|
|
|
|
|
insertCur.InsertFeature(gcBuf);
|
|
|
|
|
insertCur.Flush();
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
//进行城镇村灭失
|
|
|
|
|
if (IsMS == false) continue;
|
|
|
|
|
for (int i = 0; i < listFcCZC.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
feature = listFcCZC[i];
|
|
|
|
|
if (feature.Value[gx_CZCMJ].ToDouble(2) > 30) continue;
|
|
|
|
|
feature.Delete();
|
|
|
|
|
}
|
|
|
|
|
czcgxgcfeature.Value[gxgc_BGHBSM] = "";
|
|
|
|
|
czcgxgcfeature.Value[gxgc_BGHCZCDM] = "";
|
|
|
|
|
czcgxgcfeature.Value[gxgc_BGHCZCMC] = "";
|
|
|
|
|
czcgxgcfeature.Value[gxgc_BGHCZCLX] = "";
|
|
|
|
|
czcgxgcfeature.Value[gxgc_bgxw] = "0";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Log:小于30平图斑是否灭失执行失败:" + ex.Message);
|
|
|
|
|
Console.WriteLine("Log:小于30平图斑是否灭失执行失败:" + ex.StackTrace);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Log:正在进行城镇村小于30平的新增图斑合并...");
|
|
|
|
|
string WhereClause = $" SHAPE_Area<30 and BGXW='3' and BGHCZCLX='203' ";
|
|
|
|
|
cursor = _gxgcCzcLayer.FeatureClass.Update(new QueryFilter() { WhereClause = WhereClause }, true);
|
|
|
|
|
var strBSM = GetMaxBSM(new List<IFeatureClass>() { _gxCzcLayer.FeatureClass });
|
|
|
|
|
while ((czcgxgcfeature = cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
double bgmj = czcgxgcfeature.Value[idxCZCBGMJ].ToDecimal(2).ToDouble();
|
|
|
|
|
//与相邻更新层合并,继承最大图形的属性 删除CZC更新层碎图斑
|
|
|
|
|
List<IFeature> listFc = FeatureAPI.Identify2(czcgxgcfeature.ShapeCopy, _gxCzcLayer);
|
|
|
|
|
if (listFc.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < listFc.Count; i++)
|
|
|
|
|
{ //更新层CZC数据
|
|
|
|
|
if (listFc[i].Value[gx_CZCMJ].ToDouble(2) > 30) continue;
|
|
|
|
|
feature = listFc[i];
|
|
|
|
|
}
|
|
|
|
|
if (feature == null) continue;
|
|
|
|
|
listFc = FeatureAPI.Identify(czcgxgcfeature.ShapeCopy, _gxCzcLayer);
|
|
|
|
|
IFeature UnionFeature = null;
|
|
|
|
|
if (listFc.Count > 1)
|
|
|
|
|
{
|
|
|
|
|
var Unionlength = 0.0;
|
|
|
|
|
foreach (var ifeature in listFc)
|
|
|
|
|
{
|
|
|
|
|
if (!ifeature.Value[gx_CZCLX].Equals(czcgxgcfeature.Value[gxgc_BGHCZCLX]))
|
|
|
|
|
continue;
|
|
|
|
|
if (ifeature.Value[gx_BSM].Equals(czcgxgcfeature.Value[gxgc_BGHBSM]))
|
|
|
|
|
continue;
|
|
|
|
|
var length = FeatureAPI.LengthOfSide(czcgxgcfeature.ShapeCopy, ifeature.ShapeCopy);
|
|
|
|
|
if (length > Unionlength)
|
|
|
|
|
{
|
|
|
|
|
Unionlength = length;
|
|
|
|
|
UnionFeature = ifeature;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (UnionFeature != null)
|
|
|
|
|
{
|
|
|
|
|
czcgxgcfeature.Value[gxgc_BGHBSM] = UnionFeature.Value[gx_BSM];
|
|
|
|
|
cursor.UpdateFeature(czcgxgcfeature);
|
|
|
|
|
cursor.Flush();
|
|
|
|
|
UnionFeature.Shape = FeatureAPI.Union(UnionFeature.ShapeCopy, czcgxgcfeature.ShapeCopy);
|
|
|
|
|
UnionFeature.Value[gx_CZCMJ] = bgmj + UnionFeature.Value[gx_CZCMJ].ToDecimal(2).ToDouble();
|
|
|
|
|
UnionFeature.Store();
|
|
|
|
|
feature.Delete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (listFc.Count <= 1 || UnionFeature == null)
|
|
|
|
|
{
|
|
|
|
|
IFeatureCursor insertCur = _gxCzcLayer.FeatureClass.Insert(true);
|
|
|
|
|
IFeatureBuffer gxBuf = _gxCzcLayer.FeatureClass.CreateFeatureBuffer();
|
|
|
|
|
//提取基础城镇村范围合并30以内增量图斑
|
|
|
|
|
listFc = FeatureAPI.Identify(czcgxgcfeature.ShapeCopy, _jcCzcLayer);
|
|
|
|
|
if (listFc.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
if (listFc.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
if (!listFc[0].Value[jc_CZCSXM].ToString().Trim().Equals("203"))
|
|
|
|
|
continue;
|
|
|
|
|
UnionFeature = listFc[0];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var Unionlength = 0.00;
|
|
|
|
|
foreach (var ifeature in listFc)
|
|
|
|
|
{
|
|
|
|
|
if (!ifeature.Value[jc_CZCSXM].ToString().Trim().Equals("203"))
|
|
|
|
|
continue;
|
|
|
|
|
var length = FeatureAPI.LengthOfSide(czcgxgcfeature.ShapeCopy, ifeature.Shape);
|
|
|
|
|
if (length > Unionlength && !czcgxgcfeature.OID.Equals(ifeature.OID))
|
|
|
|
|
{
|
|
|
|
|
Unionlength = length;
|
|
|
|
|
UnionFeature = ifeature;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (UnionFeature == null) continue;
|
|
|
|
|
//提取到GXCZC图层数据
|
|
|
|
|
gxBuf.Shape = FeatureAPI.Union(UnionFeature.ShapeCopy, czcgxgcfeature.ShapeCopy);
|
|
|
|
|
gxBuf.Value[gx_CZCMJ] = Math.Round(bgmj + UnionFeature.Value[jc_CZCMJ].ToDecimal(2).ToDouble(), 2);
|
|
|
|
|
var strbsm = strBSM.Substring(0, 10);
|
|
|
|
|
var Maxbsm = strBSM.Substring(10).ToInt() + 1;
|
|
|
|
|
strBSM = strbsm + Maxbsm.ToString().PadLeft(8, '0');//最新标识码
|
|
|
|
|
gxBuf.Value[gx_BSM] = strBSM;
|
|
|
|
|
gxBuf.Value[gx_CZCDM] = UnionFeature.Value[jc_CZCDM];
|
|
|
|
|
gxBuf.Value[gx_CZCMC] = UnionFeature.Value[jc_CZCMC];
|
|
|
|
|
gxBuf.Value[gx_CZCLX] = "203";
|
|
|
|
|
gxBuf.Value[gx_YSDM] = "2099030100";
|
|
|
|
|
gxBuf.Value[gx_GXSJ] = DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31);
|
|
|
|
|
czcgxgcfeature.Value[gxgc_BGHBSM] = strBSM;
|
|
|
|
|
cursor.UpdateFeature(czcgxgcfeature);
|
|
|
|
|
cursor.Flush();
|
|
|
|
|
insertCur.InsertFeature(gxBuf);
|
|
|
|
|
insertCur.Flush();
|
|
|
|
|
//提取到GCCZC图层数据
|
|
|
|
|
insertCur = _gxgcCzcLayer.FeatureClass.Insert(true);
|
|
|
|
|
IFeatureBuffer gcBuf = _gxgcCzcLayer.FeatureClass.CreateFeatureBuffer();
|
|
|
|
|
gcBuf.Shape = UnionFeature.ShapeCopy;//基础城镇村图斑
|
|
|
|
|
for (int i = 0; i < _gxgcCzcLayer.FeatureClass.Fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = _gxgcCzcLayer.FeatureClass.Fields.Field[i];
|
|
|
|
|
if (!field.Editable || field.Name.Contains("SHAPE")) continue;
|
|
|
|
|
string sFieldName = field.Name.Replace("BGQ", "").Replace("BGH", "");
|
|
|
|
|
int idx = UnionFeature.Fields.FindField(sFieldName);
|
|
|
|
|
if (idx == -1)
|
|
|
|
|
{
|
|
|
|
|
sFieldName = field.Name.Replace("BGQTB", "").Replace("BGHTB", "");
|
|
|
|
|
idx = UnionFeature.Fields.FindField(sFieldName);
|
|
|
|
|
}
|
|
|
|
|
if (idx != -1)
|
|
|
|
|
gcBuf.Value[i] = UnionFeature.Value[idx];
|
|
|
|
|
}
|
|
|
|
|
gcBuf.Value[idxCZCBGMJ] = Math.Round(UnionFeature.Value[jc_CZCMJ].ToDecimal(2).ToDouble(), 2);
|
|
|
|
|
gcBuf.Value[gxgc_BGHBSM] = strBSM;
|
|
|
|
|
gcBuf.Value[gxgc_bgxw] = "2";
|
|
|
|
|
gcBuf.Value[gc_GXSJ] = DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31);
|
|
|
|
|
insertCur.InsertFeature(gcBuf);
|
|
|
|
|
insertCur.Flush();
|
|
|
|
|
feature.Delete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
feature = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Log:新增小于30平的图斑合并执行失败:" + ex.Message);
|
|
|
|
|
Console.WriteLine("Log:新增小于30平的图斑合并执行失败:" + ex.StackTrace);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
Console.WriteLine($"Log:城镇村更新数据提取完成{pParm.PrjInfo.LessThan30Missing}。耗时:{GetTime(StartTime)}");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Err:城镇村更新数据提取失败。");
|
|
|
|
|
Console.WriteLine("Err:城镇村更新数据提取失败。" + ex.Message);
|
|
|
|
|
Console.WriteLine("Err:城镇村更新数据提取失败。" + ex.StackTrace);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ZLBGTBExt()
|
|
|
|
|
{
|
|
|
|
|
IFeatureCursor cursur = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (GxgcTBLayer == null) return;
|
|
|
|
|
|
|
|
|
|
Dictionary<string, string> dicZLBG = new Dictionary<string, string>();
|
|
|
|
|
Dictionary<string, int> dicXZQDM = new Dictionary<string, int>();
|
|
|
|
|
List<string> BGQTBBSM = new List<string>();
|
|
|
|
|
cursur = GxgcTBLayer.FeatureClass.Search(new QueryFilterClass() { WhereClause = "ONLYZLBG='1' and (XZQTZLX='' or XZQTZLX='0' or XZQTZLX='5' or XZQTZLX is NULL)", SubFields = "BGQTBBSM,BGQZLDWDM,BGHZLDWDM,BGQZLDWMC,BGHZLDWMC" }, true);
|
|
|
|
|
IFeature f = null;
|
|
|
|
|
int idx_BGQBSM = GxgcTBLayer.FeatureClass.FindField("BGQTBBSM");
|
|
|
|
|
int idx_BGQZLDWDM = GxgcTBLayer.FeatureClass.FindField("BGQZLDWDM");
|
|
|
|
|
int idx_BGHZLDWDM = GxgcTBLayer.FeatureClass.FindField("BGHZLDWDM");
|
|
|
|
|
int idx_BGQZLDWMC = GxgcTBLayer.FeatureClass.FindField("BGQZLDWMC");
|
|
|
|
|
int idx_BGHZLDWMC = GxgcTBLayer.FeatureClass.FindField("BGHZLDWMC");
|
|
|
|
|
while ((f = cursur.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
string bgqzldwdm = f.Value[idx_BGQZLDWDM].ToTrim();
|
|
|
|
|
string bghzldwdm = f.Value[idx_BGHZLDWDM].ToTrim();
|
|
|
|
|
string bgqzldwmc = f.Value[idx_BGQZLDWMC].ToTrim();
|
|
|
|
|
string bghzldwmc = f.Value[idx_BGHZLDWMC].ToTrim();
|
|
|
|
|
string bgqtbbsm = f.Value[idx_BGQBSM].ToTrim();
|
|
|
|
|
string bgq = bgqzldwdm + "_" + bgqzldwmc;
|
|
|
|
|
string bgh = bghzldwdm + "_" + bghzldwmc;
|
|
|
|
|
if (bgq != bgh && !dicZLBG.ContainsKey(bgq))
|
|
|
|
|
{
|
|
|
|
|
dicZLBG.Add(bgq, bgh);
|
|
|
|
|
if (!dicXZQDM.ContainsKey(bgqzldwdm.Substring(0, 9)))
|
|
|
|
|
dicXZQDM.Add(bgqzldwdm.Substring(0, 9), 0);
|
|
|
|
|
}
|
|
|
|
|
if (bgq != bgh)
|
|
|
|
|
{
|
|
|
|
|
if (!BGQTBBSM.Contains(bgqtbbsm))
|
|
|
|
|
{
|
|
|
|
|
BGQTBBSM.Add(bgqtbbsm);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (dicXZQDM.Count == 0 && BGQTBBSM.Count == 0) return;
|
|
|
|
|
IGeometry BGQDLTBUnion = null;
|
|
|
|
|
int jcbsmIndex = JcTbLayer.FeatureClass.FindField("BSM");
|
|
|
|
|
#region 融合
|
|
|
|
|
string gdbFolder = Directory.GetCurrentDirectory() + "\\Temp\\CZC\\ZLBG";
|
|
|
|
|
if (!Directory.Exists(gdbFolder))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(gdbFolder);
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DelectDir(gdbFolder);//能删除就删除 删除报错不处理
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{ }
|
|
|
|
|
IWorkspaceFactory pFtWsFct = new FileGDBWorkspaceFactory();
|
|
|
|
|
string gdbFileName = Guid.NewGuid().ToString();
|
|
|
|
|
string path = System.IO.Path.Combine(gdbFolder, gdbFileName);
|
|
|
|
|
pFtWsFct.Create(path, "TempGDB", null, 0);
|
|
|
|
|
string TempfilePath = System.IO.Path.Combine(path, "TempGDB.gdb");//临时数据存放路径
|
|
|
|
|
IWorkspaceAPI wsAPI = new WorkspaceAPI(TempfilePath, WorkspaceTypeEnum.GDBFile);
|
|
|
|
|
IFeatureClassAPI CZCDYDBGTempFeatureclassAPI = wsAPI.CreateFeatureClass("CZCDYDBGTemp", (JcTbLayer.FeatureClass as IGeoDataset).SpatialReference, JcTbLayer.FeatureClass.Fields);
|
|
|
|
|
IFeatureCursor t_cursor = CZCDYDBGTempFeatureclassAPI.FeatureClass.Insert(true);
|
|
|
|
|
IFeatureCursor bgqcursor = JcTbLayer.FeatureClass.Search(new QueryFilterClass() { SubFields = "BSM,Shape" }, true);
|
|
|
|
|
while ((f = bgqcursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
string bsm = f.Value[jcbsmIndex].ToTrim();
|
|
|
|
|
if (!BGQTBBSM.Contains(bsm)) continue;
|
|
|
|
|
IFeatureBuffer buf = CZCDYDBGTempFeatureclassAPI.FeatureClass.CreateFeatureBuffer();
|
|
|
|
|
buf.Shape = f.ShapeCopy;
|
|
|
|
|
t_cursor.InsertFeature(buf);
|
|
|
|
|
}
|
|
|
|
|
t_cursor.Flush();
|
|
|
|
|
|
|
|
|
|
GPParamClass gPParamClass = new GPParamClass()
|
|
|
|
|
{
|
|
|
|
|
FirstFeatureLayer = new FeatureLayerClass() { FeatureClass = CZCDYDBGTempFeatureclassAPI.FeatureClass },
|
|
|
|
|
OutFeatureClassPath = TempfilePath,
|
|
|
|
|
FcName = "ZLBGTB",
|
|
|
|
|
IsGetOutPutFeature = true,
|
|
|
|
|
GPType = EnumGPType.FcToFc
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
IFeatureLayer zlbgTBLayer = null;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref zlbgTBLayer);
|
|
|
|
|
gPParamClass = new GPParamClass()
|
|
|
|
|
{
|
|
|
|
|
FirstFeatureLayer = zlbgTBLayer,
|
|
|
|
|
OutFeatureClassPath = TempfilePath + "\\" + "NewCZCDYD",
|
|
|
|
|
IsGetOutPutFeature = true,
|
|
|
|
|
GPType = EnumGPType.Dissolve,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
IFeatureLayer featureLayer = null;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref featureLayer);
|
|
|
|
|
|
|
|
|
|
IFeatureClassAPI TempDLTBGXGC = wsAPI.CreateFeatureClass("DLTBGXGC", (GxgcTBLayer.FeatureClass as IGeoDataset).SpatialReference, GxgcTBLayer.FeatureClass.Fields);
|
|
|
|
|
IFeatureClassAPI gxgcTbFcAPI = new FeatureClassAPI(GxgcTBLayer.FeatureClass);
|
|
|
|
|
IQueryFilter mFilter = new QueryFilterClass();
|
|
|
|
|
mFilter.WhereClause = "ONLYZLBG='1'";
|
|
|
|
|
gxgcTbFcAPI.FcToFc(TempDLTBGXGC.FeatureClass, null, false);
|
|
|
|
|
|
|
|
|
|
gPParamClass = new GPParamClass()
|
|
|
|
|
{
|
|
|
|
|
FirstFeatureLayer = JcCzcLayer,
|
|
|
|
|
SecondFeatureLayer = new FeatureLayerClass() { FeatureClass = TempDLTBGXGC.FeatureClass },
|
|
|
|
|
OutFeatureClassPath = $"{TempfilePath}\\CZC_TBGXGCUnion",
|
|
|
|
|
IsGetOutPutFeature = true,
|
|
|
|
|
PreserveAttributes = "ALL",
|
|
|
|
|
GPType = EnumGPType.Union
|
|
|
|
|
};
|
|
|
|
|
IFeatureLayer TempGxgcTBLayer = null;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref TempGxgcTBLayer);
|
|
|
|
|
|
|
|
|
|
IFeatureCursor cursor = TempGxgcTBLayer.FeatureClass.Search(null, true);
|
|
|
|
|
int idxCZCBSM = TempGxgcTBLayer.FeatureClass.FindField("BSM");
|
|
|
|
|
int idxTBOID = TempGxgcTBLayer.FeatureClass.FindField("FID_DLTBGXGC");
|
|
|
|
|
//int idxBGQZLDWDM = TempGxgcTBLayer.FeatureClass.FindField("BGQZLDWDM");
|
|
|
|
|
int idxBGHZLDWDM = TempGxgcTBLayer.FeatureClass.FindField("BGHZLDWDM");
|
|
|
|
|
//int idxBGQZLDWMC = TempGxgcTBLayer.FeatureClass.FindField("BGQZLDWMC");
|
|
|
|
|
int idxBGHZLDWMC = TempGxgcTBLayer.FeatureClass.FindField("BGHZLDWMC");
|
|
|
|
|
//int idxBGQZLDWMC = TempGxgcTBLayer.FeatureClass.FindField("BGQZLDWMC");
|
|
|
|
|
//int idxBGHZLDWMC = TempGxgcTBLayer.FeatureClass.FindField("BGHZLDWMC");
|
|
|
|
|
IFeature tempF = null;
|
|
|
|
|
Dictionary<string, string> bgDic = new Dictionary<string, string>();
|
|
|
|
|
while ((tempF = cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
string strbsm = tempF.Value[idxCZCBSM].ToTrim();
|
|
|
|
|
if (string.IsNullOrWhiteSpace(strbsm)) continue;
|
|
|
|
|
int tbOID = tempF.Value[idxTBOID].ToInt();
|
|
|
|
|
if (tbOID == -1) continue;
|
|
|
|
|
string bghZLDWDM = tempF.Value[idxBGHZLDWDM].ToTrim();
|
|
|
|
|
string bghZLDWMC = tempF.Value[idxBGHZLDWMC].ToTrim();
|
|
|
|
|
if (!bgDic.ContainsKey(strbsm))
|
|
|
|
|
bgDic.Add(strbsm, bghZLDWDM + "_" + bghZLDWMC);
|
|
|
|
|
}
|
|
|
|
|
//IFeatureLayer TempGxgcTBLayer = null;
|
|
|
|
|
//GPHelper.Instance.ExeGPForProces(gPParamClass, ref TempGxgcTBLayer);
|
|
|
|
|
//GeoprocessorHelper.DissolveAnalysis(gPParamClass, ref featureLayer, true);
|
|
|
|
|
bgqcursor = featureLayer.FeatureClass.Search(null, true);
|
|
|
|
|
IFeature bgqF = bgqcursor.NextFeature();
|
|
|
|
|
if (bgqF == null)
|
|
|
|
|
{
|
|
|
|
|
//MessageHelper.Show("完成");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
BGQDLTBUnion = bgqF.ShapeCopy;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
IFeatureClass czcgxgc = GxgcCzcLayer.FeatureClass;
|
|
|
|
|
ITable czcgxgcTable = czcgxgc as ITable;
|
|
|
|
|
ICursor cur = czcgxgcTable.Search(new QueryFilterClass() { SubFields = "OBJECTID,BGQBSM" }, true);
|
|
|
|
|
int bgqbsmIdx = czcgxgcTable.FindField("BGQBSM");
|
|
|
|
|
IRow row = null;
|
|
|
|
|
Dictionary<string, List<int>> dicBSM = new Dictionary<string, List<int>>();
|
|
|
|
|
while ((row = cur.NextRow()) != null)
|
|
|
|
|
{
|
|
|
|
|
string bgqbsm = row.Value[bgqbsmIdx].ToTrim();
|
|
|
|
|
if (!dicBSM.ContainsKey(bgqbsm))
|
|
|
|
|
{
|
|
|
|
|
dicBSM.Add(bgqbsm, new List<int>() { row.OID });
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dicBSM[bgqbsm].Add(row.OID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
IFeatureClass jcCZC = JcCzcLayer.FeatureClass;
|
|
|
|
|
IFeatureClass czcgx = GxCzcLayer.FeatureClass;
|
|
|
|
|
IFeatureCursor gxgcInsCur = czcgxgc.Insert(true);
|
|
|
|
|
IFeatureCursor gxInsCur = czcgx.Insert(true);
|
|
|
|
|
IFeatureBuffer gxgcBuf = null;
|
|
|
|
|
IFeatureBuffer gxBuf = null;
|
|
|
|
|
|
|
|
|
|
Dictionary<int, int> gcFieldMapp = new Dictionary<int, int>();
|
|
|
|
|
for (int i = 0; i < czcgxgc.Fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = czcgxgc.Fields.Field[i];
|
|
|
|
|
if (field.Name.ToUpper().Contains("SHAPE") || !field.Editable) continue;
|
|
|
|
|
int idx = jcCZC.FindField(field.Name.ToUpper().Replace("BGQ", "").Replace("BGH", ""));
|
|
|
|
|
if (idx == -1) continue;
|
|
|
|
|
gcFieldMapp.Add(i, idx);
|
|
|
|
|
}
|
|
|
|
|
Dictionary<int, int> gxFieldMapp = new Dictionary<int, int>();
|
|
|
|
|
for (int i = 0; i < czcgx.Fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = czcgx.Fields.Field[i];
|
|
|
|
|
if (field.Name.ToUpper().Contains("SHAPE") || !field.Editable) continue;
|
|
|
|
|
int idx = jcCZC.FindField(field.Name);
|
|
|
|
|
if (idx == -1) continue;
|
|
|
|
|
gxFieldMapp.Add(i, idx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cursor = jcCZC.Search(new SpatialFilterClass()
|
|
|
|
|
{
|
|
|
|
|
WhereClause = "CZCLX<>'201'",
|
|
|
|
|
Geometry = BGQDLTBUnion,
|
|
|
|
|
SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
|
|
|
|
|
}, true);
|
|
|
|
|
f = null;
|
|
|
|
|
int bsmIdx = jcCZC.FindField("BSM");
|
|
|
|
|
int bgxwIdx = czcgxgc.FindField("BGXW");
|
|
|
|
|
int bghbsmIdx = czcgxgc.FindField("BGHBSM");
|
|
|
|
|
int bghczclxIdx = czcgxgc.FindField("BGHCZCLX");
|
|
|
|
|
int bghczcdmIdx = czcgxgc.FindField("BGHCZCDM");
|
|
|
|
|
int bghczcmcIdx = czcgxgc.FindField("BGHCZCMC");
|
|
|
|
|
//变更前
|
|
|
|
|
int bgqczclxIdx = czcgxgc.FindField("BGQCZCLX");
|
|
|
|
|
int bgqczcdmIdx = czcgxgc.FindField("BGQCZCDM");
|
|
|
|
|
int bgqczcmcIdx = czcgxgc.FindField("BGQCZCMC");
|
|
|
|
|
int bgmjIdx = czcgxgc.FindField("BGMJ");
|
|
|
|
|
int GXSJIdx = czcgxgc.FindField("GXSJ");
|
|
|
|
|
int czcmjIdx = jcCZC.FindField("CZCMJ");
|
|
|
|
|
|
|
|
|
|
int gxBSMIdx = jcCZC.FindField("BSM");
|
|
|
|
|
int czcdmIdx = jcCZC.FindField("CZCDM");
|
|
|
|
|
int czcmcIdx = jcCZC.FindField("CZCMC");
|
|
|
|
|
int CZCGXSJIdx = czcgx.FindField("GXSJ");
|
|
|
|
|
//List<DataDicTionary> qsDic = pParm.PrjInfo Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.QSDM);
|
|
|
|
|
|
|
|
|
|
List<DataDicTionary> qsDic = null;
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper(System.IO.Path.Combine(pParm.PrjInfo.ProjDir, "BGTJ.sqlite"), DatabaseType.SQLite);
|
|
|
|
|
DataTable dicDt = rdbHelper.ExecuteDatatable("Dic", string.Format("SELECT * from Sys_Dicdetail where OWNERDIC=1"), true);
|
|
|
|
|
|
|
|
|
|
qsDic = KGIS.Framework.Utils.Utility.TBToList.ToList<DataDicTionary>(dicDt);// Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.QSDM);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Err:获取权属字典失败!" + ex.Message);
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int JC_DLTBBSM = JcTbLayer.FeatureClass.FindField("BSM");
|
|
|
|
|
string PrjCode = pParm.PrjInfo.CODE;
|
|
|
|
|
while ((f = cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
string bsm = f.Value[bsmIdx].ToTrim();
|
|
|
|
|
if (!bgDic.ContainsKey(bsm)) continue;
|
|
|
|
|
if (dicBSM.ContainsKey(bsm))
|
|
|
|
|
{
|
|
|
|
|
List<int> gcOIDList = dicBSM[bsm];
|
|
|
|
|
foreach (int gcOID in gcOIDList)
|
|
|
|
|
{
|
|
|
|
|
IFeature gcRow = czcgxgc.GetFeature(gcOID);
|
|
|
|
|
if (!FeatureAPI.IsInterSect(gcRow.ShapeCopy, BGQDLTBUnion)) continue;
|
|
|
|
|
string bghLX = gcRow.Value[bghczclxIdx].ToTrim();
|
|
|
|
|
string bghDM_MC = bgDic[bsm];
|
|
|
|
|
string[] bghAttr = bghDM_MC.Split('_');
|
|
|
|
|
if (bghLX.StartsWith("202"))
|
|
|
|
|
{
|
|
|
|
|
if (bghAttr[0].Length < 9) continue;
|
|
|
|
|
string dicValue = bgDic[bsm];
|
|
|
|
|
string strCZCDM2 = bghAttr[0].Substring(0, 9).PadRight(19, '0');
|
|
|
|
|
gcRow.Value[bghczcdmIdx] = strCZCDM2;
|
|
|
|
|
if (qsDic != null)
|
|
|
|
|
{
|
|
|
|
|
DataDicTionary dic = qsDic.FirstOrDefault(qs => qs.CODE == strCZCDM2 || qs.CODE.StartsWith(strCZCDM2.Substring(0, 9)));
|
|
|
|
|
if (dic != null)
|
|
|
|
|
{
|
|
|
|
|
//strCZCDM2 = dic.NAME;
|
|
|
|
|
gcRow.Value[bghczcmcIdx] = dic.NAME;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (bghLX.StartsWith("203"))
|
|
|
|
|
{
|
|
|
|
|
gcRow.Value[bghczcdmIdx] = bghAttr[0];
|
|
|
|
|
gcRow.Value[bghczcmcIdx] = bghAttr[1];
|
|
|
|
|
}
|
|
|
|
|
gcRow.Store();
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (pParm.PrjInfo.XZQDMChange == false)
|
|
|
|
|
{
|
|
|
|
|
if (!FeatureAPI.IsInterSect(f.ShapeCopy, BGQDLTBUnion)) continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<IGeometry> BG_ListGeo = new List<IGeometry>();
|
|
|
|
|
List<IGeometry> WBG_ListGeo = new List<IGeometry>();
|
|
|
|
|
|
|
|
|
|
IGeometry geo_BG = FeatureAPI.InterSect(f.ShapeCopy, BGQDLTBUnion);
|
|
|
|
|
if (pParm.PrjInfo.XZQDMChange == false && geo_BG.IsEmpty) continue;
|
|
|
|
|
BG_ListGeo = FeatureAPI.DissolveGeometryByRing(geo_BG);
|
|
|
|
|
|
|
|
|
|
IGeometry geo_WBG = FeatureAPI.Difference(f.ShapeCopy, BGQDLTBUnion);
|
|
|
|
|
string tempBGXW = "1";
|
|
|
|
|
double JcCZCMJ = f.Value[czcmjIdx].ToDecimal(2).ToDouble();
|
|
|
|
|
if (!geo_WBG.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
tempBGXW = "2";
|
|
|
|
|
WBG_ListGeo = FeatureAPI.DissolveGeometryByRing(geo_WBG);
|
|
|
|
|
}
|
|
|
|
|
Dictionary<string, IGeometry> DicAllGeo = new Dictionary<string, IGeometry>();
|
|
|
|
|
Dictionary<int, double> DicMJPC = new Dictionary<int, double>();
|
|
|
|
|
int idxNum = 0;
|
|
|
|
|
double zmj = 0;
|
|
|
|
|
foreach (var item in BG_ListGeo)
|
|
|
|
|
{
|
|
|
|
|
idxNum++;
|
|
|
|
|
double mj = JcCZCMJ;
|
|
|
|
|
if (tempBGXW == "2")
|
|
|
|
|
mj = item.GetEllipseArea().ToDouble(2);
|
|
|
|
|
DicMJPC.Add(idxNum, mj);
|
|
|
|
|
zmj += mj;
|
|
|
|
|
string key = idxNum + "_BG";
|
|
|
|
|
if (!DicAllGeo.ContainsKey(key))
|
|
|
|
|
DicAllGeo.Add(key, item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var item in WBG_ListGeo)
|
|
|
|
|
{
|
|
|
|
|
idxNum++;
|
|
|
|
|
double mj = JcCZCMJ;
|
|
|
|
|
if (tempBGXW == "2")
|
|
|
|
|
mj = item.GetEllipseArea().ToDouble(2);
|
|
|
|
|
DicMJPC.Add(idxNum, mj);
|
|
|
|
|
zmj += mj;
|
|
|
|
|
string key = idxNum + "_WBG";
|
|
|
|
|
if (!DicAllGeo.ContainsKey(key))
|
|
|
|
|
DicAllGeo.Add(key, item);
|
|
|
|
|
}
|
|
|
|
|
double mjc = (JcCZCMJ - zmj).ToDouble(2);
|
|
|
|
|
if (mjc != 0)
|
|
|
|
|
{
|
|
|
|
|
IOrderedEnumerable<KeyValuePair<int, double>> od = DicMJPC.OrderByDescending(o => o.Value);
|
|
|
|
|
foreach (var item in od)
|
|
|
|
|
{
|
|
|
|
|
DicMJPC[item.Key] = (DicMJPC[item.Key] + mjc).ToDouble(2);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int changNum = 0;
|
|
|
|
|
foreach (var key in DicAllGeo.Keys)
|
|
|
|
|
{
|
|
|
|
|
string[] subKey = key.Split('_');
|
|
|
|
|
int idxKey = subKey[0].ToInt();
|
|
|
|
|
double bgmj = DicMJPC[idxKey];
|
|
|
|
|
|
|
|
|
|
if (gxgcBuf == null)
|
|
|
|
|
gxgcBuf = czcgxgc.CreateFeatureBuffer();
|
|
|
|
|
//gxgcBuf.Shape = DicAllGeo[key];// f.ShapeCopy;
|
|
|
|
|
foreach (KeyValuePair<int, int> idx in gcFieldMapp)
|
|
|
|
|
{
|
|
|
|
|
gxgcBuf.Value[idx.Key] = f.Value[idx.Value];
|
|
|
|
|
}
|
|
|
|
|
string bghczclx = gxgcBuf.Value[bghczclxIdx].ToTrim();
|
|
|
|
|
string bghczcdm = gxgcBuf.Value[bghczcdmIdx].ToTrim();
|
|
|
|
|
string bghczcmc = gxgcBuf.Value[bghczcmcIdx].ToTrim();
|
|
|
|
|
//变更前
|
|
|
|
|
string bgqczclx = gxgcBuf.Value[bgqczclxIdx].ToTrim();
|
|
|
|
|
string bgqczcdm = gxgcBuf.Value[bgqczcdmIdx].ToTrim();
|
|
|
|
|
string bgqczcmc = gxgcBuf.Value[bgqczcmcIdx].ToTrim();
|
|
|
|
|
|
|
|
|
|
string bgh = bghczcdm + "_" + bghczcmc;
|
|
|
|
|
string strCZCDM = bghczcdm;
|
|
|
|
|
string strCZCMC = bghczcmc;
|
|
|
|
|
if (subKey[1] == "BG")
|
|
|
|
|
{
|
|
|
|
|
if (bghczclx == "203" || bghczclx == "203A" || bghczclx == "204" || bghczclx == "205")
|
|
|
|
|
{
|
|
|
|
|
string[] zlArr = bgDic[bsm].Split('_');
|
|
|
|
|
strCZCDM = zlArr[0];
|
|
|
|
|
strCZCMC = zlArr[1];
|
|
|
|
|
gxgcBuf.Value[bghczcdmIdx] = zlArr[0];
|
|
|
|
|
gxgcBuf.Value[bghczcmcIdx] = zlArr[1];
|
|
|
|
|
}
|
|
|
|
|
else if (bghczclx == "202" || bghczclx == "202A")
|
|
|
|
|
{
|
|
|
|
|
string dicValue = bgDic[bsm];
|
|
|
|
|
strCZCDM = dicValue.Substring(0, 9).PadRight(19, '0');
|
|
|
|
|
gxgcBuf.Value[bghczcdmIdx] = strCZCDM;
|
|
|
|
|
if (qsDic != null)
|
|
|
|
|
{
|
|
|
|
|
DataDicTionary dic = qsDic.FirstOrDefault(qs => qs.CODE == strCZCDM || qs.CODE.StartsWith(strCZCDM.Substring(0, 9)));
|
|
|
|
|
if (dic != null)
|
|
|
|
|
{
|
|
|
|
|
strCZCMC = dic.NAME;
|
|
|
|
|
gxgcBuf.Value[bghczcmcIdx] = strCZCMC;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (bgqczcdm == strCZCDM && bgqczcmc == strCZCMC) continue;
|
|
|
|
|
}
|
|
|
|
|
bghczcdm = gxgcBuf.Value[bghczcdmIdx].ToTrim();
|
|
|
|
|
bghczcmc = gxgcBuf.Value[bghczcmcIdx].ToTrim();
|
|
|
|
|
}
|
|
|
|
|
if (bghczcdm.Trim() == bgqczcdm.Trim() && bghczcmc.Trim() == bgqczcmc.Trim())//bghczclx.Trim() == bgqczclx.Trim() &&
|
|
|
|
|
continue;
|
|
|
|
|
changNum++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (changNum == 0) continue;
|
|
|
|
|
|
|
|
|
|
foreach (var key in DicAllGeo.Keys)
|
|
|
|
|
{
|
|
|
|
|
string[] subKey = key.Split('_');
|
|
|
|
|
int idxKey = subKey[0].ToInt();
|
|
|
|
|
double bgmj = DicMJPC[idxKey];
|
|
|
|
|
|
|
|
|
|
if (gxgcBuf == null)
|
|
|
|
|
gxgcBuf = czcgxgc.CreateFeatureBuffer();
|
|
|
|
|
gxgcBuf.Shape = DicAllGeo[key];// f.ShapeCopy;
|
|
|
|
|
foreach (KeyValuePair<int, int> idx in gcFieldMapp)
|
|
|
|
|
{
|
|
|
|
|
gxgcBuf.Value[idx.Key] = f.Value[idx.Value];
|
|
|
|
|
}
|
|
|
|
|
string bghczclx = gxgcBuf.Value[bghczclxIdx].ToTrim();
|
|
|
|
|
string bghczcdm = gxgcBuf.Value[bghczcdmIdx].ToTrim();
|
|
|
|
|
string bghczcmc = gxgcBuf.Value[bghczcmcIdx].ToTrim();
|
|
|
|
|
//变更前
|
|
|
|
|
string bgqczclx = gxgcBuf.Value[bgqczclxIdx].ToTrim();
|
|
|
|
|
string bgqczcdm = gxgcBuf.Value[bgqczcdmIdx].ToTrim();
|
|
|
|
|
string bgqczcmc = gxgcBuf.Value[bgqczcmcIdx].ToTrim();
|
|
|
|
|
|
|
|
|
|
string bgh = bghczcdm + "_" + bghczcmc;
|
|
|
|
|
string strCZCDM = bghczcdm;
|
|
|
|
|
string strCZCMC = bghczcmc;
|
|
|
|
|
if (subKey[1] == "BG")
|
|
|
|
|
{
|
|
|
|
|
if (bghczclx == "203" || bghczclx == "203A" || bghczclx == "204" || bghczclx == "205")
|
|
|
|
|
{
|
|
|
|
|
string[] zlArr = bgDic[bsm].Split('_');
|
|
|
|
|
strCZCDM = zlArr[0];
|
|
|
|
|
strCZCMC = zlArr[1];
|
|
|
|
|
gxgcBuf.Value[bghczcdmIdx] = zlArr[0];
|
|
|
|
|
gxgcBuf.Value[bghczcmcIdx] = zlArr[1];
|
|
|
|
|
}
|
|
|
|
|
else if (bghczclx == "202" || bghczclx == "202A")
|
|
|
|
|
{
|
|
|
|
|
string dicValue = bgDic[bsm];
|
|
|
|
|
strCZCDM = dicValue.Substring(0, 9).PadRight(19, '0');
|
|
|
|
|
gxgcBuf.Value[bghczcdmIdx] = strCZCDM;
|
|
|
|
|
if (qsDic != null)
|
|
|
|
|
{
|
|
|
|
|
DataDicTionary dic = qsDic.FirstOrDefault(qs => qs.CODE == strCZCDM || qs.CODE.StartsWith(strCZCDM.Substring(0, 9)));
|
|
|
|
|
if (dic != null)
|
|
|
|
|
{
|
|
|
|
|
strCZCMC = dic.NAME;
|
|
|
|
|
gxgcBuf.Value[bghczcmcIdx] = strCZCMC;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (tempBGXW == "1" && bgqczcdm == strCZCDM && bgqczcmc == strCZCMC) continue;
|
|
|
|
|
}
|
|
|
|
|
bghczcdm = gxgcBuf.Value[bghczcdmIdx].ToTrim();
|
|
|
|
|
bghczcmc = gxgcBuf.Value[bghczcmcIdx].ToTrim();
|
|
|
|
|
}
|
|
|
|
|
if (tempBGXW == "1" && bghczclx.Trim() == bgqczclx.Trim() && bghczcdm.Trim() == bgqczcdm.Trim() && bghczcmc.Trim() == bgqczcmc.Trim())
|
|
|
|
|
continue;//前后这三个字段没有前后变化则不插入
|
|
|
|
|
//gxgcBuf.Value[] = "";
|
|
|
|
|
string bghbsm = gxgcBuf.Value[bghbsmIdx].ToTrim();
|
|
|
|
|
if (!bghbsm.StartsWith(PrjCode))
|
|
|
|
|
{
|
|
|
|
|
string strR = bghbsm.Substring(0, 6);
|
|
|
|
|
gxgcBuf.Value[bghbsmIdx] = bghbsm.Replace(strR, PrjCode);
|
|
|
|
|
}
|
|
|
|
|
gxgcBuf.Value[bgxwIdx] = tempBGXW;
|
|
|
|
|
gxgcBuf.Value[bgmjIdx] = bgmj;// f.Value[czcmjIdx];
|
|
|
|
|
gxgcBuf.Value[GXSJIdx] = DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31);
|
|
|
|
|
gxgcInsCur.InsertFeature(gxgcBuf);
|
|
|
|
|
|
|
|
|
|
//if (gxBuf == null)
|
|
|
|
|
// gxBuf = czcgx.CreateFeatureBuffer();
|
|
|
|
|
//gxBuf.Shape = f.ShapeCopy;
|
|
|
|
|
//foreach (KeyValuePair<int, int> idx in gxFieldMapp)
|
|
|
|
|
//{
|
|
|
|
|
// gxBuf.Value[idx.Key] = f.Value[idx.Value];
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//string gxbsm = gxBuf.Value[gxBSMIdx].ToTrim();
|
|
|
|
|
//if (!gxbsm.StartsWith(PrjCode))
|
|
|
|
|
//{
|
|
|
|
|
// string strR = gxbsm.Substring(0, 6);
|
|
|
|
|
// gxBuf.Value[gxBSMIdx] = gxbsm.Replace(strR, PrjCode);
|
|
|
|
|
//}
|
|
|
|
|
//gxBuf.Value[czcdmIdx] = strCZCDM;
|
|
|
|
|
//gxBuf.Value[czcmcIdx] = strCZCMC;
|
|
|
|
|
//gxBuf.Value[CZCGXSJIdx] = time;
|
|
|
|
|
//gxInsCur.InsertFeature(gxBuf);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gxgcInsCur.Flush();
|
|
|
|
|
//gxInsCur.Flush();
|
|
|
|
|
if (pParm.PrjInfo.XZQDMChange == true)
|
|
|
|
|
{
|
|
|
|
|
cur = czcgxgcTable.Search(new QueryFilterClass() { SubFields = "BGQBSM" }, true);
|
|
|
|
|
bgqbsmIdx = czcgxgcTable.FindField("BGQBSM");
|
|
|
|
|
row = null;
|
|
|
|
|
Dictionary<string, int> dicBSM2 = new Dictionary<string, int>();
|
|
|
|
|
while ((row = cur.NextRow()) != null)
|
|
|
|
|
{
|
|
|
|
|
string bgqbsm = row.Value[bgqbsmIdx].ToTrim();
|
|
|
|
|
if (!dicBSM2.ContainsKey(bgqbsm))
|
|
|
|
|
{
|
|
|
|
|
dicBSM2.Add(bgqbsm, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cursor = jcCZC.Search(null, true);
|
|
|
|
|
f = null;
|
|
|
|
|
while ((f = cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
string bsm = f.Value[bsmIdx].ToTrim();
|
|
|
|
|
if (dicBSM2.ContainsKey(bsm)) continue;
|
|
|
|
|
if (gxgcBuf == null)
|
|
|
|
|
gxgcBuf = czcgxgc.CreateFeatureBuffer();
|
|
|
|
|
gxgcBuf.Shape = f.ShapeCopy;
|
|
|
|
|
foreach (KeyValuePair<int, int> idx in gcFieldMapp)
|
|
|
|
|
{
|
|
|
|
|
gxgcBuf.Value[idx.Key] = f.Value[idx.Value];
|
|
|
|
|
}
|
|
|
|
|
string bghbsm = gxgcBuf.Value[bghbsmIdx].ToTrim();
|
|
|
|
|
string bghczclx = gxgcBuf.Value[bghczclxIdx].ToTrim();
|
|
|
|
|
string bghczcdm = gxgcBuf.Value[bghczcdmIdx].ToTrim();
|
|
|
|
|
string bghczcmc = gxgcBuf.Value[bghczcmcIdx].ToTrim();
|
|
|
|
|
//变更前
|
|
|
|
|
string bgqbsm = gxgcBuf.Value[bgqbsmIdx].ToTrim();
|
|
|
|
|
string bgqczclx = gxgcBuf.Value[bgqczclxIdx].ToTrim();
|
|
|
|
|
string bgqczcdm = gxgcBuf.Value[bgqczcdmIdx].ToTrim();
|
|
|
|
|
string bgqczcmc = gxgcBuf.Value[bgqczcmcIdx].ToTrim();
|
|
|
|
|
|
|
|
|
|
bghbsm = gxgcBuf.Value[bghbsmIdx].ToTrim();
|
|
|
|
|
if (!bghbsm.StartsWith(PrjCode))
|
|
|
|
|
{
|
|
|
|
|
string strR = bghbsm.Substring(0, 6);
|
|
|
|
|
gxgcBuf.Value[bghbsmIdx] = bghbsm.Replace(strR, PrjCode);
|
|
|
|
|
}
|
|
|
|
|
if (!bghczcdm.StartsWith(PrjCode))
|
|
|
|
|
{
|
|
|
|
|
string strR = bghczcdm.Substring(0, 6);
|
|
|
|
|
gxgcBuf.Value[bghczcdmIdx] = bghczcdm.Replace(strR, PrjCode);
|
|
|
|
|
}
|
|
|
|
|
gxgcBuf.Value[bgxwIdx] = "1";
|
|
|
|
|
gxgcBuf.Value[bgmjIdx] = f.Value[czcmjIdx];
|
|
|
|
|
gxgcBuf.Value[GXSJIdx] = DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31);
|
|
|
|
|
gxgcInsCur.InsertFeature(gxgcBuf);
|
|
|
|
|
|
|
|
|
|
//if (gxBuf == null)
|
|
|
|
|
// gxBuf = czcgx.CreateFeatureBuffer();
|
|
|
|
|
//gxBuf.Shape = f.ShapeCopy;
|
|
|
|
|
//foreach (KeyValuePair<int, int> idx in gxFieldMapp)
|
|
|
|
|
//{
|
|
|
|
|
// gxBuf.Value[idx.Key] = f.Value[idx.Value];
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//string gxbsm = gxBuf.Value[gxBSMIdx].ToTrim();
|
|
|
|
|
//if (!gxbsm.StartsWith(PrjCode))
|
|
|
|
|
//{
|
|
|
|
|
// string strR = gxbsm.Substring(0, 6);
|
|
|
|
|
// gxBuf.Value[gxBSMIdx] = gxbsm.Replace(strR, PrjCode);
|
|
|
|
|
//}
|
|
|
|
|
//string gxCZCDM = gxBuf.Value[czcdmIdx].ToTrim();
|
|
|
|
|
//if (!gxCZCDM.StartsWith(PrjCode))
|
|
|
|
|
//{
|
|
|
|
|
// string strR = gxCZCDM.Substring(0, 6);
|
|
|
|
|
// gxBuf.Value[czcdmIdx] = gxCZCDM.Replace(strR, PrjCode);
|
|
|
|
|
//}
|
|
|
|
|
////gxBuf.Value[czcdmIdx] = strCZCDM;
|
|
|
|
|
////gxBuf.Value[czcmcIdx] = strCZCMC;
|
|
|
|
|
//gxBuf.Value[CZCGXSJIdx] = time;
|
|
|
|
|
//gxInsCur.InsertFeature(gxBuf);
|
|
|
|
|
}
|
|
|
|
|
gxgcInsCur.Flush();
|
|
|
|
|
//gxInsCur.Flush();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void ResultPress(IFeatureLayer pGxgcLayer, IFeatureLayer pGxLayer)
|
|
|
|
|
{
|
|
|
|
|
IFeatureCursor _cursor = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_cursor = pGxgcLayer.FeatureClass.Search(null, true);
|
|
|
|
|
Dictionary<string, int> BgqBSMList = new Dictionary<string, int>();
|
|
|
|
|
Dictionary<string, int> BghBSMList = new Dictionary<string, int>();
|
|
|
|
|
IFeature f = null;
|
|
|
|
|
int idxBgqBSM = pGxgcLayer.FeatureClass.FindField("BGQBSM");
|
|
|
|
|
int idxBghBSM = pGxgcLayer.FeatureClass.FindField("BGHBSM");
|
|
|
|
|
while ((f = _cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
string strBgqBSM = f.Value[idxBgqBSM].ToTrim();
|
|
|
|
|
string strBghBSM = f.Value[idxBghBSM].ToTrim();
|
|
|
|
|
if (BgqBSMList.ContainsKey(strBgqBSM))
|
|
|
|
|
BgqBSMList[strBgqBSM] = BgqBSMList[strBgqBSM] + 1;
|
|
|
|
|
else
|
|
|
|
|
BgqBSMList.Add(strBgqBSM, 1);
|
|
|
|
|
|
|
|
|
|
if (BghBSMList.ContainsKey(strBghBSM))
|
|
|
|
|
BghBSMList[strBghBSM] = BghBSMList[strBghBSM] + 1;
|
|
|
|
|
else
|
|
|
|
|
BghBSMList.Add(strBghBSM, 1);
|
|
|
|
|
}
|
|
|
|
|
IQueryFilter filter = new QueryFilter();
|
|
|
|
|
filter.WhereClause = "BGQCZCLX = BGHCZCLX and BGQCZCDM = BGHCZCDM and BGQCZCMC = BGHCZCMC";
|
|
|
|
|
_cursor = pGxgcLayer.FeatureClass.Update(filter, true);
|
|
|
|
|
int idxBGXW = pGxgcLayer.FeatureClass.FindField("BGXW");
|
|
|
|
|
List<string> DelBSM = new List<string>();
|
|
|
|
|
while ((f = _cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
string strBgqBSM = f.Value[idxBgqBSM].ToTrim();
|
|
|
|
|
string strBghBSM = f.Value[idxBghBSM].ToTrim();
|
|
|
|
|
if (BgqBSMList[strBgqBSM] == 1 && BghBSMList[strBghBSM] == 1)
|
|
|
|
|
{
|
|
|
|
|
f.Value[idxBGXW] = "9";
|
|
|
|
|
DelBSM.Add(strBghBSM);
|
|
|
|
|
_cursor.UpdateFeature(f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_cursor.Flush();
|
|
|
|
|
filter.WhereClause = "BGXW='9'";
|
|
|
|
|
(pGxgcLayer.FeatureClass as ITable).DeleteSearchedRows(filter);
|
|
|
|
|
_cursor = pGxLayer.FeatureClass.Update(null, true);
|
|
|
|
|
int idxBSM = pGxLayer.FeatureClass.FindField("BSM");
|
|
|
|
|
while ((f = _cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
string strBSM = f.Value[idxBSM].ToTrim();
|
|
|
|
|
if (DelBSM.Contains(strBSM))
|
|
|
|
|
{
|
|
|
|
|
f.Value[idxBSM] = "-1";
|
|
|
|
|
_cursor.UpdateFeature(f);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_cursor.Flush();
|
|
|
|
|
filter.WhereClause = "BSM='-1'";
|
|
|
|
|
(pGxLayer.FeatureClass as ITable).DeleteSearchedRows(filter);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void GenerateGXGC(IFeatureLayer pGXGCLayer, IFeatureLayer pUnion20XLayer, List<DataDicTionary> pQSDic)
|
|
|
|
|
{
|
|
|
|
|
IFeatureCursor S_Cursor = null;
|
|
|
|
|
IFeatureCursor T_Cursor = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IQueryFilter filter = new QueryFilterClass();
|
|
|
|
|
//新增的20范围
|
|
|
|
|
string strWhere = @"FID_CZCDYD = -1 AND CZCSXM IS NOT NULL AND CZCSXM <> ''";
|
|
|
|
|
//filter.WhereClause = strWhere;
|
|
|
|
|
// //灭失的20范围
|
|
|
|
|
// strWhere = @"FID_CZCDYD <> -1 AND (CZCSXM IS NULL OR CZCSXM ='')";
|
|
|
|
|
|
|
|
|
|
strWhere = @"(FID_CZCDYD = -1 AND CZCSXM IS NOT NULL AND CZCSXM <> '') OR (FID_CZCDYD <> -1 AND (CZCSXM IS NULL OR CZCSXM =''))";
|
|
|
|
|
|
|
|
|
|
filter.WhereClause = strWhere;
|
|
|
|
|
|
|
|
|
|
if (pUnion20XLayer == null) return;
|
|
|
|
|
int idx_JCOID, idx_GXOID, idx_JCCZCLX, idx_JCCZCDM, idx_GXCZCLX, idx_GXCZCDM;
|
|
|
|
|
idx_JCOID = pUnion20XLayer.FeatureClass.FindField("FID_JC_CZC20X");
|
|
|
|
|
if (idx_JCOID == -1)
|
|
|
|
|
idx_JCOID = pUnion20XLayer.FeatureClass.FindField("FID_JC_CZC203");
|
|
|
|
|
if (idx_JCOID == -1)
|
|
|
|
|
idx_JCOID = pUnion20XLayer.FeatureClass.FindField("FID_CZCDYD");
|
|
|
|
|
idx_GXOID = pUnion20XLayer.FeatureClass.FindField("FID_CZC20X");
|
|
|
|
|
if (idx_GXOID == -1)
|
|
|
|
|
idx_GXOID = pUnion20XLayer.FeatureClass.FindField("FID_CZC203");
|
|
|
|
|
if (idx_GXOID == -1)
|
|
|
|
|
idx_GXOID = pUnion20XLayer.FeatureClass.FindField("FID_TempDLTBGX");
|
|
|
|
|
|
|
|
|
|
idx_JCCZCLX = pUnion20XLayer.FeatureClass.FindField("CZCLX");
|
|
|
|
|
idx_JCCZCDM = pUnion20XLayer.FeatureClass.FindField("CZCDM");
|
|
|
|
|
idx_GXCZCDM = pUnion20XLayer.FeatureClass.FindField("ZLDWDM");
|
|
|
|
|
idx_GXCZCLX = pUnion20XLayer.FeatureClass.FindField("CZCSXM");
|
|
|
|
|
|
|
|
|
|
int idx_JCBSM, idx_JCCZCMC, idx_JCCZCMJ;
|
|
|
|
|
idx_JCBSM = pUnion20XLayer.FeatureClass.FindField("BSM");
|
|
|
|
|
idx_JCCZCMC = pUnion20XLayer.FeatureClass.FindField("CZCMC");
|
|
|
|
|
idx_JCCZCMJ = pUnion20XLayer.FeatureClass.FindField("CZCMJ");
|
|
|
|
|
|
|
|
|
|
IFeature f = null;
|
|
|
|
|
Dictionary<int, int> JcOIDs = new Dictionary<int, int>();
|
|
|
|
|
Dictionary<int, int> GxOIDs = new Dictionary<int, int>();
|
|
|
|
|
List<int> TempOIDList = new List<int>();
|
|
|
|
|
int idxArea = pUnion20XLayer.FeatureClass.FindField("Shape_Area");
|
|
|
|
|
|
|
|
|
|
S_Cursor = pUnion20XLayer.FeatureClass.Search(null, true);
|
|
|
|
|
while ((f = S_Cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
if (idx_JCOID == -1 && idx_GXOID == -1) break;
|
|
|
|
|
//double area = f.Value[idxArea].ToDecimal(2).ToDouble();
|
|
|
|
|
TempOIDList.Add(f.OID);
|
|
|
|
|
int JCOID = idx_JCOID == -1 ? -1 : f.Value[idx_JCOID].ToInt();
|
|
|
|
|
int GXOID = idx_GXOID == -1 ? -1 : f.Value[idx_GXOID].ToInt();
|
|
|
|
|
string BGXW = "";
|
|
|
|
|
if (JCOID != -1)
|
|
|
|
|
if (!JcOIDs.ContainsKey(JCOID))
|
|
|
|
|
JcOIDs.Add(JCOID, 1);
|
|
|
|
|
else
|
|
|
|
|
JcOIDs[JCOID] = JcOIDs[JCOID] + 1;
|
|
|
|
|
if (GXOID != -1)
|
|
|
|
|
if (!GxOIDs.ContainsKey(GXOID))
|
|
|
|
|
GxOIDs.Add(GXOID, 1);
|
|
|
|
|
else
|
|
|
|
|
GxOIDs[GXOID] = GxOIDs[GXOID] + 1;
|
|
|
|
|
}
|
|
|
|
|
S_Cursor = pUnion20XLayer.FeatureClass.Search(filter, true);
|
|
|
|
|
|
|
|
|
|
T_Cursor = pGXGCLayer.FeatureClass.Insert(true);
|
|
|
|
|
IFeatureBuffer buff = pGXGCLayer.FeatureClass.CreateFeatureBuffer();
|
|
|
|
|
int idx_BGXW, idx_BGQCZCLX, idx_BGQCZCDM, idx_BGHCZCLX, idx_BGQBSM, idx_BGQCZCMC, idx_BGMJ, idx_BGHCZCDM, idx_BGHBSM, idx_BGHCZCMC;
|
|
|
|
|
idx_BGXW = buff.Fields.FindField("BGXW");
|
|
|
|
|
idx_BGQCZCLX = buff.Fields.FindField("BGQCZCLX");
|
|
|
|
|
idx_BGQCZCDM = buff.Fields.FindField("BGQCZCDM");
|
|
|
|
|
idx_BGHCZCDM = buff.Fields.FindField("BGHCZCDM");
|
|
|
|
|
idx_BGHCZCLX = buff.Fields.FindField("BGHCZCLX");
|
|
|
|
|
idx_BGQBSM = buff.Fields.FindField("BGQBSM");
|
|
|
|
|
idx_BGHBSM = buff.Fields.FindField("BGHBSM");
|
|
|
|
|
idx_BGQCZCMC = buff.Fields.FindField("BGQCZCMC");
|
|
|
|
|
idx_BGHCZCMC = buff.Fields.FindField("BGHCZCMC");
|
|
|
|
|
idx_BGMJ = buff.Fields.FindField("BGMJ");
|
|
|
|
|
int idxBSM = buff.Fields.FindField("BSM");
|
|
|
|
|
int bsm = 0;
|
|
|
|
|
while ((f = S_Cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
int JCOID = idx_JCOID != -1 ? f.Value[idx_JCOID].ToInt() : -1;
|
|
|
|
|
int GXOID = idx_GXOID != -1 ? f.Value[idx_GXOID].ToInt() : -1;
|
|
|
|
|
string CZCLX = idx_JCCZCLX != -1 ? f.Value[idx_JCCZCLX].ToTrim() : "";
|
|
|
|
|
string CZCSXM = f.Value[idx_GXCZCLX].ToTrim();
|
|
|
|
|
string CZCDM = f.Value[idx_GXCZCDM].ToTrim();
|
|
|
|
|
string JCBSM = idx_JCBSM != -1 ? f.Value[idx_JCBSM].ToTrim() : "";
|
|
|
|
|
string JCCZCDM = idx_JCCZCDM != -1 ? f.Value[idx_JCCZCDM].ToTrim() : "";
|
|
|
|
|
string JCCZCMC = idx_JCCZCMC != -1 ? f.Value[idx_JCCZCMC].ToTrim() : "";
|
|
|
|
|
double BGMJ = 0;
|
|
|
|
|
//if (AreaList.ContainsKey(f.OID))
|
|
|
|
|
// BGMJ = AreaList[f.OID];
|
|
|
|
|
//else
|
|
|
|
|
string BGXW = JCOID == -1 ? "3" : "0";
|
|
|
|
|
if (BGXW == "0")
|
|
|
|
|
{
|
|
|
|
|
CZCSXM = "";
|
|
|
|
|
CZCDM = "";
|
|
|
|
|
if (JcOIDs[JCOID] == 1)
|
|
|
|
|
{
|
|
|
|
|
BGMJ = f.Value[idx_JCCZCMJ].ToDouble();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BGMJ = f.ShapeCopy.GetEllipseArea();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BGMJ = f.ShapeCopy.GetEllipseArea();
|
|
|
|
|
}
|
|
|
|
|
string BSM = "";
|
|
|
|
|
bsm++;
|
|
|
|
|
buff.Shape = f.ShapeCopy;
|
|
|
|
|
if (idxBSM != -1)
|
|
|
|
|
buff.Value[idxBSM] = pParm.PrjInfo.CODE + "2932" + bsm.ToString().PadLeft(8, '0');
|
|
|
|
|
if (idx_BGXW != -1)
|
|
|
|
|
buff.Value[idx_BGXW] = BGXW;
|
|
|
|
|
if (idx_BGQCZCLX != -1)
|
|
|
|
|
buff.Value[idx_BGQCZCLX] = CZCLX;
|
|
|
|
|
if (idx_BGHCZCLX != -1)
|
|
|
|
|
buff.Value[idx_BGHCZCLX] = CZCSXM;
|
|
|
|
|
if (idx_BGQBSM != -1)
|
|
|
|
|
buff.Value[idx_BGQBSM] = JCBSM;
|
|
|
|
|
if (idx_BGQCZCDM != -1)
|
|
|
|
|
buff.Value[idx_BGQCZCDM] = JCCZCDM;
|
|
|
|
|
if (idx_BGQCZCMC != -1)
|
|
|
|
|
buff.Value[idx_BGQCZCMC] = JCCZCMC;
|
|
|
|
|
if (idx_BGMJ != -1)
|
|
|
|
|
buff.Value[idx_BGMJ] = BGMJ;
|
|
|
|
|
if (idx_BGHCZCDM != -1)
|
|
|
|
|
buff.Value[idx_BGHCZCDM] = CZCDM;
|
|
|
|
|
if (idx_BGHBSM != -1)
|
|
|
|
|
buff.Value[idx_BGHBSM] = BSM;
|
|
|
|
|
if (idx_BGHCZCMC != -1 && !string.IsNullOrWhiteSpace(CZCDM))
|
|
|
|
|
{
|
|
|
|
|
DataDicTionary qs2 = null;
|
|
|
|
|
if (pQSDic != null)
|
|
|
|
|
{
|
|
|
|
|
qs2 = pQSDic.FirstOrDefault(d => d.CODE == CZCDM.Replace("0000000000000", "") || d.CODE == CZCDM.Replace("0000000000", ""));
|
|
|
|
|
}
|
|
|
|
|
if (qs2 != null)
|
|
|
|
|
{
|
|
|
|
|
buff.Value[idx_BGHCZCMC] = qs2.NAME;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
buff.Value[idx_BGHCZCMC] = "";
|
|
|
|
|
}
|
|
|
|
|
T_Cursor.InsertFeature(buff);
|
|
|
|
|
}
|
|
|
|
|
T_Cursor.Flush();
|
|
|
|
|
filter.WhereClause = "FID_CZCDYD <> -1 AND CZCSXM IS NOT NULL AND CZCSXM <>''";
|
|
|
|
|
S_Cursor = pUnion20XLayer.FeatureClass.Search(filter, true);
|
|
|
|
|
while ((f = S_Cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
int JCOID = idx_JCOID != -1 ? f.Value[idx_JCOID].ToInt() : -1;
|
|
|
|
|
int GXOID = idx_GXOID != -1 ? f.Value[idx_GXOID].ToInt() : -1;
|
|
|
|
|
string CZCLX = idx_JCCZCLX != -1 ? f.Value[idx_JCCZCLX].ToTrim() : "";
|
|
|
|
|
string CZCSXM = f.Value[idx_GXCZCLX].ToTrim();
|
|
|
|
|
var bgqCZCDM = f.Value[idx_JCCZCDM].ToTrim();
|
|
|
|
|
var bghCZCDM = f.Value[idx_GXCZCDM].ToTrim();
|
|
|
|
|
string JCBSM = idx_JCBSM != -1 ? f.Value[idx_JCBSM].ToTrim() : "";
|
|
|
|
|
string JCCZCMC = idx_JCCZCMC != -1 ? f.Value[idx_JCCZCMC].ToTrim() : "";
|
|
|
|
|
double JCCZCMJ = idx_JCCZCMJ != -1 ? f.Value[idx_JCCZCMJ].ToDouble() : 0;
|
|
|
|
|
double BGMJ = 0;// f.ShapeCopy.GetEllipseArea();
|
|
|
|
|
//if (AreaList.ContainsKey(f.OID))
|
|
|
|
|
// BGMJ = AreaList[f.OID];
|
|
|
|
|
//else
|
|
|
|
|
string BGXW = "";
|
|
|
|
|
string BSM = "";
|
|
|
|
|
if (JcOIDs[JCOID] == 1)
|
|
|
|
|
{
|
|
|
|
|
BGXW = "1";
|
|
|
|
|
BGMJ = f.Value[idx_JCCZCMJ].ToDouble();
|
|
|
|
|
BSM = JCBSM;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BGXW = "2";
|
|
|
|
|
BGMJ = f.ShapeCopy.GetEllipseArea();
|
|
|
|
|
}
|
|
|
|
|
bsm++;
|
|
|
|
|
buff.Shape = f.ShapeCopy;
|
|
|
|
|
if (idxBSM != -1)
|
|
|
|
|
buff.Value[idxBSM] = pParm.PrjInfo.CODE + "2932" + bsm.ToString().PadLeft(8, '0');
|
|
|
|
|
if (idx_BGXW != -1)
|
|
|
|
|
buff.Value[idx_BGXW] = BGXW;
|
|
|
|
|
if (idx_BGQCZCLX != -1)
|
|
|
|
|
buff.Value[idx_BGQCZCLX] = CZCLX;
|
|
|
|
|
if (idx_BGQCZCDM != -1)
|
|
|
|
|
buff.Value[idx_BGQCZCDM] = bgqCZCDM;
|
|
|
|
|
if (idx_BGHCZCLX != -1)
|
|
|
|
|
buff.Value[idx_BGHCZCLX] = CZCSXM;
|
|
|
|
|
if (idx_BGQBSM != -1)
|
|
|
|
|
buff.Value[idx_BGQBSM] = JCBSM;
|
|
|
|
|
if (idx_BGQCZCMC != -1)
|
|
|
|
|
buff.Value[idx_BGQCZCMC] = JCCZCMC;
|
|
|
|
|
if (idx_BGMJ != -1)
|
|
|
|
|
{
|
|
|
|
|
if (BGXW == "1" && JCCZCMJ != 0)
|
|
|
|
|
{
|
|
|
|
|
buff.Value[idx_BGMJ] = JCCZCMJ;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
buff.Value[idx_BGMJ] = BGMJ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (idx_BGHCZCDM != -1)
|
|
|
|
|
buff.Value[idx_BGHCZCDM] = bghCZCDM;
|
|
|
|
|
if (idx_BGHBSM != -1)
|
|
|
|
|
buff.Value[idx_BGHBSM] = BSM;
|
|
|
|
|
if (idx_BGHCZCMC != -1 && !string.IsNullOrWhiteSpace(bghCZCDM))
|
|
|
|
|
{
|
|
|
|
|
DataDicTionary qs2 = null;
|
|
|
|
|
if (pQSDic != null)
|
|
|
|
|
{
|
|
|
|
|
qs2 = pQSDic.FirstOrDefault(d => d.CODE == bghCZCDM.Replace("0000000000000", "") || d.CODE == bghCZCDM.Replace("0000000000", ""));
|
|
|
|
|
}
|
|
|
|
|
if (qs2 != null)
|
|
|
|
|
{
|
|
|
|
|
buff.Value[idx_BGHCZCMC] = qs2.NAME;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
T_Cursor.InsertFeature(buff);
|
|
|
|
|
}
|
|
|
|
|
T_Cursor.Flush();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (S_Cursor != null)
|
|
|
|
|
Marshal.ReleaseComObject(S_Cursor);
|
|
|
|
|
if (T_Cursor != null)
|
|
|
|
|
Marshal.ReleaseComObject(T_Cursor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GenerateXz203GXGC(IFeatureLayer pGXGCLayer, IFeatureLayer pUnion20XLayer, List<DataDicTionary> pQSDic)
|
|
|
|
|
{
|
|
|
|
|
IFeatureCursor S_Cursor = null;
|
|
|
|
|
IFeatureCursor T_Cursor = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IQueryFilter filter = new QueryFilterClass();
|
|
|
|
|
filter.WhereClause = "";
|
|
|
|
|
|
|
|
|
|
if (pUnion20XLayer == null) return;
|
|
|
|
|
S_Cursor = pUnion20XLayer.FeatureClass.Search(filter, true);
|
|
|
|
|
int idx_GXCZCLX, idx_GXCZCDM;
|
|
|
|
|
|
|
|
|
|
idx_GXCZCDM = pUnion20XLayer.FeatureClass.FindField("ZLDWDM");
|
|
|
|
|
idx_GXCZCLX = pUnion20XLayer.FeatureClass.FindField("CZCSXM");
|
|
|
|
|
|
|
|
|
|
IFeature f = null;
|
|
|
|
|
Dictionary<int, int> JcOIDs = new Dictionary<int, int>();
|
|
|
|
|
Dictionary<int, int> GxOIDs = new Dictionary<int, int>();
|
|
|
|
|
List<int> TempOIDList = new List<int>();
|
|
|
|
|
int idxArea = pUnion20XLayer.FeatureClass.FindField("Shape_Area");
|
|
|
|
|
|
|
|
|
|
T_Cursor = pGXGCLayer.FeatureClass.Insert(true);
|
|
|
|
|
IFeatureBuffer buff = pGXGCLayer.FeatureClass.CreateFeatureBuffer();
|
|
|
|
|
int idx_BGXW, idx_BGQCZCLX, idx_BGHCZCLX, idx_BGQBSM, idx_BGQCZCMC, idx_BGMJ, idx_BGHCZCDM, idx_BGHBSM, idx_BGHCZCMC;
|
|
|
|
|
idx_BGXW = buff.Fields.FindField("BGXW");
|
|
|
|
|
idx_BGQCZCLX = buff.Fields.FindField("BGQCZCLX");
|
|
|
|
|
idx_BGHCZCDM = buff.Fields.FindField("BGHCZCDM");
|
|
|
|
|
idx_BGHCZCLX = buff.Fields.FindField("BGHCZCLX");
|
|
|
|
|
idx_BGQBSM = buff.Fields.FindField("BGQBSM");
|
|
|
|
|
idx_BGHBSM = buff.Fields.FindField("BGHBSM");
|
|
|
|
|
idx_BGQCZCMC = buff.Fields.FindField("BGQCZCMC");
|
|
|
|
|
idx_BGHCZCMC = buff.Fields.FindField("BGHCZCMC");
|
|
|
|
|
idx_BGMJ = buff.Fields.FindField("BGMJ");
|
|
|
|
|
int idxBSM = buff.Fields.FindField("BSM");
|
|
|
|
|
int bsm = 0;
|
|
|
|
|
while ((f = S_Cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
string CZCSXM = f.Value[idx_GXCZCLX].ToTrim();
|
|
|
|
|
string CZCDM = f.Value[idx_GXCZCDM].ToTrim();
|
|
|
|
|
double BGMJ = 0;// f.ShapeCopy.GetEllipseArea();
|
|
|
|
|
//if (AreaList.ContainsKey(f.OID))
|
|
|
|
|
// BGMJ = AreaList[f.OID];
|
|
|
|
|
//else
|
|
|
|
|
BGMJ = f.ShapeCopy.GetEllipseArea();
|
|
|
|
|
if (BGMJ == 0)
|
|
|
|
|
continue;
|
|
|
|
|
string BGXW = "3";
|
|
|
|
|
string BSM = "";
|
|
|
|
|
buff.Shape = f.ShapeCopy;
|
|
|
|
|
bsm++;
|
|
|
|
|
if (idxBSM != -1)
|
|
|
|
|
buff.Value[idxBSM] = pParm.PrjInfo.CODE + "2932" + bsm.ToString().PadLeft(8, '0');
|
|
|
|
|
if (idx_BGXW != -1)
|
|
|
|
|
buff.Value[idx_BGXW] = BGXW;
|
|
|
|
|
if (idx_BGHCZCLX != -1)
|
|
|
|
|
buff.Value[idx_BGHCZCLX] = CZCSXM;
|
|
|
|
|
if (idx_BGMJ != -1)
|
|
|
|
|
buff.Value[idx_BGMJ] = BGMJ;
|
|
|
|
|
if (idx_BGHCZCDM != -1)
|
|
|
|
|
buff.Value[idx_BGHCZCDM] = CZCDM;
|
|
|
|
|
if (idx_BGHBSM != -1)
|
|
|
|
|
buff.Value[idx_BGHBSM] = BSM;
|
|
|
|
|
if (idx_BGHCZCMC != -1 && !string.IsNullOrWhiteSpace(CZCDM))
|
|
|
|
|
{
|
|
|
|
|
DataDicTionary qs2 = null;
|
|
|
|
|
if (pQSDic != null)
|
|
|
|
|
{
|
|
|
|
|
qs2 = pQSDic.FirstOrDefault(d => d.CODE == CZCDM.Replace("0000000000000", "") || d.CODE == CZCDM.Replace("0000000000", ""));
|
|
|
|
|
}
|
|
|
|
|
if (qs2 != null)
|
|
|
|
|
{
|
|
|
|
|
buff.Value[idx_BGHCZCMC] = qs2.NAME;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
T_Cursor.InsertFeature(buff);
|
|
|
|
|
}
|
|
|
|
|
T_Cursor.Flush();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (S_Cursor != null)
|
|
|
|
|
Marshal.ReleaseComObject(S_Cursor);
|
|
|
|
|
if (T_Cursor != null)
|
|
|
|
|
Marshal.ReleaseComObject(T_Cursor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GenerateGX(IFeatureLayer pGxgcLayer, IFeatureLayer pGXLayer)
|
|
|
|
|
{
|
|
|
|
|
IFeatureCursor S_Cursor = null;
|
|
|
|
|
IFeatureCursor T_Cursor = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IFeatureLayer DissoveLayer = null;
|
|
|
|
|
GPParamClass gPParamClass = new GPParamClass();
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
gPParamClass.FirstFeatureLayer = pGxgcLayer;
|
|
|
|
|
gPParamClass.GPType = EnumGPType.CZCBG;
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
//gPParamClass.Where_clause = "BGXW <> '3' or (BGHCZCLX <> '203' and BGHCZCLX <> '203A')";
|
|
|
|
|
|
|
|
|
|
gPParamClass.FcName = "TempCZCGX";
|
|
|
|
|
gPParamClass.TempGDBPath = TempGDBPath;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref DissoveLayer);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
////非新增203范围
|
|
|
|
|
//IFeatureLayer Fxz203Layer = null;
|
|
|
|
|
//gPParamClass = new GPParamClass();
|
|
|
|
|
//gPParamClass.FirstFeatureLayer = pGxgcLayer;
|
|
|
|
|
//gPParamClass.GPType = EnumGPType.SelectLayerByAttribute;
|
|
|
|
|
//gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
//gPParamClass.Where_clause = "BGXW <> '3' or (BGHCZCLX <> '203' and BGHCZCLX <> '203A')";
|
|
|
|
|
//gPParamClass.FcName = "FXZ203";
|
|
|
|
|
//gPParamClass.TempGDBPath = TempGDBPath;
|
|
|
|
|
//GPHelper.Instance.ExeGPForProces(gPParamClass, ref Fxz203Layer);
|
|
|
|
|
|
|
|
|
|
////新增203范围
|
|
|
|
|
//IFeatureLayer xz203Layer = null;
|
|
|
|
|
//gPParamClass = new GPParamClass();
|
|
|
|
|
//gPParamClass.FirstFeatureLayer = pGxgcLayer;
|
|
|
|
|
//gPParamClass.GPType = EnumGPType.SelectLayerByAttribute;
|
|
|
|
|
//gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
//gPParamClass.Where_clause = "BGXW = '3' and (BGHCZCLX = '203' or BGHCZCLX = '203A')";
|
|
|
|
|
//gPParamClass.FcName = "XZ203FW";
|
|
|
|
|
//gPParamClass.TempGDBPath = TempGDBPath;
|
|
|
|
|
//GPHelper.Instance.ExeGPForProces(gPParamClass, ref xz203Layer);
|
|
|
|
|
|
|
|
|
|
//gPParamClass = new GPParamClass();
|
|
|
|
|
//gPParamClass.FirstFeatureLayer = Fxz203Layer;
|
|
|
|
|
//gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\Fxz203GX_Dissolve";
|
|
|
|
|
//gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
//gPParamClass.ListDissolveFiledName = new List<string>() { "BGHCZCLX", "BGHCZCDM", "BGHCZCMC" };
|
|
|
|
|
//gPParamClass.GPType = EnumGPType.Dissolve;
|
|
|
|
|
//GPHelper.Instance.ExeGPForProces(gPParamClass, ref DissoveLayer);
|
|
|
|
|
|
|
|
|
|
//IFeatureLayer GxXz203Layer = null;
|
|
|
|
|
//gPParamClass = new GPParamClass();
|
|
|
|
|
//gPParamClass.FirstFeatureLayer = xz203Layer;
|
|
|
|
|
//gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\Xz203GX_Dissolve";
|
|
|
|
|
//gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
//gPParamClass.ListDissolveFiledName = new List<string>() { "BGHCZCLX", "BGHCZCDM", "BGHCZCMC" };
|
|
|
|
|
//gPParamClass.GPType = EnumGPType.Dissolve;
|
|
|
|
|
//GPHelper.Instance.ExeGPForProces(gPParamClass, ref GxXz203Layer);
|
|
|
|
|
//IFeatureClassAPI fcAPI = new FeatureClassAPI(GxXz203Layer.FeatureClass);
|
|
|
|
|
//fcAPI.FcToFc(DissoveLayer.FeatureClass, null, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IQueryFilter filter = new QueryFilter();
|
|
|
|
|
filter.WhereClause = "BGHCZCLX IS NOT NULL and BGHCZCLX <> ''";
|
|
|
|
|
S_Cursor = DissoveLayer.FeatureClass.Search(filter, true);
|
|
|
|
|
int idx_BGHCZCLX, idx_BGHCZCDM, idx_BGHCZCMC;
|
|
|
|
|
|
|
|
|
|
idx_BGHCZCLX = DissoveLayer.FeatureClass.FindField("BGHCZCLX");
|
|
|
|
|
idx_BGHCZCDM = DissoveLayer.FeatureClass.FindField("BGHCZCDM");
|
|
|
|
|
idx_BGHCZCMC = DissoveLayer.FeatureClass.FindField("BGHCZCMC");
|
|
|
|
|
//idx_BGHBSM = DissoveLayer.FeatureClass.FindField("BGHBSM");
|
|
|
|
|
IFeature f = null;
|
|
|
|
|
|
|
|
|
|
//(pGXLayer.FeatureClass as ITable).DeleteSearchedRows(null);
|
|
|
|
|
int idx_CZCLX, idx_CZCDM, idx_CZCMC, idx_BSM;
|
|
|
|
|
T_Cursor = pGXLayer.FeatureClass.Insert(true);
|
|
|
|
|
IFeatureBuffer buff = pGXLayer.FeatureClass.CreateFeatureBuffer();
|
|
|
|
|
idx_CZCLX = buff.Fields.FindField("CZCLX");
|
|
|
|
|
idx_CZCDM = buff.Fields.FindField("CZCDM");
|
|
|
|
|
idx_CZCMC = buff.Fields.FindField("CZCMC");
|
|
|
|
|
idx_BSM = buff.Fields.FindField("BSM");
|
|
|
|
|
int idxYSDM = buff.Fields.FindField("YSDM");
|
|
|
|
|
while ((f = S_Cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
string CZCLX = f.Value[idx_BGHCZCLX].ToTrim();
|
|
|
|
|
string CZCDM = f.Value[idx_BGHCZCDM].ToTrim();
|
|
|
|
|
string CZCMC = f.Value[idx_BGHCZCMC].ToTrim();
|
|
|
|
|
buff.Shape = f.ShapeCopy;
|
|
|
|
|
if (idxYSDM != -1)
|
|
|
|
|
buff.Value[idxYSDM] = "2099030100";
|
|
|
|
|
if (idx_CZCLX != -1)
|
|
|
|
|
buff.Value[idx_CZCLX] = CZCLX;
|
|
|
|
|
if (idx_CZCDM != -1)
|
|
|
|
|
buff.Value[idx_CZCDM] = CZCDM;
|
|
|
|
|
if (idx_CZCMC != -1)
|
|
|
|
|
buff.Value[idx_CZCMC] = CZCMC;
|
|
|
|
|
T_Cursor.InsertFeature(buff);
|
|
|
|
|
}
|
|
|
|
|
T_Cursor.Flush();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (S_Cursor != null)
|
|
|
|
|
Marshal.ReleaseComObject(S_Cursor);
|
|
|
|
|
if (T_Cursor != null)
|
|
|
|
|
Marshal.ReleaseComObject(T_Cursor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetAttribute(IFeatureLayer pGxgcLaeyr, IFeatureLayer pGxLayer, IFeatureLayer pJcCzcLayer)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IRDBHelper rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + TempDBPath, DatabaseType.SQLite);
|
|
|
|
|
IFeatureLayer Temp_UnionLayer = null;
|
|
|
|
|
GPParamClass paramClass = new GPParamClass()
|
|
|
|
|
{
|
|
|
|
|
FirstFeatureLayer = pGxLayer,
|
|
|
|
|
SecondFeatureLayer = pGxgcLaeyr,
|
|
|
|
|
OutFeatureClassPath = $"{TempGDBPath}\\GX_GXGCUnion",
|
|
|
|
|
IsGetOutPutFeature = true,
|
|
|
|
|
PreserveAttributes = "ALL",
|
|
|
|
|
GPType = EnumGPType.Union
|
|
|
|
|
};
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(paramClass, ref Temp_UnionLayer);
|
|
|
|
|
|
|
|
|
|
IFeatureCursor jcCursor = pJcCzcLayer.FeatureClass.Search(null, true);
|
|
|
|
|
IFeature f = null;
|
|
|
|
|
int idxCZCMJ = pJcCzcLayer.FeatureClass.FindField("CZCMJ");
|
|
|
|
|
int idxBSM = pJcCzcLayer.FeatureClass.FindField("BSM");
|
|
|
|
|
Dictionary<string, double> dicJcMJs = new Dictionary<string, double>();
|
|
|
|
|
|
|
|
|
|
IWorkspace ws = (Temp_UnionLayer.FeatureClass as FeatureClass).Workspace;
|
|
|
|
|
rdbHelper.ExecuteSQL(" drop table GX_GXGCUnion ");
|
|
|
|
|
|
|
|
|
|
IWorkspace pOutWork = CreateDBWorkspace(TempDBPath);
|
|
|
|
|
TableToTable(ws as IFeatureWorkspace, pOutWork, "GX_GXGCUnion");
|
|
|
|
|
|
|
|
|
|
DataTable dtBgqBSM = rdbHelper.ExecuteDatatable("bgq", "select bgqbsm from gx_gxgcUnion where bgqbsm <> '' group by bgqbsm HAVING count(bgqbsm)>1", true);
|
|
|
|
|
dtBgqBSM.PrimaryKey = new DataColumn[] { dtBgqBSM.Columns[0] };
|
|
|
|
|
|
|
|
|
|
IFeatureCursor gcCursor = Temp_UnionLayer.FeatureClass.Update(null, true);
|
|
|
|
|
int idxBGMJ = Temp_UnionLayer.FeatureClass.FindField("BGMJ");
|
|
|
|
|
int idxBGQBSM = Temp_UnionLayer.FeatureClass.FindField("BGQBSM");
|
|
|
|
|
while ((f = gcCursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
string strBGQBSM = f.Value[idxBGQBSM].ToTrim();
|
|
|
|
|
if (!dtBgqBSM.Rows.Contains(strBGQBSM)) continue;
|
|
|
|
|
if (!dicJcMJs.ContainsKey(strBGQBSM))
|
|
|
|
|
dicJcMJs.Add(strBGQBSM, 0);
|
|
|
|
|
f.Value[idxBGMJ] = f.ShapeCopy.GetEllipseArea();
|
|
|
|
|
gcCursor.UpdateFeature(f);
|
|
|
|
|
}
|
|
|
|
|
gcCursor.Flush();
|
|
|
|
|
rdbHelper.ExecuteSQL(" drop table GX_GXGCUnion ");
|
|
|
|
|
TableToTable(ws as IFeatureWorkspace, pOutWork, "GX_GXGCUnion");
|
|
|
|
|
while ((f = jcCursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
string s = (pJcCzcLayer.FeatureClass as FeatureClass).Workspace.PathName;
|
|
|
|
|
string bsm = f.Value[idxBSM].ToTrim();
|
|
|
|
|
double area = f.Value[idxCZCMJ].ToDecimal(2).ToDouble();//.ToDouble(2);
|
|
|
|
|
if (!dicJcMJs.ContainsKey(bsm))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
dicJcMJs[bsm] = area;// (area - dicJcMJs[bsm]).ToDouble(2);
|
|
|
|
|
}
|
|
|
|
|
DataTable GX_GXGCUnion = rdbHelper.ExecuteDatatable("tab", "select FID_CZCDYDGX,FID_CZCDYDGXGC,BGQBSM,BGMJ,BGXW,BGHBSM from GX_GXGCUnion order by bgmj desc", true);
|
|
|
|
|
foreach (string itemBSM in dicJcMJs.Keys)
|
|
|
|
|
{
|
|
|
|
|
List<Adjustment> shpList = new List<Adjustment>();
|
|
|
|
|
var rows = GX_GXGCUnion.Select($"BGQBSM ='{itemBSM}'");
|
|
|
|
|
var bgxw_0 = false;
|
|
|
|
|
var bgmj_0 = false;
|
|
|
|
|
foreach (var item in rows)
|
|
|
|
|
{
|
|
|
|
|
Adjustment adj = new Adjustment();
|
|
|
|
|
adj.ID = item["FID_CZCDYDGXGC"].ToInt();
|
|
|
|
|
bgxw_0 = item["BGXW"].ToTrim() == "0" ? true : false;
|
|
|
|
|
bgmj_0 = item["BGMJ"].ToTrim() == "0" ? true : false;
|
|
|
|
|
if (AreaList.ContainsKey(adj.ID))
|
|
|
|
|
adj.bgmj = AreaList[adj.ID];
|
|
|
|
|
else
|
|
|
|
|
adj.bgmj = item["BGMJ"].ToDouble();
|
|
|
|
|
shpList.Add(adj);
|
|
|
|
|
}
|
|
|
|
|
if (shpList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
AreaAdjustment(shpList, dicJcMJs[itemBSM]);//面积平差
|
|
|
|
|
foreach (var item in shpList)
|
|
|
|
|
{
|
|
|
|
|
DataRow upRow = rows.FirstOrDefault(r => r["FID_CZCDYDGXGC"].ToInt() == item.ID);
|
|
|
|
|
if (upRow != null)
|
|
|
|
|
{
|
|
|
|
|
upRow.BeginEdit();
|
|
|
|
|
upRow["BGMJ"] = item.bgmj;
|
|
|
|
|
upRow.EndEdit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#region 灭失的 面积为0的数据 将面积为0的面积修改为0.01 相同变更前标识码的面积最大的减去0.01
|
|
|
|
|
if (bgxw_0 && bgmj_0)
|
|
|
|
|
{
|
|
|
|
|
bool iscontinue = false;
|
|
|
|
|
foreach (var item in shpList)
|
|
|
|
|
{
|
|
|
|
|
DataRow upRow = rows.FirstOrDefault(r => r["FID_CZCDYDGXGC"].ToInt() == item.ID);
|
|
|
|
|
if (upRow != null)
|
|
|
|
|
{
|
|
|
|
|
upRow.BeginEdit();
|
|
|
|
|
if (item.bgmj == 0)
|
|
|
|
|
{
|
|
|
|
|
upRow["BGMJ"] = 0.01;
|
|
|
|
|
upRow.EndEdit();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (iscontinue) continue;
|
|
|
|
|
upRow["BGMJ"] = item.bgmj - 0.01;
|
|
|
|
|
upRow.EndEdit();
|
|
|
|
|
iscontinue = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Dictionary<int, int> gxIDCount = new Dictionary<int, int>();
|
|
|
|
|
foreach (DataRow dr in GX_GXGCUnion.Rows)
|
|
|
|
|
{
|
|
|
|
|
int gxID = dr["FID_CZCDYDGX"].ToInt();
|
|
|
|
|
if (gxIDCount.ContainsKey(gxID))
|
|
|
|
|
gxIDCount[gxID] = gxIDCount[gxID] + 1;
|
|
|
|
|
else
|
|
|
|
|
gxIDCount.Add(gxID, 1);
|
|
|
|
|
}
|
|
|
|
|
Dictionary<int, string> bsmDic = new Dictionary<int, string>();
|
|
|
|
|
Dictionary<int, int> OIDdic = new Dictionary<int, int>();
|
|
|
|
|
var strBSM = GetMaxBSM(new List<IFeatureClass>() { _jcCzcLayer.FeatureClass });
|
|
|
|
|
if (string.IsNullOrEmpty(strBSM))
|
|
|
|
|
strBSM = pParm.PrjInfo.CODE + "2931";
|
|
|
|
|
List<string> newBsmList = new List<string>();
|
|
|
|
|
Dictionary<int, double> DicBGMJ = new Dictionary<int, double>();
|
|
|
|
|
List<int> TXBG = new List<int>();
|
|
|
|
|
foreach (DataRow item in GX_GXGCUnion.Rows)
|
|
|
|
|
{
|
|
|
|
|
int gxID = item["FID_CZCDYDGX"].ToInt();
|
|
|
|
|
int gxgcID = item["FID_CZCDYDGXGC"].ToInt();
|
|
|
|
|
string bgxw = item["BGXW"].ToString();
|
|
|
|
|
string bgqBSM = item["BGQBSM"].ToTrim();
|
|
|
|
|
if (!DicBGMJ.ContainsKey(gxgcID))
|
|
|
|
|
DicBGMJ.Add(gxgcID, item["BGMJ"].ToDouble());
|
|
|
|
|
if (!bsmDic.ContainsKey(gxID))
|
|
|
|
|
{
|
|
|
|
|
if (bgxw == "2" || bgxw == "3" || gxIDCount[gxID] > 1)
|
|
|
|
|
{
|
|
|
|
|
var strbsm = strBSM.Substring(0, 10);
|
|
|
|
|
var Maxbsm = strBSM.Substring(10).ToInt() + 1;
|
|
|
|
|
strBSM = strbsm + Maxbsm.ToString().PadLeft(8, '0');//最新标识码
|
|
|
|
|
bsmDic.Add(gxID, strBSM);
|
|
|
|
|
if (!newBsmList.Contains(strBSM))
|
|
|
|
|
newBsmList.Add(strBSM);
|
|
|
|
|
if (bgxw == "1" && !TXBG.Contains(gxgcID))
|
|
|
|
|
{
|
|
|
|
|
TXBG.Add(gxgcID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string strGXBSM = item["BGHBSM"].ToTrim();
|
|
|
|
|
if (!strGXBSM.StartsWith(pParm.PrjInfo.CODE) || !bgqBSM.StartsWith(pParm.PrjInfo.CODE))
|
|
|
|
|
{
|
|
|
|
|
var strbsm = strBSM.Substring(0, 10);
|
|
|
|
|
var Maxbsm = strBSM.Substring(10).ToInt() + 1;
|
|
|
|
|
strBSM = strbsm + Maxbsm.ToString().PadLeft(8, '0');//最新标识码
|
|
|
|
|
bsmDic.Add(gxID, strBSM);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bsmDic.Add(gxID, item["BGHBSM"].ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (bgxw == "1" && !TXBG.Contains(gxgcID))
|
|
|
|
|
{
|
|
|
|
|
TXBG.Add(gxgcID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!OIDdic.ContainsKey(gxgcID))
|
|
|
|
|
{
|
|
|
|
|
OIDdic.Add(gxgcID, gxID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
IFeatureCursor pCursor = pGxLayer.FeatureClass.Update(null, true);
|
|
|
|
|
var _index_BSM = pGxLayer.FeatureClass.FindField("BSM");
|
|
|
|
|
var _index_YSDM = pGxLayer.FeatureClass.FindField("YSDM");//2001010100
|
|
|
|
|
var _index_TBMJ = pGxLayer.FeatureClass.FindField("CZCMJ");
|
|
|
|
|
var igx_gxsj = pGxLayer.FeatureClass.FindField("GXSJ");
|
|
|
|
|
IFeature feature = null;
|
|
|
|
|
while ((feature = pCursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
int oid = feature.OID;
|
|
|
|
|
if (bsmDic.ContainsKey(oid))
|
|
|
|
|
{
|
|
|
|
|
string arr = bsmDic[oid];
|
|
|
|
|
feature.Value[_index_BSM] = arr;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
feature.Value[_index_YSDM] = "2099030100";//要素代码
|
|
|
|
|
DataRow[] row = GX_GXGCUnion.Select($"FID_CZCDYDGX={feature.OID}");
|
|
|
|
|
double mj = 0.00;
|
|
|
|
|
if (row.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
//string gxgcid = string.Join(" or ", row.Select(r => $"OBJECTID = {r["FID_CZCDYDGXGC"].ToString()}")).ToString();
|
|
|
|
|
mj = row.Select(r => r["BGMJ"].ToDouble()).Sum().ToDouble();
|
|
|
|
|
}
|
|
|
|
|
feature.Value[_index_TBMJ] = mj;
|
|
|
|
|
feature.Value[igx_gxsj] = DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31);
|
|
|
|
|
pCursor.UpdateFeature(feature);
|
|
|
|
|
}
|
|
|
|
|
pCursor.Flush();
|
|
|
|
|
pCursor = pGxgcLaeyr.FeatureClass.Update(null, true);
|
|
|
|
|
int iBGHTBBSM = pGxgcLaeyr.FeatureClass.FindField("BGHBSM");
|
|
|
|
|
int idxBGXW = pGxgcLaeyr.FeatureClass.FindField("BGXW");
|
|
|
|
|
int idxGXSJ = pGxgcLaeyr.FeatureClass.FindField("GXSJ");
|
|
|
|
|
idxBGMJ = pGxgcLaeyr.FeatureClass.FindField("BGMJ");
|
|
|
|
|
int idxGcBSM = pGxgcLaeyr.FeatureClass.FindField("BSM");
|
|
|
|
|
int tempBsm = 0;
|
|
|
|
|
while ((feature = pCursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
var bgxw = idxBGXW != -1 ? feature.Value[idxBGXW].ToTrim() : "";
|
|
|
|
|
int oid = feature.OID;
|
|
|
|
|
if (oid == 121 || bgxw == "0")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
if (idxGcBSM != -1)
|
|
|
|
|
{
|
|
|
|
|
tempBsm++;
|
|
|
|
|
feature.Value[idxGcBSM] = pParm.PrjInfo.CODE + "2932" + tempBsm.ToString().PadLeft(8, '0'); ;
|
|
|
|
|
}
|
|
|
|
|
if (DicBGMJ.ContainsKey(oid))
|
|
|
|
|
{
|
|
|
|
|
feature.Value[idxBGMJ] = DicBGMJ[oid].ToDouble();
|
|
|
|
|
}
|
|
|
|
|
if (OIDdic.ContainsKey(oid))
|
|
|
|
|
{
|
|
|
|
|
int gxOID = OIDdic[oid];
|
|
|
|
|
if (gxOID == -1)
|
|
|
|
|
{
|
|
|
|
|
feature.Value[iBGHTBBSM] = "";
|
|
|
|
|
if ((idxBGXW != -1 && bgxw != "2" && bgxw != "3" && bgxw != "0") || TXBG.Contains(oid))
|
|
|
|
|
{
|
|
|
|
|
feature.Value[idxBGXW] = "2";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (bsmDic.ContainsKey(gxOID))
|
|
|
|
|
{
|
|
|
|
|
string arr = bsmDic[gxOID];
|
|
|
|
|
feature.Value[iBGHTBBSM] = arr;
|
|
|
|
|
if ((newBsmList.Contains(arr) && idxBGXW != -1 && bgxw != "2" && bgxw != "3" && bgxw != "0") || TXBG.Contains(oid))
|
|
|
|
|
{
|
|
|
|
|
feature.Value[idxBGXW] = "2";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (bgxw == "0")
|
|
|
|
|
{
|
|
|
|
|
feature.Value[iBGHTBBSM] = "";
|
|
|
|
|
}
|
|
|
|
|
feature.Value[idxGXSJ] = DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31);
|
|
|
|
|
pCursor.UpdateFeature(feature);
|
|
|
|
|
}
|
|
|
|
|
pCursor.Flush();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Err:城镇村属性赋值错误:" + ex.Message + ex.StackTrace);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void AreaAdjustment(List<Adjustment> shpList, double pKZMJ)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (shpList.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
shpList[0].bgmj = pKZMJ;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
shpList = shpList.OrderByDescending(o => o.bgmj).ToList();
|
|
|
|
|
double mjc = Math.Round(shpList.Sum(s => s.bgmj) - pKZMJ, 2);
|
|
|
|
|
if (Math.Abs(mjc) > 100)
|
|
|
|
|
throw new Exception($"控制面积与图形面积差值较大,请先核对数据是否正确({mjc})");
|
|
|
|
|
//平差
|
|
|
|
|
while (Math.Round(mjc, 2) != 0)
|
|
|
|
|
{
|
|
|
|
|
int tpsm = (int)(Math.Abs(Math.Round(mjc, 2)) / (double)0.01);
|
|
|
|
|
int e = tpsm / shpList.Count;
|
|
|
|
|
int f = tpsm % shpList.Count;
|
|
|
|
|
if (f != 0)
|
|
|
|
|
{
|
|
|
|
|
double tpmj = (e + 1) * 0.01;
|
|
|
|
|
for (int i = 0; i < f; i++)
|
|
|
|
|
{
|
|
|
|
|
if (mjc < 0)
|
|
|
|
|
shpList[i].bgmj = shpList[i].bgmj + tpmj;
|
|
|
|
|
else
|
|
|
|
|
shpList[i].bgmj = shpList[i].bgmj - tpmj;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (e != 0)
|
|
|
|
|
{
|
|
|
|
|
double tpmj = e * 0.01;
|
|
|
|
|
for (int i = f; i < shpList.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (mjc < 0)
|
|
|
|
|
shpList[i].bgmj = shpList[i].bgmj + tpmj;
|
|
|
|
|
else
|
|
|
|
|
shpList[i].bgmj = shpList[i].bgmj - tpmj;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mjc = Math.Round(Math.Round(shpList.Sum(s => s.bgmj), 2) - pKZMJ, 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//LogAPI.Debug("面积平差错误:" + ex.Message);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private IWorkspace CreateDBWorkspace(string pDbPath)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!File.Exists(pDbPath))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(string.Format("指定的文件路径{0}不存在!", pDbPath));
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
IWorkspaceFactory pOutWorkFactory = null;
|
|
|
|
|
pOutWorkFactory = new SqlWorkspaceFactoryClass();
|
|
|
|
|
IWorkspace pOutWork = pOutWorkFactory.OpenFromFile(pDbPath, 0);
|
|
|
|
|
return pOutWork;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool TableToTable(IFeatureWorkspace pInWork, IWorkspace pOutWork, string tableName, IQueryFilter queryFilter = null)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (pInWork == null || pOutWork == null || string.IsNullOrEmpty(tableName)) return false;
|
|
|
|
|
IWorkspace2 workspace2 = pInWork as IWorkspace2;
|
|
|
|
|
if (workspace2 != null)
|
|
|
|
|
{
|
|
|
|
|
if (!workspace2.get_NameExists(esriDatasetType.esriDTFeatureClass, tableName))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ITable pInTable = pInWork.OpenTable(tableName);
|
|
|
|
|
if (pInTable == null) return false;
|
|
|
|
|
IDataset pIndataset = (IDataset)pInTable;
|
|
|
|
|
IDatasetName pInDatasetName = (IDatasetName)pIndataset.FullName;
|
|
|
|
|
IEnumDataset enumDataset = pOutWork.get_Datasets(esriDatasetType.esriDTTable);
|
|
|
|
|
IDataset dataset;
|
|
|
|
|
enumDataset.Reset();
|
|
|
|
|
while ((dataset = enumDataset.Next()) != null)
|
|
|
|
|
{
|
|
|
|
|
string[] names = dataset.Name.Split('.');
|
|
|
|
|
if (string.Equals(names[names.Length - 1], tableName, StringComparison.CurrentCultureIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
dataset.Delete();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
IDataset pOutDataset = (IDataset)pOutWork;
|
|
|
|
|
IDatasetName pOutDatasetName = new TableNameClass();
|
|
|
|
|
pOutDatasetName.WorkspaceName = (IWorkspaceName)pOutDataset.FullName;
|
|
|
|
|
pOutDatasetName.Name = tableName;
|
|
|
|
|
IFieldChecker fieldChecker = new FieldCheckerClass();
|
|
|
|
|
IFields targetFeatureClassFields = pInTable.Fields;
|
|
|
|
|
IFields sourceFeatureClassFields = pInTable.Fields;
|
|
|
|
|
IEnumFieldError enumFieldError;
|
|
|
|
|
fieldChecker.InputWorkspace = pInWork as IWorkspace;
|
|
|
|
|
fieldChecker.ValidateWorkspace = pOutWork;
|
|
|
|
|
fieldChecker.Validate(sourceFeatureClassFields, out enumFieldError, out targetFeatureClassFields);
|
|
|
|
|
IFeatureDataConverter one2another = new FeatureDataConverterClass();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
one2another.ConvertTable(pInDatasetName, queryFilter, pOutDatasetName, targetFeatureClassFields, "", 1000, 0);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
Marshal.ReleaseComObject(one2another);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//LogAPI.Debug(ex);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void RepairGeo(IFeatureClass pFc)
|
|
|
|
|
{
|
|
|
|
|
Geoprocessor gp = new Geoprocessor();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
RepairGeometry repairgeo = new RepairGeometry();
|
|
|
|
|
repairgeo.in_features = pFc;
|
|
|
|
|
//repairgeo.out_feature_class = outFC;
|
|
|
|
|
repairgeo.delete_null = "TRUE";
|
|
|
|
|
IGeoProcessorResult tGeoResult = (IGeoProcessorResult)gp.Execute(repairgeo, null);
|
|
|
|
|
if (tGeoResult == null || tGeoResult.Status != esriJobStatus.esriJobSucceeded)
|
|
|
|
|
{
|
|
|
|
|
//LogAPI.Debug("检查图形失败:");
|
|
|
|
|
throw new Exception(ReturnMessages(gp));
|
|
|
|
|
}
|
|
|
|
|
string msg = ReturnMessages(gp);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception(ReturnMessages(gp));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private string ReturnMessages(Geoprocessor gp)
|
|
|
|
|
{
|
|
|
|
|
string ms = "";
|
|
|
|
|
if (gp.MessageCount > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int Count = 0; Count <= gp.MessageCount - 1; Count++)
|
|
|
|
|
{
|
|
|
|
|
ms += "$" + gp.GetMessage(Count) + "\n\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ms;
|
|
|
|
|
}
|
|
|
|
|
private void Get20XDLTB(IFeatureLayer pJCTBLayer, IFeatureLayer pGXTBLayer, IFeatureLayer pJCCZCLayer, ref IFeatureLayer Union20XLayer, ref IFeatureLayer Union203Layer)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//IFeatureLayer Xz203Layer = null;
|
|
|
|
|
GPParamClass gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = pJCCZCLayer;
|
|
|
|
|
gPParamClass.SecondFeatureLayer = pGXTBLayer;
|
|
|
|
|
gPParamClass.XZQDM = pParm.PrjInfo.CODE;
|
|
|
|
|
gPParamClass.GPType = EnumGPType.CZCYCL;
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.FcName = "Xz203";
|
|
|
|
|
gPParamClass.TempGDBPath = TempGDBPath;
|
|
|
|
|
|
|
|
|
|
//Console.WriteLine("Log:7-1...");
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref Union203Layer);
|
|
|
|
|
|
|
|
|
|
//Console.WriteLine("Log:7-2...");
|
|
|
|
|
IWorkspaceAPI wsAPI = new WorkspaceAPI(TempGDBPath, WorkspaceTypeEnum.GDBFile);
|
|
|
|
|
IFeatureClassAPI fcAPI = wsAPI.OpenFeatureClass("JC20X_20X");
|
|
|
|
|
Union20XLayer = new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass };
|
|
|
|
|
|
|
|
|
|
IFeatureLayer tempLayer = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = Union20XLayer;
|
|
|
|
|
gPParamClass.GPType = EnumGPType.Default;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref tempLayer);
|
|
|
|
|
|
|
|
|
|
//IWorkspaceAPI wsAPI = new WorkspaceAPI(TempGDBPath, WorkspaceTypeEnum.GDBFile);
|
|
|
|
|
//IFeatureClassAPI fcAPI = wsAPI.OpenFeatureClass("JC20X_20X_U");
|
|
|
|
|
//IFeatureLayer tempLayer2 = null;
|
|
|
|
|
//gPParamClass = new GPParamClass();
|
|
|
|
|
//gPParamClass.FirstFeatureLayer = new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass };
|
|
|
|
|
//gPParamClass.GPType = EnumGPType.Default;
|
|
|
|
|
//GPHelper.Instance.ExeGPForProces(gPParamClass, ref tempLayer2);
|
|
|
|
|
|
|
|
|
|
////Console.WriteLine("Log:7-2...");
|
|
|
|
|
|
|
|
|
|
//IFeatureLayer tempLayer = null;
|
|
|
|
|
//gPParamClass = new GPParamClass();
|
|
|
|
|
//gPParamClass.FirstFeatureLayer = new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass };
|
|
|
|
|
//gPParamClass.GPType = EnumGPType.Dissolve;
|
|
|
|
|
//gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\JC20X_U_Dissolve";
|
|
|
|
|
//gPParamClass.ListDissolveFiledName = new List<string>() { "FID_CZCDYD", "CZCLX", "BSM", "CZCDM", "CZCMC", "CZCMJ", "ZLDWDM", "CZCSXM" };
|
|
|
|
|
//GPHelper.Instance.ExeGPForProces(gPParamClass, ref tempLayer);
|
|
|
|
|
//Union20XLayer = tempLayer;// new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass };
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
//新增203范围
|
|
|
|
|
//IFeatureLayer Xz203Layer = null;
|
|
|
|
|
#region 获取新增203范围(注:新增203与原有203不合并)
|
|
|
|
|
|
|
|
|
|
IFeatureLayer dltbgx203 = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = pGXTBLayer;
|
|
|
|
|
gPParamClass.GPType = EnumGPType.SelectLayerByAttribute;
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.Where_clause = "CZCSXM = '203' or CZCSXM = '203A'";
|
|
|
|
|
gPParamClass.FcName = "DLTBGX203";
|
|
|
|
|
gPParamClass.TempGDBPath = TempGDBPath;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref dltbgx203);
|
|
|
|
|
|
|
|
|
|
IFeatureLayer Xz203Layer_s = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = dltbgx203;
|
|
|
|
|
gPParamClass.SecondFeatureLayer = pJCCZCLayer;
|
|
|
|
|
gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\Xz203_s";
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.GPType = EnumGPType.Erase;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref Xz203Layer_s);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IFeatureLayer Xz203Layer_m = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = Xz203Layer_s;
|
|
|
|
|
gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\Xz203_m";
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.ListDissolveFiledName = new List<string>() { "ZLDWDM", "CZCSXM" };
|
|
|
|
|
gPParamClass.GPType = EnumGPType.Dissolve;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref Xz203Layer_m);
|
|
|
|
|
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = Xz203Layer_m;
|
|
|
|
|
gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\Xz203";
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.GPType = EnumGPType.MultipartToSinglePath;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref Union203Layer);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//地类图斑更新层(不含新增203范围)
|
|
|
|
|
IFeatureLayer TempGxTBLayer = null;
|
|
|
|
|
#region 获取地类图斑更新层(不含新增203范围)
|
|
|
|
|
IFeatureLayer AllGxTBLayer = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = pGXTBLayer;
|
|
|
|
|
gPParamClass.OutFeatureClassPath = TempGDBPath;
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.ListDissolveFiledName = new List<string>();
|
|
|
|
|
gPParamClass.FcName = "AllDLTBGX";
|
|
|
|
|
gPParamClass.GPType = EnumGPType.FcToFc;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref AllGxTBLayer);
|
|
|
|
|
|
|
|
|
|
IFeatureLayer TempGxTB_ELayer = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = AllGxTBLayer;
|
|
|
|
|
gPParamClass.SecondFeatureLayer = Union203Layer;
|
|
|
|
|
gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\TempDLTBGX_E";
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.GPType = EnumGPType.Erase;
|
|
|
|
|
//gPParamClass.FcName=""
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref TempGxTB_ELayer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//IFeatureLayer Xz203Layer_m = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = TempGxTB_ELayer;
|
|
|
|
|
gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\TempDLTBGX";
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.ListDissolveFiledName = new List<string>() { "ZLDWDM", "CZCSXM" };
|
|
|
|
|
gPParamClass.GPType = EnumGPType.Dissolve;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref TempGxTBLayer);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
IFeatureLayer TempJcCzcLayer = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
//gPParamClass.Tolerance = "-0.001";
|
|
|
|
|
gPParamClass.FirstFeatureLayer = pJCCZCLayer;
|
|
|
|
|
gPParamClass.SecondFeatureLayer = pGXTBLayer;
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.GPType = EnumGPType.SelectLayerByLocation;
|
|
|
|
|
gPParamClass.Overlap_type = "INTERSECT";
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref TempJcCzcLayer);
|
|
|
|
|
|
|
|
|
|
IFeatureLayer TempGcLayer = null;
|
|
|
|
|
gPParamClass = new GPParamClass()
|
|
|
|
|
{
|
|
|
|
|
FirstFeatureLayer = TempJcCzcLayer,
|
|
|
|
|
SecondFeatureLayer = TempGxTBLayer,
|
|
|
|
|
OutFeatureClassPath = $"{TempGDBPath}\\JC20X_20X_U",
|
|
|
|
|
IsGetOutPutFeature = true,
|
|
|
|
|
PreserveAttributes = "ALL",
|
|
|
|
|
GPType = EnumGPType.Union
|
|
|
|
|
};
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref TempGcLayer);
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
IFeatureCursor cursor = TempGcLayer.FeatureClass.Update(null, true);
|
|
|
|
|
IFeature f = null;
|
|
|
|
|
int idx = TempGcLayer.FeatureClass.FindField("FID_TempDLTBGX");
|
|
|
|
|
int idxCZCSXM = TempGcLayer.FeatureClass.FindField("CZCSXM");
|
|
|
|
|
int idxCZCLX = TempGcLayer.FeatureClass.FindField("CZCLX");
|
|
|
|
|
int idxCZCDM = TempGcLayer.FeatureClass.FindField("CZCDM");
|
|
|
|
|
int idxZLDWDM = TempGcLayer.FeatureClass.FindField("ZLDWDM");
|
|
|
|
|
while ((f = cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
int gxID = f.Value[idx].ToInt();
|
|
|
|
|
if (gxID == 3373)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
if (gxID == -1)
|
|
|
|
|
{
|
|
|
|
|
f.Value[idxCZCSXM] = f.Value[idxCZCLX];
|
|
|
|
|
f.Value[idxZLDWDM] = f.Value[idxCZCDM];
|
|
|
|
|
f.Value[idx] = -2;
|
|
|
|
|
}
|
|
|
|
|
var czclx = f.Value[idxCZCSXM].ToTrim();
|
|
|
|
|
var zldwdm = f.Value[idxZLDWDM].ToTrim();
|
|
|
|
|
if (czclx.StartsWith("201"))
|
|
|
|
|
{
|
|
|
|
|
f.Value[idxZLDWDM] = pParm.PrjInfo.CODE + "0000000000000";
|
|
|
|
|
}
|
|
|
|
|
else if (czclx.StartsWith("202"))
|
|
|
|
|
{
|
|
|
|
|
f.Value[idxZLDWDM] = zldwdm.Substring(0, 9) + "0000000000";
|
|
|
|
|
}
|
|
|
|
|
cursor.UpdateFeature(f);
|
|
|
|
|
}
|
|
|
|
|
cursor.Flush();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IFeatureLayer TempGcLayer_M = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = TempGcLayer;
|
|
|
|
|
gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\JC20X_20X_M";
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.ListDissolveFiledName = new List<string>() { "FID_CZCDYD", "CZCLX", "BSM", "CZCDM", "CZCMC", "CZCMJ", "ZLDWDM", "CZCSXM" };
|
|
|
|
|
gPParamClass.GPType = EnumGPType.Dissolve;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref TempGcLayer_M);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//IFeatureLayer TempTempGcLayer_M = null;
|
|
|
|
|
//gPParamClass = new GPParamClass();
|
|
|
|
|
//gPParamClass.FirstFeatureLayer = AllGxTBLayer;
|
|
|
|
|
//gPParamClass.SecondFeatureLayer = Union203Layer;
|
|
|
|
|
//gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\TempJC20X_20X_M";
|
|
|
|
|
//gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
//gPParamClass.GPType = EnumGPType.Erase;
|
|
|
|
|
////gPParamClass.FcName=""
|
|
|
|
|
//GPHelper.Instance.ExeGPForProces(gPParamClass, ref TempTempGcLayer_M);
|
|
|
|
|
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = TempGcLayer_M;
|
|
|
|
|
gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\JC20X_20X";
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.GPType = EnumGPType.MultipartToSinglePath;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref Union20XLayer);
|
|
|
|
|
|
|
|
|
|
string strWhere = @"FID_CZCDYD = -1 AND( CZCSXM IS NULL OR CZCSXM = '')";
|
|
|
|
|
IQueryFilter filter2 = new QueryFilterClass();
|
|
|
|
|
filter2.WhereClause = strWhere;
|
|
|
|
|
(Union20XLayer.FeatureClass as ITable).DeleteSearchedRows(filter2);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
#region 地类图斑更新层非20X属性图斑
|
|
|
|
|
IFeatureLayer DltbGxNo201Layer = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = pGXTBLayer;
|
|
|
|
|
gPParamClass.GPType = EnumGPType.SelectLayerByAttribute;
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.Where_clause = "(CZCSXM = '201' or CZCSXM = '201A' or CZCSXM = '202' or CZCSXM = '202A' or CZCSXM = '204' or CZCSXM = '205' or CZCSXM = '203' or CZCSXM = '203A') ";//"CZCSXM IS NULL or CZCSXM = '203' OR CZCSXM = '203A'";
|
|
|
|
|
gPParamClass.FcName = "DLTBNo20X";
|
|
|
|
|
gPParamClass.TempGDBPath = TempGDBPath;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref DltbGxNo201Layer);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 基础城镇村
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IFeatureLayer JC_Czc203Layer = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = TempJcCzcLayer;
|
|
|
|
|
gPParamClass.GPType = EnumGPType.SelectLayerByAttribute;
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.Where_clause = "CZCLX = '203' or CZCLX = '203A'";
|
|
|
|
|
gPParamClass.FcName = "JC_CZC203";
|
|
|
|
|
gPParamClass.TempGDBPath = TempGDBPath;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref JC_Czc203Layer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IFeatureLayer JC_Czc20XLayer = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = TempJcCzcLayer;
|
|
|
|
|
gPParamClass.GPType = EnumGPType.SelectLayerByAttribute;
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.Where_clause = "CZCLX = '201' or CZCLX = '201A' or CZCLX = '203' or CZCLX = '203A' or CZCLX = '202' or CZCLX = '202A' or CZCLX = '204' or CZCLX = '205'";
|
|
|
|
|
gPParamClass.FcName = "JC_CZC20X";
|
|
|
|
|
gPParamClass.TempGDBPath = TempGDBPath;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref JC_Czc20XLayer);
|
|
|
|
|
|
|
|
|
|
IFeatureLayer GxCzcLayer = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = TempJcCzcLayer;
|
|
|
|
|
gPParamClass.SecondFeatureLayer = DltbGxNo201Layer;
|
|
|
|
|
gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\GxCZC_Erase";
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.GPType = EnumGPType.Erase;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref GxCzcLayer);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 20X
|
|
|
|
|
IFeatureLayer Dltb201Layer = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = pGXTBLayer;
|
|
|
|
|
gPParamClass.GPType = EnumGPType.SelectLayerByAttribute;
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.Where_clause = "CZCSXM = '201' or CZCSXM = '201A' or CZCSXM = '202' or CZCSXM = '202A' or CZCSXM = '203' or CZCSXM = '203A' or CZCSXM = '204' or CZCSXM = '205'";
|
|
|
|
|
gPParamClass.FcName = "DLTB20X";
|
|
|
|
|
gPParamClass.TempGDBPath = TempGDBPath;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref Dltb201Layer);
|
|
|
|
|
//IWorkspace tempWs = (Dltb201Layer.FeatureClass as FeatureClass).Workspace;
|
|
|
|
|
//tempWs.ExecuteSQL(string.Format("Update DLTB20X set ZLDWDM='{0}' where CZCSXM = '201'", pParm.PrjInfo.CODE + "0000000000000"));
|
|
|
|
|
|
|
|
|
|
IFeatureCursor cursor = Dltb201Layer.FeatureClass.Update(null, true);
|
|
|
|
|
IFeature f = null;
|
|
|
|
|
int idx = Dltb201Layer.FeatureClass.FindField("ZLDWDM");
|
|
|
|
|
int idxCZCSXM = Dltb201Layer.FeatureClass.FindField("CZCSXM");
|
|
|
|
|
while ((f = cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
string zldwdm = f.Value[idx].ToTrim();
|
|
|
|
|
string czclx = f.Value[idxCZCSXM].ToTrim();
|
|
|
|
|
if (czclx.StartsWith("201"))
|
|
|
|
|
f.Value[idx] = pParm.PrjInfo.CODE + "0000000000000";
|
|
|
|
|
else if (czclx.StartsWith("202"))
|
|
|
|
|
f.Value[idx] = zldwdm.Substring(0, 9) + "0000000000";
|
|
|
|
|
else
|
|
|
|
|
continue;
|
|
|
|
|
cursor.UpdateFeature(f);
|
|
|
|
|
}
|
|
|
|
|
cursor.Flush();
|
|
|
|
|
|
|
|
|
|
#region 基础库相邻20X
|
|
|
|
|
IQueryFilter filter = new QueryFilter();
|
|
|
|
|
filter.WhereClause = "CZCLX = '201' or CZCLX = '201A' or CZCLX = '202' or CZCLX = '202A' or CZCLX = '204' or CZCLX = '205'";//
|
|
|
|
|
if (Dltb201Layer.FeatureClass.FeatureCount(null) > 0)
|
|
|
|
|
CzcToDltb(GxCzcLayer, Dltb201Layer, filter);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
IFeatureLayer Czc201Layer = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = Dltb201Layer;
|
|
|
|
|
gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\TempCZC20X";
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.ListDissolveFiledName = new List<string>() { "ZLDWDM", "CZCSXM" };
|
|
|
|
|
gPParamClass.GPType = EnumGPType.Dissolve;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref Czc201Layer);
|
|
|
|
|
|
|
|
|
|
IFeatureLayer Czc20XLayer = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureClassPath = $"{TempGDBPath}\\TempCZC20X";
|
|
|
|
|
gPParamClass.OutFeatureClassPath = TempGDBPath;
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.ListDissolveFiledName = new List<string>();
|
|
|
|
|
gPParamClass.FcName = "CZC20X";
|
|
|
|
|
gPParamClass.GPType = EnumGPType.FcToFc;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref Czc20XLayer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 202
|
|
|
|
|
|
|
|
|
|
//IFeatureLayer Dltb202Layer = null;
|
|
|
|
|
//gPParamClass = new GPParamClass();
|
|
|
|
|
//gPParamClass.FirstFeatureLayer = pGXTBLayer;
|
|
|
|
|
//gPParamClass.GPType = EnumGPType.SelectLayerByAttribute;
|
|
|
|
|
//gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
//gPParamClass.Where_clause = "CZCSXM = '202' or CZCSXM = '202A' or CZCSXM = '204' or CZCSXM = '205'";
|
|
|
|
|
//gPParamClass.FcName = "DLTB202";
|
|
|
|
|
//gPParamClass.TempGDBPath = TempGDBPath;
|
|
|
|
|
//GPHelper.Instance.ExeGPForProces(gPParamClass, ref Dltb202Layer);
|
|
|
|
|
//IFeatureCursor cursor = Dltb202Layer.FeatureClass.Update(null, true);
|
|
|
|
|
//IFeature f = null;
|
|
|
|
|
//int idx = Dltb202Layer.FeatureClass.FindField("ZLDWDM");
|
|
|
|
|
//while ((f = cursor.NextFeature()) != null)
|
|
|
|
|
//{
|
|
|
|
|
// string zldwdm = f.Value[idx].ToTrim();
|
|
|
|
|
// f.Value[idx] = zldwdm.Substring(0, 9) + "0000000000";
|
|
|
|
|
// cursor.UpdateFeature(f);
|
|
|
|
|
//}
|
|
|
|
|
//cursor.Flush();
|
|
|
|
|
|
|
|
|
|
//filter.WhereClause = "CZCLX = '202' or CZCLX = '202A'";// or CZCLX = '202' or CZCLX = '202A' or CZCLX = '204' or CZCLX = '205'
|
|
|
|
|
//CzcToDltb(GxCzcLayer, Dltb202Layer, filter);
|
|
|
|
|
//IFeatureLayer Czc202Layer = null;
|
|
|
|
|
//gPParamClass = new GPParamClass();
|
|
|
|
|
//gPParamClass.FirstFeatureLayer = Dltb202Layer;
|
|
|
|
|
//gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\CZC202";
|
|
|
|
|
//gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
//gPParamClass.ListDissolveFiledName = new List<string>() { "ZLDWDM", "CZCSXM" };
|
|
|
|
|
//gPParamClass.GPType = EnumGPType.Dissolve;
|
|
|
|
|
//GPHelper.Instance.ExeGPForProces(gPParamClass, ref Czc202Layer);
|
|
|
|
|
//IFeatureClassAPI FcAPI = new FeatureClassAPI(Czc202Layer.FeatureClass);
|
|
|
|
|
//FcAPI.FcToFc(Czc20XLayer.FeatureClass, null, false);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 203
|
|
|
|
|
IFeatureLayer TempDltb203Layer = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = pGXTBLayer;
|
|
|
|
|
gPParamClass.GPType = EnumGPType.SelectLayerByAttribute;
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.Where_clause = "CZCSXM = '203' or CZCSXM = '203A'";
|
|
|
|
|
gPParamClass.FcName = "DLTB203_Temp";
|
|
|
|
|
gPParamClass.TempGDBPath = TempGDBPath;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref TempDltb203Layer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IFeatureLayer Dltb203Layer = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = TempDltb203Layer;
|
|
|
|
|
gPParamClass.SecondFeatureLayer = TempJcCzcLayer;
|
|
|
|
|
gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\DLTB203";
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.GPType = EnumGPType.Erase;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref Dltb203Layer);
|
|
|
|
|
//#region 基础库相邻203
|
|
|
|
|
//filter = new QueryFilter();
|
|
|
|
|
//filter.WhereClause = "CZCLX = '203' or CZCLX = '203A'";
|
|
|
|
|
//CzcToDltb(GxCzcLayer, Dltb203Layer, filter);
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
IFeatureLayer Czc203Layer = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = Dltb203Layer;
|
|
|
|
|
gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\CZC203_temp";
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.ListDissolveFiledName = new List<string>() { "ZLDWDM", "CZCSXM" };
|
|
|
|
|
gPParamClass.GPType = EnumGPType.Dissolve;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref Czc203Layer);
|
|
|
|
|
|
|
|
|
|
//IFeatureLayer Czc20XLayer = null;
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureClassPath = $"{TempGDBPath}\\CZC203_temp";
|
|
|
|
|
gPParamClass.OutFeatureClassPath = TempGDBPath;
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.ListDissolveFiledName = new List<string>();
|
|
|
|
|
gPParamClass.FcName = "CZC203";
|
|
|
|
|
gPParamClass.GPType = EnumGPType.FcToFc;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref Czc203Layer);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 204
|
|
|
|
|
//IFeatureLayer Dltb204Layer = null;
|
|
|
|
|
//gPParamClass = new GPParamClass();
|
|
|
|
|
//gPParamClass.FirstFeatureLayer = pGXTBLayer;
|
|
|
|
|
//gPParamClass.GPType = EnumGPType.SelectLayerByAttribute;
|
|
|
|
|
//gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
//gPParamClass.Where_clause = "CZCSXM = '204'";
|
|
|
|
|
//gPParamClass.FcName = "DLTB204";
|
|
|
|
|
//gPParamClass.TempGDBPath = TempGDBPath;
|
|
|
|
|
//GPHelper.Instance.ExeGPForProces(gPParamClass, ref Dltb204Layer);
|
|
|
|
|
|
|
|
|
|
//filter.WhereClause = "CZCLX = '204' or CZCLX = '204A'";// or CZCLX = '202' or CZCLX = '202A' or CZCLX = '204' or CZCLX = '205'
|
|
|
|
|
//CzcToDltb(GxCzcLayer, Dltb204Layer, filter);
|
|
|
|
|
//IFeatureLayer Czc204Layer = null;
|
|
|
|
|
//gPParamClass = new GPParamClass();
|
|
|
|
|
//gPParamClass.FirstFeatureLayer = Dltb204Layer;
|
|
|
|
|
//gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\CZC204";
|
|
|
|
|
//gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
//gPParamClass.ListDissolveFiledName = new List<string>() { "ZLDWDM", "CZCSXM" };
|
|
|
|
|
//gPParamClass.GPType = EnumGPType.Dissolve;
|
|
|
|
|
//GPHelper.Instance.ExeGPForProces(gPParamClass, ref Czc204Layer);
|
|
|
|
|
//FcAPI = new FeatureClassAPI(Czc204Layer.FeatureClass);
|
|
|
|
|
//FcAPI.FcToFc(Czc20XLayer.FeatureClass, null, false);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 205
|
|
|
|
|
//IFeatureLayer Dltb205Layer = null;
|
|
|
|
|
//gPParamClass = new GPParamClass();
|
|
|
|
|
//gPParamClass.FirstFeatureLayer = pGXTBLayer;
|
|
|
|
|
//gPParamClass.GPType = EnumGPType.SelectLayerByAttribute;
|
|
|
|
|
//gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
//gPParamClass.Where_clause = "CZCSXM = '205'";
|
|
|
|
|
//gPParamClass.FcName = "DLTB205";
|
|
|
|
|
//gPParamClass.TempGDBPath = TempGDBPath;
|
|
|
|
|
//GPHelper.Instance.ExeGPForProces(gPParamClass, ref Dltb205Layer);
|
|
|
|
|
|
|
|
|
|
//filter.WhereClause = "CZCLX = '205' or CZCLX = '205A'";// or CZCLX = '202' or CZCLX = '202A' or CZCLX = '204' or CZCLX = '205'
|
|
|
|
|
//CzcToDltb(GxCzcLayer, Dltb205Layer, filter);
|
|
|
|
|
//IFeatureLayer Czc205Layer = null;
|
|
|
|
|
//gPParamClass = new GPParamClass();
|
|
|
|
|
//gPParamClass.FirstFeatureLayer = Dltb205Layer;
|
|
|
|
|
//gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\CZC205";
|
|
|
|
|
//gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
//gPParamClass.ListDissolveFiledName = new List<string>() { "ZLDWDM", "CZCSXM" };
|
|
|
|
|
//gPParamClass.GPType = EnumGPType.Dissolve;
|
|
|
|
|
//GPHelper.Instance.ExeGPForProces(gPParamClass, ref Czc205Layer);
|
|
|
|
|
//FcAPI = new FeatureClassAPI(Czc205Layer.FeatureClass);
|
|
|
|
|
//FcAPI.FcToFc(Czc20XLayer.FeatureClass, null, false);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 联合
|
|
|
|
|
//IFeatureLayer Union20XLayer = null;
|
|
|
|
|
gPParamClass = new GPParamClass()
|
|
|
|
|
{
|
|
|
|
|
FirstFeatureLayer = JC_Czc20XLayer,
|
|
|
|
|
SecondFeatureLayer = Czc20XLayer,
|
|
|
|
|
OutFeatureClassPath = $"{TempGDBPath}\\JC20X_20X_M",
|
|
|
|
|
IsGetOutPutFeature = true,
|
|
|
|
|
PreserveAttributes = "ALL",
|
|
|
|
|
GPType = EnumGPType.Union
|
|
|
|
|
};
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref Union20XLayer);
|
|
|
|
|
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = Union20XLayer;
|
|
|
|
|
gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\JC20X_20X";
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.GPType = EnumGPType.MultipartToSinglePath;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref Union20XLayer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//IFeatureLayer Union203Layer = null;
|
|
|
|
|
gPParamClass = new GPParamClass()
|
|
|
|
|
{
|
|
|
|
|
FirstFeatureLayer = JC_Czc203Layer,
|
|
|
|
|
SecondFeatureLayer = Czc203Layer,
|
|
|
|
|
OutFeatureClassPath = $"{TempGDBPath}\\JC203_203_M",
|
|
|
|
|
IsGetOutPutFeature = true,
|
|
|
|
|
PreserveAttributes = "ALL",
|
|
|
|
|
GPType = EnumGPType.Union
|
|
|
|
|
};
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref Union203Layer);
|
|
|
|
|
|
|
|
|
|
gPParamClass = new GPParamClass();
|
|
|
|
|
gPParamClass.FirstFeatureLayer = Union203Layer;
|
|
|
|
|
gPParamClass.OutFeatureClassPath = $"{TempGDBPath}\\JC203_203";
|
|
|
|
|
gPParamClass.IsGetOutPutFeature = true;
|
|
|
|
|
gPParamClass.GPType = EnumGPType.MultipartToSinglePath;
|
|
|
|
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref Union203Layer);
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug($"获取城镇村范围数据失败:{ex.Message}");
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void CzcToDltb(IFeatureLayer pCzcLayer, IFeatureLayer pDltbLayer, IQueryFilter pFilter)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
IFeatureCursor S_Cursor = null;
|
|
|
|
|
IFeatureCursor T_Cursor = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
S_Cursor = pCzcLayer.FeatureClass.Search(pFilter, true);
|
|
|
|
|
int idx_JCCZCLX, idx_CZCDM;
|
|
|
|
|
string t = (pCzcLayer.FeatureClass as FeatureClass).BrowseName;
|
|
|
|
|
|
|
|
|
|
idx_JCCZCLX = pCzcLayer.FeatureClass.FindField("CZCLX");
|
|
|
|
|
idx_CZCDM = pCzcLayer.FeatureClass.FindField("CZCDM");
|
|
|
|
|
IFeature f = null;
|
|
|
|
|
S_Cursor = pCzcLayer.FeatureClass.Search(pFilter, true);
|
|
|
|
|
|
|
|
|
|
IFeatureClassLoad pFclsLoad = pDltbLayer.FeatureClass as IFeatureClassLoad;
|
|
|
|
|
if (pFclsLoad != null)
|
|
|
|
|
pFclsLoad.LoadOnlyMode = true;
|
|
|
|
|
|
|
|
|
|
int idx_CZCSXM, idx_ZLDWDM;
|
|
|
|
|
T_Cursor = pDltbLayer.FeatureClass.Insert(true);
|
|
|
|
|
IFeatureBuffer buff = pDltbLayer.FeatureClass.CreateFeatureBuffer();
|
|
|
|
|
idx_CZCSXM = buff.Fields.FindField("CZCSXM");
|
|
|
|
|
idx_ZLDWDM = buff.Fields.FindField("ZLDWDM");
|
|
|
|
|
while ((f = S_Cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
string CZCLX = f.Value[idx_JCCZCLX].ToTrim();
|
|
|
|
|
string CZCMC = f.Value[idx_CZCDM].ToTrim();
|
|
|
|
|
buff.Shape = f.ShapeCopy;
|
|
|
|
|
if (idx_CZCSXM != -1)
|
|
|
|
|
buff.Value[idx_CZCSXM] = CZCLX;
|
|
|
|
|
if (idx_ZLDWDM != -1)
|
|
|
|
|
buff.Value[idx_ZLDWDM] = CZCMC;
|
|
|
|
|
T_Cursor.InsertFeature(buff);
|
|
|
|
|
}
|
|
|
|
|
T_Cursor.Flush();
|
|
|
|
|
if (pFclsLoad != null)
|
|
|
|
|
pFclsLoad.LoadOnlyMode = false;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (S_Cursor != null)
|
|
|
|
|
Marshal.ReleaseComObject(S_Cursor);
|
|
|
|
|
if (T_Cursor != null)
|
|
|
|
|
Marshal.ReleaseComObject(T_Cursor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void CalculateArea(object pParm)
|
|
|
|
|
{
|
|
|
|
|
//IFeatureCursor pCursor = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CalcAreaParm CalParm = pParm as CalcAreaParm;
|
|
|
|
|
IFeatureLayer _Layer = GeoDBAPI.DeSerialzedPersist(CalParm.StrLayer) as IFeatureLayer;
|
|
|
|
|
IFeatureCursor pCursor = _Layer.FeatureClass.Search(new QueryFilterClass() { SubFields = "OBJECTID,SHAPE" }, true);
|
|
|
|
|
IFeature feature = null;
|
|
|
|
|
while ((feature = pCursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
if (!CalParm.OidList.Contains(feature.OID))
|
|
|
|
|
continue;
|
|
|
|
|
double area = GetEllipseArea(feature.ShapeCopy);
|
|
|
|
|
lock (AreaList)
|
|
|
|
|
{
|
|
|
|
|
AreaList.Add(feature.OID, area.ToDouble());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//Console.WriteLine(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
//if (pCursor != null)
|
|
|
|
|
// Marshal.ReleaseComObject(pCursor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private double GetEllipseArea(IGeometry polygon)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// 1、获得投影
|
|
|
|
|
String SphName = polygon.SpatialReference.Name.ToString().ToUpper();
|
|
|
|
|
// 2、获得椭球
|
|
|
|
|
ICoordinate coordinate = CoordinateFactory.CreateCoordinate();
|
|
|
|
|
if (SphName.Contains("XIAN_1980") || SphName.Contains("XIAN1980"))
|
|
|
|
|
{
|
|
|
|
|
coordinate = CoordinateFactory.CreateCoordinate(KGIS.Framework.AE.GaussCalculate.Spheroid.SphXian80);
|
|
|
|
|
}
|
|
|
|
|
else if (SphName.Contains("BEIJING_1954") || SphName.Contains("BEIJING1954"))
|
|
|
|
|
{
|
|
|
|
|
coordinate = CoordinateFactory.CreateCoordinate(KGIS.Framework.AE.GaussCalculate.Spheroid.SphBeijing54);
|
|
|
|
|
}
|
|
|
|
|
else if (SphName.Contains("WGS_1984") || SphName.Contains("WGS1984"))
|
|
|
|
|
{
|
|
|
|
|
coordinate = CoordinateFactory.CreateCoordinate(KGIS.Framework.AE.GaussCalculate.Spheroid.SphWGS84);
|
|
|
|
|
}
|
|
|
|
|
else if (SphName.Contains("CGCS_2000") || SphName.Contains("CGCS2000"))
|
|
|
|
|
{
|
|
|
|
|
coordinate = CoordinateFactory.CreateCoordinate(KGIS.Framework.AE.GaussCalculate.Spheroid.SphCGCS2000);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
// 3、计算面积
|
|
|
|
|
IGeometry pGeometry = polygon as IGeometry;
|
|
|
|
|
double PolygonArea = 0.0;
|
|
|
|
|
// 4、保留两位小数
|
|
|
|
|
PolygonArea = Math.Round(coordinate.CalculateTerranArea(pGeometry), 2, MidpointRounding.AwayFromZero);
|
|
|
|
|
return PolygonArea;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private string GetMaxBSM(List<IFeatureClass> fcList)
|
|
|
|
|
{
|
|
|
|
|
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.QueryFilter = new QueryFilterClass() { WhereClause = $"BSM like '{pParm.PrjInfo.CODE}%'" };
|
|
|
|
|
if (System.IO.Path.GetExtension((fc as FeatureClass).Workspace.PathName).ToLower().Contains(".mdb"))
|
|
|
|
|
tableSort.QueryFilter = new QueryFilterClass() { WhereClause = $"BSM like '{pParm.PrjInfo.CODE}*'" };
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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 ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex + ":删除错误不处理");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CopyDirectInfo(string sourceDir, string toDir)
|
|
|
|
|
{
|
|
|
|
|
if (!Directory.Exists(sourceDir))
|
|
|
|
|
{
|
|
|
|
|
throw new ApplicationException("未找到文件:" + sourceDir);
|
|
|
|
|
}
|
|
|
|
|
if (!Directory.Exists(toDir))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(toDir);
|
|
|
|
|
}
|
|
|
|
|
DirectoryInfo directInfo = new DirectoryInfo(sourceDir);
|
|
|
|
|
FileInfo[] filesInfos = directInfo.GetFiles();
|
|
|
|
|
foreach (FileInfo fileinfo in filesInfos)
|
|
|
|
|
{
|
|
|
|
|
string fileName = fileinfo.Name;
|
|
|
|
|
File.Copy(fileinfo.FullName, toDir + @"/" + fileName, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class PCModel
|
|
|
|
|
{
|
|
|
|
|
public string BGQBSM { get; set; }
|
|
|
|
|
public string BGHBSM { get; set; }
|
|
|
|
|
public double BGHMJ { get; set; }
|
|
|
|
|
public double KZMJ { get; set; }
|
|
|
|
|
//public Dictionary<int, double> GCData { get; set; }
|
|
|
|
|
public List<GCMJModel> GCData { get; set; }
|
|
|
|
|
public PCModel()
|
|
|
|
|
{
|
|
|
|
|
GCData = new List<GCMJModel>();
|
|
|
|
|
}
|
|
|
|
|
public void PC()
|
|
|
|
|
{
|
|
|
|
|
//IOrderedEnumerable<KeyValuePair<int, double>> GCData2 = GCData.OrderByDescending(e => e.Value);
|
|
|
|
|
//GCData = new Dictionary<int, double>();
|
|
|
|
|
//foreach (var item in GCData2)
|
|
|
|
|
//{
|
|
|
|
|
// GCData.Add(item.Key, item.Value);
|
|
|
|
|
//}
|
|
|
|
|
GCData = GCData.OrderByDescending(o => o.MJ).ToList();
|
|
|
|
|
double zmj = GCData.Sum(s => s.MJ);
|
|
|
|
|
double mjc = Math.Round(zmj - KZMJ, 2);
|
|
|
|
|
if (Math.Round(mjc, 2) == 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
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 / GCData.Count;
|
|
|
|
|
int f = tpsm % GCData.Count;
|
|
|
|
|
if (f != 0)
|
|
|
|
|
{
|
|
|
|
|
double tpmj = (e + 1) * 0.01;
|
|
|
|
|
for (int j = 0; j < f; j++)
|
|
|
|
|
{
|
|
|
|
|
if (mjc < 0)
|
|
|
|
|
GCData[j].MJ = GCData[j].MJ + tpmj;
|
|
|
|
|
else if (GCData[j].MJ > 0.01)
|
|
|
|
|
GCData[j].MJ = GCData[j].MJ - tpmj;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (e != 0)
|
|
|
|
|
{
|
|
|
|
|
double tpmj = e * 0.01;
|
|
|
|
|
for (int j = f; j < GCData.Count; j++)
|
|
|
|
|
{
|
|
|
|
|
if (mjc < 0)
|
|
|
|
|
GCData[j].MJ = GCData[j].MJ + tpmj;
|
|
|
|
|
else if (GCData[j].MJ > 0.01)
|
|
|
|
|
GCData[j].MJ = GCData[j].MJ - tpmj;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
zmj = GCData.Sum(s => s.MJ);
|
|
|
|
|
mjc = Math.Round(zmj - KZMJ, 2);
|
|
|
|
|
//mjc = Math.Round(shpList.Sum(s => s.MJ), 2) - pKZMJ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void PC2()
|
|
|
|
|
{
|
|
|
|
|
//IOrderedEnumerable<KeyValuePair<int, double>> GCData2 = GCData.OrderByDescending(e => e.Value);
|
|
|
|
|
//GCData = new Dictionary<int, double>();
|
|
|
|
|
//foreach (var item in GCData2)
|
|
|
|
|
//{
|
|
|
|
|
// GCData.Add(item.Key, item.Value);
|
|
|
|
|
//}
|
|
|
|
|
GCData = GCData.OrderByDescending(o => o.MJ).ToList();
|
|
|
|
|
double zmj = GCData.Sum(s => s.MJ);
|
|
|
|
|
double mjc = Math.Round(zmj - KZMJ, 2);
|
|
|
|
|
if (Math.Round(mjc, 2) == 0 || (zmj == 0 && mjc < 0))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int num = 0;
|
|
|
|
|
while (Math.Round(mjc, 2) != 0 && num < 10)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in GCData)
|
|
|
|
|
{
|
|
|
|
|
if (Math.Round(mjc, 2) == 0) break;
|
|
|
|
|
if (mjc < 0)
|
|
|
|
|
{
|
|
|
|
|
if (item.MJ <= 0.01) continue;
|
|
|
|
|
item.MJ = Math.Round(item.MJ + 0.01, 2);
|
|
|
|
|
zmj = GCData.Sum(s => s.MJ);
|
|
|
|
|
mjc = Math.Round(zmj - KZMJ, 2);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (item.MJ <= 0.01) continue;
|
|
|
|
|
item.MJ = Math.Round(item.MJ - 0.01, 2);
|
|
|
|
|
zmj = GCData.Sum(s => s.MJ);
|
|
|
|
|
mjc = Math.Round(zmj - KZMJ, 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
////平差
|
|
|
|
|
//while (Math.Round(mjc, 2) != 0 && num < 10)
|
|
|
|
|
//{
|
|
|
|
|
// num++;
|
|
|
|
|
// int tpsm = (int)(Math.Abs(Math.Round(mjc, 2)) / (double)0.01);
|
|
|
|
|
// int e = tpsm / GCData.Count;
|
|
|
|
|
// int f = tpsm % GCData.Count;
|
|
|
|
|
// if (f != 0)
|
|
|
|
|
// {
|
|
|
|
|
// double tpmj = (e + 1) * 0.01;
|
|
|
|
|
// for (int j = 0; j < f; j++)
|
|
|
|
|
// {
|
|
|
|
|
// if (mjc < 0)
|
|
|
|
|
// GCData[j].MJ = GCData[j].MJ + tpmj;
|
|
|
|
|
// else if (GCData[j].MJ > 0.01)
|
|
|
|
|
// GCData[j].MJ = GCData[j].MJ - tpmj;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// if (e != 0)
|
|
|
|
|
// {
|
|
|
|
|
// double tpmj = e * 0.01;
|
|
|
|
|
// for (int j = f; j < GCData.Count; j++)
|
|
|
|
|
// {
|
|
|
|
|
// if (mjc < 0)
|
|
|
|
|
// GCData[j].MJ = GCData[j].MJ + tpmj;
|
|
|
|
|
// else if (GCData[j].MJ > 0.01)
|
|
|
|
|
// GCData[j].MJ = GCData[j].MJ - tpmj;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// zmj = GCData.Sum(s => s.MJ);
|
|
|
|
|
// mjc = Math.Round(zmj - KZMJ, 2);
|
|
|
|
|
// //mjc = Math.Round(shpList.Sum(s => s.MJ), 2) - pKZMJ;
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class GCMJModel
|
|
|
|
|
{
|
|
|
|
|
public int OID { get; set; }
|
|
|
|
|
public double MJ { get; set; }
|
|
|
|
|
}
|
|
|
|
|
public class CZC_Param
|
|
|
|
|
{
|
|
|
|
|
public IFeatureLayer GXCZCLayer { get; set; }
|
|
|
|
|
public IFeatureLayer GXGCCZCLayer { get; set; }
|
|
|
|
|
public IFeatureLayer GXTBLayer { get; set; }
|
|
|
|
|
public IFeatureLayer JCCZCLayer { get; set; }
|
|
|
|
|
public IFeatureLayer JCTBLayer { get; set; }
|
|
|
|
|
public IFeatureLayer BGTBLayer { get; set; }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class CalcAreaParm
|
|
|
|
|
{
|
|
|
|
|
public string StrLayer { get; set; }
|
|
|
|
|
public int StartIndex { get; set; }
|
|
|
|
|
public List<int> OidList { get; set; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|