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.
3089 lines
130 KiB
3089 lines
130 KiB
using ESRI.ArcGIS.ADF; |
|
using ESRI.ArcGIS.Carto; |
|
using ESRI.ArcGIS.DataSourcesGDB; |
|
using ESRI.ArcGIS.Geodatabase; |
|
using ESRI.ArcGIS.Geometry; |
|
using KGIS.Framework.AE; |
|
using KGIS.Framework.AE.Enum; |
|
using KGIS.Framework.AE.GPHelper; |
|
using KGIS.Framework.AE.ExtensionMethod; |
|
using KGIS.Framework.DBOperator; |
|
using KGIS.Framework.Maps; |
|
using KGIS.Framework.Utils; |
|
using KGIS.Framework.Utils.ExtensionMethod; |
|
using Kingo.PluginServiceInterface; |
|
using System; |
|
using System.Collections.Generic; |
|
using System.Data; |
|
using System.IO; |
|
using System.Linq; |
|
using System.Runtime.InteropServices; |
|
using System.Text.RegularExpressions; |
|
using System.Threading; |
|
|
|
namespace Kingo.Plugin.DLTB_IDG |
|
{ |
|
public class ThreadParam |
|
{ |
|
public ManualResetEvent mrEvent; |
|
public int[] Data; |
|
public string DataPath; |
|
public string XZQDM; |
|
} |
|
public class DLTBBGHelper |
|
{ |
|
private string MaxBSM { get; set; } |
|
|
|
private Dictionary<string, int> jc_FieldsIndex; |
|
private Dictionary<string, int> gx_FieldsIndex; |
|
private Dictionary<string, int> gxgc_FieldsIndex; |
|
private static readonly object objLock = new object(); |
|
|
|
public Action<string, object> ExeState; |
|
public Dictionary<string, int> TempBSMDic = new Dictionary<string, int>(); |
|
public Dictionary<string, int> TempTBBHDic = new Dictionary<string, int>(); |
|
|
|
private IFeatureLayer _CZC203Layer = null; |
|
private IFeatureLayer _CZC20XLayer = null; |
|
|
|
/// <summary> |
|
/// 基础地类图斑层 |
|
/// </summary> |
|
private IFeatureLayer jcdltb_Layer = null; |
|
/// <summary> |
|
/// 部分图斑变更 |
|
/// </summary> |
|
public DLTBBGHelper() |
|
{ |
|
jcdltb_Layer = MapsManager.Instance.MapService.GetFeatureLayerByName("DLTB"); |
|
IFeatureLayer czcjLayer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("城镇村等用地"); |
|
//_CZC20XLayer = GeoDBAPI.CreateFeatureLayerInmemeory("CZC20X", "城镇村20X范围", (czcjLayer.FeatureClass as IGeoDataset).SpatialReference, czcjLayer.FeatureClass.ShapeType, czcjLayer.FeatureClass.Fields); |
|
//_CZC203Layer = GeoDBAPI.CreateFeatureLayerInmemeory("CZC203", "城镇村203范围", (czcjLayer.FeatureClass as IGeoDataset).SpatialReference, czcjLayer.FeatureClass.ShapeType, czcjLayer.FeatureClass.Fields); |
|
//InsertDataToMemeoryLayer(czcjLayer.FeatureClass); |
|
} |
|
|
|
private void InsertDataToMemeoryLayer(IFeatureClass pSource) |
|
{ |
|
try |
|
{ |
|
if (pSource == null || (_CZC203Layer == null && _CZC20XLayer == null)) return; |
|
IFeatureClassAPI fcAPI = new FeatureClassAPI(pSource); |
|
IQueryFilter filter = new QueryFilterClass |
|
{ |
|
WhereClause = " CZCLX = '203'" |
|
}; |
|
if (_CZC203Layer != null && _CZC203Layer.FeatureClass != null) |
|
fcAPI.FcToFc(_CZC203Layer.FeatureClass, null, false); |
|
filter.WhereClause = " CZCLX <> '203'"; |
|
if (_CZC20XLayer != null && _CZC20XLayer.FeatureClass != null) |
|
fcAPI.FcToFc(_CZC20XLayer.FeatureClass, null, false); |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("获取城镇村范围数据失败:"); |
|
LogAPI.Debug(ex); |
|
} |
|
} |
|
|
|
public void DelectDir(string srcPath) |
|
{ |
|
try |
|
{ |
|
DirectoryInfo dir = new DirectoryInfo(srcPath); |
|
FileSystemInfo[] fileinfo = dir.GetFileSystemInfos(); //返回目录中所有文件和子目录 |
|
foreach (FileSystemInfo i in fileinfo) |
|
{ |
|
if (i is DirectoryInfo) //判断是否文件夹 |
|
{ |
|
DirectoryInfo subdir = new DirectoryInfo(i.FullName); |
|
subdir.Delete(true); //删除子目录和文件 |
|
} |
|
else |
|
{ |
|
File.Delete(i.FullName); //删除指定文件 |
|
} |
|
} |
|
} |
|
catch (Exception e) |
|
{ |
|
throw; |
|
} |
|
} |
|
|
|
List<IFeatureClass> GetBSMFcList = null; |
|
public void SingleThreadExe(object obj) |
|
{ |
|
IFeatureClass bg_Fc = null; |
|
IFeatureLayer bg_FL = null; |
|
/// <summary> |
|
/// 临时基础地类图斑层 |
|
/// </summary> |
|
IFeatureLayer XZQTZQJCTB_FL = null; |
|
/// <summary> |
|
/// 地类图斑更新层 |
|
/// </summary> |
|
IFeatureLayer gx_Layer = null; |
|
/// <summary> |
|
/// 地类图斑更新过程层 |
|
/// </summary> |
|
IFeatureLayer gxgc_Layer = null; |
|
ThreadParam param = (ThreadParam)obj; |
|
ITable table = null; |
|
try |
|
{ |
|
if (Directory.Exists(param.DataPath)) |
|
{ |
|
using (ComReleaser comRelease = new ComReleaser()) |
|
{ |
|
bg_Fc = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBBG"); |
|
bg_FL = MapsManager.Instance.MapService.GetFeatureLayerByName("DLTBBG"); |
|
XZQTZQJCTB_FL = MapsManager.Instance.MapService.GetFeatureLayerByName("XZQTZQJCTB"); |
|
gx_Layer = MapsManager.Instance.MapService.GetFeatureLayerByName("DLTBGX"); |
|
gxgc_Layer = MapsManager.Instance.MapService.GetFeatureLayerByName("DLTBGXGC"); |
|
if (GetBSMFcList == null) |
|
{ |
|
GetBSMFcList = new List<IFeatureClass> |
|
{ |
|
jcdltb_Layer.FeatureClass, |
|
gx_Layer.FeatureClass |
|
}; |
|
} |
|
if (string.IsNullOrWhiteSpace(MaxBSM)) |
|
{ |
|
MaxBSM = GetMaxBSM(GetBSMFcList); |
|
} |
|
|
|
#region 创建临时GDB,存储基础地类图斑数据 |
|
string gdbFolder = Directory.GetCurrentDirectory() + "\\Temp\\GXGC"; |
|
if (!Directory.Exists(gdbFolder)) |
|
{ |
|
Directory.CreateDirectory(gdbFolder); |
|
} |
|
try |
|
{ |
|
DelectDir(gdbFolder);//能删除就删除 删除报错不处理 |
|
} |
|
catch |
|
{ } |
|
IWorkspaceFactory pFtWsFct = null; |
|
IWorkspaceName workspaceName = null; |
|
pFtWsFct = new FileGDBWorkspaceFactory(); |
|
|
|
string gdbFileName = Guid.NewGuid().ToString() + ".gdb"; |
|
string path = System.IO.Path.Combine(gdbFolder, gdbFileName); |
|
//~\\Apps\\Temp\\GXGC 临时模板 |
|
workspaceName = pFtWsFct.Create(gdbFolder, gdbFileName, null, 0); |
|
|
|
IFeatureLayer pjbntFeatureLayer = null; |
|
//基础地类图斑临时对象 |
|
//IFeatureLayer TempJC_DLTB_FL = null; |
|
|
|
//设置基础地类图斑选中(加上容差,执行失败) |
|
GPParamClass gPParamClass = new GPParamClass |
|
{ |
|
FirstFeatureLayer = jcdltb_Layer, |
|
SecondFeatureLayer = bg_FL, |
|
GPType = EnumGPType.Intersect |
|
}; |
|
GeoprocessorHelper.SelectLayerByLocationAnalysis(gPParamClass, ref pjbntFeatureLayer); |
|
|
|
//gPParamClass = new GPParamClass |
|
//{ |
|
// FirstFeatureLayer = jcdltb_Layer, |
|
// OutFeatureClassPath = path, |
|
// IsGetOutPutFeature = true |
|
//}; |
|
//GeoprocessorHelper.FeatureClassToFeatureClass(gPParamClass, "JC_DLTB_Temp", ref TempJC_DLTB_FL); |
|
|
|
IFeatureSelection selection = jcdltb_Layer as IFeatureSelection; |
|
selection.Clear(); |
|
#endregion |
|
|
|
IQueryFilter filter = new QueryFilter |
|
{ |
|
WhereClause = $" ZLDWDM not like '{param.XZQDM}%' " |
|
}; |
|
table = gx_Layer.FeatureClass as ITable; |
|
table.DeleteSearchedRows(filter); |
|
filter.WhereClause = $" BGHZLDWDM not like '{param.XZQDM}%' "; |
|
table = gxgc_Layer.FeatureClass as ITable; |
|
table.DeleteSearchedRows(filter); |
|
|
|
if (jc_FieldsIndex == null || jc_FieldsIndex.Count == 0) |
|
jc_FieldsIndex = GetFieldsIndex(jcdltb_Layer.FeatureClass.Fields); |
|
|
|
if (gx_FieldsIndex == null || gx_FieldsIndex.Count == 0) |
|
gx_FieldsIndex = GetFieldsIndex(gx_Layer.FeatureClass.Fields); |
|
|
|
if (gxgc_FieldsIndex == null || gxgc_FieldsIndex.Count == 0) |
|
gxgc_FieldsIndex = GetFieldsIndex(gxgc_Layer.FeatureClass.Fields); |
|
int bgztIndex = bg_Fc.FindField("BGZT"); |
|
// 遍历变更表 |
|
foreach (int oid in param.Data) |
|
{ |
|
IFeature f = null; |
|
try |
|
{ |
|
f = bg_Fc.GetFeature(oid); |
|
} |
|
catch (Exception) |
|
{ |
|
continue; |
|
} |
|
if (f == null) continue; |
|
if (bgztIndex != -1) |
|
{ |
|
if (f.Value[bgztIndex].ToTrim() == "已变更2成功") |
|
{ |
|
Marshal.ReleaseComObject(f); |
|
continue; |
|
} |
|
} |
|
var JCJG_index = f.Fields.FindField("JCZT"); |
|
bool isContinue = false; |
|
List<IFeature> jcFeatures = FeatureAPI.Identify2(f.ShapeCopy, jcdltb_Layer); |
|
//List<IFeature> jcFeatures2 = FeatureAPI.Identify2(f.ShapeCopy, TempJC_DLTB_FL);//GP 基础地类图斑 |
|
if (jcFeatures.Count == 1) |
|
{ |
|
if (FeatureAPI.IsContains(jcFeatures[0].ShapeCopy, f.ShapeCopy) || FeatureAPI.GetEqual(jcFeatures[0].ShapeCopy, f.ShapeCopy)) |
|
{ |
|
DLTBGXAttribute gx1 = new DLTBGXAttribute(gx_FieldsIndex); |
|
gx1.SetAttribure(jcFeatures[0], jc_FieldsIndex); |
|
DLTBGXAttribute gx2 = new DLTBGXAttribute(gx_FieldsIndex); |
|
gx2.SetAttribure(f); |
|
if (gx1.IsEqual(gx2)) |
|
{ |
|
f.Value[bgztIndex] = "变更失败"; |
|
if (JCJG_index != -1) |
|
f.Value[JCJG_index] = "变更图斑与基础图斑属性相同,且变更范围未超出基础图斑范围"; |
|
f.Store(); |
|
Marshal.ReleaseComObject(f); |
|
continue; |
|
} |
|
} |
|
IGeometry Difference = FeatureAPI.Difference(jcFeatures[0].ShapeCopy, f.ShapeCopy); |
|
if (!Difference.IsEmpty) |
|
{ |
|
IArea area = Difference as IArea; |
|
if (area.Area < 0.01) |
|
{ |
|
f.Value[bgztIndex] = "变更失败"; |
|
if (JCJG_index != -1) |
|
f.Value[JCJG_index] = "变更图斑与基础图斑压盖面积存在小于0.1平方米的图形"; |
|
f.Store(); |
|
isContinue = true; |
|
} |
|
} |
|
} |
|
else |
|
{ |
|
bool bg = false; |
|
foreach (var item in jcFeatures) |
|
{ |
|
if (param.XZQDM.Length == 9) |
|
{ |
|
var bgindex = f.Fields.FindField("ZLDWDM"); |
|
var jcindex = item.Fields.FindField("ZLDWDM"); |
|
if (f.Value[bgindex].ToTrim() != item.Value[jcindex].ToTrim()) |
|
{ |
|
bg = true; |
|
break; |
|
} |
|
} |
|
//变更数据相交压盖到基础数据 |
|
IGeometry Difference = null; |
|
IGeometry geo = FeatureAPI.InterSect(item.ShapeCopy, f.ShapeCopy); |
|
if (geo.IsEmpty) |
|
Difference = FeatureAPI.Difference(item.ShapeCopy, f.ShapeCopy); |
|
if (!geo.IsEmpty || !Difference.IsEmpty) |
|
{ |
|
IArea area = geo.IsEmpty == false ? (geo as IArea) : (Difference as IArea); |
|
if (area.Area < 0.01) |
|
{ |
|
if (JCJG_index != -1) |
|
f.Value[JCJG_index] = "变更图斑与基础图斑压盖面积存在小于0.1平方米的图形"; |
|
f.Store(); |
|
isContinue = true; |
|
break; |
|
} |
|
} |
|
if (Difference != null) |
|
Marshal.ReleaseComObject(Difference); |
|
Marshal.ReleaseComObject(geo); |
|
} |
|
if (bg) |
|
{ |
|
f.Value[bgztIndex] = "变更失败"; |
|
if (JCJG_index != -1) |
|
f.Value[JCJG_index] = "变更图斑范围跨越多个村级调查区,可能导致变更结果有误,该数据需单独变更"; |
|
f.Store(); |
|
//ExeState?.Invoke("变更失败", $"重新变更{oid}"); |
|
Marshal.ReleaseComObject(f); |
|
continue; |
|
} |
|
} |
|
if (isContinue) |
|
{ |
|
f.Value[bgztIndex] = "已变更(失败)"; |
|
f.Store(); |
|
continue; |
|
} |
|
if (ExeBgDataGeneration(f, jcdltb_Layer, XZQTZQJCTB_FL, gx_Layer, gxgc_Layer, param.XZQDM)) |
|
{ |
|
bgztIndex = f.Fields.FindField("BGZT"); |
|
if (bgztIndex != -1) |
|
{ |
|
f.Value[bgztIndex] = "已变更(成功)"; |
|
f.Store(); |
|
} |
|
} |
|
else |
|
{ |
|
f.Value[bgztIndex] = "已变更(失败)"; |
|
f.Store(); |
|
} |
|
} |
|
//Marshal.ReleaseComObject(pjbntFeatureLayer);--测试~,暂时注释 |
|
//Marshal.ReleaseComObject(pJC_DLTB_FL); |
|
//Marshal.ReleaseComObject(selection); |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug(ex.Message); |
|
} |
|
finally |
|
{ |
|
if (gx_Layer != null) |
|
Marshal.ReleaseComObject(gx_Layer); |
|
if (gxgc_Layer != null) |
|
Marshal.ReleaseComObject(gxgc_Layer); |
|
if (bg_Fc != null) |
|
Marshal.ReleaseComObject(bg_Fc); |
|
} |
|
} |
|
List<DLTBGXAttribute> gxDataList = null; |
|
|
|
/// <summary> |
|
/// 地类图斑变更-增量数据生成 |
|
/// </summary> |
|
/// <param name="pBGFeature">变更图斑</param> |
|
/// <param name="pJC_Layer">基础地类图斑</param> |
|
/// <param name="pJC_Layer2">行政区调整前基础图斑</param> |
|
/// <param name="pGX_Layer"></param> |
|
/// <param name="pGXGC_Layer"></param> |
|
/// <param name="pTempBSMPrefix">临时BSM前缀</param> |
|
/// <returns></returns> |
|
public bool ExeBgDataGeneration(IFeature pBGFeature, IFeatureLayer pJC_Layer, IFeatureLayer pJC_Layer2, IFeatureLayer pGX_Layer, IFeatureLayer pGXGC_Layer, string pTempBSMPrefix) |
|
{ |
|
bool result = false; |
|
try |
|
{ |
|
#region 获取字段下标 |
|
if (jc_FieldsIndex == null || jc_FieldsIndex.Count == 0) |
|
jc_FieldsIndex = GetFieldsIndex(pJC_Layer.FeatureClass.Fields); |
|
|
|
if (gx_FieldsIndex == null || gx_FieldsIndex.Count == 0) |
|
gx_FieldsIndex = GetFieldsIndex(pGX_Layer.FeatureClass.Fields); |
|
|
|
if (gxgc_FieldsIndex == null || gxgc_FieldsIndex.Count == 0) |
|
gxgc_FieldsIndex = GetFieldsIndex(pGXGC_Layer.FeatureClass.Fields); |
|
#endregion |
|
|
|
gxDataList = new List<DLTBGXAttribute>(); |
|
int idx = pBGFeature.Fields.FindField("XZQTZLX"); |
|
if (idx != -1) |
|
{ |
|
if (pBGFeature.Value[idx].ToTrim() == "1")//行政区调入图斑数据 |
|
{ |
|
gxDataList = GetGXGCData2(pBGFeature, pJC_Layer2, pGXGC_Layer, pGX_Layer); |
|
} |
|
else |
|
{ |
|
gxDataList = GetGXGCData2(pBGFeature, pJC_Layer, pGXGC_Layer, pGX_Layer); |
|
} |
|
} |
|
else |
|
{ |
|
gxDataList = GetGXGCData2(pBGFeature, pJC_Layer, pGXGC_Layer, pGX_Layer); |
|
} |
|
foreach (var item in gxDataList) |
|
{ |
|
if (item.GCDataList.Count == 1 && string.IsNullOrWhiteSpace(item.GCDataList[0].XZQTZLX)) |
|
item.GCDataList[0].SetXZQTZLX(); |
|
if (item.GCDataList.Count == 1 && item.GCDataList[0].BGXW == "1" && item.GCDataList[0].XZQTZLX == "0") |
|
{ |
|
continue; |
|
} |
|
if (item.GCDataList.Count == 1 && item.GCDataList[0].BGXW == "2") |
|
item.BSM = ""; |
|
if (!item.IsUpdate) |
|
item.BSM = ""; |
|
} |
|
#region 标记是否更新图斑编号 |
|
int ds_index = pBGFeature.Fields.FindField("DataSource"); |
|
bool isUpdateTBBH = false; |
|
if (ds_index != -1) |
|
{ |
|
object obj = pBGFeature.Value[ds_index]; |
|
if (!(obj is DBNull)) |
|
{ |
|
isUpdateTBBH = true; |
|
} |
|
} |
|
#endregion |
|
try |
|
{ |
|
foreach (var item in gxDataList) |
|
{ |
|
item.TempBSMPrefix = pTempBSMPrefix; |
|
if (item.BGTBOID == null) |
|
item.BGTBOID = pBGFeature.OID.ToString(); |
|
if (!item.BGTBOID.Contains(pBGFeature.OID.ToString())) |
|
{ |
|
item.BGTBOID += "," + pBGFeature.OID.ToString(); |
|
item.BGTBOID = item.BGTBOID.Trim(','); |
|
} |
|
foreach (var gc in item.GCDataList) |
|
{ |
|
item.BGTBOID += "," + gc.BGTBOID; |
|
} |
|
item.BGTBOID = String.Join(",", item.BGTBOID.Split(',').Distinct()); |
|
//(非更新 变更行为为2)| 更新图斑编号 | 更新数据的图斑编号为空 | 过程层数据变更前坐落代码与更新层坐落代码不一致 |
|
if ((!item.IsUpdate && item.GCDataList.FirstOrDefault(f => f.BGXW == "2") != null) || isUpdateTBBH || string.IsNullOrWhiteSpace(item.TBBH) || (item.GCDataList.FirstOrDefault(f => f.FieldsValue["BGQZLDWDM"].ToTrim() != item.FieldsValue["ZLDWDM"].ToTrim()) != null)) |
|
{ |
|
if (TempTBBHDic.Keys.Contains(item.FieldsValue["ZLDWDM"].ToTrim())) |
|
{ |
|
TempTBBHDic[item.FieldsValue["ZLDWDM"].ToTrim()]++; |
|
} |
|
else |
|
{ |
|
int maxTBBH = GetNewTBBH(new List<IFeatureClass>() { pJC_Layer.FeatureClass, pGX_Layer.FeatureClass }, item.FieldsValue["ZLDWDM"].ToTrim()); |
|
TempTBBHDic.Add(item.FieldsValue["ZLDWDM"].ToTrim(), maxTBBH); |
|
} |
|
item.TBBH = TempTBBHDic[item.FieldsValue["ZLDWDM"].ToTrim()].ToString(); |
|
if (isUpdateTBBH) |
|
{ |
|
item.GCDataList.ForEach(f => { f.BGHTBBH = item.TBBH; }); |
|
} |
|
if ((item.GCDataList.FirstOrDefault(f => f.FieldsValue["BGQZLDWDM"].ToTrim() != item.FieldsValue["ZLDWDM"].ToTrim()) != null)) |
|
{ |
|
item.GCDataList.ForEach(f => { f.BGHTBBH = item.TBBH; }); |
|
isUpdateTBBH = true; |
|
} |
|
} |
|
InsertGXFeature(item, pGX_Layer, isUpdateTBBH); |
|
} |
|
foreach (var gx in gxDataList) |
|
{ |
|
foreach (var gxgc in gx.GCDataList) |
|
{ |
|
gxgc.SetXZQTZLX(); |
|
gxgc.BGTBOID = gx.BGTBOID; |
|
string UnEqualAttr = string.Empty; |
|
int oid = InsertGXGCFeature(gxgc, gx, pGXGC_Layer); |
|
IFeature s = pGXGC_Layer.FeatureClass.GetFeature(oid); |
|
|
|
if (BGQ_BGH_AttrEqual(s, ref UnEqualAttr) && !string.IsNullOrWhiteSpace(UnEqualAttr) && gxgc.BGXW == "1") |
|
{ |
|
//仅记录变更一览表,不记录更新层和过程层 |
|
s.Delete(); |
|
IFeature f = pGX_Layer.FeatureClass.GetFeature(gx.OID); |
|
f.Delete(); |
|
} |
|
BHXXB(gxgc, gx, pGXGC_Layer); |
|
//gxgc.IsUpdate = true; |
|
//gxgc.UpdateOID = oid; |
|
Marshal.ReleaseComObject(gxgc.Shape); |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug(ex.Message); |
|
} |
|
result = true; |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("图斑变更发生异常!异常信息如下:"); |
|
LogAPI.Debug(ex); |
|
LogAPI.Debug("异常信息结束"); |
|
} |
|
return result; |
|
} |
|
private bool BGQ_BGH_AttrEqual(IFeature pf, ref string UnEqualAttr) |
|
{ |
|
bool result = true; |
|
for (int i = 0; i < pf.Fields.FieldCount; i++) |
|
{ |
|
IField field = pf.Fields.Field[i]; |
|
if ("BSM".Contains(field.Name.ToUpper()) || field.Name.ToUpper().Contains("MJ")) continue; |
|
int bghIdx = pf.Fields.FindField(field.Name.Replace("BGQ", "BGH")); |
|
if (bghIdx == -1) continue; |
|
if ("BGQTBBSM,BGQTBBH,BGQZLDWDM,BGQZLDWMC,BGQQSDWDM,BGQQSDWMC".Contains(field.Name.ToUpper())) |
|
{ |
|
if (pf.Value[i].ToTrim() != pf.Value[bghIdx].ToTrim()) |
|
{ |
|
UnEqualAttr += field.Name.ToUpper() + ","; |
|
} |
|
continue; |
|
} |
|
if (!Equals(pf.Value[i].ToTrim(), pf.Value[bghIdx].ToTrim())) |
|
{ |
|
result = false; |
|
break; |
|
} |
|
} |
|
return result; |
|
} |
|
|
|
/// <summary> |
|
/// 获取更新过程数据 |
|
/// </summary> |
|
/// <param name="pBGFeature">勾选得变更数据</param> |
|
/// <param name="pJC_Layer">基础_地类图斑/行政区调整前基础图斑</param> |
|
/// <param name="pGXGC_Layer">地类图斑更新过程层</param> |
|
/// <param name="pGX_Layer">地类图斑更新层</param> |
|
/// <returns></returns> |
|
private List<DLTBGXAttribute> GetGXGCData2(IFeature pBGFeature, IFeatureLayer pJC_Layer, IFeatureLayer pGXGC_Layer, IFeatureLayer pGX_Layer) |
|
{ |
|
try |
|
{ |
|
//当前变更图斑pBGFeature |
|
DLTBGXAttribute tempGXData = new DLTBGXAttribute(gx_FieldsIndex); |
|
tempGXData.SetAttribure(pBGFeature); |
|
tempGXData.Shape2 = pBGFeature.ShapeCopy; |
|
|
|
#region 从更新层里获取(判断该图斑是否已进行过一次变更) |
|
List<IFeature> gx_Features = FeatureAPI.Identify(pBGFeature.ShapeCopy, pGX_Layer); |
|
if (gx_Features.Count != 0) |
|
{ |
|
foreach (var gxItem in gx_Features) |
|
{ |
|
DLTBGXAttribute temp = new DLTBGXAttribute(gx_FieldsIndex) |
|
{ |
|
UpdateOID = gxItem.OID, |
|
IsUpdate = true |
|
}; |
|
temp.SetAttribure(gxItem); |
|
temp.Shape2 = gxItem.ShapeCopy; |
|
if (FeatureAPI.IsAdjacent(gxItem.ShapeCopy, pBGFeature.ShapeCopy)) |
|
{ |
|
if (temp.IsEqual(tempGXData)) |
|
{ |
|
if (tempGXData.IsUpdate && tempGXData.UpdateOID > 0)//相邻的更新层图斑与变更层属性相同-数据合并 |
|
{ |
|
gxItem.Delete(); |
|
} |
|
else |
|
{ |
|
tempGXData.UpdateOID = gxItem.OID; |
|
tempGXData.IsUpdate = true; |
|
tempGXData.SetAttribure(gxItem, gx_FieldsIndex); |
|
} |
|
tempGXData.Shape2 = FeatureAPI.Union(temp.Shape2, tempGXData.Shape2); |
|
} |
|
} |
|
else if (FeatureAPI.IsContains(gxItem.ShapeCopy, pBGFeature.ShapeCopy)) |
|
{ |
|
if (!temp.IsEqual(tempGXData))//更新图斑包含变更图斑且属性相同 |
|
{ |
|
IGeometry geo = FeatureAPI.Difference(temp.Shape2, tempGXData.Shape2); |
|
if (geo.IsEmpty) |
|
{ |
|
if (tempGXData.IsUpdate && tempGXData.UpdateOID > 0) |
|
{ |
|
gxItem.Delete(); |
|
} |
|
else |
|
{ |
|
tempGXData.IsUpdate = temp.IsUpdate; |
|
tempGXData.UpdateOID = temp.UpdateOID; |
|
tempGXData.TBBH = temp.TBBH; |
|
} |
|
continue; |
|
} |
|
List<IGeometry> geoList = FeatureAPI.DissolveGeometryByRing(geo); |
|
foreach (var item in geoList) |
|
{ |
|
temp = new DLTBGXAttribute(gx_FieldsIndex) |
|
{ |
|
UpdateOID = gxItem.OID |
|
}; |
|
if (geoList.IndexOf(item) == 0) |
|
temp.IsUpdate = true; |
|
temp.SetAttribure(gxItem); |
|
temp.Shape2 = item; |
|
gxDataList.Add(temp); |
|
} |
|
} |
|
else |
|
{ |
|
IRelationalOperator relational = tempGXData.Shape2 as IRelationalOperator; |
|
if (relational.Equals(temp.Shape2)) |
|
{ |
|
gxItem.Delete(); |
|
} |
|
tempGXData.Shape2 = temp.Shape2; |
|
} |
|
} |
|
else if (FeatureAPI.IsContains(pBGFeature.ShapeCopy, gxItem.ShapeCopy)) |
|
{ |
|
if (tempGXData.IsUpdate && tempGXData.UpdateOID > 0) |
|
{ |
|
gxItem.Delete(); |
|
} |
|
else |
|
{ |
|
tempGXData.IsUpdate = temp.IsUpdate; |
|
tempGXData.UpdateOID = temp.UpdateOID; |
|
} |
|
} |
|
else if (FeatureAPI.IsInterSect(gxItem.ShapeCopy, pBGFeature.ShapeCopy)) |
|
{ |
|
if (temp.IsEqual(tempGXData))//相交且属性相同 |
|
{ |
|
if (tempGXData.IsUpdate && tempGXData.UpdateOID != 0) |
|
{ |
|
tempGXData.Shape2 = FeatureAPI.Union(temp.Shape2, tempGXData.Shape2); |
|
gxItem.Delete(); |
|
} |
|
else |
|
{ |
|
tempGXData.Shape2 = FeatureAPI.Union(temp.Shape2, tempGXData.Shape2); |
|
tempGXData.IsUpdate = true; |
|
tempGXData.UpdateOID = temp.UpdateOID; |
|
} |
|
} |
|
else |
|
{ |
|
temp.Shape2 = FeatureAPI.Difference(temp.Shape2, tempGXData.Shape2); |
|
if (!temp.Shape2.IsEmpty) |
|
{ |
|
List<IGeometry> subGX_Items = FeatureAPI.DissolveGeometryByRing(temp.Shape2); |
|
foreach (var item in subGX_Items) |
|
{ |
|
if (subGX_Items.IndexOf(item) == 0) |
|
{ |
|
temp.Shape2 = item; |
|
gxDataList.Add(temp); |
|
continue; |
|
} |
|
temp = new DLTBGXAttribute(gx_FieldsIndex); |
|
temp.SetAttribure(gxItem); |
|
temp.Shape2 = item; |
|
gxDataList.Add(temp); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
gxDataList.Add(tempGXData);//若是更新层没有数据,直接添加勾选的变更图斑 |
|
foreach (var gxItem in gxDataList) |
|
{ |
|
List<IFeature> jc_Features = FeatureAPI.Identify(gxItem.Shape2, pJC_Layer); |
|
foreach (var jc in jc_Features) |
|
{ |
|
DLTBGXAttribute jcData = new DLTBGXAttribute(gx_FieldsIndex); |
|
jcData.SetAttribure(jc, jc_FieldsIndex); |
|
if (FeatureAPI.IsAdjacent(gxItem.Shape2, jc.ShapeCopy))//两个图斑是否相邻 |
|
{ |
|
if (gxItem.IsEqual(jcData)) |
|
{ |
|
List<IFeature> list = FeatureAPI.Identify2(jc.ShapeCopy, pGX_Layer); |
|
if (list.Count > 0) |
|
continue; |
|
gxItem.Shape2 = FeatureAPI.Union(gxItem.Shape2, jc.ShapeCopy); |
|
} |
|
} |
|
else if (FeatureAPI.IsInterSect(gxItem.Shape2, jc.ShapeCopy) && !FeatureAPI.IsContains(jc.ShapeCopy, gxItem.Shape2))//相交不包含(部分相交) |
|
{ |
|
if (gxItem.IsEqual(jcData)) |
|
{ |
|
List<IFeature> list = FeatureAPI.Identify2(jc.ShapeCopy, pGX_Layer); |
|
if (list.Count > 0) |
|
continue; |
|
gxItem.Shape2 = FeatureAPI.Union(gxItem.Shape2, jc.ShapeCopy); |
|
} |
|
} |
|
} |
|
} |
|
List<DLTBGXAttribute> newGXDataList = new List<DLTBGXAttribute>(); |
|
foreach (var gxItem in gxDataList)//根据变更图斑获取更新过程数据 |
|
{ |
|
gxItem.GCDataList.AddRange(GetGXGCData(gxItem, gxItem.Shape2, pGXGC_Layer, pJC_Layer, ref newGXDataList));//已存在的过程数据 |
|
|
|
if (gxItem.Shape == null)//从基础库获取过程数据 |
|
{ |
|
gxItem.GCDataList.AddRange(GetGXGCDataForJCLayer(gxItem, gxItem.Shape2, pJC_Layer, ref newGXDataList)); |
|
continue; |
|
} |
|
IRelationalOperator relational = gxItem.Shape as IRelationalOperator; |
|
if (!relational.Equals(gxItem.Shape2)) |
|
{ |
|
List<DLTBGXGCAttribute> gcList = GetGXGCDataForJCLayer(gxItem, FeatureAPI.Difference(gxItem.Shape2, gxItem.Shape), pJC_Layer, ref newGXDataList); |
|
foreach (var gc in gcList) |
|
{ |
|
if (FeatureAPI.IsInterSect(gxItem.Shape, gc.Shape) || FeatureAPI.IsInterSect(gc.Shape, gxItem.Shape)) |
|
continue; |
|
gxItem.GCDataList.Add(gc); |
|
} |
|
} |
|
} |
|
//擦除(更新)和相交(过程)的是否相交的部分 |
|
foreach (var item in newGXDataList) |
|
{ |
|
if (item.GCDataList.Count > 0) |
|
if (gxDataList.FirstOrDefault(f => FeatureAPI.IsInterSect(f.Shape2, item.Shape)) == null) |
|
{ |
|
gxDataList.Add(item); |
|
} |
|
} |
|
#endregion |
|
|
|
if (gxDataList.Count > 1) |
|
{ |
|
gxDataList = gxDataList.OrderByDescending(f => f.TBMJ).ToList(); |
|
List<DLTBGXAttribute> result = new List<DLTBGXAttribute>(); |
|
foreach (var item in gxDataList) |
|
{ |
|
if (item.Shape == null) |
|
continue; |
|
if (item.GCDataList.Count == 1) |
|
{ |
|
List<IFeature> jc_Features = new List<IFeature>(); |
|
jc_Features = FeatureAPI.Identify2(item.GCDataList[0].Shape, pJC_Layer); |
|
if (jc_Features.Count == 1) |
|
{ |
|
IRelationalOperator relational = item.GCDataList[0].Shape as IRelationalOperator; |
|
if (relational.Equals(jc_Features[0].ShapeCopy))//是否是图形变化(过程数据与基础库数据进行对比) |
|
{ |
|
item.GCDataList[0].BGXW = "1"; |
|
item.BSM = jc_Features[0].Value[jc_Features[0].Fields.FindField("BSM")].ToTrim(); |
|
item.GCDataList[0].BGHTBBSM = item.BSM; |
|
item.TBBH = jc_Features[0].Value[jc_Features[0].Fields.FindField("TBBH")].ToTrim(); |
|
result.Add(item); |
|
continue; |
|
} |
|
} |
|
} |
|
|
|
ShapeInfo InterShape = new ShapeInfo(item.Shape); |
|
DLTBAreaHandle InterHandle = new DLTBAreaHandle(InterShape); |
|
List<ShapeInfo> InterShapes = InterHandle.GetFeatures(); |
|
if (InterShapes.Count > 1) |
|
{ |
|
foreach (var subItem in InterShapes) |
|
{ |
|
DLTBGXAttribute gx = new DLTBGXAttribute(gx_FieldsIndex, item.GCDataList[0]); |
|
if (InterShapes.IndexOf(subItem) == 0) |
|
{ |
|
gx.UpdateOID = item.UpdateOID; |
|
gx.IsUpdate = item.IsUpdate; |
|
} |
|
else |
|
{ |
|
gx.IsUpdate = false; |
|
} |
|
gx.GCDataList.AddRange(item.GCDataList.FindAll(f => FeatureAPI.IsContains(subItem.Shape, f.Shape))); |
|
|
|
gx.BSM = ""; |
|
gx.TBBH = ""; |
|
gx.GCDataList.ForEach(f => |
|
{ |
|
if (f.IsUpdate && !string.IsNullOrWhiteSpace(f.BGHTBBSM)) |
|
{ |
|
gx.TBBH = f.BGHTBBH; |
|
gx.BSM = f.BGHTBBSM; |
|
} |
|
f.BGXW = "2"; |
|
}); |
|
if (string.IsNullOrWhiteSpace(gx.BSM)) |
|
{ |
|
gx.IsUpdate = false; |
|
} |
|
if (gx.GCDataList.Count > 1 && !gx.IsUpdate) |
|
gx.BSM = ""; |
|
result.Add(gx); |
|
} |
|
} |
|
else |
|
{ |
|
if (result.Count == 0) |
|
{ |
|
result.Add(item); |
|
} |
|
else |
|
{ |
|
if (result.FirstOrDefault(f => FeatureAPI.IsContains(f.Shape, item.Shape)) != null) |
|
{ |
|
continue; |
|
} |
|
else |
|
{ |
|
if (result.FirstOrDefault(f => f.BSM == item.BSM) != null) |
|
{ |
|
item.BSM = ""; |
|
item.GCDataList.ForEach(f => f.BGHTBBSM = ""); |
|
} |
|
result.Add(item); |
|
} |
|
} |
|
item.BSM = ""; |
|
item.TBBH = ""; |
|
item.GCDataList.ForEach(f => |
|
{ |
|
if (f.IsUpdate && !string.IsNullOrWhiteSpace(f.BGHTBBSM)) |
|
{ |
|
item.TBBH = f.BGHTBBH; |
|
item.BSM = f.BGHTBBSM; |
|
} |
|
f.BGXW = "2"; |
|
}); |
|
} |
|
} |
|
return result; |
|
} |
|
if (gxDataList.Count == 1) |
|
{ |
|
if (gxDataList[0].GCDataList.Count == 1) |
|
{ |
|
if (!gxDataList[0].IsUpdate) |
|
{ |
|
gxDataList[0].GCDataList[0].BGXW = "1"; |
|
gxDataList[0].BSM = gxDataList[0].GCDataList[0].BGHTBBSM; |
|
gxDataList[0].TBBH = gxDataList[0].GCDataList[0].BGHTBBH; |
|
} |
|
else |
|
{ |
|
gxDataList[0].GCDataList[0].BGXW = "2"; |
|
} |
|
} |
|
else |
|
{ |
|
gxDataList[0].TBBH = ""; |
|
gxDataList[0].BSM = ""; |
|
gxDataList[0].GCDataList.ForEach(f => |
|
{ |
|
if (f.IsUpdate && !string.IsNullOrWhiteSpace(f.BGHTBBSM)) |
|
{ |
|
gxDataList[0].TBBH = f.BGHTBBH; |
|
gxDataList[0].BSM = f.BGHTBBSM; |
|
} |
|
f.BGXW = "2"; |
|
}); |
|
if (gxDataList[0].UpdateOID == 0) |
|
gxDataList[0].IsUpdate = false; |
|
} |
|
} |
|
return gxDataList; |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug(ex.Message); |
|
throw ex; |
|
} |
|
} |
|
|
|
private List<DLTBGXGCAttribute> GetGXGCDataForJCLayer(DLTBGXAttribute pBGFeature, IGeometry pGXShape, IFeatureLayer pJC_Layer, ref List<DLTBGXAttribute> newGXData) |
|
{ |
|
List<DLTBGXGCAttribute> result = new List<DLTBGXGCAttribute>(); |
|
List<IFeature> jc_Features = new List<IFeature>(); |
|
jc_Features = FeatureAPI.Identify2(pGXShape, pJC_Layer); |
|
foreach (var jc in jc_Features) |
|
{ |
|
DLTBGXGCAttribute gxgc = new DLTBGXGCAttribute(gxgc_FieldsIndex); |
|
//gxgc.BGTBOID = pBGFeature.OID.ToString(); |
|
gxgc.SetBGQAttribure(jc, jc_FieldsIndex); |
|
gxgc.SetBGHAttribure(jc, jc_FieldsIndex); |
|
gxgc.BGMJ = jc.Value[jc.Fields.FindField("TBMJ")].ToDouble(); |
|
gxgc.BGHTBBH = jc.Value[jc.Fields.FindField("TBBH")].ToTrim(); |
|
if (FeatureAPI.IsAdjacent(jc.ShapeCopy, pGXShape)) |
|
{ |
|
DLTBGXAttribute tempgx = new DLTBGXAttribute(gx_FieldsIndex); |
|
tempgx.SetAttribure(jc, jc_FieldsIndex); |
|
if (pBGFeature.IsEqual(tempgx)) |
|
{ |
|
gxgc.Shape = jc.ShapeCopy; |
|
result.Add(gxgc); |
|
} |
|
} |
|
else if (FeatureAPI.IsContains(pGXShape, jc.ShapeCopy)) |
|
{ |
|
gxgc.Shape = jc.ShapeCopy; |
|
gxgc.SetBGHAttribure(pBGFeature); |
|
if (pBGFeature.FieldsValue.ContainsKey("XZQTZLX")) |
|
{ |
|
gxgc.SetXZQTZLX(pBGFeature.FieldsValue["XZQTZLX"].ToTrim()); |
|
} |
|
if (FeatureAPI.IsContains(jc.ShapeCopy, pGXShape)) |
|
{ |
|
gxgc.BGHTBBSM = jc.Value[jc.Fields.FindField("BSM")].ToTrim(); |
|
} |
|
result.Add(gxgc); |
|
} |
|
else |
|
{ |
|
double jc_MJ = gxgc.BGMJ; |
|
//相交部分图形 |
|
IGeometry IntersectGeo = FeatureAPI.InterSect(jc.ShapeCopy, pGXShape); |
|
if (IntersectGeo.IsEmpty) |
|
continue; |
|
#region 图斑分割/合并/拆分多部件后进行面积平差 |
|
List<DLTBGXGCAttribute> Area_GXGCAttribure = new List<DLTBGXGCAttribute>(); |
|
ShapeInfo InterShape = new ShapeInfo(IntersectGeo); |
|
DLTBAreaHandle InterHandle = new DLTBAreaHandle(InterShape); |
|
List<ShapeInfo> InterShapes = InterHandle.GetFeatures(); |
|
List<ShapeInfo> areaOperationData = new List<ShapeInfo>(); |
|
int id = 0; |
|
foreach (var item in InterShapes) |
|
{ |
|
id++; |
|
item.ID = id; |
|
areaOperationData.Add(item); |
|
} |
|
IGeometry DiffGeo = FeatureAPI.Difference(jc.ShapeCopy, pGXShape); |
|
List<ShapeInfo> DiffShapes = null; |
|
if (DiffGeo != null && !DiffGeo.IsEmpty) |
|
{ |
|
ShapeInfo DiffShape = new ShapeInfo(DiffGeo); |
|
DLTBAreaHandle DiffHandle = new DLTBAreaHandle(DiffShape); |
|
DiffShapes = DiffHandle.GetFeatures(); |
|
foreach (var item in DiffShapes) |
|
{ |
|
id++; |
|
item.ID = id; |
|
areaOperationData.Add(item); |
|
} |
|
} |
|
AreaAdjustment2(areaOperationData, jc_MJ);//过程数据平差 |
|
foreach (var item in areaOperationData) |
|
{ |
|
if (InterShapes != null) |
|
{ |
|
if (InterShapes.FirstOrDefault(f => f.ID == item.ID) != null) |
|
{ |
|
InterShapes.FirstOrDefault(f => f.ID == item.ID).SetArea(item.Area); |
|
} |
|
else if (DiffShapes != null) |
|
{ |
|
if (DiffShapes.FirstOrDefault(f => f.ID == item.ID) != null) |
|
{ |
|
DiffShapes.FirstOrDefault(f => f.ID == item.ID).SetArea(item.Area); |
|
} |
|
} |
|
} |
|
} |
|
#endregion |
|
|
|
foreach (var item in InterShapes)//return 过程数据 |
|
{ |
|
DLTBGXGCAttribute gxgc2 = new DLTBGXGCAttribute(gxgc_FieldsIndex); |
|
gxgc2.SetBGQAttribure(jc, jc_FieldsIndex); |
|
gxgc2.SetBGHAttribure(pBGFeature); |
|
gxgc2.BGMJ = item.Area; |
|
gxgc2.Shape = item.Shape; |
|
result.Add(gxgc2); |
|
} |
|
for (int j = 0; j < DiffShapes.Count; j++)//ref newGXData更新数据 |
|
{ |
|
DLTBGXGCAttribute gxgc2 = new DLTBGXGCAttribute(gxgc_FieldsIndex); |
|
gxgc2.SetBGQAttribure(jc, jc_FieldsIndex); |
|
gxgc2.SetBGHAttribure(jc, jc_FieldsIndex); |
|
gxgc2.Shape = DiffShapes[j].Shape; |
|
gxgc2.BGMJ = DiffShapes[j].Area; |
|
DLTBGXAttribute newGXData3 = new DLTBGXAttribute(gx_FieldsIndex, gxgc2); |
|
newGXData3.BSM = gxgc.BGHTBBSM; |
|
//newGXData3.TBBH = gxgc.BGHTBBH; |
|
newGXData3.GCDataList.Add(gxgc2); |
|
newGXData.Add(newGXData3); |
|
} |
|
} |
|
} |
|
return result; |
|
} |
|
|
|
/// <summary> |
|
/// 从更新过程层获取过程数据 |
|
/// </summary> |
|
/// <param name="pBGFeature">勾选的变更数据</param> |
|
/// <param name="pGXShape">变更图形</param> |
|
/// <param name="pGXGC_Layer"></param> |
|
/// <param name="pJC_Layer"></param> |
|
/// <param name="newGXData"></param> |
|
/// <returns></returns> |
|
private List<DLTBGXGCAttribute> GetGXGCData(DLTBGXAttribute pBGFeature, IGeometry pGXShape, IFeatureLayer pGXGC_Layer, IFeatureLayer pJC_Layer, ref List<DLTBGXAttribute> newGXData) |
|
{ |
|
List<DLTBGXGCAttribute> result = new List<DLTBGXGCAttribute>(); |
|
//foreach (var gx in newGXData) |
|
int gxCount = newGXData.Count; |
|
for (int num = 0; num < gxCount; num++) |
|
{ |
|
var gx = newGXData[num]; |
|
foreach (var gc in gx.GCDataList) |
|
{ |
|
if (FeatureAPI.IsContains(gc.Shape, pGXShape)) |
|
{ |
|
double jc_MJ = gc.BGMJ; |
|
//相交部分图形 |
|
IGeometry IntersectGeo = FeatureAPI.InterSect(gc.Shape, pGXShape); |
|
if (IntersectGeo.IsEmpty) |
|
continue; |
|
#region 图斑分割/合并/拆分多部件后进行面积平差 |
|
List<DLTBGXGCAttribute> Area_GXGCAttribure = new List<DLTBGXGCAttribute>(); |
|
ShapeInfo InterShape = new ShapeInfo(IntersectGeo); |
|
DLTBAreaHandle InterHandle = new DLTBAreaHandle(InterShape); |
|
List<ShapeInfo> InterShapes = InterHandle.GetFeatures(); |
|
List<ShapeInfo> areaOperationData = new List<ShapeInfo>(); |
|
int id = 0; |
|
foreach (var item in InterShapes) |
|
{ |
|
id++; |
|
item.ID = id; |
|
areaOperationData.Add(item); |
|
} |
|
|
|
IGeometry DiffGeo = FeatureAPI.Difference(gc.Shape, pGXShape); |
|
List<ShapeInfo> DiffShapes = null; |
|
if (DiffGeo != null && !DiffGeo.IsEmpty) |
|
{ |
|
ShapeInfo DiffShape = new ShapeInfo(DiffGeo); |
|
DLTBAreaHandle DiffHandle = new DLTBAreaHandle(DiffShape); |
|
DiffShapes = DiffHandle.GetFeatures(); |
|
foreach (var item in DiffShapes) |
|
{ |
|
id++; |
|
item.ID = id; |
|
areaOperationData.Add(item); |
|
} |
|
} |
|
AreaAdjustment2(areaOperationData, jc_MJ); |
|
foreach (var item in areaOperationData) |
|
{ |
|
if (InterShapes != null) |
|
{ |
|
if (InterShapes.FirstOrDefault(f => f.ID == item.ID) != null) |
|
{ |
|
InterShapes.FirstOrDefault(f => f.ID == item.ID).SetArea(item.Area); |
|
} |
|
else if (DiffShapes != null) |
|
{ |
|
if (DiffShapes.FirstOrDefault(f => f.ID == item.ID) != null) |
|
{ |
|
DiffShapes.FirstOrDefault(f => f.ID == item.ID).SetArea(item.Area); |
|
} |
|
} |
|
} |
|
} |
|
#endregion |
|
for (int i = 0; i < InterShapes.Count; i++) |
|
{ |
|
DLTBGXGCAttribute gxgc2 = new DLTBGXGCAttribute(gxgc_FieldsIndex); |
|
gxgc2.SetBGQAttribure(gc); |
|
gxgc2.SetBGHAttribure(pBGFeature); |
|
gxgc2.BGMJ = InterShapes[i].Area; |
|
if (i == 0) |
|
{ |
|
gxgc2.Shape = InterShapes[i].Shape; |
|
result.Add(gxgc2); |
|
} |
|
else |
|
{ |
|
gc.BGMJ = InterShapes[i].Area; |
|
gc.Shape = InterShapes[i].Shape; |
|
} |
|
} |
|
if (DiffShapes != null) |
|
{ |
|
for (int j = 0; j < DiffShapes.Count; j++) |
|
{ |
|
if (j == 0) |
|
{ |
|
gc.Shape = DiffShapes[j].Shape; |
|
gc.BGMJ = DiffShapes[j].Area; |
|
} |
|
else |
|
{ |
|
DLTBGXGCAttribute gxgc2 = new DLTBGXGCAttribute(gxgc_FieldsIndex); |
|
gxgc2.SetBGQAttribure(gc); |
|
gxgc2.SetBGHAttribure(pBGFeature); |
|
gxgc2.Shape = DiffShapes[j].Shape; |
|
gxgc2.BGMJ = DiffShapes[j].Area; |
|
|
|
DLTBGXAttribute newGXData3 = new DLTBGXAttribute(gx_FieldsIndex, gxgc2) |
|
{ |
|
BSM = gc.BGHTBBSM |
|
}; |
|
newGXData3.GCDataList.Add(gxgc2); |
|
newGXData.Add(newGXData3); |
|
} |
|
} |
|
} |
|
else |
|
{ |
|
gx.GCDataList.Remove(gc); |
|
} |
|
break; |
|
} |
|
else if (FeatureAPI.GetEqual(gc.Shape, pGXShape) || FeatureAPI.IsContains(pGXShape, gc.Shape)) |
|
{ |
|
gc.SetBGHAttribure(pBGFeature); |
|
result.Add(gc); |
|
gx.GCDataList.Remove(gc); |
|
break; |
|
} |
|
else |
|
{ |
|
double jc_MJ = gc.BGMJ; |
|
//相交部分图形 |
|
IGeometry IntersectGeo = FeatureAPI.InterSect(gc.Shape, pGXShape); |
|
if (IntersectGeo.IsEmpty) |
|
continue; |
|
#region 图斑分割/合并/拆分多部件后进行面积平差 |
|
List<DLTBGXGCAttribute> Area_GXGCAttribure = new List<DLTBGXGCAttribute>(); |
|
ShapeInfo InterShape = new ShapeInfo(IntersectGeo); |
|
DLTBAreaHandle InterHandle = new DLTBAreaHandle(InterShape); |
|
List<ShapeInfo> InterShapes = InterHandle.GetFeatures(); |
|
List<ShapeInfo> areaOperationData = new List<ShapeInfo>(); |
|
int id = 0; |
|
foreach (var item in InterShapes) |
|
{ |
|
id++; |
|
item.ID = id; |
|
areaOperationData.Add(item); |
|
} |
|
|
|
IGeometry DiffGeo = FeatureAPI.Difference(gc.Shape, pGXShape); |
|
List<ShapeInfo> DiffShapes = null; |
|
if (DiffGeo != null && !DiffGeo.IsEmpty) |
|
{ |
|
ShapeInfo DiffShape = new ShapeInfo(DiffGeo); |
|
DLTBAreaHandle DiffHandle = new DLTBAreaHandle(DiffShape); |
|
DiffShapes = DiffHandle.GetFeatures(); |
|
|
|
foreach (var item in DiffShapes) |
|
{ |
|
id++; |
|
item.ID = id; |
|
areaOperationData.Add(item); |
|
} |
|
} |
|
|
|
AreaAdjustment2(areaOperationData, jc_MJ); |
|
foreach (var item in areaOperationData) |
|
{ |
|
if (InterShapes != null) |
|
{ |
|
if (InterShapes.FirstOrDefault(f => f.ID == item.ID) != null) |
|
{ |
|
InterShapes.FirstOrDefault(f => f.ID == item.ID).SetArea(item.Area); |
|
} |
|
else if (DiffShapes != null) |
|
{ |
|
if (DiffShapes.FirstOrDefault(f => f.ID == item.ID) != null) |
|
{ |
|
DiffShapes.FirstOrDefault(f => f.ID == item.ID).SetArea(item.Area); |
|
} |
|
} |
|
} |
|
} |
|
#endregion |
|
for (int i = 0; i < InterShapes.Count; i++) |
|
{ |
|
DLTBGXGCAttribute gxgc2 = new DLTBGXGCAttribute(gxgc_FieldsIndex); |
|
gxgc2.SetBGQAttribure(gc); |
|
gxgc2.SetBGHAttribure(pBGFeature); |
|
gxgc2.BGMJ = InterShapes[i].Area; |
|
if (i == 0) |
|
{ |
|
IRelationalOperator relational = InterShapes[i].Shape as IRelationalOperator; |
|
if (result.Count > 0) |
|
{ |
|
bool x = false; |
|
foreach (var item in result) |
|
{ |
|
if (relational.Equals(item.Shape)) |
|
{ |
|
x = true; |
|
} |
|
} |
|
if (!x) |
|
{ |
|
gxgc2.Shape = InterShapes[i].Shape; |
|
result.Add(gxgc2); |
|
} |
|
} |
|
else |
|
{ |
|
gxgc2.Shape = InterShapes[i].Shape; |
|
result.Add(gxgc2); |
|
} |
|
} |
|
else |
|
{ |
|
gc.BGMJ = InterShapes[i].Area; |
|
gc.Shape = InterShapes[i].Shape; |
|
} |
|
} |
|
if (DiffShapes != null) |
|
{ |
|
for (int j = 0; j < DiffShapes.Count; j++) |
|
{ |
|
if (j == 0) |
|
{ |
|
gc.Shape = DiffShapes[j].Shape; |
|
gc.BGMJ = DiffShapes[j].Area; |
|
} |
|
else |
|
{ |
|
DLTBGXGCAttribute gxgc2 = new DLTBGXGCAttribute(gxgc_FieldsIndex); |
|
gxgc2.SetBGQAttribure(gc); |
|
gxgc2.SetBGHAttribure(pBGFeature); |
|
gxgc2.Shape = DiffShapes[j].Shape; |
|
gxgc2.BGMJ = DiffShapes[j].Area; |
|
|
|
DLTBGXAttribute newGXData3 = new DLTBGXAttribute(gx_FieldsIndex, gxgc2); |
|
newGXData3.BSM = gc.BGHTBBSM; |
|
newGXData3.GCDataList.Add(gxgc2); |
|
newGXData.Add(newGXData3); |
|
} |
|
//gc.Shape = DiffShapes[j].Shape; |
|
//gc.BGMJ = DiffShapes[j].Area; |
|
} |
|
} |
|
break; |
|
} |
|
} |
|
gxCount = newGXData.Count; |
|
} |
|
|
|
List<IFeature> gxgc_Features = FeatureAPI.Identify2(pGXShape, pGXGC_Layer); |
|
foreach (var gxgcItem in gxgc_Features) |
|
{ |
|
if (result.FirstOrDefault(f => FeatureAPI.IsInterSect(f.Shape, gxgcItem.ShapeCopy)) != null) |
|
continue;//变更层生成更新层数据相交到过程层数据直接略过 |
|
DLTBGXGCAttribute gxgc = new DLTBGXGCAttribute(gxgc_FieldsIndex); |
|
gxgc.SetAttribure(gxgcItem, gxgc_FieldsIndex); |
|
gxgc.Shape = gxgcItem.ShapeCopy; |
|
gxgc.IsUpdate = true; |
|
gxgc.UpdateOID = gxgcItem.OID; |
|
gxgc.BGMJ = gxgcItem.Value[gxgcItem.Fields.FindField("TBBGMJ")].ToDouble(); |
|
if (FeatureAPI.GetEqual(pGXShape, gxgcItem.ShapeCopy) || FeatureAPI.IsContains(pGXShape, gxgcItem.ShapeCopy)) |
|
{//更新层与过程层图形是否相等/包含 |
|
List<IFeature> jc_Features = new List<IFeature>(); |
|
var jc = FeatureAPI.Identify2(pGXShape, pJC_Layer); |
|
if (jc.Count == 1 && FeatureAPI.Difference(jc[0].ShapeCopy, gxgcItem.ShapeCopy).IsEmpty) |
|
{ |
|
gxgc.BGHTBBSM = jc[0].Value[jc[0].Fields.FindField("BSM")].ToString(); |
|
gxgc.BGHTBBH = jc[0].Value[jc[0].Fields.FindField("TBBH")].ToString(); |
|
} |
|
else |
|
{ |
|
//if (gxgc.BGXW == "1") |
|
gxgc.BGHTBBSM = ""; |
|
} |
|
result.Add(gxgc); |
|
} |
|
else |
|
{ |
|
double jc_MJ = gxgc.BGMJ; |
|
//相交部分图形 |
|
IGeometry IntersectGeo = FeatureAPI.InterSect(gxgcItem.ShapeCopy, pGXShape); |
|
#region 图斑分割/合并/拆分多部件后进行面积平差 |
|
List<DLTBGXGCAttribute> Area_GXGCAttribure = new List<DLTBGXGCAttribute>(); |
|
ShapeInfo InterShape = new ShapeInfo(IntersectGeo); |
|
DLTBAreaHandle InterHandle = new DLTBAreaHandle(InterShape); |
|
List<ShapeInfo> InterShapes = InterHandle.GetFeatures(); |
|
List<ShapeInfo> areaOperationData = new List<ShapeInfo>(); |
|
int id = 0; |
|
foreach (var item in InterShapes) |
|
{ |
|
id++; |
|
item.ID = id; |
|
areaOperationData.Add(item); |
|
} |
|
|
|
IGeometry DiffGeo = FeatureAPI.Difference(gxgcItem.ShapeCopy, pGXShape); |
|
List<ShapeInfo> DiffShapes = null; |
|
if (DiffGeo != null && !DiffGeo.IsEmpty) |
|
{ |
|
ShapeInfo DiffShape = new ShapeInfo(DiffGeo); |
|
DLTBAreaHandle DiffHandle = new DLTBAreaHandle(DiffShape); |
|
DiffShapes = DiffHandle.GetFeatures(); |
|
foreach (var item in DiffShapes) |
|
{ |
|
id++; |
|
item.ID = id; |
|
areaOperationData.Add(item); |
|
} |
|
} |
|
|
|
AreaAdjustment2(areaOperationData, jc_MJ); |
|
foreach (var item in areaOperationData) |
|
{ |
|
if (InterShapes != null) |
|
{ |
|
if (InterShapes.FirstOrDefault(f => f.ID == item.ID) != null) |
|
{ |
|
InterShapes.FirstOrDefault(f => f.ID == item.ID).SetArea(item.Area); |
|
} |
|
else if (DiffShapes != null) |
|
{ |
|
if (DiffShapes.FirstOrDefault(f => f.ID == item.ID) != null) |
|
{ |
|
DiffShapes.FirstOrDefault(f => f.ID == item.ID).SetArea(item.Area); |
|
} |
|
} |
|
} |
|
} |
|
#endregion |
|
|
|
for (int i = 0; i < InterShapes.Count; i++) |
|
{ |
|
DLTBGXGCAttribute gxgc2 = new DLTBGXGCAttribute(gxgc_FieldsIndex); |
|
gxgc2.SetAttribure(gxgcItem, gxgc_FieldsIndex); |
|
gxgc2.SetBGHAttribure(pBGFeature); |
|
gxgc2.BGMJ = InterShapes[i].Area; |
|
gxgc2.Shape = InterShapes[i].Shape; |
|
if (i == 0) |
|
{ |
|
gxgc2.IsUpdate = true; |
|
gxgc2.UpdateOID = gxgc.UpdateOID; |
|
gxgc2.BGHTBBSM = gxgc.BGHTBBSM; |
|
result.Add(gxgc2); |
|
} |
|
else |
|
{ |
|
result.Add(gxgc2); |
|
continue; |
|
} |
|
} |
|
//release.ManageLifetime(IntersectGeo); |
|
for (int j = 0; j < DiffShapes.Count; j++) |
|
{ |
|
DLTBGXGCAttribute gxgc2 = new DLTBGXGCAttribute(gxgc_FieldsIndex); |
|
gxgc2.SetAttribure(gxgcItem, gxgc_FieldsIndex); |
|
//gxgc2.SetBGHAttribure(gxgcItem, gxgc_FieldsIndex); |
|
gxgc2.Shape = DiffShapes[j].Shape; |
|
gxgc2.BGMJ = DiffShapes[j].Area; |
|
|
|
DLTBGXAttribute newGXData3 = new DLTBGXAttribute(gx_FieldsIndex, gxgc2); |
|
newGXData3.BSM = gxgc.BGHTBBSM; |
|
newGXData3.GCDataList.Add(gxgc2); |
|
newGXData.Add(newGXData3); |
|
} |
|
} |
|
} |
|
return result; |
|
} |
|
public void InsertGXFeature(DLTBGXAttribute pGXData, IFeatureLayer pGX_Layer, bool isUpdateTBBH) |
|
{ |
|
IFeatureCursor updateCursor = null; |
|
IFeatureCursor gx_cursor = null; |
|
IFeatureBuffer gx_buffer = null; |
|
try |
|
{ |
|
if (pGXData.IsUpdate) |
|
{ |
|
if (string.IsNullOrWhiteSpace(pGXData.BSM)) |
|
{ |
|
string bsmPrefix = MaxBSM.Substring(0, 10); |
|
int MaxNum = Convert.ToInt32(MaxBSM.Substring(9)); |
|
MaxBSM = bsmPrefix + (MaxNum + 1).ToString().PadLeft(8, '0'); |
|
pGXData.BSM = MaxBSM; |
|
} |
|
IFeature f = pGX_Layer.FeatureClass.GetFeature(pGXData.UpdateOID); |
|
if (pGXData.GCDataList.Count == 1 && pGXData.GCDataList[0].BGXW == "1") |
|
{ |
|
if (!isUpdateTBBH) |
|
{ |
|
f.Value[gx_FieldsIndex["TBBH"]] = pGXData.GCDataList[0].BGHTBBH; |
|
} |
|
} |
|
UpdateFeature(f, pGXData); |
|
f.Store(); |
|
pGXData.OID = f.OID; |
|
foreach (var gxgc in pGXData.GCDataList) |
|
{ |
|
gxgc.BGHTBBSM = pGXData.BSM; |
|
gxgc.BGHTBBH = pGXData.TBBH; |
|
} |
|
return; |
|
} |
|
else if (pGXData.GCDataList.Count == 1) |
|
{ |
|
//新增不需要合并的,判断BSM是否为空,为空认为是图形变更,需进行重新编号 |
|
if (string.IsNullOrWhiteSpace(pGXData.BSM)) |
|
{ |
|
string bsmPrefix = MaxBSM.Substring(0, 10); |
|
int MaxNum = Convert.ToInt32(MaxBSM.Substring(9)); |
|
MaxBSM = bsmPrefix + (MaxNum + 1).ToString().PadLeft(8, '0'); |
|
pGXData.BSM = MaxBSM; |
|
pGXData.GCDataList[0].BGHTBBSM = pGXData.BSM; |
|
pGXData.GCDataList[0].BGHTBBH = pGXData.TBBH; |
|
} |
|
else |
|
{ |
|
pGXData.GCDataList[0].BGXW = "1"; |
|
} |
|
} |
|
else if (pGXData.GCDataList.Count > 1) |
|
{ |
|
//新增需要合并的,认为图形变更 |
|
if (string.IsNullOrWhiteSpace(pGXData.BSM)) |
|
{ |
|
string bsmPrefix = MaxBSM.Substring(0, 10); |
|
int MaxNum = Convert.ToInt32(MaxBSM.Substring(9)); |
|
MaxBSM = bsmPrefix + (MaxNum + 1).ToString().PadLeft(8, '0'); |
|
pGXData.BSM = MaxBSM; |
|
pGXData.GCDataList.ForEach(f => { f.BGXW = "2"; f.BGHTBBSM = pGXData.BSM; }); |
|
} |
|
} |
|
else |
|
{ |
|
return; |
|
} |
|
gx_cursor = pGX_Layer.FeatureClass.Insert(true); |
|
gx_buffer = pGX_Layer.FeatureClass.CreateFeatureBuffer(); |
|
gx_buffer.Shape = pGXData.Shape; |
|
foreach (var fieldName in gx_FieldsIndex.Keys) |
|
{ |
|
if (fieldName == "TBMJ") |
|
{ |
|
gx_buffer.Value[gx_FieldsIndex[fieldName]] = pGXData.TBMJ; |
|
continue; |
|
} |
|
if (fieldName == "GXSJ") |
|
{ |
|
gx_buffer.Value[gx_FieldsIndex[fieldName]] = DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31); |
|
continue; |
|
} |
|
if (fieldName == "TBBH") |
|
{ |
|
if (pGXData.GCDataList.Count == 1 && pGXData.GCDataList[0].BGXW == "1") |
|
{ |
|
if (!isUpdateTBBH) |
|
{ |
|
if (!string.IsNullOrWhiteSpace(pGXData.GCDataList[0].BGHTBBH)) |
|
gx_buffer.Value[gx_FieldsIndex[fieldName]] = pGXData.GCDataList[0].BGHTBBH; |
|
else |
|
gx_buffer.Value[gx_FieldsIndex[fieldName]] = pGXData.FieldsValue[fieldName]; |
|
} |
|
else |
|
{ |
|
gx_buffer.Value[gx_FieldsIndex[fieldName]] = pGXData.FieldsValue[fieldName]; |
|
} |
|
} |
|
else |
|
{ |
|
gx_buffer.Value[gx_FieldsIndex[fieldName]] = pGXData.FieldsValue[fieldName]; |
|
} |
|
continue; |
|
} |
|
if (fieldName == "YSDM") |
|
{ |
|
gx_buffer.Value[gx_FieldsIndex[fieldName]] = "2001010100"; |
|
continue; |
|
} |
|
if (fieldName == "SJNF") |
|
{ |
|
gx_buffer.Value[gx_FieldsIndex[fieldName]] = "2023"; |
|
continue; |
|
} |
|
if (fieldName == "KCMJ") |
|
{ |
|
gx_buffer.Value[gx_FieldsIndex[fieldName]] = Math.Round(pGXData.TBMJ * pGXData.KCXS, 2); |
|
continue; |
|
} |
|
if (fieldName == "TBDLMJ") |
|
{ |
|
double dKCMJ_Temp = Math.Round(pGXData.TBMJ * pGXData.KCXS, 2); |
|
gx_buffer.Value[gx_FieldsIndex[fieldName]] = Math.Round(pGXData.TBMJ - dKCMJ_Temp, 2); |
|
continue; |
|
} |
|
if (fieldName == "BGTBOID") |
|
{ |
|
gx_buffer.Value[gx_FieldsIndex[fieldName]] = pGXData.BGTBOID; |
|
continue; |
|
} |
|
if (pGXData.FieldsValue.Keys.Contains(fieldName)) |
|
gx_buffer.Value[gx_FieldsIndex[fieldName]] = pGXData.FieldsValue[fieldName]; |
|
} |
|
object oid = gx_cursor.InsertFeature(gx_buffer); |
|
gx_cursor.Flush(); |
|
pGXData.OID = Convert.ToInt32(oid); |
|
Marshal.ReleaseComObject(gx_buffer); |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("写入更新层数据时发生异常,异常信息如下:"); |
|
LogAPI.Debug(ex); |
|
LogAPI.Debug("异常信息结束"); |
|
} |
|
finally |
|
{ |
|
if (updateCursor != null) |
|
Marshal.ReleaseComObject(updateCursor); |
|
if (gx_cursor != null) |
|
Marshal.ReleaseComObject(gx_cursor); |
|
if (gx_buffer != null) |
|
Marshal.ReleaseComObject(gx_buffer); |
|
} |
|
} |
|
public void UpdateFeature(IFeature pFeature, DLTBGXAttribute pData) |
|
{ |
|
try |
|
{ |
|
pFeature.Shape = pData.Shape; |
|
foreach (var key in pData.FieldsIndex.Keys) |
|
{ |
|
if (pData.FieldsValue == null) |
|
{ |
|
break; |
|
} |
|
if (key == "JCTBBSM") |
|
continue; |
|
if (key == "TBBH") |
|
{ |
|
pFeature.Value[pData.FieldsIndex[key]] = pData.TBBH; |
|
continue; |
|
} |
|
if (key == "SJNF") |
|
{ |
|
pFeature.Value[pData.FieldsIndex[key]] = "2019"; |
|
continue; |
|
} |
|
if (key == "TBMJ") |
|
{ |
|
pFeature.Value[pData.FieldsIndex[key]] = pData.TBMJ; |
|
continue; |
|
} |
|
if (key == "BGTBOID") |
|
{ |
|
pFeature.Value[pData.FieldsIndex[key]] = pData.BGTBOID; |
|
continue; |
|
} |
|
if (key == "YSDM") |
|
{ |
|
pFeature.Value[pData.FieldsIndex[key]] = "2001010100"; |
|
continue; |
|
} |
|
if (key == "GXSJ") |
|
{ |
|
pFeature.Value[pData.FieldsIndex[key]] = new DateTime(2019, 12, 31); |
|
continue; |
|
} |
|
if (pData.FieldsValue.Keys.Contains(key)) |
|
{ |
|
pFeature.Value[pData.FieldsIndex[key]] = pData.FieldsValue[key]; |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw ex; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 获取字段名称及下标值 |
|
/// </summary> |
|
/// <param name="pFields">要素类字段集合</param> |
|
/// <returns></returns> |
|
private Dictionary<string, int> GetFieldsIndex(IFields pFields) |
|
{ |
|
Dictionary<string, int> result = new Dictionary<string, int>(); |
|
for (int i = 0; i < pFields.FieldCount; i++) |
|
{ |
|
IField field = pFields.Field[i]; |
|
if (!field.Editable || field.Name.ToUpper().Contains("SHAPE") || field.Name.ToUpper() == "SJNF") continue; |
|
result.Add(field.Name.ToUpper(), i); |
|
Marshal.ReleaseComObject(field); |
|
} |
|
return result; |
|
} |
|
|
|
public int InsertGXGCFeature(DLTBGXGCAttribute pGxgc, DLTBGXAttribute pGx, IFeatureLayer pFC) |
|
{ |
|
IFeatureCursor gxgc_cursor = null; |
|
IFeatureBuffer gxgc_buffer = null; |
|
try |
|
{ |
|
if (pGxgc.IsUpdate) |
|
{ |
|
IFeature updateFeature = pFC.FeatureClass.GetFeature(pGxgc.UpdateOID); |
|
foreach (var fieldName in gxgc_FieldsIndex.Keys) |
|
{ |
|
if (fieldName == "TBBGMJ") |
|
{ |
|
updateFeature.Value[gxgc_FieldsIndex[fieldName]] = pGxgc.BGMJ; |
|
continue; |
|
} |
|
if (fieldName == "BGXW") |
|
{ |
|
updateFeature.Value[gxgc_FieldsIndex[fieldName]] = pGxgc.BGXW; |
|
continue; |
|
} |
|
if (fieldName == "BGTBOID") |
|
{ |
|
updateFeature.Value[gxgc_FieldsIndex[fieldName]] = pGxgc.BGTBOID; |
|
continue; |
|
} |
|
if (fieldName == "BGHTBBSM") |
|
{ |
|
updateFeature.Value[gxgc_FieldsIndex[fieldName]] = pGx.BSM; |
|
continue; |
|
} |
|
if (pGxgc.FieldsValue.Keys.Contains(fieldName) && fieldName.Contains("BGH") && pGx.FieldsValue.ContainsKey(GetRemovePrefixString(fieldName, "BGH"))) |
|
{ |
|
updateFeature.Value[gxgc_FieldsIndex[fieldName]] = pGx.FieldsValue[GetRemovePrefixString(fieldName, "BGH")]; |
|
} |
|
if (pGxgc.FieldsValue == null) |
|
continue; |
|
if (pGxgc.FieldsValue.Keys.Contains(fieldName) && !fieldName.Contains("BGH")) |
|
{ |
|
updateFeature.Value[gxgc_FieldsIndex[fieldName]] = pGxgc.FieldsValue[fieldName]; |
|
} |
|
} |
|
|
|
#region 变更前_面积维护 |
|
double kcxs = 0; |
|
//获取变更前扣除系数 |
|
int buffer_F_Index = updateFeature.Fields.FindField("BGQKCXS"); |
|
if (buffer_F_Index != -1) |
|
{ |
|
if (!(updateFeature.Value[buffer_F_Index] is DBNull)) |
|
kcxs = (double)updateFeature.Value[buffer_F_Index]; |
|
} |
|
//变更前扣除面积 |
|
double kcmj = 0; |
|
buffer_F_Index = updateFeature.Fields.FindField("BGQKCMJ"); |
|
if (buffer_F_Index != -1) |
|
{ |
|
kcmj = Math.Round(pGxgc.BGMJ * kcxs, 2); |
|
updateFeature.Value[buffer_F_Index] = kcmj; |
|
} |
|
//变更前图斑地类面积 |
|
buffer_F_Index = updateFeature.Fields.FindField("BGQTBDLMJ"); |
|
if (buffer_F_Index != -1) |
|
{ |
|
updateFeature.Value[buffer_F_Index] = pGxgc.BGMJ - kcmj; |
|
} |
|
#endregion |
|
#region 变更后_面积维护 |
|
kcxs = 0; |
|
//获取变更后扣除系数 |
|
buffer_F_Index = updateFeature.Fields.FindField("BGHKCXS"); |
|
if (buffer_F_Index != -1) |
|
{ |
|
if (!(updateFeature.Value[buffer_F_Index] is DBNull)) |
|
kcxs = (double)updateFeature.Value[buffer_F_Index]; |
|
} |
|
//变更后扣除面积 |
|
kcmj = 0; |
|
buffer_F_Index = updateFeature.Fields.FindField("BGHKCMJ"); |
|
if (buffer_F_Index != -1) |
|
{ |
|
kcmj = Math.Round(pGxgc.BGMJ * kcxs, 2); |
|
updateFeature.Value[buffer_F_Index] = kcmj; |
|
} |
|
//变更后图斑地类面积 |
|
buffer_F_Index = updateFeature.Fields.FindField("BGHTBDLMJ"); |
|
if (buffer_F_Index != -1) |
|
{ |
|
updateFeature.Value[buffer_F_Index] = pGxgc.BGMJ - kcmj; |
|
} |
|
#endregion |
|
updateFeature.Shape = pGxgc.Shape; |
|
updateFeature.Store(); |
|
Marshal.ReleaseComObject(updateFeature); |
|
return pGxgc.UpdateOID; |
|
} |
|
else |
|
{ |
|
gxgc_cursor = pFC.FeatureClass.Insert(true); |
|
gxgc_buffer = pFC.FeatureClass.CreateFeatureBuffer(); |
|
gxgc_buffer.Shape = pGxgc.Shape; |
|
foreach (var fieldName in gxgc_FieldsIndex.Keys) |
|
{ |
|
if (fieldName == "TBBGMJ") |
|
{ |
|
gxgc_buffer.Value[gxgc_FieldsIndex[fieldName]] = pGxgc.BGMJ; |
|
continue; |
|
} |
|
if (fieldName == "BGXW") |
|
{ |
|
gxgc_buffer.Value[gxgc_FieldsIndex[fieldName]] = pGxgc.BGXW; |
|
continue; |
|
} |
|
if (fieldName == "GXSJ") |
|
{ |
|
gxgc_buffer.Value[gxgc_FieldsIndex[fieldName]] = new DateTime(2019, 12, 31); |
|
continue; |
|
} |
|
if (fieldName == "BGTBOID") |
|
{ |
|
gxgc_buffer.Value[gxgc_FieldsIndex[fieldName]] = pGxgc.BGTBOID; |
|
continue; |
|
} |
|
if (fieldName == "BGHTBBSM") |
|
{ |
|
gxgc_buffer.Value[gxgc_FieldsIndex[fieldName]] = pGx.BSM; |
|
continue; |
|
} |
|
if (pGxgc.FieldsValue.Keys.Contains(fieldName) && fieldName.Contains("BGH") && pGx.FieldsValue.ContainsKey(GetRemovePrefixString(fieldName, "BGH"))) |
|
{ |
|
gxgc_buffer.Value[gxgc_FieldsIndex[fieldName]] = pGx.FieldsValue[GetRemovePrefixString(fieldName, "BGH")]; |
|
} |
|
if (pGxgc.FieldsValue.Keys.Contains(fieldName) && !fieldName.Contains("BGH")) |
|
gxgc_buffer.Value[gxgc_FieldsIndex[fieldName]] = pGxgc.FieldsValue[fieldName]; |
|
} |
|
#region 变更前_面积维护 |
|
double kcxs = 0; |
|
//获取变更前扣除系数 |
|
int buffer_F_Index = gxgc_buffer.Fields.FindField("BGQKCXS"); |
|
if (buffer_F_Index != -1) |
|
{ |
|
if (!(gxgc_buffer.Value[buffer_F_Index] is DBNull)) |
|
kcxs = (double)gxgc_buffer.Value[buffer_F_Index]; |
|
} |
|
//变更前扣除面积 |
|
double kcmj = 0; |
|
buffer_F_Index = gxgc_buffer.Fields.FindField("BGQKCMJ"); |
|
if (buffer_F_Index != -1) |
|
{ |
|
kcmj = Math.Round(pGxgc.BGMJ * kcxs, 2); |
|
gxgc_buffer.Value[buffer_F_Index] = kcmj; |
|
} |
|
//变更前图斑地类面积 |
|
buffer_F_Index = gxgc_buffer.Fields.FindField("BGQTBDLMJ"); |
|
if (buffer_F_Index != -1) |
|
{ |
|
gxgc_buffer.Value[buffer_F_Index] = pGxgc.BGMJ - kcmj; |
|
} |
|
#endregion |
|
#region 变更后_面积维护 |
|
kcxs = 0; |
|
//获取变更后扣除系数 |
|
buffer_F_Index = gxgc_buffer.Fields.FindField("BGHKCXS"); |
|
if (buffer_F_Index != -1) |
|
{ |
|
if (!(gxgc_buffer.Value[buffer_F_Index] is DBNull)) |
|
kcxs = (double)gxgc_buffer.Value[buffer_F_Index]; |
|
} |
|
//变更后扣除面积 |
|
kcmj = 0; |
|
buffer_F_Index = gxgc_buffer.Fields.FindField("BGHKCMJ"); |
|
if (buffer_F_Index != -1) |
|
{ |
|
kcmj = Math.Round(pGxgc.BGMJ * kcxs, 2); |
|
gxgc_buffer.Value[buffer_F_Index] = kcmj; |
|
} |
|
//变更后图斑地类面积 |
|
buffer_F_Index = gxgc_buffer.Fields.FindField("BGHTBDLMJ"); |
|
if (buffer_F_Index != -1) |
|
{ |
|
gxgc_buffer.Value[buffer_F_Index] = pGxgc.BGMJ - kcmj; |
|
} |
|
#endregion |
|
object oid = gxgc_cursor.InsertFeature(gxgc_buffer); |
|
gxgc_cursor.Flush(); |
|
Marshal.ReleaseComObject(gxgc_buffer); |
|
return (int)oid; |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw; |
|
} |
|
finally |
|
{ |
|
if (gxgc_cursor != null) |
|
Marshal.ReleaseComObject(gxgc_cursor); |
|
} |
|
|
|
} |
|
|
|
private void BHXXB(DLTBGXGCAttribute pGxgc, DLTBGXAttribute pGx, IFeatureLayer pFC) |
|
{ |
|
string dbPath = System.IO.Path.GetDirectoryName((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).ProjDir) + @"\BGTJ.sqlite"; |
|
IRDBHelper rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite); |
|
if (!rdbHelper.TableIsExist("BHXXB")) |
|
{ |
|
rdbHelper.ExecuteSQL(" Create TABLE BHXXB ( BGQTBBSM text(100),BGHTBBSM text(100),BGQTBBH text(100),BGHTBBH text(100),BGQZLDWDM text(100),BGHZLDWDM text(100)," + |
|
"BGQZLDWMC text(100),BGHZLDWMC text(100),BGQQSDWDM text(100),BGHQSDWDM text(100),BGQQSDWMC text(100),BGHQSDWMC text(100),BGQQSXZ text(100),BGHQSXZ text(100)," + |
|
"BGQDLBM text(100),BGHDLBM text(100),BGQKCDLBM text(100),BGHKCDLBM text(100),BGQKCXS text(100),BGHKCXS text(100),BGQKCMJ NUMERIC,BGHKCMJ NUMERIC,BGQGDLX text(100),BGHGDLX text(100),BGQGDPDJB text(100),BGHGDPDJB text(100),BGQCZCSXM text(100),BGHCZCSXM text(100)," + |
|
"BGQTBXHDM text(100),BGHTBXHDM text(100),BGQZZSXDM text(100),BGHZZSXDM text(100),BGQMSSM text(100),BGHMSSM text(100),BGQGDDB text(100),BGHGDDB text(100)," + |
|
"BGMJ NUMERIC,XZQTZLX text(100),BZ text(10),BGXW text(10) ) "); |
|
} |
|
string bhxxbField = "BGQTBBSM,BGHTBBSM,BGQTBBH,BGHTBBH,BGQZLDWDM,BGHZLDWDM,BGQZLDWMC,BGHZLDWMC,BGQQSDWDM,BGHQSDWDM,BGQQSDWMC,BGHQSDWMC,BGQQSXZ,BGHQSXZ,BGQDLBM,BGHDLBM,BGQKCDLBM,BGHKCDLBM,BGQKCXS,BGHKCXS,BGQKCMJ,BGHKCMJ,BGQGDLX,BGHGDLX,BGQGDPDJB,BGHGDPDJB,BGQCZCSXM,BGHCZCSXM,BGQTBXHDM,BGHTBXHDM,BGQZZSXDM,BGHZZSXDM,BGQMSSM,BGHMSSM,BGQGDDB,BGHGDDB,BGMJ,XZQTZLX,BZ,BGXW"; |
|
List<string> strSQL = new List<string>(); |
|
|
|
//生成sql语句代码块开始 |
|
string[] bhxxbfieldArr = bhxxbField.Split(','); |
|
string bhxxbValue = string.Empty; |
|
foreach (var item in bhxxbfieldArr) |
|
{ |
|
if (pGxgc.FieldsValue.ContainsKey(item)) |
|
{ |
|
bhxxbValue += string.Format("'{0}',", pGxgc.FieldsValue[item]); |
|
} |
|
else if (item == "BGMJ") |
|
{ |
|
bhxxbValue += string.Format("{0},", pGxgc.BGMJ); |
|
} |
|
else if (item == "BGXW") |
|
{ |
|
bhxxbValue += string.Format("'{0}',", pGxgc.BGXW); |
|
} |
|
else |
|
{ |
|
bhxxbValue += string.Format("'{0}',", ""); |
|
} |
|
} |
|
bhxxbValue = bhxxbValue.TrimEnd(','); |
|
string strSQLTemp = string.Format("Insert into BHXXB ({0}) values ({1})", bhxxbField, bhxxbValue); |
|
|
|
strSQL.Add(strSQLTemp); |
|
|
|
//生成sql代码块结束 |
|
try |
|
{ |
|
rdbHelper.BeginTransaction(); |
|
rdbHelper.ExecuteSQL(string.Format("delete from BHXXB where BGQTBBSM='{0}' and BGHTBBH='{1}'", pGxgc.FieldsValue["BGQTBBSM"], pGxgc.BGHTBBH)); |
|
rdbHelper.ExecuteSQL(strSQLTemp); |
|
rdbHelper.Commit(); |
|
rdbHelper.DisConnect(); |
|
} |
|
catch (Exception ex) |
|
{ |
|
rdbHelper.Rollback(); |
|
throw ex; |
|
} |
|
finally |
|
{ |
|
rdbHelper.DisConnect(); |
|
} |
|
} |
|
|
|
#region 获取最新标识码 |
|
private string GetMaxBSM(List<IFeatureClass> fcList) |
|
{ |
|
//System.Windows.Forms.Application.DoEvents(); |
|
int xh = 0; |
|
string MaxBSM = ""; |
|
string leftStr = string.Empty; |
|
foreach (var fc in fcList) |
|
{ |
|
string BSM = string.Empty; |
|
int BSMIndex = fc.FindField("BSM"); |
|
if (BSMIndex == -1) return BSM; |
|
|
|
ITable table = (ITable)fc; |
|
// 创建一个ITableSort接口对象 |
|
ITableSort tableSort = new TableSortClass |
|
{ |
|
Table = table, |
|
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 && !string.IsNullOrWhiteSpace(BSMStr.Trim())) 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; |
|
} |
|
#endregion |
|
|
|
#region 获取最新图斑编号 |
|
private int GetNewTBBH(List<IFeatureClass> fc, string pZLDWDM) |
|
{ |
|
fc = GetBSMFcList; |
|
int result = 0; |
|
foreach (var item in fc) |
|
{ |
|
int maxTBBH = GetMaxTBBH(item, pZLDWDM); |
|
if (result < maxTBBH) |
|
result = maxTBBH; |
|
} |
|
result++; |
|
return result; |
|
} |
|
private int GetMaxTBBH(IFeatureClass fc, string pZLDWDM) |
|
{ |
|
string fileName = "TBBH"; |
|
int result = 0; |
|
int index = fc.FindField(fileName); |
|
if (index == -1) return result; |
|
|
|
ITable table = (ITable)fc; |
|
// 创建一个ITableSort接口对象 |
|
ITableSort tableSort = new TableSortClass(); |
|
tableSort.Table = table; |
|
tableSort.Fields = fileName; |
|
tableSort.QueryFilter = new QueryFilterClass() { WhereClause = string.Format("ZLDWDM='{0}'", pZLDWDM) }; |
|
tableSort.set_Ascending(fileName, false); |
|
tableSort.Sort(null); |
|
ICursor cursor = tableSort.Rows; |
|
IRow row = cursor.NextRow(); |
|
while (row != null) |
|
{ |
|
int tbbh = 0; |
|
if (row.Value[index] is DBNull) |
|
{ |
|
tbbh = 0; |
|
} |
|
else |
|
{ |
|
int.TryParse(row.Value[index].ToString(), out tbbh); |
|
} |
|
if (result < tbbh) |
|
{ |
|
result = tbbh; |
|
} |
|
row = cursor.NextRow(); |
|
} |
|
return result; |
|
} |
|
#endregion |
|
|
|
///<summary> |
|
/// 移除前缀字符串 |
|
///</summary> |
|
///<param name="val">原字符串</param> |
|
///<param name="str">前缀字符串</param> |
|
///<returns></returns> |
|
public string GetRemovePrefixString(string val, string str) |
|
{ |
|
string strRegex = @"^(" + str + ")"; |
|
return Regex.Replace(val, strRegex, ""); |
|
} |
|
|
|
/// <summary> |
|
/// 面积平差 |
|
/// </summary> |
|
/// <param name="shpList">需要平差的对象集合</param> |
|
/// <param name="pKZMJ">控制面积</param> |
|
public void AreaAdjustment2(List<ShapeInfo> shpList, double pKZMJ) |
|
{ |
|
if (shpList.Count == 1) |
|
{ |
|
shpList[0].SetArea(pKZMJ); |
|
return; |
|
} |
|
//如果面积=0,计算椭球面积 |
|
shpList.ForEach(f => |
|
{ |
|
if (f.Area == 0) |
|
f.CalculationArea(); |
|
}); |
|
shpList = shpList.OrderByDescending(o => o.Area).ToList(); |
|
double mjc = Math.Round(shpList.Sum(s => s.Area) - 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].SetArea(shpList[i].Area + tpmj); |
|
else |
|
shpList[i].SetArea(shpList[i].Area - tpmj); |
|
} |
|
} |
|
if (e != 0) |
|
{ |
|
double tpmj = e * 0.01; |
|
for (int i = f; i < shpList.Count; i++) |
|
{ |
|
if (mjc < 0) |
|
shpList[i].SetArea(shpList[i].Area + tpmj); |
|
else |
|
shpList[i].SetArea(shpList[i].Area - tpmj); |
|
} |
|
} |
|
mjc = Math.Round(shpList.Sum(s => s.Area), 2) - pKZMJ; |
|
} |
|
} |
|
} |
|
/// <summary> |
|
/// 考虑待定 |
|
/// </summary> |
|
public class DLTBGXGCAttribute |
|
{ |
|
public bool IsAdjacent { get; set; } |
|
/// <summary> |
|
/// 是否已被合并 |
|
/// </summary> |
|
public bool IsUnioned { get; set; } |
|
public string TempBSMPrefix { get; set; } |
|
public string BGTBOID |
|
{ |
|
get |
|
{ |
|
if (FieldsValue != null && FieldsValue.Keys.Contains("BGTBOID")) |
|
{ |
|
return FieldsValue["BGTBOID"].ToTrim(); |
|
} |
|
return ""; |
|
} |
|
set |
|
{ |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsValue.Keys.Contains("BGTBOID")) |
|
{ |
|
FieldsValue["BGTBOID"] = value; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add("BGTBOID", value); |
|
} |
|
} |
|
} |
|
public bool IsUpdate { get; set; } |
|
public int UpdateOID { get; set; } |
|
public string BGHTBBH |
|
{ |
|
get |
|
{ |
|
if (FieldsValue != null && FieldsValue.Keys.Contains("BGHTBBH")) |
|
{ |
|
return FieldsValue["BGHTBBH"].ToTrim(); |
|
} |
|
return ""; |
|
} |
|
set |
|
{ |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsValue.Keys.Contains("BGHTBBH")) |
|
{ |
|
FieldsValue["BGHTBBH"] = value; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add("BGHTBBH", value); |
|
} |
|
} |
|
} |
|
/// <summary> |
|
/// 数据年份 |
|
/// </summary> |
|
public int SJNF { get; set; } |
|
public string BGHTBBSM |
|
{ |
|
get |
|
{ |
|
if (FieldsValue != null && FieldsValue.Keys.Contains("BGHTBBSM")) |
|
{ |
|
return FieldsValue["BGHTBBSM"].ToTrim(); |
|
} |
|
return ""; |
|
} |
|
set |
|
{ |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsValue.Keys.Contains("BGHTBBSM")) |
|
{ |
|
FieldsValue["BGHTBBSM"] = value; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add("BGHTBBSM", value); |
|
} |
|
} |
|
} |
|
/// <summary> |
|
/// 变更行为 |
|
/// </summary> |
|
public string BGXW { get; set; } |
|
/// <summary> |
|
/// 变更面积 |
|
/// </summary> |
|
public double BGMJ |
|
{ |
|
get |
|
{ |
|
if (FieldsValue != null && FieldsValue.Keys.Contains("TBBGMJ")) |
|
{ |
|
return FieldsValue["TBBGMJ"].ToDouble(); |
|
} |
|
return 0; |
|
} |
|
set |
|
{ |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsValue.Keys.Contains("TBBGMJ")) |
|
{ |
|
FieldsValue["TBBGMJ"] = value; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add("TBBGMJ", value); |
|
} |
|
} |
|
} |
|
public string XZQTZLX { get; set; } |
|
public void SetXZQTZLX(string pValue = "") |
|
{ |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
string result = ""; |
|
if (string.IsNullOrWhiteSpace(pValue)) |
|
{ |
|
if (FieldsValue.ContainsKey("XZQTZLX")) |
|
result = FieldsValue["XZQTZLX"].ToString(); |
|
if (string.IsNullOrWhiteSpace(result)) |
|
{ |
|
if (!FieldsValue.ContainsKey("BGQZLDWDM") || !FieldsValue.ContainsKey("BGHZLDWDM")) |
|
result = ""; |
|
if (!FieldsValue["BGQZLDWDM"].ToString().StartsWith(FieldsValue["BGHZLDWDM"].ToString().Substring(0, 6))) |
|
result = "5"; |
|
if (string.IsNullOrWhiteSpace(result)) |
|
result = "0"; |
|
} |
|
} |
|
else |
|
{ |
|
result = pValue; |
|
} |
|
if (FieldsValue.Keys.Contains("XZQTZLX")) |
|
{ |
|
FieldsValue["XZQTZLX"] = result; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add("XZQTZLX", result); |
|
} |
|
XZQTZLX = result; |
|
|
|
} |
|
public Dictionary<string, int> FieldsIndex { get; set; } |
|
public Dictionary<string, object> FieldsValue { get; set; } |
|
public DLTBGXGCAttribute() |
|
{ |
|
|
|
} |
|
public DLTBGXGCAttribute(IFields pFields) |
|
{ |
|
if (FieldsIndex == null) |
|
FieldsIndex = new Dictionary<string, int>(); |
|
using (ComReleaser releaser = new ComReleaser()) |
|
{ |
|
for (int i = 0; i < pFields.FieldCount; i++) |
|
{ |
|
IField field = pFields.Field[i]; |
|
releaser.ManageLifetime(field); |
|
if (!field.Editable || field.Name.ToUpper().Contains("SHAPE")) continue; |
|
FieldsIndex.Add(field.Name.ToUpper(), i); |
|
} |
|
} |
|
} |
|
public DLTBGXGCAttribute(Dictionary<string, int> pFieldsIndex) |
|
{ |
|
this.FieldsIndex = pFieldsIndex; |
|
} |
|
public IGeometry Shape { get; set; } |
|
public void SetBGQAttribure(IFeature pFeature, Dictionary<string, int> pFieldsIndex) |
|
{ |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsIndex == null) |
|
return; |
|
foreach (var item in pFieldsIndex.Keys) |
|
{ |
|
string bghAttr = "BGQ" + item; |
|
if (!FieldsIndex.Keys.Contains(bghAttr)) |
|
{ |
|
bghAttr = "BGQTB" + item; |
|
} |
|
if (!FieldsIndex.Keys.Contains(bghAttr)) |
|
continue; |
|
if (FieldsValue.Keys.Contains(bghAttr)) |
|
{ |
|
FieldsValue[bghAttr] = pFeature.Value[pFieldsIndex[item]]; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add(bghAttr, pFeature.Value[pFieldsIndex[item]]); |
|
} |
|
} |
|
} |
|
public void SetBGQAttribure(DLTBGXGCAttribute pGXGCData) |
|
{ |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsIndex == null) |
|
return; |
|
foreach (var item in pGXGCData.FieldsValue.Keys) |
|
{ |
|
if (item.Contains("BGH")) |
|
continue; |
|
string bghAttr = item; |
|
if (!FieldsValue.Keys.Contains(bghAttr)) |
|
{ |
|
bghAttr = item; |
|
} |
|
if (!FieldsIndex.Keys.Contains(bghAttr)) |
|
continue; |
|
if (FieldsValue.Keys.Contains(bghAttr)) |
|
{ |
|
FieldsValue[bghAttr] = pGXGCData.FieldsValue[item]; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add(bghAttr, pGXGCData.FieldsValue[item]); |
|
} |
|
} |
|
} |
|
public void SetBGHAttribure(DLTBGXGCAttribute pGXGCData) |
|
{ |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsIndex == null) |
|
return; |
|
foreach (var item in pGXGCData.FieldsValue.Keys) |
|
{ |
|
if (item.Contains("BGQ")) |
|
continue; |
|
string bghAttr = item; |
|
if (!FieldsValue.Keys.Contains(bghAttr)) |
|
{ |
|
bghAttr = item; |
|
} |
|
if (!FieldsIndex.Keys.Contains(bghAttr)) |
|
continue; |
|
if (FieldsValue.Keys.Contains(bghAttr)) |
|
{ |
|
FieldsValue[bghAttr] = pGXGCData.FieldsValue[item]; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add(bghAttr, pGXGCData.FieldsValue[item]); |
|
} |
|
} |
|
} |
|
public void SetBGHAttribure(DLTBGXAttribute pGXData) |
|
{ |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsIndex == null) |
|
return; |
|
foreach (var item in pGXData.FieldsValue.Keys) |
|
{ |
|
string bghAttr = "BGH" + item; |
|
if (!FieldsIndex.Keys.Contains(bghAttr)) |
|
{ |
|
bghAttr = "BGHTB" + item; |
|
} |
|
if (!FieldsIndex.Keys.Contains(bghAttr)) |
|
continue; |
|
if (FieldsValue.Keys.Contains(bghAttr)) |
|
{ |
|
FieldsValue[bghAttr] = pGXData.FieldsValue[item]; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add(bghAttr, pGXData.FieldsValue[item]); |
|
} |
|
} |
|
} |
|
public void SetBGHAttribure(IFeature pFeature, Dictionary<string, int> pFieldsIndex) |
|
{ |
|
|
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsIndex == null) |
|
return; |
|
foreach (var item in pFieldsIndex.Keys) |
|
{ |
|
string bghAttr = "BGH" + item; |
|
if (!FieldsIndex.Keys.Contains(bghAttr)) |
|
{ |
|
bghAttr = "BGHTB" + item; |
|
} |
|
if (!FieldsIndex.Keys.Contains(bghAttr)) |
|
continue; |
|
if (FieldsValue.Keys.Contains(bghAttr)) |
|
{ |
|
FieldsValue[bghAttr] = pFeature.Value[pFieldsIndex[item]]; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add(bghAttr, pFeature.Value[pFieldsIndex[item]]); |
|
} |
|
} |
|
} |
|
public void SetAttribure(IFeature pFeature, Dictionary<string, int> pGxgcFieldsIndex) |
|
{ |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsIndex == null) |
|
return; |
|
foreach (var item in pGxgcFieldsIndex.Keys) |
|
{ |
|
if (FieldsIndex.Keys.Contains(item)) |
|
{ |
|
if (FieldsValue.Keys.Contains(item)) |
|
{ |
|
FieldsValue[item] = pFeature.Value[pGxgcFieldsIndex[item]]; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add(item, pFeature.Value[pGxgcFieldsIndex[item]]); |
|
} |
|
if (item == "BGXW") |
|
{ |
|
BGXW = pFeature.Value[pGxgcFieldsIndex[item]].ToTrim(); |
|
} |
|
} |
|
} |
|
} |
|
public void CalculationArea() |
|
{ |
|
BGMJ = Shape.GetEllipseArea(); //ATEllipseArea.GetPolygonArea(Shape as IPolygon); |
|
} |
|
/// <summary> |
|
/// 判断变更后属性是否相同(除面积、BSM、道路、河流之外) |
|
/// </summary> |
|
/// <param name="pOther"></param> |
|
/// <returns></returns> |
|
public bool BGHAttribureIsEqual(DLTBGXGCAttribute pOther, bool IsXZTBIntrenal = false) |
|
{ |
|
bool result = true; |
|
if (FieldsValue == null || pOther.FieldsValue == null) |
|
{ |
|
result = false; |
|
return result; |
|
} |
|
foreach (var item in FieldsIndex.Keys) |
|
{ |
|
if ("BGHTBBSM,BGHTBBH,BGHCZCSXM".Contains(item) || item.Contains("MJ") || !item.Contains("BGH")) |
|
continue; |
|
if (item == "BGHDLBM") |
|
{ |
|
if ("1003、1004、1006、1101、1107、1107A".Contains(FieldsValue[item].ToString()) && !IsXZTBIntrenal) |
|
{ |
|
result = false; |
|
break; |
|
} |
|
} |
|
if (!pOther.FieldsValue.Keys.Contains(item)) continue; |
|
if (!Equals(FieldsValue[item], pOther.FieldsValue[item])) |
|
{ |
|
result = false; |
|
break; |
|
} |
|
} |
|
return result; |
|
} |
|
|
|
public DLTBGXGCAttribute UnionDLTBGXGCAttr(DLTBGXGCAttribute OtherData) |
|
{ |
|
DLTBGXGCAttribute result = this; |
|
result.Shape = FeatureAPI.Union(result.Shape, OtherData.Shape); |
|
result.BGMJ += OtherData.BGMJ; |
|
return result; |
|
} |
|
private bool Equals(object obj1, object obj2) |
|
{ |
|
if (obj1 == null || obj1 is DBNull) |
|
{ |
|
obj1 = ""; |
|
} |
|
if (obj2 == null || obj2 is DBNull) |
|
{ |
|
obj2 = ""; |
|
} |
|
if (obj2.ToString() == "0") |
|
obj2 = ""; |
|
if (obj1.ToString() == "0") |
|
obj1 = ""; |
|
if (obj1.ToTrim() == obj2.ToTrim()) |
|
{ |
|
return true; |
|
} |
|
return false; |
|
} |
|
} |
|
public class DLTBGXAttribute |
|
{ |
|
public int OID { get; set; } |
|
public string TempBSMPrefix { get; set; } |
|
public string BSM |
|
{ |
|
get |
|
{ |
|
if (FieldsValue != null && FieldsValue.Keys.Contains("BSM")) |
|
{ |
|
return FieldsValue["BSM"].ToTrim(); |
|
} |
|
return ""; |
|
} |
|
set |
|
{ |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsValue.Keys.Contains("BSM")) |
|
{ |
|
FieldsValue["BSM"] = value; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add("BSM", value); |
|
} |
|
} |
|
} |
|
|
|
public string TBBH |
|
{ |
|
get |
|
{ |
|
if (FieldsValue != null && FieldsValue.Keys.Contains("TBBH")) |
|
{ |
|
return FieldsValue["TBBH"].ToTrim(); |
|
} |
|
return ""; |
|
} |
|
set |
|
{ |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsValue.Keys.Contains("TBBH")) |
|
{ |
|
FieldsValue["TBBH"] = value; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add("TBBH", value); |
|
} |
|
} |
|
} |
|
|
|
public string CZCSXM |
|
{ |
|
get |
|
{ |
|
if (FieldsValue != null && FieldsValue.Keys.Contains("CZCSXM")) |
|
{ |
|
return FieldsValue["CZCSXM"].ToTrim(); |
|
} |
|
return ""; |
|
} |
|
set |
|
{ |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsValue.Keys.Contains("CZCSXM")) |
|
{ |
|
FieldsValue["CZCSXM"] = value; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add("CZCSXM", value); |
|
} |
|
} |
|
} |
|
public string BGTBOID { get; set; } |
|
public bool IsUpdate { get; set; } |
|
public bool IsAdd { get; set; } |
|
public int UpdateOID { get; set; } |
|
/// <summary> |
|
/// 继承OID |
|
/// </summary> |
|
public int InheritOID { get; set; } |
|
private List<DLTBGXGCAttribute> _GCDataList; |
|
public List<DLTBGXGCAttribute> GCDataList |
|
{ |
|
get |
|
{ |
|
if (_GCDataList == null) |
|
_GCDataList = new List<DLTBGXGCAttribute>(); |
|
return _GCDataList; |
|
} |
|
set |
|
{ |
|
_GCDataList = value; |
|
} |
|
} |
|
public string DLBM |
|
{ |
|
get |
|
{ |
|
if (FieldsValue != null && FieldsValue.Keys.Contains("DLBM")) |
|
{ |
|
return FieldsValue["DLBM"].ToTrim(); |
|
} |
|
return ""; |
|
} |
|
} |
|
/// <summary> |
|
/// 数据年份 |
|
/// </summary> |
|
public int SJNF |
|
{ |
|
get |
|
{ |
|
if (FieldsValue != null && FieldsValue.Keys.Contains("SJNF")) |
|
{ |
|
return Convert.ToInt32(FieldsValue["SJNF"]); |
|
} |
|
return 0; |
|
} |
|
set |
|
{ |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsValue.Keys.Contains("SJNF")) |
|
{ |
|
FieldsValue["SJNF"] = value; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add("SJNF", value); |
|
} |
|
} |
|
} |
|
public double TBMJ |
|
{ |
|
get |
|
{ |
|
if (FieldsValue != null && FieldsValue.Keys.Contains("TBMJ")) |
|
{ |
|
return FieldsValue["TBMJ"].ToDouble(); |
|
} |
|
return 0; |
|
} |
|
set |
|
{ |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsValue.Keys.Contains("TBMJ")) |
|
{ |
|
FieldsValue["TBMJ"] = value; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add("TBMJ", value); |
|
} |
|
if (FieldsValue.Keys.Contains("KCMJ")) |
|
{ |
|
FieldsValue["KCMJ"] = Math.Round(value * KCXS, 2); |
|
} |
|
else |
|
{ |
|
FieldsValue.Add("KCMJ", Math.Round(value * KCXS, 2)); |
|
} |
|
if (FieldsValue.Keys.Contains("TBDLMJ")) |
|
{ |
|
//FieldsValue["TBDLMJ"] = Math.Round(TBMJ - value * KCXS, 2); |
|
|
|
double dTBDLMJ_Temp2 = Math.Round(value * KCXS, 2); |
|
FieldsValue["TBDLMJ"] = Math.Round(TBMJ - dTBDLMJ_Temp2, 2); |
|
} |
|
else |
|
{ |
|
//FieldsValue.Add("TBDLMJ", Math.Round(TBMJ - value * KCXS, 2)); |
|
|
|
double dTBDLMJ_Temp2 = Math.Round(value * KCXS, 2); |
|
FieldsValue.Add("TBDLMJ", Math.Round(TBMJ - dTBDLMJ_Temp2, 2)); |
|
} |
|
} |
|
} |
|
public double KCXS |
|
{ |
|
get |
|
{ |
|
if (FieldsValue != null && FieldsValue.Keys.Contains("KCXS")) |
|
{ |
|
return FieldsValue["KCXS"].ToDouble(); |
|
} |
|
return 0; |
|
} |
|
set |
|
{ |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsValue.Keys.Contains("KCXS")) |
|
{ |
|
FieldsValue["KCXS"] = value; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add("KCXS", value); |
|
} |
|
if (FieldsValue.Keys.Contains("KCMJ")) |
|
{ |
|
FieldsValue["KCMJ"] = Math.Round(value * TBMJ, 2); |
|
} |
|
else |
|
{ |
|
FieldsValue.Add("KCMJ", Math.Round(value * TBMJ, 2)); |
|
} |
|
if (FieldsValue.Keys.Contains("TBDLMJ")) |
|
{ |
|
//FieldsValue["TBDLMJ"] = Math.Round(TBMJ - value * TBMJ, 2); |
|
|
|
double dTBDLMJ_Temp3 = Math.Round(value * TBMJ, 2); |
|
FieldsValue["TBDLMJ"] = Math.Round(TBMJ - dTBDLMJ_Temp3, 2); |
|
} |
|
else |
|
{ |
|
//FieldsValue.Add("TBDLMJ", Math.Round(TBMJ - value * TBMJ, 2)); |
|
|
|
double dTBDLMJ_Temp3 = Math.Round(value * TBMJ, 2); |
|
FieldsValue.Add("TBDLMJ", Math.Round(TBMJ - dTBDLMJ_Temp3, 2)); |
|
} |
|
} |
|
} |
|
private IGeometry _Shape; |
|
public IGeometry Shape |
|
{ |
|
get |
|
{ |
|
if (_GCDataList != null) |
|
{ |
|
_Shape = UnionGXGC(); |
|
} |
|
return _Shape; |
|
} |
|
set { _Shape = value; } |
|
} |
|
public IGeometry Shape2 { get; set; } |
|
public Dictionary<string, int> FieldsIndex { get; set; } |
|
public Dictionary<string, object> FieldsValue { get; set; } |
|
public DLTBGXAttribute(Dictionary<string, int> pFieldsIndex, DLTBGXGCAttribute pGXGCData) |
|
{ |
|
this.FieldsIndex = pFieldsIndex; |
|
if (pGXGCData == null) |
|
return; |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsIndex == null) |
|
return; |
|
foreach (var item in FieldsIndex.Keys) |
|
{ |
|
string bghAttr = "BGH" + item; |
|
if (!pGXGCData.FieldsValue.Keys.Contains(bghAttr)) |
|
{ |
|
bghAttr = "BGHTB" + item; |
|
} |
|
if (!pGXGCData.FieldsValue.Keys.Contains(bghAttr)) |
|
{ |
|
FieldsValue.Add(item, null); |
|
continue; |
|
} |
|
if (FieldsValue.Keys.Contains(item)) |
|
{ |
|
FieldsValue[item] = pGXGCData.FieldsValue[bghAttr]; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add(item, pGXGCData.FieldsValue[bghAttr]); |
|
} |
|
} |
|
TempBSMPrefix = pGXGCData.TempBSMPrefix; |
|
BGTBOID = pGXGCData.BGTBOID; |
|
Shape = pGXGCData.Shape; |
|
TBMJ = pGXGCData.BGMJ; |
|
//SJNF = pGXGCData.SJNF; |
|
FieldsValue["TBBH"] = pGXGCData.BGHTBBH; |
|
} |
|
public DLTBGXAttribute(Dictionary<string, int> pFieldsIndex) |
|
{ |
|
FieldsIndex = pFieldsIndex; |
|
} |
|
public void SetAttribureNew(IFeature pFeature, Dictionary<string, int> pFieldsIndex = null) |
|
{ |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsIndex == null) |
|
return; |
|
Shape = pFeature.ShapeCopy; |
|
Dictionary<string, int> fields = FieldsIndex; |
|
if (pFieldsIndex != null) |
|
{ |
|
FieldsIndex = pFieldsIndex; |
|
fields = pFieldsIndex; |
|
} |
|
foreach (var item in fields.Keys) |
|
{ |
|
if (item == "OBJECTID" || item == "FID") |
|
{ |
|
continue; |
|
} |
|
|
|
|
|
if (item == "BGTBOID") |
|
{ |
|
continue; |
|
} |
|
if (item == "FID_JC_DLTB" || item == "FID_DLTBBG_BUFFER") |
|
{ |
|
continue; |
|
} |
|
|
|
if (pFieldsIndex != null) |
|
{ |
|
if (item == "TBMJ") |
|
{ |
|
TBMJ = pFeature.Value[pFieldsIndex[item]].ToDouble(); |
|
} |
|
if (FieldsValue.Keys.Contains(item)) |
|
{ |
|
FieldsValue[item] = pFeature.Value[pFieldsIndex[item]]; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add(item, pFeature.Value[pFieldsIndex[item]]); |
|
} |
|
} |
|
else |
|
{ |
|
if (item == "TBMJ") |
|
{ |
|
TBMJ = pFeature.Value[FieldsIndex[item]].ToDouble(); |
|
} |
|
if (FieldsValue.Keys.Contains(item)) |
|
{ |
|
FieldsValue[item] = pFeature.Value[FieldsIndex[item]]; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add(item, pFeature.Value[FieldsIndex[item]]); |
|
} |
|
} |
|
} |
|
} |
|
|
|
public void SetAttribure(IFeature pFeature, Dictionary<string, int> pFieldsIndex = null) |
|
{ |
|
if (FieldsValue == null) |
|
FieldsValue = new Dictionary<string, object>(); |
|
if (FieldsIndex == null) |
|
return; |
|
Shape = pFeature.ShapeCopy; |
|
Dictionary<string, int> fields = FieldsIndex; |
|
if (pFieldsIndex != null) |
|
fields = pFieldsIndex; |
|
foreach (var item in fields.Keys) |
|
{ |
|
if (pFeature.Fields.Field[fields[item]].Name == "SJNF") continue; |
|
if (item == "TBMJ") |
|
{ |
|
TBMJ = pFeature.Value[fields[item]].ToDouble(); |
|
} |
|
if (item == "XZQTZLX") |
|
{ |
|
int idx = pFeature.Fields.FindField(item); |
|
if (idx == -1) continue; |
|
FieldsValue[item] = pFeature.Value[idx]; |
|
continue; |
|
//BGTBOID = pFeature.Value[FieldsIndex[item]].ToTrim(); |
|
} |
|
//if (item == "SJNF") |
|
//{ |
|
// SJNF = Convert.ToInt32(pFeature.Value[FieldsIndex[item]]); |
|
//} |
|
if (FieldsValue.Keys.Contains(item)) |
|
{ |
|
FieldsValue[item] = pFeature.Value[fields[item]]; |
|
} |
|
else |
|
{ |
|
FieldsValue.Add(item, pFeature.Value[fields[item]]); |
|
} |
|
} |
|
} |
|
public bool IsEqual(DLTBGXAttribute pData) |
|
{ |
|
bool result = true; |
|
if (FieldsValue == null || pData.FieldsValue == null) |
|
{ |
|
result = false; |
|
return result; |
|
} |
|
foreach (var item in FieldsIndex.Keys) |
|
{ |
|
if ("SHAPE,TBBSM,YSDM,SJNF,TBBH,TBYBH,JCTBBSM,BGTBOID,GXSJ,MSSM,BZ,XZQTZLX,CZCSXM".Contains(item) || item.Contains("MJ")) |
|
continue; |
|
if (item == "DLBM") |
|
{ |
|
if ("1003、1004、1006、1101、1107、1107A".Contains(FieldsValue[item].ToString())) |
|
{ |
|
result = false; |
|
break; |
|
} |
|
} |
|
if (!pData.FieldsValue.Keys.Contains(item) || !FieldsValue.Keys.Contains(item)) continue; |
|
if (!Equals(FieldsValue[item], pData.FieldsValue[item])) |
|
{ |
|
result = false; |
|
break; |
|
} |
|
} |
|
return result; |
|
} |
|
private bool Equals(object obj1, object obj2) |
|
{ |
|
if (obj1 == null || obj1 is DBNull) |
|
{ |
|
obj1 = ""; |
|
} |
|
if (obj2 == null || obj2 is DBNull) |
|
{ |
|
obj2 = ""; |
|
} |
|
if (obj2.ToString() == "0") |
|
obj2 = ""; |
|
if (obj1.ToString() == "0") |
|
obj1 = ""; |
|
if (obj1.ToTrim() == obj2.ToTrim()) |
|
{ |
|
return true; |
|
} |
|
return false; |
|
} |
|
|
|
private IGeometry UnionGXGC() |
|
{ |
|
IGeometry result = null; |
|
List<int> updateOIDs = new List<int>(); |
|
foreach (var item in _GCDataList) |
|
{ |
|
if (item.Shape == null || item.Shape.IsEmpty) |
|
{ |
|
continue; |
|
} |
|
if (item.IsUpdate) |
|
{ |
|
if (updateOIDs.Contains(item.UpdateOID)) |
|
{ |
|
continue; |
|
} |
|
updateOIDs.Add(item.UpdateOID); |
|
} |
|
if (result == null) |
|
{ |
|
result = item.Shape; |
|
TBMJ = item.BGMJ; |
|
} |
|
else |
|
{ |
|
ITopologicalOperator topo = result as ITopologicalOperator; |
|
topo.Simplify(); |
|
ITopologicalOperator topo2 = item.Shape as ITopologicalOperator; |
|
topo2.Simplify(); |
|
IGeometry result2 = topo.Union(item.Shape); |
|
result = result2; |
|
TBMJ = Math.Round(TBMJ + item.BGMJ, 2); |
|
} |
|
} |
|
return result; |
|
} |
|
} |
|
public class DLTBAreaHandle |
|
{ |
|
/// <summary> |
|
/// 要素 |
|
/// </summary> |
|
private ShapeInfo m_FeatureInfo; |
|
private bool m_IsPolycyclic; |
|
public bool IsPolycyclic { get { return m_IsPolycyclic; } } |
|
public DLTBAreaHandle(ShapeInfo pFeature) |
|
{ |
|
m_FeatureInfo = pFeature; |
|
} |
|
|
|
public List<ShapeInfo> GetFeatures(bool IsAdjustment = true) |
|
{ |
|
List<ShapeInfo> result = new List<ShapeInfo>(); |
|
//将多环图形打散 |
|
List<IGeometry> geoList = FeatureAPI.DissolveGeometryByRing(m_FeatureInfo.Shape); |
|
foreach (IGeometry item in geoList) |
|
{ |
|
result.Add(new ShapeInfo(item)); |
|
|
|
//Marshal.ReleaseComObject(item); |
|
} |
|
if (m_FeatureInfo.Area == 0) |
|
{ |
|
m_FeatureInfo.CalculationArea(); |
|
} |
|
if (result.Count == 1) |
|
{ |
|
result[0].SetArea(m_FeatureInfo.Area); |
|
} |
|
else if (result.Count > 1 && IsAdjustment) |
|
{ |
|
AreaHandle.AreaAdjustment(result, m_FeatureInfo.Area); |
|
} |
|
return result; |
|
} |
|
} |
|
public class ShapeInfo |
|
{ |
|
private string m_BGXW; |
|
private string m_TBBSM; |
|
private string m_TBBH; |
|
private string m_ZLDWDM; |
|
private double m_Area; |
|
private IGeometry m_Shape; |
|
private IFeature m_AttrSourceFeature; |
|
public int ID { get; set; } |
|
public IFeature AttrSourceFeature { get { return m_AttrSourceFeature; } } |
|
/// <summary> |
|
/// 变更行为 |
|
/// </summary> |
|
public string BGXW { get { return m_BGXW; } } |
|
/// <summary> |
|
/// 图斑标识码 |
|
/// </summary> |
|
public string TBBSM { get { return m_TBBSM; } } |
|
/// <summary> |
|
/// 图斑编号 |
|
/// </summary> |
|
public string TBBH { get { return m_TBBH; } } |
|
/// <summary> |
|
/// 图斑编号 |
|
/// </summary> |
|
public string ZLDWDM { get { return m_ZLDWDM; } } |
|
/// <summary> |
|
/// 图斑面积 |
|
/// </summary> |
|
public double Area { get { return Math.Round(m_Area, 2); } } |
|
public IGeometry Shape { get { return m_Shape; } } |
|
public ShapeInfo() { } |
|
public ShapeInfo(IGeometry pGeo) |
|
{ |
|
m_Shape = pGeo; |
|
} |
|
public void SetAttrSourceFeature(IFeature pFeature) |
|
{ |
|
m_AttrSourceFeature = pFeature; |
|
} |
|
public void SetShape(IGeometry pGeo) |
|
{ |
|
m_Shape = pGeo; |
|
} |
|
public void CalculationArea() |
|
{ |
|
m_Area = m_Shape.GetEllipseArea();// ATEllipseArea.GetPolygonArea(m_Shape as IPolygon); |
|
} |
|
public void SetArea(double pArea) |
|
{ |
|
m_Area = pArea; |
|
} |
|
public void SetBGXW(string pBGXW) |
|
{ |
|
m_BGXW = pBGXW; |
|
} |
|
public void SetTBBSM(string pTBBSM) |
|
{ |
|
m_TBBSM = pTBBSM; |
|
} |
|
public void SetTBBH(string pTBBH) |
|
{ |
|
m_TBBH = pTBBH; |
|
} |
|
public void SetZLDWDM(string pZLDWDM) |
|
{ |
|
m_ZLDWDM = pZLDWDM; |
|
} |
|
} |
|
public class AreaHandle |
|
{ |
|
/// <summary> |
|
/// 面积平差 |
|
/// </summary> |
|
/// <param name="shpList">需要平差的对象集合</param> |
|
/// <param name="pKZMJ">控制面积</param> |
|
public static void AreaAdjustment(List<ShapeInfo> shpList, double pKZMJ) |
|
{ |
|
//如果面积=0,计算椭球面积 |
|
shpList.ForEach(f => |
|
{ |
|
if (f.Area == 0) |
|
f.CalculationArea(); |
|
}); |
|
shpList = shpList.OrderByDescending(o => o.Area).ToList(); |
|
double mjc = Math.Round(shpList.Sum(s => s.Area) - 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].SetArea(shpList[i].Area + tpmj); |
|
else |
|
shpList[i].SetArea(shpList[i].Area - tpmj); |
|
} |
|
} |
|
if (e != 0) |
|
{ |
|
double tpmj = e * 0.01; |
|
for (int i = f; i < shpList.Count; i++) |
|
{ |
|
if (mjc < 0) |
|
shpList[i].SetArea(shpList[i].Area + tpmj); |
|
else |
|
shpList[i].SetArea(shpList[i].Area - tpmj); |
|
} |
|
} |
|
mjc = Math.Round(shpList.Sum(s => s.Area), 2) - pKZMJ; |
|
} |
|
} |
|
} |
|
}
|
|
|