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.
1055 lines
50 KiB
1055 lines
50 KiB
using ESRI.ArcGIS.Carto; |
|
using ESRI.ArcGIS.DataSourcesGDB; |
|
using ESRI.ArcGIS.Geodatabase; |
|
using ESRI.ArcGIS.Geoprocessing; |
|
using ESRI.ArcGIS.Geoprocessor; |
|
//using IDEParameter; |
|
using KGIS.Framework.AE; |
|
using KGIS.Framework.AE.Enum; |
|
using KGIS.Framework.AE.GPHelper; |
|
using Kingo.PluginServiceInterface; |
|
//using KGIS.Framework.AE.GPHelper; |
|
using Kingo.PluginServiceInterface.Model; |
|
using System; |
|
using System.Collections.Generic; |
|
using System.IO; |
|
using System.Linq; |
|
using System.Runtime.InteropServices; |
|
using System.Text; |
|
using System.Threading.Tasks; |
|
|
|
namespace IDGForNDBG |
|
{ |
|
public class BaseIDG |
|
{ |
|
//private IFeatureLayer jCLayer; |
|
//private IFeatureLayer gXLayer; |
|
internal IFeatureLayer _jcTbLayer; |
|
internal IFeatureLayer _gxgcTBLayer; |
|
internal IFeatureLayer _gxTbLayer; |
|
internal IFeatureLayer _bgTbLayer; |
|
internal IFeatureLayer _jcCjdcqLayer; |
|
internal IFeatureLayer _jcCjdcqJxLayer; |
|
internal IFeatureLayer _gxCjdcqLayer; |
|
internal IFeatureLayer _gxgcCjdcqLayer; |
|
internal IFeatureLayer _gxCjdcqJxLayer; |
|
internal IFeatureLayer _jcXzqLayer; |
|
internal IFeatureLayer _jcXzqJxLayer; |
|
internal IFeatureLayer _gxXzqLayer; |
|
internal IFeatureLayer _gxgcXzqLayer; |
|
internal IFeatureLayer _gxXzqJxLayer; |
|
internal IFeatureLayer _jcCzcLayer; |
|
internal IFeatureLayer _gxCzcLayer; |
|
internal IFeatureLayer _gxgcCzcLayer; |
|
internal IFeatureLayer _jcGddbLayer; |
|
internal IFeatureLayer _gxGddbLayer; |
|
internal IFeatureLayer _jcPdtLayer; |
|
internal IFeatureLayer _gxPdtLayer; |
|
internal IFeatureLayer _nmTbLayer; |
|
|
|
public IWorkspaceAPI BgWsAPI { get; set; } |
|
public Dictionary<string, IWorkspaceAPI> DicWsAPI { get; set; } |
|
public IWorkspaceAPI ZlWsAPI { get; set; } |
|
public IWorkspaceAPI NmWsAPI { get; set; } |
|
//public IFeatureLayer JCLayer { get => jCLayer; set => jCLayer = value; } |
|
//public IFeatureLayer GXLayer { get => gXLayer; set => gXLayer = value; } |
|
public IFeatureLayer NmTbLayer { get => _nmTbLayer; set => _nmTbLayer = value; } |
|
#region 地类图斑 |
|
public IFeatureLayer JcTbLayer { get => _jcTbLayer; } |
|
public IFeatureLayer JcPdtLayer { get => _jcPdtLayer; } |
|
public IFeatureLayer GxgcTBLayer { get => _gxgcTBLayer; } |
|
public IFeatureLayer GxTbLayer { get => _gxTbLayer; } |
|
public IFeatureLayer GxPdtLayer { get => _gxPdtLayer; } |
|
public IFeatureLayer BgTbLayer { get => _bgTbLayer; } |
|
#endregion |
|
|
|
#region 村级调查区 |
|
public IFeatureLayer JcCjdcqLayer { get => _jcCjdcqLayer; set => _jcCjdcqLayer = value; } |
|
public IFeatureLayer JcCjdcqJxLayer { get => _jcCjdcqJxLayer; } |
|
public IFeatureLayer GxCjdcqLayer { get => _gxCjdcqLayer; } |
|
public IFeatureLayer GxgcCjdcqLayer { get => _gxgcCjdcqLayer; } |
|
public IFeatureLayer GxCjdcqJxLayer { get => _gxCjdcqJxLayer; } |
|
#endregion |
|
|
|
#region 行政区 |
|
public IFeatureLayer JcXzqLayer { get => _jcXzqLayer; set => _jcXzqLayer = value; } |
|
public IFeatureLayer JcXzqJxLayer { get => _jcXzqJxLayer; } |
|
public IFeatureLayer GxXzqLayer { get => _gxXzqLayer; } |
|
public IFeatureLayer GxgcXzqLayer { get => _gxgcXzqLayer; } |
|
public IFeatureLayer GxXzqJxLayer { get => _gxXzqJxLayer; } |
|
#endregion |
|
|
|
#region 城镇村 |
|
public IFeatureLayer JcCzcLayer { get => _jcCzcLayer; } |
|
public IFeatureLayer GxCzcLayer { get => _gxCzcLayer; } |
|
public IFeatureLayer GxgcCzcLayer { get => _gxgcCzcLayer; } |
|
#endregion |
|
|
|
#region 耕地等别 |
|
public IFeatureLayer JcGddbLayer { get => _jcGddbLayer; } |
|
public IFeatureLayer GxGddbLayer { get => _gxGddbLayer; } |
|
#endregion |
|
public virtual void CreateNMK2(IDGParameter parm) |
|
{ |
|
try |
|
{ |
|
//GeoprocessorHelper gpHelper = new GeoprocessorHelper(); |
|
//string path = Path.Combine(parm.PrjInfo.ProjDir, "NMDB" + ".gdb"); |
|
|
|
//FileInfo fileInfo = new FileInfo(parm.PrjInfo.BGDatabase); |
|
//string path = Path.Combine(fileInfo.DirectoryName, "NMDB" + ".gdb"); |
|
//if (JcTbLayer == null || GxTbLayer == null) |
|
// OpenDB(parm); |
|
IFeatureLayer TempNMKLayer = null; |
|
GPParamClass gPParamClass = new GPParamClass(); |
|
gPParamClass.FirstFeatureLayer = JcTbLayer;//基础地类图斑要素类 |
|
gPParamClass.SecondFeatureLayer = GxTbLayer;//地类图斑更新要素类 |
|
gPParamClass.OutFeatureClassPath = parm.PrjInfo.NMDatabase + "\\" + "DLTB_NMK";//要添加的要素类图层 |
|
gPParamClass.IsGetOutPutFeature = true;//是否获取GP工具生成后的图层 |
|
gPParamClass.GPType = EnumGPType.Erase; |
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref TempNMKLayer);//擦除/相减分析 |
|
IFeatureClassAPI fcAPI = new FeatureClassAPI(TempNMKLayer.FeatureClass); |
|
fcAPI.AddField("XZQDM", esriFieldType.esriFieldTypeString, "行政区代码"); |
|
fcAPI.AddField("XZQTZLX", esriFieldType.esriFieldTypeInteger, "行政区调整类型"); |
|
//fcAPI.FcToFc(NMKLayer.FeatureClass, null, false); |
|
fcAPI = new FeatureClassAPI(GxTbLayer.FeatureClass); |
|
fcAPI.FcToFc(TempNMKLayer.FeatureClass, null, false); |
|
|
|
ITable nmkTable = TempNMKLayer.FeatureClass as ITable; |
|
//更新后年末库 |
|
ICursor nmkCur = nmkTable.Update(null, true); |
|
IRow nmkRow = null; |
|
int bsmIdx = nmkTable.FindField("BSM"); |
|
int zldwIdx = nmkTable.FindField("ZLDWDM"); |
|
int xzqdmIdx = nmkTable.FindField("XZQDM"); |
|
int XZQTZLXmIdx = nmkTable.FindField("XZQTZLX"); |
|
int HDMCIdx = nmkTable.FindField("HDMC"); |
|
while ((nmkRow = nmkCur.NextRow()) != null) |
|
{ |
|
//string bsm = nmkRow.Value[bsmIdx].ToTrim(); |
|
//if (hcbghbsm.Contains(bsm)) |
|
//{ |
|
// nmkRow.Value[XZQTZLXmIdx] = 2; |
|
//} |
|
//else if (msbghbsm.Contains(bsm)) |
|
//{ |
|
// nmkRow.Value[XZQTZLXmIdx] = 4; |
|
//} |
|
//else if (msbgqbsm.Contains(bsm) && !bghbsmDic.ContainsKey(bsm)) |
|
//{ |
|
// nmkRow.Value[XZQTZLXmIdx] = 4; |
|
//} |
|
//if (bhxxDic.ContainsKey(bsm)) |
|
//{ |
|
// for (int i = 0; i < nmkRow.Fields.FieldCount; i++) |
|
// { |
|
// IField field = nmkRow.Fields.Field[i]; |
|
// string bghField = "BGH" + field.Name; |
|
// DataRow dr = bhxxDic[bsm]; |
|
// if (!dr.Table.Columns.Contains(bghField)) |
|
// bghField = "BGHTB" + field.Name; |
|
// if (dr.Table.Columns.Contains(bghField)) |
|
// { |
|
// if (field.Type == esriFieldType.esriFieldTypeString) |
|
// { |
|
// nmkRow.Value[i] = msbghbsm.Contains(bsm) ? "" : dr[bghField]; |
|
// } |
|
// else if (field.Type == esriFieldType.esriFieldTypeDouble) |
|
// { |
|
// nmkRow.Value[i] = msbghbsm.Contains(bsm) ? 0 : dr[bghField].ToDouble(); |
|
// } |
|
// } |
|
// } |
|
//} |
|
if (zldwIdx != -1 && xzqdmIdx != -1) |
|
{ |
|
string zldwdm = nmkRow.Value[zldwIdx].ToTrim(); |
|
if (!string.IsNullOrWhiteSpace(zldwdm) && zldwdm.Length > 9) |
|
{ |
|
nmkRow.Value[xzqdmIdx] = zldwdm.Substring(0, 9); |
|
} |
|
} |
|
if (HDMCIdx != -1) |
|
nmkRow.Value[HDMCIdx] = nmkRow.Value[HDMCIdx].ToString().ToTrim() == "" ? "" : nmkRow.Value[HDMCIdx].ToString().ToTrim(); |
|
nmkCur.UpdateRow(nmkRow); |
|
} |
|
nmkCur.Flush(); |
|
nmkTable.DeleteSearchedRows(new QueryFilterClass() { WhereClause = "XZQTZLX=4 or XZQTZLX=2" }); |
|
_nmTbLayer = TempNMKLayer; |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw ex; |
|
} |
|
} |
|
|
|
public void SetJcCzcLayer(IFeatureLayer pLayer) |
|
{ |
|
_jcCzcLayer = pLayer; |
|
} |
|
public virtual void CreateNMK(IDGParameter parm) |
|
{ |
|
IFeatureCursor _cursor = null; |
|
try |
|
{ |
|
//GeoprocessorHelper gpHelper = new GeoprocessorHelper(); |
|
//string path = Path.Combine(parm.PrjInfo.ProjDir, "NMDB" + ".gdb"); |
|
|
|
//FileInfo fileInfo = new FileInfo(parm.PrjInfo.BGDatabase); |
|
//string path = Path.Combine(fileInfo.DirectoryName, "NMDB" + ".gdb"); |
|
//if (JcTbLayer == null || GxTbLayer == null) |
|
// OpenDB(parm); |
|
IFeatureLayer TempNMKLayer = null; |
|
GPParamClass gPParamClass = new GPParamClass(); |
|
gPParamClass.FirstFeatureLayer = JcTbLayer;//基础地类图斑要素类 |
|
//gPParamClass.SecondFeatureLayer = GxTbLayer;//地类图斑更新要素类 |
|
gPParamClass.OutFeatureClassPath = parm.PrjInfo.NMDatabase;// + "\\" + "DLTB_NMK";//要添加的要素类图层 |
|
gPParamClass.IsGetOutPutFeature = true;//是否获取GP工具生成后的图层 |
|
gPParamClass.GPType = EnumGPType.FcToFc; |
|
gPParamClass.FcName = "DLTB_NMK"; |
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref TempNMKLayer);//擦除/相减分析 |
|
|
|
_cursor = GxgcTBLayer.FeatureClass.Search(new QueryFilterClass() { SubFields = "BGQTBBSM" }, true); |
|
Dictionary<string, int> DicJcBSMs = new Dictionary<string, int>(); |
|
IFeature f = null; |
|
int idx = GxgcTBLayer.FeatureClass.FindField("BGQTBBSM"); |
|
if (idx == -1) return; |
|
while ((f = _cursor.NextFeature()) != null) |
|
{ |
|
string jcbsm = f.Value[idx].ToTrim(); |
|
if (!DicJcBSMs.ContainsKey(jcbsm)) |
|
DicJcBSMs.Add(jcbsm, 0); |
|
} |
|
_cursor = TempNMKLayer.FeatureClass.Update(null, true); |
|
idx = TempNMKLayer.FeatureClass.FindField("BSM"); |
|
if (idx == -1) return; |
|
while ((f = _cursor.NextFeature()) != null) |
|
{ |
|
string bsm = f.Value[idx].ToTrim(); |
|
if (DicJcBSMs.ContainsKey(bsm)) |
|
{ |
|
f.Value[idx] = "-1"; |
|
_cursor.UpdateFeature(f); |
|
} |
|
} |
|
_cursor.Flush(); |
|
(TempNMKLayer.FeatureClass as ITable).DeleteSearchedRows(new QueryFilterClass() { WhereClause = "BSM = '-1'" }); |
|
IFeatureClassAPI fcAPI = new FeatureClassAPI(GxTbLayer.FeatureClass); |
|
fcAPI.FcToFc(TempNMKLayer.FeatureClass, null, false); |
|
|
|
fcAPI = new FeatureClassAPI(TempNMKLayer.FeatureClass); |
|
fcAPI.AddField("XZQDM", esriFieldType.esriFieldTypeString, "行政区代码"); |
|
fcAPI.AddField("XZQTZLX", esriFieldType.esriFieldTypeInteger, "行政区调整类型"); |
|
////fcAPI.FcToFc(NMKLayer.FeatureClass, null, false); |
|
//fcAPI = new FeatureClassAPI(GxTbLayer.FeatureClass); |
|
//fcAPI.FcToFc(TempNMKLayer.FeatureClass, null, false); |
|
|
|
ITable nmkTable = TempNMKLayer.FeatureClass as ITable; |
|
//更新后年末库 |
|
ICursor nmkCur = nmkTable.Update(null, true); |
|
IRow nmkRow = null; |
|
int bsmIdx = nmkTable.FindField("BSM"); |
|
int zldwIdx = nmkTable.FindField("ZLDWDM"); |
|
int xzqdmIdx = nmkTable.FindField("XZQDM"); |
|
int XZQTZLXmIdx = nmkTable.FindField("XZQTZLX"); |
|
int HDMCIdx = nmkTable.FindField("HDMC"); |
|
while ((nmkRow = nmkCur.NextRow()) != null) |
|
{ |
|
//string bsm = nmkRow.Value[bsmIdx].ToTrim(); |
|
//if (hcbghbsm.Contains(bsm)) |
|
//{ |
|
// nmkRow.Value[XZQTZLXmIdx] = 2; |
|
//} |
|
//else if (msbghbsm.Contains(bsm)) |
|
//{ |
|
// nmkRow.Value[XZQTZLXmIdx] = 4; |
|
//} |
|
//else if (msbgqbsm.Contains(bsm) && !bghbsmDic.ContainsKey(bsm)) |
|
//{ |
|
// nmkRow.Value[XZQTZLXmIdx] = 4; |
|
//} |
|
//if (bhxxDic.ContainsKey(bsm)) |
|
//{ |
|
// for (int i = 0; i < nmkRow.Fields.FieldCount; i++) |
|
// { |
|
// IField field = nmkRow.Fields.Field[i]; |
|
// string bghField = "BGH" + field.Name; |
|
// DataRow dr = bhxxDic[bsm]; |
|
// if (!dr.Table.Columns.Contains(bghField)) |
|
// bghField = "BGHTB" + field.Name; |
|
// if (dr.Table.Columns.Contains(bghField)) |
|
// { |
|
// if (field.Type == esriFieldType.esriFieldTypeString) |
|
// { |
|
// nmkRow.Value[i] = msbghbsm.Contains(bsm) ? "" : dr[bghField]; |
|
// } |
|
// else if (field.Type == esriFieldType.esriFieldTypeDouble) |
|
// { |
|
// nmkRow.Value[i] = msbghbsm.Contains(bsm) ? 0 : dr[bghField].ToDouble(); |
|
// } |
|
// } |
|
// } |
|
//} |
|
if (zldwIdx != -1 && xzqdmIdx != -1) |
|
{ |
|
string zldwdm = nmkRow.Value[zldwIdx].ToTrim(); |
|
if (!string.IsNullOrWhiteSpace(zldwdm) && zldwdm.Length > 9) |
|
{ |
|
nmkRow.Value[xzqdmIdx] = zldwdm.Substring(0, 9); |
|
} |
|
} |
|
if (HDMCIdx != -1) |
|
nmkRow.Value[HDMCIdx] = nmkRow.Value[HDMCIdx].ToString().ToTrim() == "" ? "" : nmkRow.Value[HDMCIdx].ToString().ToTrim(); |
|
nmkCur.UpdateRow(nmkRow); |
|
} |
|
nmkCur.Flush(); |
|
//nmkTable.DeleteSearchedRows(new QueryFilterClass() { WhereClause = "XZQTZLX=4 or XZQTZLX=2" }); |
|
_nmTbLayer = TempNMKLayer; |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw ex; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 生成年末库图层-GP创建年末库图层 |
|
/// </summary> |
|
/// <param name="parm"></param> |
|
public virtual void CreateNMK3(DBLayerSourceHelper pLayerSource) |
|
{ |
|
IFeatureCursor _cursor = null; |
|
try |
|
{ |
|
//GeoprocessorHelper gpHelper = new GeoprocessorHelper(); |
|
//string path = Path.Combine(parm.PrjInfo.ProjDir, "NMDB" + ".gdb"); |
|
|
|
//FileInfo fileInfo = new FileInfo(parm.PrjInfo.BGDatabase); |
|
//string path = Path.Combine(fileInfo.DirectoryName, "NMDB" + ".gdb"); |
|
//if (JcTbLayer == null || GxTbLayer == null) |
|
// OpenDB(parm); |
|
IFeatureLayer TempNMKLayer = null; |
|
GPParamClass gPParamClass = new GPParamClass(); |
|
gPParamClass.FirstFeatureLayer = pLayerSource.JcTbLayer;//基础地类图斑要素类 |
|
//gPParamClass.SecondFeatureLayer = GxTbLayer;//地类图斑更新要素类 |
|
gPParamClass.OutFeatureClassPath = pLayerSource.NmWsAPI.CurrentWorkspace.PathName;// + "\\" + "DLTB_NMK";//要添加的要素类图层 |
|
gPParamClass.IsGetOutPutFeature = true;//是否获取GP工具生成后的图层 |
|
gPParamClass.GPType = EnumGPType.FcToFc; |
|
gPParamClass.FcName = "DLTB_NMK"; |
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref TempNMKLayer);//擦除/相减分析 |
|
|
|
_cursor = pLayerSource.GxgcTBLayer.FeatureClass.Search(new QueryFilterClass() { SubFields = "BGQTBBSM" }, true); |
|
Dictionary<string, int> DicJcBSMs = new Dictionary<string, int>(); |
|
IFeature f = null; |
|
int idx = pLayerSource.GxgcTBLayer.FeatureClass.FindField("BGQTBBSM"); |
|
if (idx == -1) return; |
|
while ((f = _cursor.NextFeature()) != null) |
|
{ |
|
string jcbsm = f.Value[idx].ToTrim(); |
|
if (!DicJcBSMs.ContainsKey(jcbsm)) |
|
DicJcBSMs.Add(jcbsm, 0); |
|
} |
|
_cursor = TempNMKLayer.FeatureClass.Update(null, true); |
|
idx = TempNMKLayer.FeatureClass.FindField("BSM"); |
|
if (idx == -1) return; |
|
while ((f = _cursor.NextFeature()) != null) |
|
{ |
|
string bsm = f.Value[idx].ToTrim(); |
|
if (DicJcBSMs.ContainsKey(bsm)) |
|
{ |
|
f.Value[idx] = "-1"; |
|
_cursor.UpdateFeature(f); |
|
} |
|
} |
|
_cursor.Flush(); |
|
(TempNMKLayer.FeatureClass as ITable).DeleteSearchedRows(new QueryFilterClass() { WhereClause = "BSM = '-1'" }); |
|
IFeatureClassAPI fcAPI = new FeatureClassAPI(pLayerSource.GxTbLayer.FeatureClass); |
|
fcAPI.FcToFc(TempNMKLayer.FeatureClass, null, false); |
|
|
|
fcAPI = new FeatureClassAPI(TempNMKLayer.FeatureClass); |
|
fcAPI.AddField("XZQDM", esriFieldType.esriFieldTypeString, "行政区代码"); |
|
fcAPI.AddField("XZQTZLX", esriFieldType.esriFieldTypeInteger, "行政区调整类型"); |
|
////fcAPI.FcToFc(NMKLayer.FeatureClass, null, false); |
|
//fcAPI = new FeatureClassAPI(pLayerSource.GxTbLayer.FeatureClass); |
|
//fcAPI.FcToFc(TempNMKLayer.FeatureClass, null, false); |
|
|
|
ITable nmkTable = TempNMKLayer.FeatureClass as ITable; |
|
//更新后年末库 |
|
ICursor nmkCur = nmkTable.Update(null, true); |
|
IRow nmkRow = null; |
|
int bsmIdx = nmkTable.FindField("BSM"); |
|
int zldwIdx = nmkTable.FindField("ZLDWDM"); |
|
int xzqdmIdx = nmkTable.FindField("XZQDM"); |
|
int XZQTZLXmIdx = nmkTable.FindField("XZQTZLX"); |
|
int HDMCIdx = nmkTable.FindField("HDMC"); |
|
while ((nmkRow = nmkCur.NextRow()) != null) |
|
{ |
|
//string bsm = nmkRow.Value[bsmIdx].ToTrim(); |
|
//if (hcbghbsm.Contains(bsm)) |
|
//{ |
|
// nmkRow.Value[XZQTZLXmIdx] = 2; |
|
//} |
|
//else if (msbghbsm.Contains(bsm)) |
|
//{ |
|
// nmkRow.Value[XZQTZLXmIdx] = 4; |
|
//} |
|
//else if (msbgqbsm.Contains(bsm) && !bghbsmDic.ContainsKey(bsm)) |
|
//{ |
|
// nmkRow.Value[XZQTZLXmIdx] = 4; |
|
//} |
|
//if (bhxxDic.ContainsKey(bsm)) |
|
//{ |
|
// for (int i = 0; i < nmkRow.Fields.FieldCount; i++) |
|
// { |
|
// IField field = nmkRow.Fields.Field[i]; |
|
// string bghField = "BGH" + field.Name; |
|
// DataRow dr = bhxxDic[bsm]; |
|
// if (!dr.Table.Columns.Contains(bghField)) |
|
// bghField = "BGHTB" + field.Name; |
|
// if (dr.Table.Columns.Contains(bghField)) |
|
// { |
|
// if (field.Type == esriFieldType.esriFieldTypeString) |
|
// { |
|
// nmkRow.Value[i] = msbghbsm.Contains(bsm) ? "" : dr[bghField]; |
|
// } |
|
// else if (field.Type == esriFieldType.esriFieldTypeDouble) |
|
// { |
|
// nmkRow.Value[i] = msbghbsm.Contains(bsm) ? 0 : dr[bghField].ToDouble(); |
|
// } |
|
// } |
|
// } |
|
//} |
|
if (zldwIdx != -1 && xzqdmIdx != -1) |
|
{ |
|
string zldwdm = nmkRow.Value[zldwIdx].ToTrim(); |
|
if (!string.IsNullOrWhiteSpace(zldwdm) && zldwdm.Length > 9) |
|
{ |
|
nmkRow.Value[xzqdmIdx] = zldwdm.Substring(0, 9); |
|
} |
|
} |
|
if (HDMCIdx != -1) |
|
nmkRow.Value[HDMCIdx] = nmkRow.Value[HDMCIdx].ToString().ToTrim() == "" ? "" : nmkRow.Value[HDMCIdx].ToString().ToTrim(); |
|
nmkCur.UpdateRow(nmkRow); |
|
} |
|
nmkCur.Flush(); |
|
//nmkTable.DeleteSearchedRows(new QueryFilterClass() { WhereClause = "XZQTZLX=4 or XZQTZLX=2" }); |
|
_nmTbLayer = TempNMKLayer; |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw ex; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 生成年末库数据(BUG:新增 年末库 图层) |
|
/// </summary> |
|
/// <param name="parm"></param> |
|
public virtual void CreateNMK(DBLayerSourceHelper pLayerSource) |
|
{ |
|
IFeatureCursor _cursor = null; |
|
try |
|
{ |
|
(pLayerSource.NmTbLayer.FeatureClass as ITable).DeleteSearchedRows(null); |
|
IFeatureClassAPI featureClassAPI = new FeatureClassAPI(pLayerSource.JcTbLayer.FeatureClass); |
|
featureClassAPI.FcToFc(pLayerSource.NmTbLayer.FeatureClass, null, false); |
|
|
|
_cursor = pLayerSource.GxgcTBLayer.FeatureClass.Search(new QueryFilterClass() { SubFields = "BGQTBBSM" }, true); |
|
Dictionary<string, int> DicJcBSMs = new Dictionary<string, int>(); |
|
IFeature f = null; |
|
int idx = pLayerSource.GxgcTBLayer.FeatureClass.FindField("BGQTBBSM"); |
|
if (idx == -1) return; |
|
while ((f = _cursor.NextFeature()) != null) |
|
{ |
|
string jcbsm = f.Value[idx].ToTrim(); |
|
if (!DicJcBSMs.ContainsKey(jcbsm)) |
|
DicJcBSMs.Add(jcbsm, 0); |
|
} |
|
_cursor = pLayerSource.NmTbLayer.FeatureClass.Update(null, true); |
|
idx = pLayerSource.NmTbLayer.FeatureClass.FindField("BSM"); |
|
if (idx == -1) return; |
|
while ((f = _cursor.NextFeature()) != null) |
|
{ |
|
string bsm = f.Value[idx].ToTrim(); |
|
if (DicJcBSMs.ContainsKey(bsm)) |
|
{ |
|
f.Value[idx] = "-1"; |
|
_cursor.UpdateFeature(f); |
|
} |
|
} |
|
_cursor.Flush(); |
|
(pLayerSource.NmTbLayer.FeatureClass as ITable).DeleteSearchedRows(new QueryFilterClass() { WhereClause = "BSM = '-1'" }); |
|
IFeatureClassAPI fcAPI = new FeatureClassAPI(pLayerSource.GxTbLayer.FeatureClass); |
|
fcAPI.FcToFc(pLayerSource.NmTbLayer.FeatureClass, null, false); |
|
|
|
ITable nmkTable = pLayerSource.NmTbLayer.FeatureClass as ITable; |
|
//更新后年末库 |
|
ICursor nmkCur = nmkTable.Update(null, true); |
|
IRow nmkRow = null; |
|
int bsmIdx = nmkTable.FindField("BSM"); |
|
int zldwIdx = nmkTable.FindField("ZLDWDM"); |
|
int xzqdmIdx = nmkTable.FindField("XZQDM"); |
|
int XZQTZLXmIdx = nmkTable.FindField("XZQTZLX"); |
|
int HDMCIdx = nmkTable.FindField("HDMC"); |
|
while ((nmkRow = nmkCur.NextRow()) != null) |
|
{ |
|
if (zldwIdx != -1 && xzqdmIdx != -1) |
|
{ |
|
string zldwdm = nmkRow.Value[zldwIdx].ToTrim(); |
|
if (!string.IsNullOrWhiteSpace(zldwdm) && zldwdm.Length > 9) |
|
{ |
|
nmkRow.Value[xzqdmIdx] = zldwdm.Substring(0, 9); |
|
} |
|
} |
|
if (HDMCIdx != -1) |
|
nmkRow.Value[HDMCIdx] = nmkRow.Value[HDMCIdx].ToString().ToTrim() == "" ? "" : nmkRow.Value[HDMCIdx].ToString().ToTrim(); |
|
nmkCur.UpdateRow(nmkRow); |
|
} |
|
nmkCur.Flush(); |
|
_nmTbLayer = pLayerSource.NmTbLayer; |
|
} |
|
catch (Exception ex) |
|
{ |
|
Console.WriteLine("Err:地类图斑数据提取-生成年末库数据异常!" + ex.Message); |
|
Console.WriteLine("Err:地类图斑数据提取-生成年末库数据异常!" + ex.StackTrace); |
|
throw ex; |
|
} |
|
} |
|
|
|
//public virtual void OpenDB(IDGParameter3 parm) |
|
//{ |
|
// IFeatureClassAPI BgTBFcAPI = null; |
|
// IFeatureClassAPI JcTBFcAPI = null; |
|
// IFeatureClassAPI GxTBFcAPI = null; |
|
// IFeatureClassAPI GxGcTBFcAPI = null; |
|
// GPParamClass paramClass = null;// new GPParamClass(); |
|
// //GeoprocessorHelper gpHelper = new GeoprocessorHelper(); |
|
// try |
|
// { |
|
// BgWsAPI = new WorkspaceAPI(parm.BgDbPath, WorkspaceTypeEnum.GDBFile); |
|
// if (BgWsAPI.CurrentWorkspace == null) |
|
// { |
|
// Console.WriteLine("打开变更数据库失败!"); |
|
// return; |
|
// } |
|
// JcWsAPI = new WorkspaceAPI(parm.JcDbPath, WorkspaceTypeEnum.GDBFile); |
|
// if (JcWsAPI.CurrentWorkspace == null) |
|
// { |
|
// Console.WriteLine("打开基础数据库失败!"); |
|
// return; |
|
// } |
|
// ZlWsAPI = new WorkspaceAPI(parm.ZLDbPath, WorkspaceTypeEnum.GDBFile); |
|
// if (ZlWsAPI.CurrentWorkspace == null) |
|
// { |
|
// Console.WriteLine("打开增量数据库失败!"); |
|
// return; |
|
// } |
|
// NmWsAPI = new WorkspaceAPI(parm.NmDbPath, WorkspaceTypeEnum.GDBFile); |
|
|
|
// BgTBFcAPI = BgWsAPI.OpenFeatureClass("DLTBBG"); |
|
// JcTBFcAPI = JcWsAPI.OpenFeatureClass("DLTB"); |
|
// GxTBFcAPI = ZlWsAPI.OpenFeatureClass("DLTBGX"); |
|
// GxGcTBFcAPI = ZlWsAPI.OpenFeatureClass("DLTBGXGC"); |
|
|
|
// if (JcTBFcAPI.FeatureClass != null) |
|
// { |
|
// //paramClass = new GPParamClass(); |
|
// //paramClass.FirstFeatureClass = JcTBFcAPI.FeatureClass; |
|
// //paramClass.OutFeatureClassPath = "DLTB"; |
|
// //paramClass.IsGetOutPutFeature = true; |
|
// //gpHelper.MakeFeatureLayer(paramClass, ref jCLayer); |
|
|
|
// jCLayer = new FeatureLayerClass(); |
|
// jCLayer.FeatureClass = JcTBFcAPI.FeatureClass; |
|
// jCLayer.Name = JcTBFcAPI.FeatureClass.AliasName; |
|
// } |
|
// if (GxTBFcAPI.FeatureClass != null) |
|
// { |
|
// //paramClass = new GPParamClass(); |
|
// //paramClass.FirstFeatureClass = GxTBFcAPI.FeatureClass; |
|
// //paramClass.OutFeatureClassPath = "DLTBGX"; |
|
// //paramClass.IsGetOutPutFeature = true; |
|
// //gpHelper.MakeFeatureLayer(paramClass, ref gXLayer); |
|
|
|
// gXLayer = new FeatureLayerClass(); |
|
// gXLayer.FeatureClass = GxTBFcAPI.FeatureClass; |
|
// gXLayer.Name = GxTBFcAPI.FeatureClass.AliasName; |
|
// } |
|
// } |
|
// catch (Exception ex) |
|
// { |
|
// throw ex; |
|
// } |
|
//} |
|
|
|
//public virtual 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 = 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 = 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"); |
|
|
|
// } |
|
// if (parm.ExeCJDCQ) |
|
// { |
|
// LayerCfg _JcCjdcqLayerInfo = NcList.FirstOrDefault(f => f.LayerName == "村级调查区"); |
|
// _jcCjdcqLayer = OpenLayer(_JcCjdcqLayerInfo); |
|
// if (_jcCjdcqLayer == null) |
|
// throw new Exception("Err:获取年初村级调查区数据失败!"); |
|
// LayerCfg _JcCjdcqJxLayerInfo = NcList.FirstOrDefault(f => f.LayerName == "村级调查区界线"); |
|
// _jcCjdcqJxLayer = OpenLayer(_JcCjdcqJxLayerInfo); |
|
// if (_JcCjdcqJxLayerInfo == null) |
|
// throw new Exception("Err:获取年初村级调查区界线数据失败!"); |
|
// _gxCjdcqLayer = OpenLayer(ZlWsAPI, "CJDCQGX"); |
|
// _gxgcCjdcqLayer = OpenLayer(ZlWsAPI, "CJDCQGXGC"); |
|
// _gxCjdcqJxLayer = OpenLayer(ZlWsAPI, "CJDCQJXGX"); |
|
// _gxgcTBLayer = OpenLayer(ZlWsAPI, "DLTBGXGC"); |
|
// } |
|
// if (parm.ExeXZQ) |
|
// { |
|
// LayerCfg _JcXzqLayerInfo = NcList.FirstOrDefault(f => f.LayerName == "行政区"); |
|
// _jcXzqLayer = OpenLayer(_JcXzqLayerInfo); |
|
// if (_JcXzqLayerInfo == null) |
|
// throw new Exception("Err:获取年初行政区数据失败!"); |
|
// LayerCfg _JcXzqJxLayerInfo = NcList.FirstOrDefault(f => f.LayerName == "行政区界线"); |
|
// _jcXzqJxLayer = OpenLayer(_JcXzqJxLayerInfo); |
|
// if (_JcXzqJxLayerInfo == null) |
|
// throw new Exception("Err:获取年初行政区界线数据失败!"); |
|
// _gxXzqLayer = OpenLayer(ZlWsAPI, "XZQGX"); |
|
// _gxgcXzqLayer = OpenLayer(ZlWsAPI, "XZQGXGC"); |
|
// _gxXzqJxLayer = OpenLayer(ZlWsAPI, "XZQJXGX"); |
|
// _gxgcTBLayer = OpenLayer(ZlWsAPI, "DLTBGXGC"); |
|
// //if (_nmTbLayer != null) |
|
// // _nmTbLayer = OpenLayer(NmWsAPI, "DLTB_NMK"); |
|
// } |
|
// if (parm.ExeCZC) |
|
// { |
|
// LayerCfg _JcCzcLayerInfo = NcList.FirstOrDefault(f => f.LayerName == "城镇村等用地"); |
|
// _jcCzcLayer = OpenLayer(_JcCzcLayerInfo); |
|
// if (_JcCzcLayerInfo == null) |
|
// throw new Exception("Err:获取年初城镇村等用地数据失败!"); |
|
// //if (_nmTbLayer != null) |
|
// // _nmTbLayer = OpenLayer(NmWsAPI, "DLTB_NMK"); |
|
// _gxCzcLayer = OpenLayer(ZlWsAPI, "CZCDYDGX"); |
|
// _gxgcCzcLayer = OpenLayer(ZlWsAPI, "CZCDYDGXGC"); |
|
// } |
|
// if (parm.ExeGDDB) |
|
// { |
|
// LayerCfg _JcGddbLayerInfo = NcList.FirstOrDefault(f => f.LayerName == "耕地等别"); |
|
// _jcGddbLayer = OpenLayer(_JcGddbLayerInfo); |
|
// if (_JcGddbLayerInfo == null) |
|
// throw new Exception("Err:获取年初耕地等别数据失败!"); |
|
// //if (_nmTbLayer != null) |
|
// // _nmTbLayer = OpenLayer(NmWsAPI, "DLTB_NMK"); |
|
// _gxGddbLayer = OpenLayer(ZlWsAPI, "GDDBGX"); |
|
|
|
// } |
|
// } |
|
// catch (Exception ex) |
|
// { |
|
// throw ex; |
|
// } |
|
//} |
|
internal IFeatureLayer OpenLayer(LayerCfg pLayerInfo) |
|
{ |
|
if (pLayerInfo == null) |
|
return null; |
|
if (string.IsNullOrWhiteSpace(pLayerInfo.FcPath) || string.IsNullOrWhiteSpace(pLayerInfo.FcName)) |
|
return null; |
|
if (!File.Exists(pLayerInfo.FcPath) && !Directory.Exists(pLayerInfo.FcPath)) |
|
return null; |
|
FileInfo fInfo = new FileInfo(pLayerInfo.FcPath); |
|
WorkspaceTypeEnum wsType = WorkspaceTypeEnum.GDBFile; |
|
if (fInfo.FullName.EndsWith(".gdb")) |
|
wsType = WorkspaceTypeEnum.GDBFile; |
|
else if (fInfo.FullName.EndsWith(".mdb")) |
|
wsType = WorkspaceTypeEnum.MDBFile; |
|
else |
|
wsType = WorkspaceTypeEnum.ShapeFile; |
|
if (DicWsAPI == null) |
|
DicWsAPI = new Dictionary<string, IWorkspaceAPI>(); |
|
if (!DicWsAPI.ContainsKey(fInfo.FullName)) |
|
{ |
|
IWorkspaceAPI wsAPI = new WorkspaceAPI(fInfo.FullName, wsType); |
|
DicWsAPI.Add(fInfo.FullName, wsAPI); |
|
} |
|
IFeatureClassAPI fcAPI = DicWsAPI[fInfo.FullName].OpenFeatureClass(pLayerInfo.FcName); |
|
return new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass, Name = fcAPI.FeatureClass.AliasName }; |
|
} |
|
internal IFeatureLayer OpenLayer(IWorkspaceAPI pWsAPI, string pLayerName) |
|
{ |
|
try |
|
{ |
|
if (string.IsNullOrWhiteSpace(pLayerName)) |
|
return null; |
|
if (pWsAPI != null && pWsAPI.CurrentWorkspace != null) |
|
{ |
|
IFeatureClassAPI fcAPI = pWsAPI.OpenFeatureClass(pLayerName); |
|
return new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass, Name = fcAPI.FeatureClass.AliasName }; |
|
} |
|
return null; |
|
} |
|
catch (Exception ex) |
|
{ |
|
Console.WriteLine(string.Format("Err:{0}图层获取失败", pLayerName)); |
|
return null; |
|
} |
|
} |
|
|
|
public virtual string CreateTempDB(string pType, string pSubType = "") |
|
{ |
|
string result = string.Empty; |
|
try |
|
{ |
|
string dbPath = Path.Combine(Directory.GetCurrentDirectory(), "Temp" + ".db"); |
|
string gdbFolder = Directory.GetCurrentDirectory() + "\\Temp\\" + pType; |
|
if (!Directory.Exists(gdbFolder)) |
|
Directory.CreateDirectory(gdbFolder); |
|
try |
|
{ |
|
DelectDirect(gdbFolder); |
|
} |
|
catch |
|
{ |
|
//删除临时数据异常 不做处理 |
|
} |
|
|
|
IWorkspaceFactory pFtWsFct = new FileGDBWorkspaceFactory(); |
|
string gdbFileName = DateTime.Now.ToString("yyyyMMddHHmmssfff");// Guid.NewGuid().ToString().Replace("-", ""); |
|
string path = System.IO.Path.Combine(gdbFolder, string.IsNullOrWhiteSpace(pSubType) ? gdbFileName : pSubType); |
|
pFtWsFct.Create(path, "TempGDB", null, 0); |
|
if (!Directory.Exists(path)) |
|
{ |
|
Directory.CreateDirectory(path); |
|
} |
|
if (File.Exists(dbPath)) |
|
{ |
|
File.Copy(dbPath, Path.Combine(path, "Temp" + ".sqlite")); |
|
} |
|
else |
|
{ |
|
Console.WriteLine(string.Format("文件{0}不存在!", dbPath)); |
|
} |
|
result = path;// System.IO.Path.Combine(path, "TempGDB.gdb");//临时数据存放路径 |
|
} |
|
catch (Exception ex) |
|
{ |
|
Console.WriteLine("创建临时数据库失败!" + ex.Message); |
|
throw ex; |
|
} |
|
return result; |
|
} |
|
public virtual void DelectDirect(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; |
|
} |
|
} |
|
public bool DirectoryCopy(string sourceDir, string targetDirPath) |
|
{ |
|
try |
|
{ |
|
if (!Directory.Exists(sourceDir)) return false; |
|
string targetDir = targetDirPath + "\\" + System.IO.Path.GetFileName(sourceDir); |
|
if (!Directory.Exists(targetDir)) Directory.CreateDirectory(targetDir); |
|
// 文件及文件夹名称数组 |
|
string[] dirColl = Directory.GetDirectories(sourceDir); |
|
string[] fileColl = Directory.GetFiles(sourceDir); |
|
// 便利所有文件 |
|
if (fileColl.Length > 0) |
|
{ |
|
string fileName; |
|
foreach (string fileDir in fileColl) |
|
{ |
|
fileName = System.IO.Path.GetFileName(fileDir); |
|
File.Copy(sourceDir + "\\" + fileName, targetDir + "\\" + fileName, true); |
|
} |
|
} |
|
// 遍历所有文件夹 |
|
if (dirColl.Length > 0) |
|
{ |
|
string folderName; |
|
foreach (string dir in dirColl) |
|
{ |
|
folderName = System.IO.Path.GetFileName(dir); |
|
// 递归调用 |
|
Directory.CreateDirectory(targetDir + "\\" + folderName); |
|
DirectoryCopy(dir, targetDir + "\\" + folderName); |
|
} |
|
} |
|
return true; |
|
} |
|
catch (Exception ex) |
|
{ |
|
//LogAPI.Debug("新建工程页面中,文件夹复制时失败,异常原因: " + ex + " ; "); |
|
Console.WriteLine("行政区提取时,数据拷贝失败!"); |
|
return false; |
|
//throw; |
|
} |
|
} |
|
|
|
public string GetTime(DateTime timeA) |
|
{ |
|
//timeA 表示需要计算 |
|
DateTime timeB = DateTime.Now; //获取当前时间 |
|
TimeSpan ts = timeB - timeA; //计算时间差 |
|
//string time = ts.TotalSeconds.ToString(); //将时间差转换为秒 |
|
|
|
string str = ""; |
|
if (ts.Hours > 0) |
|
{ |
|
str = String.Format("{0:00}", ts.Hours) + ":" + String.Format("{0:00}", ts.Minutes) + ":" + String.Format("{0:00}", ts.Seconds); |
|
} |
|
if (ts.Hours == 0 && ts.Minutes > 0) |
|
{ |
|
str = "00:" + String.Format("{0:00}", ts.Minutes) + ":" + String.Format("{0:00}", ts.Seconds); |
|
} |
|
if (ts.Hours == 0 && ts.Minutes == 0) |
|
{ |
|
str = "00:00:" + String.Format("{0:00}", ts.Seconds); |
|
} |
|
return str; |
|
} |
|
public void MakeFeatureLayer(GPParamClass paramClass, ref IFeatureLayer pFeatureLayer) |
|
{ |
|
try |
|
{ |
|
lock (this) |
|
{ |
|
//融合 |
|
ESRI.ArcGIS.Geoprocessor.Geoprocessor geoprocessor = new Geoprocessor(); |
|
geoprocessor.OverwriteOutput = true; |
|
ESRI.ArcGIS.DataManagementTools.MakeFeatureLayer makeFly = new ESRI.ArcGIS.DataManagementTools.MakeFeatureLayer(); |
|
if (!string.IsNullOrWhiteSpace(paramClass.FirstFeatureClassPath)) |
|
{ |
|
makeFly.in_features = paramClass.FirstFeatureClassPath; |
|
} |
|
else if (paramClass.FirstFeatureClass != null) |
|
{ |
|
makeFly.in_features = paramClass.FirstFeatureClass; |
|
} |
|
else if (paramClass.FirstFeatureLayer != null) |
|
{ |
|
makeFly.in_features = paramClass.FirstFeatureLayer; |
|
} |
|
else |
|
{ |
|
throw new Exception("输入要素类参数为空!"); |
|
} |
|
makeFly.out_layer = paramClass.OutFeatureClassPath; |
|
IGeoProcessorResult tGeoResult = null; |
|
try |
|
{ |
|
tGeoResult = (IGeoProcessorResult)geoprocessor.Execute(makeFly, null); |
|
} |
|
catch (Exception) |
|
{ |
|
object sev = null; |
|
string message = geoprocessor.GetMessages(ref sev); |
|
throw new Exception(message); |
|
} |
|
if (paramClass.IsGetOutPutFeature && tGeoResult != null && tGeoResult.Status == ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded) |
|
{ |
|
pFeatureLayer = GetOutPutFeatureClass(tGeoResult); |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
//LogAPI.Debug("融合分析失败,原因: " + ex + " ; "); |
|
throw ex; |
|
} |
|
} |
|
public IFeatureLayer GetOutPutFeatureClass(IGeoProcessorResult tGeoResult) |
|
{ |
|
IGPUtilities pGPUtilities = new GPUtilitiesClass(); |
|
IFeatureClass pFeatureClass = null; |
|
IQueryFilter pQueryFilter = null; |
|
try |
|
{ |
|
pGPUtilities.DecodeFeatureLayer(tGeoResult.GetOutput(0), out pFeatureClass, out pQueryFilter); |
|
//int count = pFeatureClass.FeatureCount(null);//统计Feature对象个数 |
|
//郑英杰 2018-09-06 发现多余无用代码 |
|
//IFeatureCursor pCursor = pFeatureClass.Insert(true); //提取FeatureCursor对象 |
|
IFeatureLayer pFeatureLayer = new FeatureLayerClass(); |
|
pFeatureLayer.FeatureClass = pFeatureClass; |
|
pFeatureLayer.Name = pFeatureClass.AliasName; |
|
return pFeatureLayer; |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw new Exception("获取生成图层异常:" + ex.Message); |
|
} |
|
finally |
|
{ |
|
if (pQueryFilter != null) |
|
{ |
|
Marshal.ReleaseComObject(pQueryFilter); |
|
} |
|
} |
|
} |
|
} |
|
|
|
public class DBLayerSourceHelper |
|
{ |
|
public Dictionary<string, IWorkspaceAPI> DicWsAPI { get; set; } |
|
public IWorkspaceAPI BgWsAPI { get; set; } |
|
public IWorkspaceAPI ZlWsAPI { get; set; } |
|
public IWorkspaceAPI NmWsAPI { get; set; } |
|
//public IFeatureLayer JCLayer { get => jCLayer; set => jCLayer = value; } |
|
//public IFeatureLayer GXLayer { get => gXLayer; set => gXLayer = value; } |
|
public IFeatureLayer NmTbLayer { get; set; } |
|
#region 地类图斑 |
|
public IFeatureLayer JcTbLayer { get; set; } |
|
public IFeatureLayer JcPdtLayer { get; set; } |
|
public IFeatureLayer GxgcTBLayer { get; set; } |
|
public IFeatureLayer GxTbLayer { get; set; } |
|
public IFeatureLayer GxPdtLayer { get; set; } |
|
public IFeatureLayer BgTbLayer { get; set; } |
|
#endregion |
|
|
|
#region 村级调查区 |
|
public IFeatureLayer JcCjdcqLayer { get; set; } |
|
public IFeatureLayer JcCjdcqJxLayer { get; set; } |
|
public IFeatureLayer GxCjdcqLayer { get; set; } |
|
public IFeatureLayer GxgcCjdcqLayer { get; set; } |
|
public IFeatureLayer GxCjdcqJxLayer { get; set; } |
|
#endregion |
|
|
|
#region 行政区 |
|
public IFeatureLayer JcXzqLayer { get; set; } |
|
public IFeatureLayer JcXzqJxLayer { get; set; } |
|
public IFeatureLayer GxXzqLayer { get; set; } |
|
public IFeatureLayer GxgcXzqLayer { get; set; } |
|
public IFeatureLayer GxXzqJxLayer { get; set; } |
|
#endregion |
|
|
|
#region 城镇村 |
|
public IFeatureLayer JcCzcLayer { get; set; } |
|
public IFeatureLayer GxCzcLayer { get; set; } |
|
public IFeatureLayer GxgcCzcLayer { get; set; } |
|
#endregion |
|
|
|
#region 耕地等别 |
|
public IFeatureLayer JcGddbLayer { get; set; } |
|
public IFeatureLayer GxGddbLayer { get; set; } |
|
#endregion |
|
|
|
public IFeatureLayer OpenLayer(LayerCfg pLayerInfo) |
|
{ |
|
if (pLayerInfo == null) |
|
return null; |
|
if (string.IsNullOrWhiteSpace(pLayerInfo.FcPath) || string.IsNullOrWhiteSpace(pLayerInfo.FcName)) |
|
return null; |
|
if (!File.Exists(pLayerInfo.FcPath) && !Directory.Exists(pLayerInfo.FcPath)) |
|
return null; |
|
FileInfo fInfo = new FileInfo(pLayerInfo.FcPath); |
|
WorkspaceTypeEnum wsType = WorkspaceTypeEnum.GDBFile; |
|
if (fInfo.FullName.EndsWith(".gdb")) |
|
wsType = WorkspaceTypeEnum.GDBFile; |
|
else if (fInfo.FullName.EndsWith(".mdb")) |
|
wsType = WorkspaceTypeEnum.MDBFile; |
|
else |
|
wsType = WorkspaceTypeEnum.ShapeFile; |
|
if (DicWsAPI == null) |
|
DicWsAPI = new Dictionary<string, IWorkspaceAPI>(); |
|
if (!DicWsAPI.ContainsKey(fInfo.FullName)) |
|
{ |
|
IWorkspaceAPI wsAPI = new WorkspaceAPI(fInfo.FullName, wsType); |
|
DicWsAPI.Add(fInfo.FullName, wsAPI); |
|
} |
|
IFeatureClassAPI fcAPI = DicWsAPI[fInfo.FullName].OpenFeatureClass(pLayerInfo.FcName); |
|
return new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass, Name = fcAPI.FeatureClass.AliasName }; |
|
} |
|
public IFeatureLayer OpenLayer(IWorkspaceAPI pWsAPI, string pLayerName) |
|
{ |
|
try |
|
{ |
|
if (string.IsNullOrWhiteSpace(pLayerName)) |
|
return null; |
|
if (pWsAPI != null && pWsAPI.CurrentWorkspace != null) |
|
{ |
|
IFeatureClassAPI fcAPI = pWsAPI.OpenFeatureClass(pLayerName); |
|
return new FeatureLayerClass() { FeatureClass = fcAPI.FeatureClass, Name = fcAPI.FeatureClass.AliasName }; |
|
} |
|
return null; |
|
} |
|
catch (Exception ex) |
|
{ |
|
Console.WriteLine(string.Format("Err:{0}图层获取失败", pLayerName)); |
|
return null; |
|
} |
|
} |
|
} |
|
}
|
|
|