You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1781 lines
89 KiB
1781 lines
89 KiB
using ESRI.ArcGIS.Carto; |
|
using ESRI.ArcGIS.DataSourcesGDB; |
|
using ESRI.ArcGIS.Geodatabase; |
|
using ESRI.ArcGIS.Geometry; |
|
//using IDEParameter; |
|
using KGIS.Framework.AE; |
|
using KGIS.Framework.AE.Enum; |
|
using KGIS.Framework.AE.GaussCalculate; |
|
using KGIS.Framework.AE.GPHelper; |
|
using KGIS.Framework.DBOperator; |
|
using KGIS.Framework.Utils; |
|
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 DLTB_IDGHelper : BaseIDG |
|
{ |
|
private IFeatureClass BGFeatureClass = null; |
|
private IFeatureLayer JCFeatureLayer = null; |
|
//private IFeatureLayer BgTbLayer = null; |
|
//private IFeatureLayer GxgcTBLayer = null; |
|
//private IFeatureLayer GXPDTLayer = null; |
|
//private IFeatureLayer JCPDTLayer = null; |
|
private string TempDbPath = string.Empty; |
|
IWorkspace pOutWork = null; |
|
Dictionary<int, double> AreaList = new Dictionary<int, double>(); |
|
|
|
private IDGParameter Parm = null; |
|
|
|
public void Execute(IDGParameter parm) |
|
{ |
|
Parm = parm; |
|
|
|
IFeatureLayer Temp_DLTBGXGC = null; |
|
IFeatureLayer Temp_BGTBLayer = null;//变更图斑融合 |
|
IFeatureLayer DissolveAnalysisFeatureLayer = null;//更新层融合后的图层 |
|
IFeatureLayer EraseAnalysisLayer = null; |
|
IFeature feature = null; |
|
IFeatureCursor pCursor = null; |
|
IFeatureClassAPI fcAPI = null; |
|
GPParamClass paramClass = new GPParamClass(); |
|
try |
|
{ |
|
OpenDB(parm); |
|
string TempDir = CreateTempDB("DLTB"); |
|
TempDbPath = System.IO.Path.Combine(TempDir, "TempGDB.gdb"); |
|
|
|
ITable dltbgxTb = GxTbLayer.FeatureClass as ITable; |
|
dltbgxTb.DeleteSearchedRows(null); |
|
ITable dltbgxgcTb = GxgcTBLayer.FeatureClass as ITable; |
|
dltbgxgcTb.DeleteSearchedRows(null); |
|
#region 判断是否存在坐落变更 提取相关数据 |
|
if (Parm.PrjInfo.ListZLXXInfo.Count > 0) |
|
{ |
|
Console.WriteLine("Msg:正在处理坐落变更数据..."); |
|
IWorkspaceAPI wsAPI = new WorkspaceAPI(TempDbPath, WorkspaceTypeEnum.GDBFile); |
|
IFeatureClassAPI DLTBBG_ZLBGAPI = wsAPI.CreateFeatureClass("TempDLTBBG", (BgTbLayer.FeatureClass as IGeoDataset).SpatialReference, BgTbLayer.FeatureClass.Fields); |
|
foreach (var item in Parm.PrjInfo.ListZLXXInfo) |
|
{ |
|
if (string.IsNullOrWhiteSpace(item.BGQDM.ToTrim()) || string.IsNullOrWhiteSpace(item.BGHDM.ToTrim())) continue; |
|
fcAPI = new FeatureClassAPI(JcTbLayer.FeatureClass); |
|
IQueryFilter filter = new QueryFilterClass() { WhereClause = $"ZLDWDM like '{item.BGQDM }%'" }; |
|
fcAPI.FcToFc(DLTBBG_ZLBGAPI.FeatureClass, filter, false); |
|
ITable tempBGTb = DLTBBG_ZLBGAPI.FeatureClass as ITable; |
|
ICursor _cursor = tempBGTb.Update(filter, true); |
|
IRow _row = null; |
|
int _idx = DLTBBG_ZLBGAPI.FeatureClass.FindField("ZLDWDM"); |
|
int _idxQS = DLTBBG_ZLBGAPI.FeatureClass.FindField("QSDWDM"); |
|
while ((_row = _cursor.NextRow()) != null && _idx != -1) |
|
{ |
|
_row.Value[_idx] = _row.Value[_idx].ToTrim().Replace(item.BGQDM, item.BGHDM); |
|
_row.Value[_idxQS] = _row.Value[_idxQS].ToTrim().Replace(item.BGQDM, item.BGHDM); |
|
_cursor.UpdateRow(_row); |
|
} |
|
_cursor.Flush(); |
|
} |
|
|
|
#region 变更图斑擦除坐落变更的图斑 |
|
paramClass.FirstFeatureLayer = new FeatureLayerClass() { FeatureClass = DLTBBG_ZLBGAPI.FeatureClass }; |
|
paramClass.SecondFeatureLayer = BgTbLayer; |
|
paramClass.OutFeatureClassPath = $"{TempDbPath}\\BGTB_Erase"; |
|
paramClass.IsGetOutPutFeature = true; |
|
paramClass.GPType = EnumGPType.Erase; |
|
GPHelper.Instance.ExeGPForProces(paramClass, ref EraseAnalysisLayer); |
|
#endregion |
|
ITable tempdltb = DLTBBG_ZLBGAPI.FeatureClass as ITable; |
|
tempdltb.DeleteSearchedRows(null); |
|
|
|
fcAPI = new FeatureClassAPI(EraseAnalysisLayer.FeatureClass); |
|
fcAPI.FcToFc(DLTBBG_ZLBGAPI.FeatureClass, null, false); |
|
fcAPI = new FeatureClassAPI(BgTbLayer.FeatureClass); |
|
fcAPI.FcToFc(DLTBBG_ZLBGAPI.FeatureClass, null, false); |
|
BgTbLayer.FeatureClass = DLTBBG_ZLBGAPI.FeatureClass; |
|
} |
|
#endregion |
|
|
|
|
|
Console.WriteLine("Msg:正在处理变更图斑数据..."); |
|
Temp_BGTBLayer = ProcessBGTB(); |
|
string dbPath = TempDir + @"\Temp" + ".sqlite"; |
|
|
|
pOutWork = CreateDBWorkspace(dbPath); |
|
|
|
|
|
Console.WriteLine("Msg:正在生成临时过程数据..."); |
|
Temp_DLTBGXGC = GenerateTempGXGC(Temp_BGTBLayer, dbPath); |
|
|
|
IRDBHelper rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite); |
|
Console.WriteLine("Msg:正在进行变更行为赋值..."); |
|
#region BGXW=2 |
|
//变更图斑与基础库图斑一对多 |
|
rdbHelper.ExecuteSQL(" UPDATE GXGC_Multipart set BGXW='2' where FID_DLTBBG in (select FID_DLTBBG from GXGC_Multipart where FID_DLTBBG <> -1 GROUP BY FID_DLTBBG HAVING COUNT(FID_DLTBBG) > 1) "); |
|
rdbHelper.ExecuteSQL(@" UPDATE GXGC_Multipart set BGXW='2' where BGXW ISNULL and FID_DLTB in (select FID_DLTB from GXGC_Multipart GROUP BY FID_DLTB HAVING COUNT(FID_DLTB) > 1 ) "); |
|
#endregion |
|
|
|
#region BGXW=1 |
|
rdbHelper.ExecuteSQL(@"UPDATE GXGC_Multipart set BGXW='1' where BGXW ISNULL and OBJECTID in (select OBJECTID from |
|
( |
|
select FID_DLTBBG,OBJECTID,BGXW, |
|
case when DLBM ISNULL OR DLBM=' ' THEN '' ELSE DLBM END DLBM, |
|
case when DLBM_1 ISNULL OR DLBM_1=' ' THEN '' ELSE DLBM_1 END DLBM_1, |
|
|
|
case when DLMC ISNULL OR DLMC=' ' THEN '' ELSE DLMC END DLMC, |
|
case when DLMC_1 ISNULL OR DLMC_1=' ' THEN '' ELSE DLMC_1 END DLMC_1, |
|
|
|
case when QSXZ ISNULL OR QSXZ=' ' THEN '' ELSE QSXZ END QSXZ, |
|
case when QSXZ_1 ISNULL OR QSXZ_1=' ' THEN '' ELSE QSXZ_1 END QSXZ_1, |
|
|
|
case when QSDWDM ISNULL OR QSDWDM=' ' THEN '' ELSE QSDWDM END QSDWDM, |
|
case when QSDWDM_1 ISNULL OR QSDWDM_1=' ' THEN '' ELSE QSDWDM_1 END QSDWDM_1, |
|
|
|
case when QSDWMC ISNULL OR QSDWMC=' ' THEN '' ELSE QSDWMC END QSDWMC, |
|
case when QSDWMC_1 ISNULL OR QSDWMC_1=' ' THEN '' ELSE QSDWMC_1 END QSDWMC_1, |
|
|
|
case when ZLDWDM ISNULL OR ZLDWDM=' ' THEN '' ELSE ZLDWDM END ZLDWDM, |
|
case when ZLDWDM_1 ISNULL OR ZLDWDM_1=' ' THEN '' ELSE ZLDWDM_1 END ZLDWDM_1, |
|
|
|
case when ZLDWMC ISNULL OR ZLDWMC=' ' THEN '' ELSE ZLDWMC END ZLDWMC, |
|
case when ZLDWMC_1 ISNULL OR ZLDWMC_1=' ' THEN '' ELSE ZLDWMC_1 END ZLDWMC_1, |
|
|
|
case when KCDLBM ISNULL or KCDLBM=' ' THEN '' ELSE KCDLBM END KCDLBM, |
|
case when KCDLBM_1 ISNULL or KCDLBM_1=' ' THEN '' ELSE KCDLBM_1 END KCDLBM_1, |
|
|
|
case when KCXS ISNULL or KCXS=' ' THEN '' ELSE KCXS END KCXS, |
|
case when KCXS_1 ISNULL or KCXS_1=' ' THEN '' ELSE KCXS_1 END KCXS_1, |
|
|
|
case when GDLX ISNULL or GDLX=' ' THEN '' ELSE GDLX END GDLX, |
|
case when GDLX_1 ISNULL or GDLX_1=' ' THEN '' ELSE GDLX_1 END GDLX_1, |
|
|
|
case when GDPDJB ISNULL or GDPDJB=' ' THEN '' ELSE GDPDJB END GDPDJB, |
|
case when GDPDJB_1 ISNULL or GDPDJB_1=' ' THEN '' ELSE GDPDJB_1 END GDPDJB_1, |
|
|
|
case when XZDWKD ISNULL or XZDWKD=' ' or XZDWKD=0.0 THEN 0 ELSE XZDWKD END XZDWKD, |
|
case when XZDWKD_1 ISNULL or XZDWKD_1=' ' or XZDWKD_1=0.0 THEN 0 ELSE XZDWKD_1 END XZDWKD_1, |
|
|
|
case when TBXHDM ISNULL or TBXHDM=' ' THEN '' ELSE TBXHDM END TBXHDM, |
|
case when TBXHDM_1 ISNULL or TBXHDM_1=' ' THEN '' ELSE TBXHDM_1 END TBXHDM_1, |
|
|
|
case when TBXHMC ISNULL or TBXHMC=' ' THEN '' ELSE TBXHMC END TBXHMC, |
|
case when TBXHMC_1 ISNULL or TBXHMC_1=' ' THEN '' ELSE TBXHMC_1 END TBXHMC_1, |
|
|
|
case when ZZSXDM ISNULL or ZZSXDM=' ' THEN '' ELSE ZZSXDM END ZZSXDM, |
|
case when ZZSXDM_1 ISNULL or ZZSXDM_1=' ' THEN '' ELSE ZZSXDM_1 END ZZSXDM_1, |
|
|
|
case when ZZSXMC ISNULL or ZZSXMC=' ' THEN '' ELSE ZZSXMC END ZZSXMC, |
|
case when ZZSXMC_1 ISNULL or ZZSXMC_1=' ' THEN '' ELSE ZZSXMC_1 END ZZSXMC_1, |
|
|
|
case when GDDB ISNULL or GDDB=' ' or GDDB=0 THEN '' ELSE GDDB END GDDB, |
|
case when GDDB_1 ISNULL or GDDB_1=' ' or GDDB_1=0 THEN '' ELSE GDDB_1 END GDDB_1, |
|
|
|
case when FRDBS ISNULL or FRDBS=' ' THEN '' ELSE FRDBS END FRDBS, |
|
case when FRDBS_1 ISNULL or FRDBS_1=' ' THEN '' ELSE FRDBS_1 END FRDBS_1, |
|
|
|
case when CZCSXM ISNULL or CZCSXM=' ' THEN '' ELSE CZCSXM END CZCSXM, |
|
case when CZCSXM_1 ISNULL or CZCSXM_1=' ' THEN '' ELSE CZCSXM_1 END CZCSXM_1, |
|
|
|
case when MSSM ISNULL or MSSM=' ' THEN '' ELSE MSSM END MSSM, |
|
case when MSSM_1 ISNULL or MSSM_1=' ' THEN '' ELSE MSSM_1 END MSSM_1, |
|
|
|
case when HDMC ISNULL or HDMC=' ' THEN '' ELSE HDMC END HDMC, |
|
case when HDMC_1 ISNULL or HDMC_1=' ' THEN '' ELSE HDMC_1 END HDMC_1 |
|
from GXGC_Multipart WHERE BGXW ISNULL and |
|
FID_DLTBBG<>-1 and |
|
FID_DLTB in (select FID_DLTB from GXGC_Multipart GROUP BY FID_DLTB HAVING COUNT(FID_DLTB) = 1) and |
|
FID_DLTBBG in (select FID_DLTBBG from GXGC_Multipart GROUP BY FID_DLTBBG HAVING COUNT(FID_DLTBBG) = 1) |
|
) |
|
WHERE (DLBM != DLBM_1 or DLMC != DLMC_1 or QSXZ != QSXZ_1 or QSDWDM != QSDWDM_1 or QSDWMC != QSDWMC_1 or ZLDWDM != ZLDWDM_1 or ZLDWMC != ZLDWMC_1 or KCDLBM != KCDLBM_1 or KCXS != KCXS_1 or GDLX != GDLX_1 or GDPDJB != GDPDJB_1 or XZDWKD != XZDWKD_1 or TBXHDM != TBXHDM_1 or TBXHMC != TBXHMC_1 or ZZSXDM != ZZSXDM_1 or ZZSXMC != ZZSXMC_1 or GDDB != GDDB_1 or FRDBS != FRDBS_1 or CZCSXM != CZCSXM_1 or MSSM != MSSM_1 or HDMC != HDMC_1) )"); |
|
#endregion |
|
|
|
|
|
|
|
Console.WriteLine("Msg:正在进行面积平差..."); |
|
#region 面积平差 |
|
DataTable data_BSM = rdbHelper.ExecuteDatatable("tab", "select BSM,TBMJ_1 from GXGC_Multipart GROUP BY BSM HAVING count(BSM)>1", true); |
|
List<string> pcBSMList = new List<string>(); |
|
if (data_BSM != null && data_BSM.Rows.Count > 0) |
|
{ |
|
foreach (DataRow row in data_BSM.Rows) |
|
{ |
|
var jc_bsm = row["BSM"].ToTrim(); |
|
if (!pcBSMList.Contains(jc_bsm)) |
|
pcBSMList.Add(jc_bsm); |
|
} |
|
} |
|
if (pcBSMList.Count > 1000) |
|
{ |
|
int num = pcBSMList.Count / 4; |
|
for (int i = 0; i < 4; i++) |
|
{ |
|
List<string> tempBsmList = new List<string>(); |
|
if (i < 3) |
|
{ |
|
tempBsmList = pcBSMList.GetRange(i * num, num); |
|
} |
|
else |
|
{ |
|
tempBsmList = pcBSMList.GetRange(i * num, pcBSMList.Count - i * num); |
|
} |
|
CalcAreaParm threadParm = new CalcAreaParm(); |
|
threadParm.BsmList = tempBsmList; |
|
threadParm.StrLayer = GeoDBAPI.SerialzedPersist(Temp_DLTBGXGC); |
|
//ThreadManager.Instance.QueueUserWorkItem(new System.Threading.WaitCallback(CalculateArea), threadParm); |
|
CalculateArea(threadParm); |
|
} |
|
//while (ThreadManager.Instance.ActiveCount > 0) { } |
|
//if (AreaList.Count > 0) |
|
//{ |
|
|
|
//} |
|
} |
|
else |
|
{ |
|
pCursor = Temp_DLTBGXGC.FeatureClass.Search(new QueryFilterClass() { SubFields = "OBJECTID,BSM,TBMJ,SHAPE" }, true); |
|
var _itbmj = Temp_DLTBGXGC.FeatureClass.FindField("TBMJ"); |
|
var bsmIdx = Temp_DLTBGXGC.FeatureClass.FindField("BSM"); |
|
feature = null; |
|
//int _i = 0; |
|
while ((feature = pCursor.NextFeature()) != null) |
|
{ |
|
string bsm = feature.Value[bsmIdx].ToTrim(); |
|
if (!pcBSMList.Contains(bsm)) |
|
continue; |
|
//_i++; |
|
double area = GetEllipseArea(feature.ShapeCopy); |
|
//lock (AreaList) |
|
//{ |
|
AreaList.Add(feature.OID, area.ToDouble()); |
|
//} |
|
//if (_i == 100) |
|
//{ |
|
// _i = 0; |
|
// Console.Clear(); |
|
// Console.Write(feature.OID); |
|
//} |
|
} |
|
} |
|
|
|
DataTable data = rdbHelper.ExecuteDatatable("tab", "select OBJECTID,BSM,TBMJ,TBMJ_1 from GXGC_Multipart ", true); |
|
Dictionary<int, double> _GXGCvaluePairs = new Dictionary<int, double>();//记录平差结果 |
|
if (data_BSM != null && data_BSM.Rows.Count > 0) |
|
{ |
|
foreach (DataRow row in data_BSM.Rows) |
|
{ |
|
var jc_TBMJ = row["TBMJ_1"].ToDouble(); |
|
List<Adjustment> shpList = new List<Adjustment>(); |
|
var rows = data.Select($"BSM ='{row["BSM"]}'"); |
|
foreach (var item in rows) |
|
{ |
|
Adjustment adj = new Adjustment(); |
|
adj.ID = item["OBJECTID"].ToInt(); |
|
if (AreaList.ContainsKey(adj.ID)) |
|
adj.bgmj = AreaList[adj.ID]; |
|
shpList.Add(adj); |
|
} |
|
if (shpList.Count > 0) |
|
{ |
|
AreaAdjustment(shpList, jc_TBMJ);//面积平差 |
|
foreach (var item in shpList) |
|
{ |
|
if (!_GXGCvaluePairs.ContainsKey(item.ID)) |
|
_GXGCvaluePairs.Add(item.ID, item.bgmj); |
|
} |
|
} |
|
} |
|
} |
|
#endregion |
|
|
|
Console.WriteLine("Msg:正在写入过程数据..."); |
|
#region 生成更新过程层 |
|
DataTable data_BGXW = rdbHelper.ExecuteDatatable("tab", @"select FID_DLTBBG,FID_DLTB,BGXW,OBJECTID,TBMJ_1 from GXGC_Multipart WHERE BGXW NOTNULL ", true); |
|
GXGCFcToFc(Temp_DLTBGXGC.FeatureClass, GxgcTBLayer.FeatureClass, null, false, data_BGXW, _GXGCvaluePairs); |
|
#endregion |
|
Console.WriteLine("Msg:正在写入更新数据..."); |
|
|
|
#region 生成更新层 |
|
IWorkspaceAPI wsAPI1 = new WorkspaceAPI(TempDbPath, WorkspaceTypeEnum.GDBFile); |
|
IFeatureClassAPI DLTBGX = wsAPI1.CreateFeatureClass("DLTBGX", (GxTbLayer.FeatureClass as IGeoDataset).SpatialReference, GxTbLayer.FeatureClass.Fields); |
|
GXFcToFc(GxgcTBLayer.FeatureClass, DLTBGX.FeatureClass, new QueryFilterClass() { WhereClause = "BGHDLBM <>'1001' and BGHDLBM <>'1002' and BGHDLBM <>'1003' and BGHDLBM<>'1004' and BGHDLBM <>'1006' and BGHDLBM<>'1009' and BGHDLBM<>'1101' and BGHDLBM<>'1107' and BGHDLBM<>'1107A'" }); |
|
|
|
paramClass = new GPParamClass(); |
|
paramClass.FirstFeatureLayer = new FeatureLayer() { FeatureClass = DLTBGX.FeatureClass }; |
|
paramClass.OutFeatureClassPath = $"{TempDbPath}\\GX_Dissolve"; |
|
paramClass.IsGetOutPutFeature = true; |
|
paramClass.ListDissolveFiledName = new List<string>() { "DLBM", "DLMC", "QSXZ", "QSDWDM", "QSDWMC", "ZLDWDM", "ZLDWMC", "KCDLBM", "KCXS", "GDLX", "GDPDJB", "TBXHDM", "TBXHMC", "ZZSXDM", "ZZSXMC", "GDDB", "FRDBS", "CZCSXM", "MSSM", "HDMC" }; |
|
paramClass.GPType = EnumGPType.Dissolve; |
|
GPHelper.Instance.ExeGPForProces(paramClass, ref DissolveAnalysisFeatureLayer); |
|
//(GxTbLayer.FeatureClass as ITable).DeleteSearchedRows(null); |
|
fcAPI = new FeatureClassAPI(DissolveAnalysisFeatureLayer.FeatureClass); |
|
fcAPI.FcToFc(GxTbLayer.FeatureClass, null, false); |
|
|
|
|
|
IFeatureLayer tempGcLayer = null; |
|
paramClass = new GPParamClass(); |
|
paramClass.FirstFeatureLayer = GxgcTBLayer; |
|
paramClass.GPType = EnumGPType.SelectLayerByAttribute; |
|
paramClass.IsGetOutPutFeature = true; |
|
paramClass.Where_clause = "BGXW = '2' and (BGHDLBM ='1001' or BGHDLBM ='1002' or BGHDLBM ='1003' or BGHDLBM='1004' or BGHDLBM ='1006' or BGHDLBM='1009' or BGHDLBM='1101' or BGHDLBM='1107' or BGHDLBM='1107A')"; |
|
paramClass.FcName = "TempGC"; |
|
paramClass.TempGDBPath = TempDbPath; |
|
GPHelper.Instance.ExeGPForProces(paramClass, ref tempGcLayer); |
|
|
|
IFeatureLayer tempGcEraseLayer = null; |
|
paramClass.FirstFeatureLayer = tempGcLayer; |
|
paramClass.SecondFeatureLayer = Temp_BGTBLayer; |
|
paramClass.OutFeatureClassPath = $"{TempDbPath}\\TempGcErase"; |
|
paramClass.IsGetOutPutFeature = true; |
|
paramClass.GPType = EnumGPType.Erase; |
|
GPHelper.Instance.ExeGPForProces(paramClass, ref tempGcEraseLayer); |
|
|
|
GXFcToFc(Temp_BGTBLayer.FeatureClass, GxTbLayer.FeatureClass, new QueryFilterClass() { WhereClause = "DLBM ='1001' or DLBM ='1002' or DLBM ='1003' or DLBM='1004' or DLBM ='1006' or DLBM='1009' or DLBM='1101' or DLBM='1107' or DLBM='1107A'" }); |
|
|
|
GXFcToFc(tempGcEraseLayer.FeatureClass, GxTbLayer.FeatureClass, new QueryFilterClass() { WhereClause = "BGHDLBM ='1001' or BGHDLBM ='1002' or BGHDLBM ='1003' or BGHDLBM='1004' or BGHDLBM ='1006' or BGHDLBM='1009' or BGHDLBM='1101' or BGHDLBM='1107' or BGHDLBM='1107A'" }); |
|
#endregion |
|
Console.WriteLine("Msg:正在进行属性赋值..."); |
|
|
|
#region 更新层/更新过程层 标识码,图斑编号等赋值 |
|
paramClass = new GPParamClass() |
|
{ |
|
FirstFeatureLayer = GxTbLayer, |
|
SecondFeatureLayer = GxgcTBLayer, |
|
OutFeatureClassPath = $"{TempDbPath}\\GX_GXGCUnion", |
|
IsGetOutPutFeature = true, |
|
PreserveAttributes = "ALL", |
|
GPType = EnumGPType.Union |
|
}; |
|
GPHelper.Instance.ExeGPForProces(paramClass, ref Temp_DLTBGXGC); |
|
IWorkspace ws = (Temp_DLTBGXGC.FeatureClass as FeatureClass).Workspace; |
|
rdbHelper.ExecuteSQL(" drop table GX_GXGCUnion "); |
|
|
|
TableToTable(ws as IFeatureWorkspace, pOutWork, "GX_GXGCUnion"); |
|
|
|
DataTable GX_GXGCUnion = rdbHelper.ExecuteDatatable("tab", "select FID_DLTBGX,FID_DLTBGXGC,TBBGMJ,ZLDWDM,BGXW,BGHTBBH,BGHTBBSM from GX_GXGCUnion", true); |
|
Dictionary<int, string[]> bsmDic = new Dictionary<int, string[]>(); |
|
Dictionary<int, int> OIDdic = new Dictionary<int, int>(); |
|
var strBSM = GetNewBSM(new List<IFeatureClass>() { JcTbLayer.FeatureClass }); |
|
Dictionary<string, int> dicTBBH = new Dictionary<string, int>(); |
|
GetMaxTBBH(JcTbLayer.FeatureClass, ref dicTBBH); |
|
foreach (DataRow item in GX_GXGCUnion.Rows) |
|
{ |
|
int gxID = item["FID_DLTBGX"].ToInt(); |
|
string zldwdm = item["ZLDWDM"].ToString(); |
|
string bgxw = item["BGXW"].ToString(); |
|
string TBBH = string.Empty; |
|
if (!bsmDic.ContainsKey(gxID)) |
|
{ |
|
if (bgxw == "2") |
|
{ |
|
var strbsm = strBSM.Substring(0, 10); |
|
var Maxbsm = strBSM.Substring(10).ToInt() + 1; |
|
strBSM = strbsm + Maxbsm.ToString().PadLeft(8, '0');//最新标识码 |
|
if (dicTBBH.ContainsKey(zldwdm)) |
|
{ |
|
dicTBBH[zldwdm] = dicTBBH[zldwdm] + 1;//最大图斑编号-去最新值 |
|
TBBH = dicTBBH[zldwdm].ToTrim(); |
|
} |
|
else |
|
{ |
|
dicTBBH.Add(zldwdm, 1); |
|
TBBH = dicTBBH[zldwdm].ToTrim(); |
|
} |
|
bsmDic.Add(gxID, new string[] { strBSM, TBBH }); |
|
} |
|
else |
|
{ |
|
bsmDic.Add(gxID, new string[] { item["BGHTBBSM"].ToString(), item["BGHTBBH"].ToString() }); |
|
} |
|
} |
|
int gxgcID = item["FID_DLTBGXGC"].ToInt(); |
|
if (!OIDdic.ContainsKey(gxgcID)) |
|
{ |
|
OIDdic.Add(gxgcID, gxID); |
|
} |
|
} |
|
pCursor = GxTbLayer.FeatureClass.Update(null, true); |
|
var _index_BSM = GxTbLayer.FeatureClass.FindField("BSM"); |
|
var _index_YSDM = GxTbLayer.FeatureClass.FindField("YSDM");//2001010100 |
|
var _index_TBBH = GxTbLayer.FeatureClass.FindField("TBBH"); |
|
var _index_TBMJ = GxTbLayer.FeatureClass.FindField("TBMJ"); |
|
var _index_KCXS = GxTbLayer.FeatureClass.FindField("KCXS"); |
|
var _index_KCMJ = GxTbLayer.FeatureClass.FindField("KCMJ"); |
|
var _index_TBDLMJ = GxTbLayer.FeatureClass.FindField("TBDLMJ"); |
|
var igx_gxsj = GxTbLayer.FeatureClass.FindField("GXSJ"); |
|
var igx_xzqtzlx = GxTbLayer.FeatureClass.FindField("XZQTZLX"); |
|
while ((feature = pCursor.NextFeature()) != null) |
|
{ |
|
int oid = feature.OID; |
|
if (bsmDic.ContainsKey(oid)) |
|
{ |
|
string[] arr = bsmDic[oid]; |
|
feature.Value[_index_BSM] = arr[0]; |
|
feature.Value[_index_TBBH] = arr[1]; |
|
} |
|
var kcxs = feature.Value[_index_KCXS].ToDouble();//扣除系数 |
|
feature.Value[_index_YSDM] = "2001010100";//要素代码 |
|
DataRow[] row = GX_GXGCUnion.Select($"FID_DLTBGX={feature.OID}"); |
|
double mj = 0.00; |
|
if (row.Length > 0) |
|
{ |
|
string gxgcid = string.Join(" or ", row.Select(r => $"OBJECTID = {r["FID_DLTBGXGC"].ToString()}")).ToString(); |
|
mj = row.Select(r => r["TBBGMJ"].ToDouble()).Sum().ToDouble(2); |
|
} |
|
feature.Value[_index_TBMJ] = mj; |
|
var kcmj = Math.Round((decimal)(mj * kcxs), 2, MidpointRounding.AwayFromZero).ToDouble(); |
|
feature.Value[_index_KCMJ] = kcmj; |
|
feature.Value[_index_TBDLMJ] = Math.Round(mj - kcmj, 2); |
|
feature.Value[igx_gxsj] = DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31); |
|
feature.Value[igx_xzqtzlx] = 0; |
|
pCursor.UpdateFeature(feature); |
|
} |
|
pCursor.Flush(); |
|
pCursor = GxgcTBLayer.FeatureClass.Update(null, true); |
|
int iBGHTBBSM = GxgcTBLayer.FeatureClass.FindField("BGHTBBSM"); |
|
int iBGHTBBH = GxgcTBLayer.FeatureClass.FindField("BGHTBBH"); |
|
var igxgc_xzqtzlx = GxgcTBLayer.FeatureClass.FindField("XZQTZLX"); |
|
while ((feature = pCursor.NextFeature()) != null) |
|
{ |
|
int oid = feature.OID; |
|
if (OIDdic.ContainsKey(oid)) |
|
{ |
|
int gxOID = OIDdic[oid]; |
|
if (bsmDic.ContainsKey(gxOID)) |
|
{ |
|
string[] arr = bsmDic[gxOID]; |
|
feature.Value[iBGHTBBSM] = arr[0]; |
|
feature.Value[iBGHTBBH] = arr[1]; |
|
} |
|
} |
|
feature.Value[igxgc_xzqtzlx] = 0; |
|
pCursor.UpdateFeature(feature); |
|
} |
|
pCursor.Flush(); |
|
#endregion |
|
rdbHelper.ExecuteSQL(" drop table DLTBGXGC "); |
|
TableToTable((GxgcTBLayer.FeatureClass as FeatureClass).Workspace as IFeatureWorkspace, pOutWork, "DLTBGXGC"); |
|
DataTable DLTBGXGC = rdbHelper.ExecuteDatatable("tab", @"select BGHTBBSM from DLTBGXGC WHERE BGXW = 1 and BGQZLDWDM != BGHZLDWDM |
|
and(BGQDLBM = BGHDLBM or(BGQDLBM isnull and BGHDLBM isnull)) |
|
and(BGQDLMC = BGHDLMC or(BGQDLMC isnull and BGHDLMC isnull)) |
|
and(BGQQSXZ = BGHQSXZ or(BGQQSXZ isnull and BGHQSXZ isnull)) |
|
and(BGQKCDLBM = BGHKCDLBM or(BGQKCDLBM isnull and BGHKCDLBM isnull)) |
|
and(BGQKCXS = BGHKCXS or(BGQKCXS isnull and BGHKCXS isnull)) |
|
and(BGQGDLX = BGHGDLX or(BGQGDLX isnull and BGHGDLX isnull)) |
|
and(BGQGDPDJB = BGHGDPDJB or(BGQGDPDJB isnull and BGHGDPDJB isnull)) |
|
and(BGQXZDWKD = BGHXZDWKD or(BGQXZDWKD isnull and BGHXZDWKD isnull)) |
|
and(BGQTBXHDM = BGHTBXHDM or(BGQTBXHDM isnull and BGHTBXHDM isnull)) |
|
and(BGQTBXHMC = BGHTBXHMC or(BGQTBXHMC isnull and BGHTBXHMC isnull)) |
|
and(BGQZZSXDM = BGHZZSXDM or(BGQZZSXDM isnull and BGHZZSXDM isnull)) |
|
and(BGQZZSXMC = BGHZZSXMC or(BGQZZSXMC isnull and BGHZZSXMC isnull)) |
|
and(BGQGDDB = BGHGDDB or(BGQGDDB isnull and BGHGDDB isnull)) |
|
and(BGQFRDBS = BGHFRDBS or(BGQFRDBS isnull and BGHFRDBS isnull)) |
|
and(BGQCZCSXM = BGHCZCSXM or(BGQCZCSXM isnull and BGHCZCSXM isnull))", true); |
|
if (DLTBGXGC != null && DLTBGXGC.Rows.Count > 0) |
|
{ |
|
List<string> bghbsm = DLTBGXGC.Rows.OfType<DataRow>().Select(r => $"{r["BGHTBBSM"].ToString()}").ToList(); |
|
int ibghtbbsm = GxgcTBLayer.FeatureClass.FindField("BGHTBBSM"); |
|
int ijczt = GxgcTBLayer.FeatureClass.FindField("ONLYZLBG"); |
|
pCursor = GxgcTBLayer.FeatureClass.Update(null, true); |
|
while ((feature = pCursor.NextFeature()) != null) |
|
{ |
|
string bghtbbsm = feature.Value[ibghtbbsm].ToString(); |
|
if (bghbsm.Contains(bghtbbsm)) |
|
{ |
|
feature.Value[ijczt] = "1"; |
|
pCursor.UpdateFeature(feature); |
|
} |
|
} |
|
pCursor.Flush(); |
|
pCursor = GxTbLayer.FeatureClass.Update(null, true); |
|
ijczt = GxTbLayer.FeatureClass.FindField("ONLYZLBG"); |
|
int ibsm = GxTbLayer.FeatureClass.FindField("BSM"); |
|
while ((feature = pCursor.NextFeature()) != null) |
|
{ |
|
string bsm = feature.Value[ibsm].ToString(); |
|
if (bghbsm.Contains(bsm)) |
|
{ |
|
feature.Value[ijczt] = "1"; |
|
pCursor.UpdateFeature(feature); |
|
} |
|
} |
|
pCursor.Flush(); |
|
} |
|
Console.WriteLine("Msg:正在生成年末数据..."); |
|
base.CreateNMK(parm); |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug(ex); |
|
Console.WriteLine("Err:地类图斑数据提取失败!" + ex.Message); |
|
Console.WriteLine("Err:地类图斑数据提取失败!" + ex.StackTrace); |
|
} |
|
finally |
|
{ |
|
//this.CloseLoading(); |
|
//if (JcTbLayer.FeatureClass != null) |
|
// Marshal.ReleaseComObject(JcTbLayer.FeatureClass); |
|
//if (GxTbLayer.FeatureClass != null) |
|
// Marshal.ReleaseComObject(GxTbLayer.FeatureClass); |
|
//if (GxgcTBLayer.FeatureClass != null) |
|
// Marshal.ReleaseComObject(GxgcTBLayer.FeatureClass); |
|
//if (BgTbLayer.FeatureClass != null) |
|
// Marshal.ReleaseComObject(BgTbLayer.FeatureClass); |
|
} |
|
} |
|
public void CalculateArea(object pParm) |
|
{ |
|
try |
|
{ |
|
CalcAreaParm CalParm = pParm as CalcAreaParm; |
|
IFeatureLayer _Layer = GeoDBAPI.DeSerialzedPersist(CalParm.StrLayer) as IFeatureLayer; |
|
IFeatureCursor pCursor = _Layer.FeatureClass.Search(new QueryFilterClass() { SubFields = "OBJECTID,BSM,TBMJ,SHAPE" }, true); |
|
var _itbmj = _Layer.FeatureClass.FindField("TBMJ"); |
|
var bsmIdx = _Layer.FeatureClass.FindField("BSM"); |
|
IFeature feature = null; |
|
while ((feature = pCursor.NextFeature()) != null) |
|
{ |
|
string bsm = feature.Value[bsmIdx].ToTrim(); |
|
if (!CalParm.BsmList.Contains(bsm)) |
|
continue; |
|
double area = GetEllipseArea(feature.ShapeCopy); |
|
lock (AreaList) |
|
{ |
|
AreaList.Add(feature.OID, area.ToDouble()); |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
//Console.WriteLine(ex.Message); |
|
} |
|
} |
|
public class CalcAreaParm |
|
{ |
|
public string StrLayer { get; set; } |
|
public int StartIndex { get; set; } |
|
public List<string> BsmList { get; set; } |
|
} |
|
|
|
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 _JcPdtLayerInfo = NcList.FirstOrDefault(f => f.LayerName == "坡度图"); |
|
_jcPdtLayer = OpenLayer(_JcPdtLayerInfo); |
|
if (_jcPdtLayer == null) |
|
{ |
|
//throw new Exception("Err:获取年初坡度图数据失败!"); |
|
} |
|
_bgTbLayer = OpenLayer(BgWsAPI, "DLTBBG"); |
|
_gxTbLayer = OpenLayer(ZlWsAPI, "DLTBGX"); |
|
_gxgcTBLayer = OpenLayer(ZlWsAPI, "DLTBGXGC"); |
|
_gxPdtLayer = OpenLayer(ZlWsAPI, "PDTGX"); |
|
//_nmTbLayer = OpenLayer(NmWsAPI, "DLTB_NMK"); |
|
|
|
//} |
|
} |
|
catch (Exception ex) |
|
{ |
|
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) |
|
{ |
|
Console.WriteLine($"Log:CreateDBWorkspace错误:{ex.Message}"); |
|
throw; |
|
} |
|
} |
|
|
|
private IFeatureLayer ProcessBGTB() |
|
{ |
|
IFeatureLayer result = null; |
|
try |
|
{ |
|
#region 空属性值 赋值 |
|
#region 变更图斑 |
|
string BgtbName = (BgTbLayer.FeatureClass as FeatureClass).BrowseName; |
|
(BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set KCDLBM =Null where KCDLBM is Null or KCDLBM=' ' or KCDLBM=' ' "); |
|
(BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set KCXS=0 where KCXS is Null "); |
|
(BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set GDLX =Null where GDLX is Null or GDLX=' ' or GDLX=' ' "); |
|
(BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set GDPDJB =Null where GDPDJB is Null or GDPDJB=' ' or GDPDJB=' ' "); |
|
(BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set XZDWKD=0 where XZDWKD is Null "); |
|
(BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set TBXHDM =Null where TBXHDM is Null or TBXHDM=' ' or TBXHDM=' ' "); |
|
(BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set TBXHMC =Null where TBXHMC is Null or TBXHMC=' ' or TBXHMC=' ' "); |
|
(BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set ZZSXDM =Null where ZZSXDM is Null or ZZSXDM=' ' or ZZSXDM=' ' "); |
|
(BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set ZZSXMC =Null where ZZSXMC is Null or ZZSXMC=' ' or ZZSXMC=' ' "); |
|
(BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set GDDB =0 where GDDB is Null "); |
|
(BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set FRDBS =Null where FRDBS is Null or FRDBS=' ' or FRDBS=' ' "); |
|
(BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set CZCSXM =Null where CZCSXM is Null or CZCSXM=' ' or CZCSXM=' ' "); |
|
(BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set MSSM =Null where MSSM is Null or MSSM=' ' or MSSM=' ' "); |
|
(BgTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {BgtbName} set HDMC =Null where HDMC is Null or HDMC=' ' or HDMC=' ' "); |
|
#endregion |
|
#region 基础地类图斑 |
|
string JC_DLTBName = (JcTbLayer.FeatureClass as FeatureClass).BrowseName; |
|
(JcTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {JC_DLTBName} set KCDLBM =Null where KCDLBM is Null or KCDLBM=' ' or KCDLBM=' ' "); |
|
(JcTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {JC_DLTBName} set KCXS =0 where KCXS is Null"); |
|
(JcTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {JC_DLTBName} set GDLX =Null where GDLX is Null or GDLX=' ' or GDLX=' ' "); |
|
(JcTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {JC_DLTBName} set GDPDJB =Null where GDPDJB is Null or GDPDJB=' ' or GDPDJB=' ' "); |
|
(JcTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {JC_DLTBName} set XZDWKD =0 where XZDWKD is Null"); |
|
(JcTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {JC_DLTBName} set TBXHDM =Null where TBXHDM is Null or TBXHDM=' ' or TBXHDM=' ' "); |
|
(JcTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {JC_DLTBName} set TBXHMC =Null where TBXHMC is Null or TBXHMC=' ' or TBXHMC=' ' "); |
|
(JcTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {JC_DLTBName} set ZZSXDM =Null where ZZSXDM is Null or ZZSXDM=' ' or ZZSXDM=' ' "); |
|
(JcTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {JC_DLTBName} set ZZSXMC =Null where ZZSXMC is Null or ZZSXMC=' ' or ZZSXMC=' ' "); |
|
(JcTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {JC_DLTBName} set GDDB =0 where GDDB is Null"); |
|
(JcTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {JC_DLTBName} set FRDBS =Null where FRDBS is Null or FRDBS=' ' or FRDBS=' ' "); |
|
(JcTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {JC_DLTBName} set CZCSXM =Null where CZCSXM is Null or CZCSXM=' ' or CZCSXM=' ' "); |
|
(JcTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {JC_DLTBName} set MSSM =Null where MSSM is Null or MSSM=' ' or MSSM=' ' "); |
|
(JcTbLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update {JC_DLTBName} set HDMC =Null where HDMC is Null or HDMC=' ' or HDMC=' ' "); |
|
#endregion |
|
#endregion |
|
GPParamClass paramClass = new GPParamClass(); |
|
|
|
|
|
IFeatureLayer tempLayer = null; |
|
|
|
paramClass = new GPParamClass(); |
|
paramClass.FirstFeatureLayer = JcTbLayer; |
|
paramClass.SecondFeatureLayer = BgTbLayer; |
|
paramClass.TempGDBPath = $"{TempDbPath}"; |
|
paramClass.Tolerance = "0.0001"; |
|
paramClass.IsGetOutPutFeature = true; |
|
paramClass.GPType = EnumGPType.BGTBYCL; |
|
GPHelper.Instance.ExeGPForProces(paramClass, ref tempLayer); |
|
IWorkspaceAPI wsAPI = new WorkspaceAPI(TempDbPath, WorkspaceTypeEnum.GDBFile); |
|
IFeatureClassAPI fcAPI = wsAPI.OpenFeatureClass("DLTBBG"); |
|
result = new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass, Name = fcAPI.FeatureClass.AliasName }; |
|
|
|
//IFeatureLayer tempJcDltbLayer = null; |
|
//IFeatureLayer tempBgTbLayer = null; |
|
//if (JcTbLayer.FeatureClass.FeatureCount(null) != BgTbLayer.FeatureClass.FeatureCount(null)) |
|
//{ |
|
// paramClass.Tolerance = "0.0001"; |
|
// paramClass.FirstFeatureLayer = JcTbLayer; |
|
// paramClass.SecondFeatureLayer = BgTbLayer; |
|
// paramClass.IsGetOutPutFeature = true; |
|
// paramClass.GPType = EnumGPType.SelectLayerByLocation; |
|
// paramClass.Overlap_type = "INTERSECT"; |
|
// GPHelper.Instance.ExeGPForProces(paramClass, ref tempJcDltbLayer); |
|
// Console.WriteLine($"Log:ExeGPForProces:INTERSECT"); |
|
// paramClass.FirstFeatureLayer = tempJcDltbLayer; |
|
// paramClass.SecondFeatureLayer = BgTbLayer; |
|
// paramClass.OutFeatureClassPath = $"{TempDbPath}\\BGTB_Erase2"; |
|
// paramClass.IsGetOutPutFeature = true; |
|
// paramClass.GPType = EnumGPType.Erase; |
|
// GPHelper.Instance.ExeGPForProces(paramClass, ref tempBgTbLayer); |
|
// Console.WriteLine($"Log:ExeGPForProces:Erase"); |
|
//} |
|
//IFeatureClassAPI fcAPI = new FeatureClassAPI(BgTbLayer.FeatureClass); |
|
//fcAPI.FcToFc(tempBgTbLayer.FeatureClass, null, false); |
|
//Console.WriteLine($"Log:FcToFc:tempBgTbLayer"); |
|
//paramClass = new GPParamClass(); |
|
//paramClass.FirstFeatureLayer = tempBgTbLayer; |
|
//paramClass.OutFeatureClassPath = $"{TempDbPath}\\DLTBBG"; |
|
//paramClass.IsGetOutPutFeature = true; |
|
//paramClass.ListDissolveFiledName = new List<string>() { "DLBM", "DLMC", "QSXZ", "QSDWDM", "QSDWMC", "ZLDWDM", "ZLDWMC", "KCDLBM", "KCXS", "GDLX", "GDPDJB", "XZDWKD", "TBXHDM", "TBXHMC", "ZZSXDM", "ZZSXMC", "GDDB", "FRDBS", "CZCSXM", "MSSM", "HDMC" }; |
|
//paramClass.GPType = EnumGPType.Dissolve; |
|
//GPHelper.Instance.ExeGPForProces(paramClass, ref result); |
|
|
|
|
|
|
|
|
|
//paramClass = new GPParamClass(); |
|
//paramClass.FirstFeatureLayer = result; |
|
//paramClass.SecondFeatureLayer = JcTbLayer; |
|
//paramClass.OutFeatureClassPath = $"{TempDbPath}\\DLTBBG_Intersect"; |
|
//paramClass.IsGetOutPutFeature = true; |
|
//paramClass.GPType = EnumGPType.Intersect; |
|
//GPHelper.Instance.ExeGPForProces(paramClass, ref tempLayer); |
|
|
|
#region 变更图斑与基础地类图斑相交 删除属性完全相同的部分 |
|
|
|
IQueryFilter filter = new QueryFilter(); |
|
filter.SubFields = "FID_DLTB,FID_DLTBBG"; |
|
IFeatureCursor tempCursor = tempLayer.FeatureClass.Search(filter, true); |
|
IFeature f = null; |
|
Dictionary<int, int> dicJcOIds = new Dictionary<int, int>(); |
|
Dictionary<int, int> dicBgOIds = new Dictionary<int, int>(); |
|
int idxDLTBID, idxBGTBID; |
|
idxDLTBID = tempLayer.FeatureClass.FindField("FID_DLTB"); |
|
idxBGTBID = tempLayer.FeatureClass.FindField("FID_DLTBBG"); |
|
while ((f = tempCursor.NextFeature()) != null) |
|
{ |
|
int jcOId = f.Value[idxDLTBID].ToInt(); |
|
int bgOid = f.Value[idxBGTBID].ToInt(); |
|
if (!dicJcOIds.ContainsKey(jcOId)) |
|
dicJcOIds.Add(jcOId, 1); |
|
else |
|
dicJcOIds[jcOId] = dicJcOIds[jcOId] + 1; |
|
if (!dicBgOIds.ContainsKey(bgOid)) |
|
dicBgOIds.Add(bgOid, 1); |
|
else |
|
dicBgOIds[bgOid] = dicBgOIds[bgOid] + 1; |
|
} |
|
//filter.WhereClause = "DLBM = DLBM_1 and DLMC = DLMC_1 and QSXZ = QSXZ_1 and QSDWDM = QSDWDM_1 and QSDWMC = QSDWMC_1 and ZLDWDM = ZLDWDM_1 and ZLDWMC = ZLDWMC_1 and KCDLBM = KCDLBM_1 and KCXS = KCXS_1 and GDLX = GDLX_1 and GDPDJB = GDPDJB_1 and XZDWKD = XZDWKD_1 and TBXHDM = TBXHDM_1 and TBXHMC = TBXHMC_1 and ZZSXDM = ZZSXDM_1 and ZZSXMC = ZZSXMC_1 and GDDB = GDDB_1 and FRDBS = FRDBS_1 and CZCSXM = CZCSXM_1 and MSSM = MSSM_1 and HDMC = HDMC_1"; |
|
filter.WhereClause = @"DLBM = DLBM_1 and DLMC = DLMC_1 and QSXZ = QSXZ_1 and QSDWDM = QSDWDM_1 and QSDWMC = QSDWMC_1 and ZLDWDM = ZLDWDM_1 and ZLDWMC = ZLDWMC_1 and |
|
(KCDLBM = KCDLBM_1 or(KCDLBM is null and KCDLBM_1 is null)) and |
|
(KCXS = KCXS_1 or(KCXS is null and KCXS_1 is null)) and |
|
(GDLX = GDLX_1 or(GDLX is null and GDLX_1 is null)) and |
|
(GDPDJB = GDPDJB_1 or(GDPDJB is null and GDPDJB_1 is null)) and |
|
(XZDWKD = XZDWKD_1 or(XZDWKD is null and XZDWKD_1 is null)) and |
|
(TBXHDM = TBXHDM_1 or(TBXHDM is null and TBXHDM_1 is null)) and |
|
(TBXHMC = TBXHMC_1 or(TBXHMC is null and TBXHMC_1 is null)) and |
|
(ZZSXDM = ZZSXDM_1 or(ZZSXDM is null and ZZSXDM_1 is null)) and |
|
(ZZSXMC = ZZSXMC_1 or(ZZSXMC is null and ZZSXMC_1 is null)) and |
|
(GDDB = GDDB_1 or(GDDB is null and GDDB_1 is null)) and |
|
(FRDBS = FRDBS_1 or(FRDBS is null and FRDBS_1 is null)) and |
|
(CZCSXM = CZCSXM_1 or(CZCSXM is null and CZCSXM_1 is null)) and |
|
(MSSM = MSSM_1 or(MSSM is null and MSSM_1 is null)) and |
|
(HDMC = HDMC_1 or(HDMC is null and HDMC_1 is null))"; |
|
tempCursor = tempLayer.FeatureClass.Search(filter, true); |
|
List<int> DeleOids = new List<int>(); |
|
while ((f = tempCursor.NextFeature()) != null) |
|
{ |
|
int jcOId = f.Value[idxDLTBID].ToInt(); |
|
int bgOid = f.Value[idxBGTBID].ToInt(); |
|
if (dicJcOIds[jcOId] == 1 && dicBgOIds[bgOid] == 1) |
|
{ |
|
DeleOids.Add(bgOid); |
|
} |
|
} |
|
tempCursor = result.FeatureClass.Update(null, true); |
|
int idx = result.FeatureClass.FindField("HDMC"); |
|
if (idx != -1) |
|
{ |
|
while ((f = tempCursor.NextFeature()) != null) |
|
{ |
|
if (DeleOids.Contains(f.OID)) |
|
{ |
|
f.Value[idx] = "del"; |
|
tempCursor.UpdateFeature(f); |
|
} |
|
} |
|
tempCursor.Flush(); |
|
(result.FeatureClass as ITable).DeleteSearchedRows(new QueryFilterClass() { WhereClause = "HDMC='del'" }); |
|
} |
|
else |
|
{ |
|
foreach (var oid in DeleOids) |
|
{ |
|
result.FeatureClass.GetFeature(oid).Delete(); |
|
} |
|
} |
|
#endregion |
|
|
|
#region 变更图斑 属性相同 图形相邻的合并 |
|
|
|
ITable Dissolve = result as ITable; |
|
Dissolve.DeleteSearchedRows(new QueryFilterClass() { WhereClause = "DLBM ='1001' or DLBM ='1002' or DLBM ='1003' or DLBM='1004' or DLBM ='1006' or DLBM='1009' or DLBM='1101' or DLBM='1107' or DLBM='1107A'" }); |
|
FcToFc(BgTbLayer.FeatureClass, result.FeatureClass, new QueryFilterClass() { WhereClause = "DLBM ='1001' or DLBM ='1002' or DLBM ='1003' or DLBM='1004' or DLBM ='1006' or DLBM='1009' or DLBM='1101' or DLBM='1107' or DLBM='1107A'" }); |
|
//添加字段 |
|
IFieldEdit _field = new FieldClass(); |
|
_field.Name_2 = "TBMJ"; |
|
_field.Type_2 = esriFieldType.esriFieldTypeDouble; |
|
_field.Length_2 = 8; |
|
if (result.FeatureClass.FindField("TBMJ") == -1) |
|
result.FeatureClass.AddField(_field as IField); |
|
#endregion |
|
|
|
#region 计算最新耕地坡度级别 |
|
GDPDExcute(); |
|
#endregion |
|
} |
|
catch (Exception ex) |
|
{ |
|
Console.WriteLine($"Log:变更前执行变更图斑数据处理失败:{ex.Message}"); |
|
Console.WriteLine($"Log:变更前执行变更图斑数据处理失败:{ex.StackTrace}"); |
|
throw ex; |
|
} |
|
return result; |
|
} |
|
|
|
private IFeatureLayer GenerateTempGXGC(IFeatureLayer pTempBgTbLayer, string pTempAttrDBPath) |
|
{ |
|
IFeatureLayer result = null; |
|
GPParamClass paramClass = new GPParamClass(); |
|
try |
|
{ |
|
|
|
//GPParamClass paramClass = new GPParamClass(); |
|
|
|
|
|
IFeatureLayer tempLayer = null; |
|
|
|
paramClass = new GPParamClass(); |
|
paramClass.FirstFeatureLayer = JcTbLayer; |
|
paramClass.SecondFeatureLayer = pTempBgTbLayer; |
|
paramClass.TempGDBPath = $"{TempDbPath}"; |
|
paramClass.Tolerance = "-0.001"; |
|
paramClass.IsGetOutPutFeature = true; |
|
paramClass.GPType = EnumGPType.YBG; |
|
GPHelper.Instance.ExeGPForProces(paramClass, ref tempLayer); |
|
IWorkspaceAPI wsAPI = new WorkspaceAPI(TempDbPath, WorkspaceTypeEnum.GDBFile); |
|
IFeatureClassAPI fcAPI = wsAPI.OpenFeatureClass("GXGC_Multipart"); |
|
result = new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass, Name = fcAPI.FeatureClass.AliasName }; |
|
|
|
return result; |
|
|
|
#region 设置基础地类图斑选中 |
|
if (JcTbLayer.FeatureClass.FeatureCount(null) != pTempBgTbLayer.FeatureClass.FeatureCount(null)) |
|
{ |
|
paramClass.Tolerance = "0.0001"; |
|
paramClass.FirstFeatureLayer = JcTbLayer; |
|
paramClass.SecondFeatureLayer = pTempBgTbLayer; |
|
paramClass.IsGetOutPutFeature = true; |
|
paramClass.GPType = EnumGPType.SelectLayerByLocation; |
|
paramClass.Overlap_type = "INTERSECT"; |
|
GPHelper.Instance.ExeGPForProces(paramClass, ref result); |
|
|
|
} |
|
#endregion |
|
|
|
#region 变更层与基础地类图斑联合 |
|
paramClass = new GPParamClass() |
|
{ |
|
FirstFeatureLayer = pTempBgTbLayer, |
|
SecondFeatureLayer = result, |
|
OutFeatureClassPath = $"{TempDbPath}\\BGTB_DLTBUnion", |
|
IsGetOutPutFeature = true, |
|
PreserveAttributes = "ALL", |
|
GPType = EnumGPType.Union |
|
}; |
|
GPHelper.Instance.ExeGPForProces(paramClass, ref result); |
|
#endregion |
|
|
|
#region 拆分多部件 |
|
paramClass = new GPParamClass(); |
|
paramClass.FirstFeatureLayer = result; |
|
paramClass.OutFeatureClassPath = $"{TempDbPath}\\GXGC_Multipart"; |
|
paramClass.IsGetOutPutFeature = true; |
|
paramClass.GPType = EnumGPType.MultipartToSinglePath; |
|
GPHelper.Instance.ExeGPForProces(paramClass, ref result); |
|
#endregion |
|
|
|
|
|
#region TableToTable |
|
string dbPath = pTempAttrDBPath; |
|
IRDBHelper rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite); |
|
rdbHelper.ExecuteSQL(" drop table GXGC_Multipart "); |
|
rdbHelper.DisConnect(); |
|
IWorkspace ws = (result.FeatureClass as FeatureClass).Workspace; |
|
//添加字段 |
|
IFieldEdit _field = new FieldClass(); |
|
_field.Name_2 = "BGXW"; |
|
_field.Type_2 = esriFieldType.esriFieldTypeString; |
|
_field.Length_2 = 2; |
|
if (result.FeatureClass.FindField("BGXW") == -1) |
|
result.FeatureClass.AddField(_field as IField); |
|
//矢量数据至db文件 |
|
//(result.FeatureClass as ITable).DeleteSearchedRows(new QueryFilterClass() { WhereClause = "Shape_area < 0.01" }); |
|
TableToTable(ws as IFeatureWorkspace, pOutWork, "GXGC_Multipart"); |
|
#endregion |
|
} |
|
catch (Exception ex) |
|
{ |
|
Console.WriteLine($"Log:生成临时更新过程层数据失败:{ex.Message}"); |
|
throw ex; |
|
} |
|
return result; |
|
} |
|
public 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; |
|
} |
|
} |
|
|
|
public void GDPDExcute() |
|
{ |
|
//IFeatureClassAPI GXAPI = null; |
|
//IFeatureClassAPI pdtFcAPI = null; |
|
IFeatureLayer PDTLayer = null; |
|
IFeature feature = null; |
|
IFeatureCursor cursor = null; |
|
IWorkspaceFactory pFtWsFct = null; |
|
IWorkspaceName workspaceName = null; |
|
IFeatureLayer unionLayer = null; |
|
IFeatureClassAPI unionFcAPI = null; |
|
try |
|
{ |
|
Console.WriteLine("Msg:正在进行耕地坡度级别赋值,请稍后..."); |
|
|
|
#region 变更图斑层(GDB) |
|
//// 获取变更图斑 |
|
//GXAPI = new FeatureClassAPI(BgTbLayer.FeatureClass); |
|
//if (GXAPI == null || GXAPI.FeatureClass == null) |
|
//{ |
|
// Console.WriteLine("Err:未获取到更新层图斑"); |
|
// return; |
|
//} |
|
#endregion |
|
#region 坡度图层(MDB) |
|
PDTLayer = GxPdtLayer; |
|
if (GxPdtLayer == null && JcPdtLayer == null) |
|
{ |
|
Console.WriteLine("Warning:当前工程不存在坡度图图层!"); |
|
return; |
|
} |
|
if (PDTLayer.FeatureClass.FeatureCount(null) <= 0) |
|
{ |
|
PDTLayer = JcPdtLayer; |
|
} |
|
if (PDTLayer.FeatureClass.FeatureCount(null) <= 0) |
|
{ |
|
Console.WriteLine("Warning:当前工程中未导入坡度数据!"); |
|
return; |
|
} |
|
#endregion |
|
|
|
|
|
//IWorkspaceAPI psTempWorkspaceAPI = new WorkspaceAPI(pTempGDbPath, WorkspaceTypeEnum.GDBFile); |
|
//IFeatureClassAPI tempdltbgxFeatureclassAPI = psTempWorkspaceAPI.CreateFeatureClass("TempDLTBGX", (BgTbLayer.FeatureClass as IGeoDataset).SpatialReference, BgTbLayer.FeatureClass.Fields); |
|
//tempdltbgxFeatureclassAPI.AddField("OLDOBJECTID", esriFieldType.esriFieldTypeInteger, "老OBJECTID"); |
|
//IFeatureClass tempdltbgxFC = tempdltbgxFeatureclassAPI.FeatureClass; |
|
//Dictionary<int, int> fieldsDic = new Dictionary<int, int>(); |
|
//for (int i = 0; i < tempdltbgxFC.Fields.FieldCount; i++) |
|
//{ |
|
// IField field = tempdltbgxFC.Fields.Field[i]; |
|
// if (field.Name == tempdltbgxFC.ShapeFieldName || field.Name.Contains(tempdltbgxFC.ShapeFieldName) || field.Name == tempdltbgxFC.OIDFieldName || !field.Editable) continue; |
|
|
|
// if (!"DLBM,GDLX,GDDB,GDPDJB,KCXS".Contains(field.Name)) continue; |
|
// int index = -1; |
|
// index = BgTbLayer.FeatureClass.Fields.FindField(field.Name); |
|
// if (index == -1) |
|
// index = BgTbLayer.FeatureClass.Fields.FindFieldByAliasName(field.AliasName); |
|
// if (index == -1) |
|
// continue; |
|
|
|
// fieldsDic.Add(i, index); |
|
//} |
|
|
|
//if (fieldsDic.Count == 0) |
|
// return; |
|
//IFeatureBuffer buffer = tempdltbgxFC.CreateFeatureBuffer(); |
|
//IFeatureCursor tempgxCursor = tempdltbgxFC.Insert(true); |
|
//int oldOIDIndex = tempdltbgxFC.FindField("OLDOBJECTID"); |
|
//if (oldOIDIndex == -1) |
|
// return; |
|
|
|
//IQueryFilter queryfilter = new QueryFilterClass(); |
|
//queryfilter.WhereClause = string.Format("DLBM like '01%' "); |
|
|
|
//int gdCount = BgTbLayer.FeatureClass.FeatureCount(queryfilter); |
|
//if (gdCount == 0) |
|
// return; |
|
|
|
//IFeature gxtbFeature = null; |
|
//IFeatureCursor dltbgxCursor = BgTbLayer.FeatureClass.Search(queryfilter, true); |
|
//int OIDIndex = BgTbLayer.FeatureClass.FindField("OBJECTID"); |
|
//int num = 0; |
|
//while ((gxtbFeature = dltbgxCursor.NextFeature()) != null) |
|
//{ |
|
// num++; |
|
// if (gxtbFeature.ShapeCopy.IsEmpty) continue; |
|
// buffer.Shape = gxtbFeature.ShapeCopy; |
|
// foreach (int item in fieldsDic.Keys) |
|
// { |
|
// if (string.IsNullOrWhiteSpace(gxtbFeature.Value[fieldsDic[item]].ToTrim())) |
|
// buffer.Value[item] = DBNull.Value; |
|
// buffer.Value[item] = gxtbFeature.Value[fieldsDic[item]]; |
|
// } |
|
|
|
// buffer.Value[oldOIDIndex] = gxtbFeature.Value[OIDIndex]; |
|
// tempgxCursor.InsertFeature(buffer); |
|
// if (num % 1000 == 0) |
|
// { |
|
// tempgxCursor.Flush(); |
|
// } |
|
// Marshal.ReleaseComObject(gxtbFeature); |
|
//} |
|
//tempgxCursor.Flush(); |
|
|
|
//DLTBGX与PDTGX 相交 |
|
GPParamClass gPParamClass = new GPParamClass(); |
|
gPParamClass.FirstFeatureLayer = BgTbLayer; |
|
gPParamClass.SecondFeatureLayer = PDTLayer; |
|
gPParamClass.OutFeatureClassPath = TempDbPath + "\\TB_PD"; |
|
gPParamClass.IsGetOutPutFeature = true; |
|
gPParamClass.GPType = EnumGPType.Identify; |
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref unionLayer); |
|
unionFcAPI = new FeatureClassAPI(unionLayer.FeatureClass); |
|
cursor = unionFcAPI.FeatureClass.Search(null, true); |
|
feature = null; |
|
Dictionary<int, string> DicPDJB = new Dictionary<int, string>(); |
|
Dictionary<int, double> DicMJ = new Dictionary<int, double>(); |
|
Dictionary<int, List<PDJBModel>> DicPDJB_MJ = new Dictionary<int, List<PDJBModel>>(); |
|
int idxOID = unionFcAPI.FeatureClass.FindField("OLDOBJECTID"); |
|
if (idxOID == -1) |
|
{ |
|
return; |
|
} |
|
int idxArea = unionFcAPI.FeatureClass.FindField("SHAPE_AREA"); |
|
int idxPDJB = unionFcAPI.FeatureClass.FindField("PDJB"); |
|
while ((feature = cursor.NextFeature()) != null) |
|
{ |
|
int oid = Convert.ToInt32(feature.Value[idxOID].ToTrim()); |
|
if (oid == 456) |
|
{ |
|
} |
|
double area = feature.Value[idxArea].ToDouble(2); |
|
string pdjb = feature.Value[idxPDJB].ToTrim(); |
|
if (!DicPDJB_MJ.ContainsKey(oid)) |
|
{ |
|
DicPDJB_MJ.Add(oid, new List<PDJBModel>() { new PDJBModel() { PDJB = pdjb, MJ = area } }); |
|
} |
|
else |
|
{ |
|
List<PDJBModel> list = DicPDJB_MJ[oid]; |
|
PDJBModel pdjbMod = list.FirstOrDefault(f => f.PDJB == pdjb); |
|
if (pdjbMod == null) |
|
{ |
|
list.Add(new PDJBModel() { PDJB = pdjb, MJ = area }); |
|
} |
|
else |
|
{ |
|
pdjbMod.MJ += area; |
|
} |
|
DicPDJB_MJ[oid] = list; |
|
} |
|
if (!DicMJ.ContainsKey(oid)) |
|
{ |
|
DicMJ.Add(oid, area); |
|
DicPDJB.Add(oid, pdjb); |
|
} |
|
else if (DicMJ[oid] < area) |
|
{ |
|
DicMJ[oid] = area; |
|
DicPDJB[oid] = pdjb; |
|
} |
|
} |
|
|
|
cursor = BgTbLayer.FeatureClass.Update(new QueryFilter() { WhereClause = "DLBM like '01%' " }, false); |
|
int Objectid_GX = BgTbLayer.FeatureClass.FindField("objectid"); |
|
int BSM_GX = BgTbLayer.FeatureClass.FindField("BSM"); |
|
int GDPDJB_GX = BgTbLayer.FeatureClass.FindField("GDPDJB"); |
|
int GDLX_GX = BgTbLayer.FeatureClass.FindField("GDLX"); |
|
int idxKCXS = BgTbLayer.FeatureClass.FindField("KCXS"); |
|
int DLBM_GX = BgTbLayer.FeatureClass.FindField("DLBM"); |
|
int GDPDJBIndex = PDTLayer.FeatureClass.FindField("PDJB"); |
|
var count = BgTbLayer.FeatureClass.FeatureCount(new QueryFilter() { WhereClause = "DLBM like '01%' " }); |
|
var featurecount = 0; |
|
while ((feature = cursor.NextFeature()) != null) |
|
{ |
|
featurecount++; |
|
if (featurecount % 500 == 0) |
|
{ |
|
Console.WriteLine($"Msg:正在进行耕地坡度赋值...【{featurecount}/{count}】"); |
|
} |
|
if (feature.OID == 529) |
|
{ |
|
} |
|
string pdjb = string.Empty; |
|
if (!DicPDJB_MJ.ContainsKey(feature.OID)) |
|
{ |
|
continue; |
|
} |
|
double tempmj = feature.Value[feature.Fields.FindField("SHAPE_AREA")].ToDouble(0); |
|
if (tempmj == 850.0) |
|
{ |
|
} |
|
List<PDJBModel> list = DicPDJB_MJ[feature.OID]; |
|
list = list.OrderByDescending(o => o.MJ).ToList(); |
|
pdjb = list[0].PDJB;//[feature.OID]; |
|
feature.Value[GDPDJB_GX] = pdjb; |
|
string dlbm = feature.Value[DLBM_GX].ToString(); |
|
string bghbsm = feature.Value[BSM_GX].ToString(); |
|
string UpdateGCSql = string.Empty; |
|
string strGDLX = feature.Value[GDLX_GX].ToTrim(); |
|
if (pdjb == "1") |
|
{ |
|
strGDLX = ""; |
|
} |
|
else |
|
if (!string.IsNullOrWhiteSpace(dlbm) && "2,3,4,5".Contains(pdjb) && string.IsNullOrWhiteSpace(strGDLX)) |
|
{ |
|
string kcxsKey1 = string.Format("{0}-{1}", "TT", pdjb); |
|
double xs1 = 0; |
|
if (Parm.KCXSDic.ContainsKey(kcxsKey1)) |
|
{ |
|
xs1 = Parm.KCXSDic[kcxsKey1].ToDouble(); |
|
} |
|
string kcxsKey2 = string.Format("{0}-{1}", "PD", pdjb); |
|
double xs2 = 0; |
|
if (Parm.KCXSDic.ContainsKey(kcxsKey2)) |
|
{ |
|
xs2 = Parm.KCXSDic[kcxsKey2].ToDouble(); |
|
} |
|
if (xs1 == 0 && xs2 != 0) |
|
{ |
|
strGDLX = "PD"; |
|
} |
|
else if (xs1 != 0 && xs2 == 0) |
|
{ |
|
strGDLX = "TT"; |
|
} |
|
else |
|
{ |
|
if (dlbm == "0101") |
|
{ |
|
strGDLX = "TT"; |
|
} |
|
else if ("0102,0103".Contains(dlbm)) |
|
{ |
|
strGDLX = "PD"; |
|
} |
|
} |
|
} |
|
string kcxsKey = string.Format("{0}-{1}", strGDLX, pdjb); |
|
if (Parm.KCXSDic.ContainsKey(kcxsKey)) |
|
{ |
|
feature.Value[idxKCXS] = Parm.KCXSDic[kcxsKey].ToDouble(); |
|
} |
|
feature.Value[GDLX_GX] = strGDLX; |
|
cursor.UpdateFeature(feature); |
|
|
|
Marshal.ReleaseComObject(feature); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
Console.WriteLine("Warning:耕地坡度级别赋值异常:" + ex.Message); |
|
Console.WriteLine("Warning:耕地坡度级别赋值异常:" + ex); |
|
} |
|
finally |
|
{ |
|
//ProgressHelper.CloseProcessBar(); |
|
if (feature != null) |
|
Marshal.ReleaseComObject(feature); |
|
if (cursor != null) |
|
Marshal.ReleaseComObject(cursor); |
|
if (pFtWsFct != null) |
|
Marshal.ReleaseComObject(pFtWsFct); |
|
if (workspaceName != null) |
|
Marshal.ReleaseComObject(workspaceName); |
|
if (unionLayer != null) |
|
Marshal.ReleaseComObject(unionLayer); |
|
} |
|
} |
|
|
|
#region 获取最新图斑编号 |
|
private void GetMaxTBBH(IFeatureClass fc, ref Dictionary<string, int> result) |
|
{ |
|
ICursor cursor = (fc as ITable).Search(new QueryFilterClass() { SubFields = "ZLDWDM,TBBH" }, true); |
|
IRow row = null; |
|
int zlIndex = -1; |
|
int bhIndex = -1; |
|
while ((row = cursor.NextRow()) != null) |
|
{ |
|
if (zlIndex == -1) |
|
zlIndex = row.Fields.FindField("ZLDWDM"); |
|
if (bhIndex == -1) |
|
bhIndex = row.Fields.FindField("TBBH"); |
|
if (zlIndex != -1 && bhIndex != -1) |
|
{ |
|
string zl = row.Value[zlIndex].ToTrim(); |
|
zl = zl.Replace(zl.Substring(0, 6), Parm.PrjInfo.CODE); |
|
int tbbh = 0; |
|
int.TryParse(row.Value[bhIndex].ToString(), out tbbh); |
|
|
|
if (result.ContainsKey(zl)) |
|
{ |
|
if (result[zl] < tbbh) |
|
result[zl] = tbbh; |
|
} |
|
else |
|
{ |
|
result.Add(zl, tbbh); |
|
} |
|
} |
|
} |
|
} |
|
#endregion |
|
|
|
#region 获取最新标识码 |
|
public string GetNewBSM(List<IFeatureClass> fcList) |
|
{ |
|
string result = string.Empty; |
|
int xh = 0; |
|
string leftStr = string.Empty; |
|
foreach (var item in fcList) |
|
{ |
|
string MaxBSM = GetMaxBSM(item); |
|
if (MaxBSM.Length != 18) |
|
continue; |
|
int xh2 = Convert.ToInt32(MaxBSM.Substring(10)); |
|
leftStr = MaxBSM.Substring(0, 10); |
|
if (xh < xh2) |
|
xh = xh2; |
|
} |
|
xh++; |
|
if (string.IsNullOrWhiteSpace(leftStr)) |
|
leftStr = Parm.PrjInfo.CODE + "1210"; |
|
result = leftStr + xh.ToString().PadLeft(8, '0'); |
|
return result; |
|
} |
|
private static string GetMaxBSM(IFeatureClass fc) |
|
{ |
|
string BSM = string.Empty; |
|
int BSMIndex = fc.FindField("BSM"); |
|
if (BSMIndex == -1) return BSM; |
|
|
|
ITable table = (ITable)fc; |
|
// 创建一个ITableSort接口对象 |
|
ITableSort tableSort = new TableSortClass(); |
|
tableSort.Table = table; |
|
tableSort.Fields = "BSM"; |
|
tableSort.set_Ascending("BSM", false); |
|
tableSort.Sort(null); |
|
ICursor cursor = tableSort.Rows; |
|
IRow row = cursor.NextRow(); |
|
if (row != null) |
|
{ |
|
int maxBSM = 0; |
|
int currBSM = 0; |
|
string BSMStr = row.Value[BSMIndex].ToString(); |
|
if (BSMStr.Length != 18) return BSM; |
|
string subBSMStr = BSMStr.Substring(9); |
|
try |
|
{ |
|
currBSM = Convert.ToInt32(subBSMStr); |
|
} |
|
catch (Exception) |
|
{ |
|
return BSM; |
|
} |
|
if (currBSM > maxBSM) maxBSM = currBSM; |
|
|
|
if (BSMStr.Length != 18) return BSM; |
|
string maxStr = maxBSM.ToString(); |
|
int zeroNum = 9 - maxStr.Length; |
|
for (int i = 0; i < zeroNum; i++) |
|
{ |
|
maxStr = 0 + maxStr; |
|
} |
|
BSM = BSMStr.Substring(0, 9) + maxStr; |
|
} |
|
return BSM; |
|
} |
|
#endregion |
|
|
|
#region 面积平差 |
|
/// <summary> |
|
/// 面积平差 |
|
/// </summary> |
|
/// <param name="shpList">需要平差的对象集合</param> |
|
/// <param name="pKZMJ">控制面积</param> |
|
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); |
|
//平差 |
|
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(shpList.Sum(s => s.bgmj), 2) - pKZMJ; |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
//LogAPI.Debug("面积平差错误:" + ex.Message); |
|
throw ex; |
|
} |
|
} |
|
#endregion |
|
|
|
#region GXGCFcToFc |
|
public bool GXGCFcToFc(IFeatureClass FeatureClass, IFeatureClass pFc, IQueryFilter pFilter, bool pIsCut, DataTable data_BSM, Dictionary<int, double> GXGCvaluePairs) |
|
{ |
|
IFeatureCursor S_Cursor = null; |
|
IFeatureCursor T_Cursor = null; |
|
try |
|
{ |
|
if (FeatureClass == null || pFc == null) return false; |
|
//获取对应关系 |
|
Dictionary<int, int> dicField = new Dictionary<int, int>(); |
|
Dictionary<int, int> dicField1 = new Dictionary<int, int>(); |
|
for (int i = 0; i < pFc.Fields.FieldCount; i++) |
|
{ |
|
//IField field = pFc.Fields.Field[i]; |
|
//if (field.Name == pFc.ShapeFieldName || field.Name.Contains(pFc.ShapeFieldName) || field.Name == pFc.OIDFieldName || !field.Editable) continue; |
|
//int index = -1; |
|
//if (field.Name.Contains("BGQ")) |
|
//{ |
|
// index = FeatureClass.Fields.FindField($"{field.Name.Replace("BGQTB", "")}_1"); |
|
// if (index == -1) |
|
// index = FeatureClass.Fields.FindField($"{field.Name.Replace("BGQ", "")}_1"); |
|
// if (index == -1) |
|
// index = FeatureClass.Fields.FindField($"{field.Name.Replace("BGQ", "")}"); |
|
//} |
|
//else |
|
//if (field.Name.Contains("BGH")) |
|
//{ |
|
// index = FeatureClass.Fields.FindField(field.Name.Replace("BGHTB", "")); |
|
// if (index == -1) |
|
// index = FeatureClass.Fields.FindField(field.Name.Replace("BGH", "")); |
|
//} |
|
//else |
|
//if (field.Name == "BGHTBBSM" || field.Name == "BGQTBBSM") |
|
//{ |
|
// index = FeatureClass.Fields.FindField($"BSM"); |
|
//} |
|
//if (index == -1) continue; |
|
//dicField.Add(i, index); |
|
//index = FeatureClass.Fields.FindField($"{field.Name.Replace("BGQTB", "").Replace("BGHTB", "")}_1"); |
|
//if (index == -1) |
|
// index = FeatureClass.Fields.FindField($"{field.Name.Replace("BGQ", "").Replace("BGH", "")}_1"); |
|
//if (field.Name == "BGHTBBSM" || field.Name == "BGQTBBSM") |
|
//{ |
|
// index = FeatureClass.Fields.FindField($"BSM"); |
|
//} |
|
//if (index == -1) continue; |
|
//dicField1.Add(i, index); |
|
|
|
IField field = pFc.Fields.Field[i]; |
|
if (field.Name == pFc.ShapeFieldName || field.Name.Contains(pFc.ShapeFieldName) || field.Name == pFc.OIDFieldName || !field.Editable) continue; |
|
int index = -1; |
|
if (field.Name.Contains("BGQ")) |
|
{ |
|
string fieldName = field.Name.Replace("BGQTB", "").Replace("BGQ", ""); |
|
if ("BGQTBBH,BGQTBMJ,BGQTBXHDM,BGQTBXHMC,BGQTBDLMJ".Contains(field.Name)) |
|
fieldName = field.Name.Replace("BGQ", ""); |
|
index = FeatureClass.Fields.FindField($"{fieldName}_1"); |
|
if (index == -1) |
|
index = FeatureClass.Fields.FindField(fieldName); |
|
} |
|
else |
|
if (field.Name.Contains("BGH")) |
|
{ |
|
string fieldName = field.Name.Replace("BGHTB", "").Replace("BGH", ""); |
|
if ("BGHTBBH,BGHTBMJ,BGHTBXHDM,BGHTBXHMC,BGHTBDLMJ".Contains(field.Name)) |
|
fieldName = field.Name.Replace("BGH", ""); |
|
index = FeatureClass.Fields.FindField(fieldName); |
|
} |
|
if (index == -1) continue; |
|
dicField.Add(i, index); |
|
string fName = field.Name.Replace("BGQTB", "").Replace("BGHTB", "").Replace("BGQ", "").Replace("BGH", ""); |
|
index = FeatureClass.Fields.FindField($"{fName}_1"); |
|
|
|
if ("BGQTBBH,BGQTBMJ,BGQTBXHDM,BGQTBXHMC,BGQTBDLMJ,BGHTBBH,BGHTBMJ,BGHTBXHDM,BGHTBXHMC,BGHTBDLMJ".Contains(field.Name)) |
|
fName = field.Name.Replace("BGH", "").Replace("BGQ", ""); |
|
index = FeatureClass.Fields.FindField($"{fName}_1"); |
|
if (index == -1) |
|
index = FeatureClass.Fields.FindField(fName); |
|
if (index == -1) continue; |
|
dicField1.Add(i, index); |
|
} |
|
(pFc as ITable).DeleteSearchedRows(null); |
|
string s = (pFc as FeatureClass).Workspace.PathName; |
|
IFeatureClassLoad pFclsLoad = pFc as IFeatureClassLoad; |
|
if (pFclsLoad != null) |
|
pFclsLoad.LoadOnlyMode = true; |
|
//此处写编辑的代码 |
|
S_Cursor = FeatureClass.Search(pFilter, true); |
|
IFeature f = null; |
|
T_Cursor = pFc.Insert(true); |
|
IFeatureBuffer buffer = pFc.CreateFeatureBuffer(); |
|
var iFID_DLTBBG = FeatureClass.FindField("FID_DLTBBG"); |
|
var iFID_DLTB = FeatureClass.FindField("FID_DLTB"); |
|
var ibgxw = pFc.FindField("BGXW"); |
|
var itbbgmj = pFc.FindField("TBBGMJ"); |
|
var ibgqkcxs = pFc.FindField("BGQKCXS"); |
|
var ibgqkcmj = pFc.FindField("BGQKCMJ"); |
|
var ibgqtbdlmj = pFc.FindField("BGQTBDLMJ"); |
|
var ibghkcxs = pFc.FindField("BGHKCXS"); |
|
var ibghkcmj = pFc.FindField("BGHKCMJ"); |
|
var ibghtbdlmj = pFc.FindField("BGHTBDLMJ"); |
|
var ibsm = pFc.FindField("BSM"); |
|
var igxsj = pFc.FindField("GXSJ"); |
|
var idxBGHTBBH = pFc.FindField("BGHTBBH"); |
|
var idxJCTBBH = FeatureClass.FindField("TBBH_1"); |
|
if (idxJCTBBH == -1) |
|
idxJCTBBH = FeatureClass.FindField("TBBH"); |
|
var tbbgmj = 0.00; |
|
int bsm = 1; |
|
while ((f = S_Cursor.NextFeature()) != null) |
|
{ |
|
|
|
if (GXGCvaluePairs.ContainsKey(f.OID)) |
|
{ |
|
tbbgmj = GXGCvaluePairs[f.OID]; |
|
if (tbbgmj == 0) continue; |
|
} |
|
var FID_DLTBBG = f.Value[iFID_DLTBBG].ToString(); |
|
var FID_DLTB = f.Value[iFID_DLTB].ToString(); |
|
var row = data_BSM.Select($"FID_DLTBBG={FID_DLTBBG} and FID_DLTB={FID_DLTB} "); |
|
if (row == null || row.Length == 0) continue; |
|
buffer.Shape = f.ShapeCopy; |
|
if (pFilter is ISpatialFilter && pIsCut) |
|
{ |
|
if (FeatureAPI.IsInterSect((pFilter as ISpatialFilter).Geometry, f.ShapeCopy)) |
|
{ |
|
buffer.Shape = FeatureAPI.InterSect(f.ShapeCopy, (pFilter as SpatialFilterClass).Geometry); |
|
} |
|
else |
|
{ |
|
continue; |
|
} |
|
} |
|
if (FID_DLTBBG == "-1") |
|
{ |
|
foreach (int item in dicField1.Keys)//被动变更的图斑 变更前后属性相同 |
|
{ |
|
try |
|
{ |
|
if (f.Value[dicField1[item]].ToString().Contains(" ") || f.Value[dicField1[item]] is DBNull) |
|
{ |
|
buffer.Value[item] = f.Value[dicField1[item]].ToTrim(); |
|
} |
|
else |
|
{ |
|
buffer.Value[item] = f.Value[dicField1[item]]; |
|
} |
|
} |
|
catch |
|
{ |
|
buffer.Value[item] = f.Value[dicField1[item]]; |
|
} |
|
} |
|
} |
|
else |
|
{ |
|
foreach (int item in dicField.Keys) |
|
{ |
|
try |
|
{ |
|
buffer.Value[item] = f.Value[dicField[item]]; |
|
} |
|
catch |
|
{ |
|
buffer.Value[item] = f.Value[dicField[item]]; |
|
} |
|
} |
|
} |
|
if (idxJCTBBH != -1) |
|
buffer.Value[idxBGHTBBH] = f.Value[idxJCTBBH]; |
|
buffer.Value[ibgxw] = row[0]["BGXW"]; |
|
if (GXGCvaluePairs.ContainsKey(f.OID)) |
|
tbbgmj = GXGCvaluePairs[f.OID]; |
|
else |
|
tbbgmj = row[0]["TBMJ_1"].ToDouble(); |
|
buffer.Value[itbbgmj] = Math.Round(tbbgmj, 2);//图斑变更面积 |
|
var bgqkcmj = Math.Round((decimal)(buffer.Value[ibgqkcxs].ToDouble() * tbbgmj), 2, MidpointRounding.AwayFromZero).ToDouble();//变更前扣除面积 |
|
buffer.Value[ibgqkcmj] = bgqkcmj; |
|
buffer.Value[ibgqtbdlmj] = tbbgmj - bgqkcmj;//变更前图斑地类面积 |
|
var bghkcmj = Math.Round((decimal)(buffer.Value[ibghkcxs].ToDouble() * tbbgmj), 2, MidpointRounding.AwayFromZero).ToDouble();//变更后扣除面积 |
|
buffer.Value[ibghkcmj] = bghkcmj; |
|
buffer.Value[ibghtbdlmj] = tbbgmj - bghkcmj;//变更后图斑地类面积 |
|
buffer.Value[ibsm] = $"{Parm.PrjInfo.CODE}2111{(bsm++).ToString().PadLeft(8, '0')}"; |
|
buffer.Value[igxsj] = DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31); |
|
T_Cursor.InsertFeature(buffer); |
|
} |
|
T_Cursor.Flush(); |
|
if (pFclsLoad != null) |
|
pFclsLoad.LoadOnlyMode = false; |
|
return true; |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw ex; |
|
} |
|
} |
|
#endregion |
|
|
|
#region GXFcToFc |
|
public bool GXFcToFc(IFeatureClass FeatureClass, IFeatureClass pFc, IQueryFilter pFilter) |
|
{ |
|
IFeatureCursor S_Cursor = null; |
|
IFeatureCursor T_Cursor = null; |
|
try |
|
{ |
|
if (FeatureClass == null || pFc == null) return false; |
|
Dictionary<int, int> dicField = new Dictionary<int, int>(); |
|
int index = -1; |
|
for (int i = 0; i < pFc.Fields.FieldCount; i++) |
|
{ |
|
IField field = pFc.Fields.Field[i]; |
|
if (field.Name == pFc.ShapeFieldName || field.Name.Contains(pFc.ShapeFieldName) || field.Name == pFc.OIDFieldName || !field.Editable) continue; |
|
index = FeatureClass.Fields.FindField($"BGH{field.Name}"); |
|
if (index == -1) |
|
index = FeatureClass.Fields.FindField($"BGHTB{field.Name}"); |
|
if (index == -1) |
|
index = FeatureClass.Fields.FindField(field.Name); |
|
if (index == -1) continue; |
|
dicField.Add(i, index); |
|
} |
|
IFeatureClassLoad pFclsLoad = pFc as IFeatureClassLoad; |
|
if (pFclsLoad != null) |
|
pFclsLoad.LoadOnlyMode = true; |
|
//此处写编辑的代码 |
|
S_Cursor = FeatureClass.Search(pFilter, true); |
|
IFeature f = null; |
|
T_Cursor = pFc.Insert(true); |
|
IFeatureBuffer buffer = pFc.CreateFeatureBuffer(); |
|
while ((f = S_Cursor.NextFeature()) != null) |
|
{ |
|
buffer.Shape = f.ShapeCopy; |
|
foreach (int item in dicField.Keys) |
|
{ |
|
buffer.Value[item] = f.Value[dicField[item]]; |
|
} |
|
T_Cursor.InsertFeature(buffer); |
|
} |
|
T_Cursor.Flush(); |
|
if (pFclsLoad != null) |
|
pFclsLoad.LoadOnlyMode = false; |
|
return true; |
|
} |
|
catch (Exception) |
|
{ |
|
throw; |
|
} |
|
} |
|
#endregion |
|
|
|
#region FcToFc |
|
public bool FcToFc(IFeatureClass FeatureClass, IFeatureClass pFc, IQueryFilter pFilter) |
|
{ |
|
IFeatureCursor S_Cursor = null; |
|
IFeatureCursor T_Cursor = null; |
|
try |
|
{ |
|
if (FeatureClass == null || pFc == null) return false; |
|
Dictionary<int, int> dicField = new Dictionary<int, int>(); |
|
int index = -1; |
|
for (int i = 0; i < pFc.Fields.FieldCount; i++) |
|
{ |
|
IField field = pFc.Fields.Field[i]; |
|
if (field.Name == pFc.ShapeFieldName || field.Name.Contains(pFc.ShapeFieldName) || field.Name == pFc.OIDFieldName || !field.Editable) continue; |
|
index = FeatureClass.Fields.FindField($"{field.Name}"); |
|
if (index == -1) |
|
continue; |
|
dicField.Add(i, index); |
|
} |
|
IFeatureClassLoad pFclsLoad = pFc as IFeatureClassLoad; |
|
if (pFclsLoad != null) |
|
pFclsLoad.LoadOnlyMode = true; |
|
//此处写编辑的代码 |
|
S_Cursor = FeatureClass.Search(pFilter, true); |
|
IFeature f = null; |
|
IFeatureBuffer buffer = pFc.CreateFeatureBuffer(); |
|
T_Cursor = pFc.Insert(true); |
|
while ((f = S_Cursor.NextFeature()) != null) |
|
{ |
|
buffer.Shape = f.ShapeCopy; |
|
foreach (int item in dicField.Keys) |
|
{ |
|
buffer.Value[item] = f.Value[dicField[item]]; |
|
} |
|
T_Cursor.InsertFeature(buffer); |
|
} |
|
T_Cursor.Flush(); |
|
if (pFclsLoad != null) |
|
pFclsLoad.LoadOnlyMode = false; |
|
return true; |
|
} |
|
catch (Exception) |
|
{ |
|
throw; |
|
} |
|
} |
|
#endregion |
|
|
|
#region TableToTable |
|
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; |
|
} |
|
} |
|
|
|
#endregion |
|
} |
|
public class Adjustment |
|
{ |
|
public int ID { get; set; } |
|
public double bgmj { get; set; } |
|
} |
|
public class PDJBModel |
|
{ |
|
public string PDJB { get; set; } |
|
public double MJ { get; set; } |
|
} |
|
|
|
}
|
|
|