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.
961 lines
46 KiB
961 lines
46 KiB
using ESRI.ArcGIS.Carto; |
|
using ESRI.ArcGIS.Geodatabase; |
|
using KGIS.Framework.AE; |
|
using KGIS.Framework.AE.Enum; |
|
using KGIS.Framework.AE.GPHelper; |
|
using KGIS.Framework.Utils; |
|
using KGIS.Framework.Utils.ExtensionMethod; |
|
using Kingo.PluginServiceInterface; |
|
using Kingo.PluginServiceInterface.Model; |
|
using System; |
|
using System.Collections.Generic; |
|
using System.IO; |
|
|
|
namespace KGIS_DLTB |
|
{ |
|
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 |
|
{ |
|
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; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 生成年末库图层-GP创建年末库图层 |
|
/// </summary> |
|
/// <param name="parm"></param> |
|
public virtual void CreateNMK3(IDGParameter parm) |
|
{ |
|
IFeatureCursor _cursor = null; |
|
try |
|
{ |
|
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> |
|
/// 生成年末库数据(BUG:新增 年末库 图层) |
|
/// </summary> |
|
/// <param name="parm"></param> |
|
public virtual void CreateNMK(IDGParameter parm) |
|
{ |
|
IFeatureCursor _cursor = null; |
|
try |
|
{ |
|
//if (NmWsAPI.OpenFeatureClass("DLTB_NMK").FeatureClass is IFeatureClass ClassFC) |
|
// NmTbLayer = new FeatureLayer() { Name = ClassFC.AliasName, FeatureClass = ClassFC }; |
|
if (NmTbLayer == null) return; |
|
(NmTbLayer.FeatureClass as ITable).DeleteSearchedRows(null); |
|
IFeatureClassAPI featureClassAPI = new FeatureClassAPI(JcTbLayer.FeatureClass); |
|
featureClassAPI.FcToFc(NmTbLayer.FeatureClass, null, false); |
|
_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 = NmTbLayer.FeatureClass.Update(null, true); |
|
idx = 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(); |
|
(NmTbLayer.FeatureClass as ITable).DeleteSearchedRows(new QueryFilterClass() { WhereClause = "BSM = '-1'" }); |
|
IFeatureClassAPI fcAPI = new FeatureClassAPI(GxTbLayer.FeatureClass); |
|
fcAPI.FcToFc(NmTbLayer.FeatureClass, null, false); |
|
|
|
ITable nmkTable = 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(); |
|
} |
|
catch (Exception ex) |
|
{ |
|
Console.WriteLine("Err:地类图斑数据提取-生成年末库数据异常!" + ex.Message); |
|
Console.WriteLine("Err:地类图斑数据提取-生成年末库数据异常!" + ex.StackTrace); |
|
throw ex; |
|
} |
|
} |
|
|
|
public virtual void CreateNMK(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; |
|
} |
|
} |
|
|
|
//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"); |
|
// //_nmTbLayer = OpenLayer(NmWsAPI, "DLTB_NMK"); |
|
|
|
// } |
|
// 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(_nmTbLayer!=null) |
|
// // _nmTbLayer = OpenLayer(NmWsAPI, "DLTB_NMK"); |
|
// } |
|
// 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 = null; |
|
if (wsType == WorkspaceTypeEnum.GDBFile) |
|
{ |
|
wsAPI = new WorkspaceAPI(fInfo.FullName, wsType, true); |
|
} |
|
else |
|
{ |
|
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 ESRI.ArcGIS.DataSourcesGDB.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); |
|
} |
|
string savePath = Path.Combine(path, "TempGDB.gdb"); |
|
string templeteGDBPath = Path.Combine(SysAppPath.GetCurrentAppPath(), "Template", "TempGDB.gdb"); |
|
CopyDirectory(templeteGDBPath, savePath, true); |
|
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; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 拷贝模板gdb文件夹 |
|
/// </summary> |
|
/// <param name="SourcePath"></param> |
|
/// <param name="DestinationPath"></param> |
|
/// <param name="overwriteexisting"></param> |
|
public static void CopyDirectory(string SourcePath, string DestinationPath, bool overwriteexisting) |
|
{ |
|
try |
|
{ |
|
SourcePath = SourcePath.EndsWith(@"\") ? SourcePath : SourcePath + @"\"; |
|
DestinationPath = DestinationPath.EndsWith(@"\") ? DestinationPath : DestinationPath + @"\"; |
|
|
|
if (Directory.Exists(SourcePath)) |
|
{ |
|
if (Directory.Exists(DestinationPath) == false) |
|
Directory.CreateDirectory(DestinationPath); |
|
|
|
foreach (string fls in Directory.GetFiles(SourcePath)) |
|
{ |
|
FileInfo flinfo = new FileInfo(fls); |
|
flinfo.CopyTo(DestinationPath + flinfo.Name, overwriteexisting); |
|
} |
|
foreach (string drs in Directory.GetDirectories(SourcePath)) |
|
{ |
|
DirectoryInfo drinfo = new DirectoryInfo(drs); |
|
CopyDirectory(drs, DestinationPath + drinfo.Name, overwriteexisting); |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw ex; |
|
} |
|
} |
|
|
|
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 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; |
|
} |
|
} |
|
} |
|
}
|
|
|