//设置区划中心点和边界 private void SetRegionInfo(csGovRegion csGR) { try { //获取GIS信息 Recordset recdst2 = GetRecordsetByCode(csGR.RegionCode); if (recdst2 != null && recdst2.RecordCount > 0) { csGR.RegionCenter = new csCenter(); csGR.RegionBounds = new csBounds(); GeoLine geoLine1 = recdst2.GetGeometry() as GeoLine; csGR.RegionCenter.center = GetCenterPoint(csGR.RegionCode); double dKey = 10714896 / 111000 / 0.08; while (!recdst2.IsEOF) { try { GeoLine geoLine2 = recdst2.GetGeometry() as GeoLine; for (int i = 0; i < geoLine2.PartCount; i++) { GeoLine geoL = new GeoLine(geoLine2[i]); GeoLine geoLine = null; if (geoL[0].Count < 400) { geoLine = geoL; } else { double dTolerance = geoL.Length / dKey; { //dTolerance = GetTolerance(csGR.RegionCode); } geoLine = Geometrist.Resample(geoL, ResampleType.RTGeneral, dTolerance) as GeoLine; } csGR.RegionBounds.bounds.Add(geoLine[0].Clone()); } } catch (SystemException sysEx) { string strErr = sysEx.Message; } recdst2.MoveNext(); } } } catch {} }
//更新XZQH的边界线 private void Update_XZQH_Boundary() { string strTableName = "T_BUSI_XZQH"; int iIndex = 0; try { string strWhere = "qhjb=1"; { string strSQL = string.Format("select id,qhmc,qhbm,pid,qhjb from {0} where {1}", strTableName, strWhere); DataSet dtSet = DbHelperOra.Query(DbHelperOra.connectionString_Local, strSQL); DataTable dtTable = dtSet.Tables[0]; foreach (DataRow dr in dtTable.Rows) { iIndex++; string strID = string.Format("{0}", dr[0]); string strQHMC = string.Format("{0}", dr[1]); string strQHBM = string.Format("{0}", dr[2]); string strPID = string.Format("{0}", dr[3]); string strQHJB = string.Format("{0}", dr[4]); double dTolerance = 0.0002; { dTolerance = GetTolerance(strQHBM); } Recordset recdst2 = GetRecordsetByCode(strQHBM); Lib.Base.Define.csBounds b = new Lib.Base.Define.csBounds(); if (recdst2 != null && recdst2.RecordCount > 0) { GeoLine geoLine1 = recdst2.GetGeometry() as GeoLine; while (!recdst2.IsEOF) { try { GeoLine geoLine2 = recdst2.GetGeometry() as GeoLine; for (int i = 0; i < geoLine2.PartCount; i++) { GeoLine geoL = new GeoLine(geoLine2[i]); GeoLine geoLine = null; if (geoL[0].Count < 400) { geoLine = geoL; } else { geoLine = Geometrist.Resample(geoL, ResampleType.RTGeneral, dTolerance) as GeoLine; } b.bounds.Add(geoLine[0].Clone()); } } catch (SystemException sysEx) { string strErr = sysEx.Message; } recdst2.MoveNext(); } if (strQHBM.Length > 0) { string strPoints = JSONHelper.ObjectToJSON(b.bounds); string strFilter = string.Format("qhbm = '{0}'", strQHBM); DbHelperOra.RwiteRegionBoundsBlobToTable(DbHelperOra.connectionString_Local, strTableName, "VIEWBOUNDS", strFilter, strPoints); } } else { try { string strLogFile = string.Format("{0}Undolog.txt", AppDomain.CurrentDomain.BaseDirectory); if (File.Exists(strLogFile)) { StreamWriter sw = new StreamWriter(strLogFile, true); string strContext = string.Format("未能找到图元的编码,{0}:{1}", strQHBM, strQHMC); sw.WriteLine(strContext); sw.Close(); } else { StreamWriter sw = File.CreateText(strLogFile); string strContext = string.Format("未能找到图元的编码,{0}:{1}", strQHBM, strQHMC); sw.WriteLine(strContext); sw.Close(); } } catch { } } } MessageBox.Show("入库完毕"); } } catch (SystemException sysEx) { string strErr = sysEx.Message; } }
//以业务行政区划为主,添加到数据库中 private void WriteToDatabaseByMIS() { string strTableName = "T_BUSI_XZQH"; string strTableName2 = "t_base_013_district"; int iIndex = 0; try { //using (conn = new OracleConnection(connString)) { string strQuery = string.Format("select t.district_code,t.district_name,t.district_parent,t.district_level from {0} t where t.district_parent is not null order by t.district_level", strTableName2); DataSet dtSet = DbHelperOra.Query(DbHelperOra.connectionString_Local, strQuery); DataTable dtTable = dtSet.Tables[0]; foreach (DataRow dr in dtTable.Rows) { iIndex++; string strBM = string.Format("{0}", dr[0]); string strName = string.Format("{0}", dr[1]); string strPCODE = string.Format("{0}", dr[2]); string strRLEVEL = string.Format("{0}", dr[3]); double dTolerance = 0.0002; { dTolerance = GetTolerance(strBM); } Recordset recdst2 = GetRecordsetByCode(strBM); Lib.Base.Define.csCenter c = new Lib.Base.Define.csCenter(); Lib.Base.Define.csBounds b = new Lib.Base.Define.csBounds(); if (recdst2 != null && recdst2.RecordCount > 0) { GeoLine geoLine1 = recdst2.GetGeometry() as GeoLine; //c.center = geoLine1.Bounds.Center; c.center = GetCenterPoint(strBM); strName = string.Format("{0}", recdst2.GetFieldValue("NAME")); while (!recdst2.IsEOF) { try { GeoLine geoLine2 = recdst2.GetGeometry() as GeoLine; for (int i = 0; i < geoLine2.PartCount; i++) { GeoLine geoL = new GeoLine(geoLine2[i]); GeoLine geoLine = null; if (geoL[0].Count < 400) { geoLine = geoL; } else { geoLine = Geometrist.Resample(geoL, ResampleType.RTGeneral, dTolerance) as GeoLine; } b.bounds.Add(geoLine[0].Clone()); } } catch (SystemException sysEx) { string strErr = sysEx.Message; } recdst2.MoveNext(); } string strCenter = JSONHelper.ObjectToJSON(c.center); if (strBM.Length > 0) { string strGUID = Guid.NewGuid().ToString("N").ToUpper(); string strPoints = JSONHelper.ObjectToJSON(b); string strSQL = string.Format("insert into {0}(ID,QHMC,QHBM,PID,CENTER,QHJB,VIEWBOUNDS) values('{1}','{2}','{3}','{4}','{5}',{6},empty_blob())", strTableName, strGUID, strName, strBM, strPCODE, strCenter, strRLEVEL); string strROWID = DbHelperOra.ExecuteOracleSql(DbHelperOra.connectionString_172, strSQL); string strFilter = string.Format("rowid = '{0}'", strROWID); DbHelperOra.RwiteRegionBoundsBlobToTable(DbHelperOra.connectionString_172, strTableName, "VIEWBOUNDS", strFilter, strPoints); } } else { try { string strLogFile = string.Format("{0}Undolog.txt", AppDomain.CurrentDomain.BaseDirectory); if (File.Exists(strLogFile)) { StreamWriter sw = new StreamWriter(strLogFile, true); string strContext = string.Format("未能找到图元的编码,{0}:{1}", strBM, strName); sw.WriteLine(strContext); sw.Close(); } else { StreamWriter sw = File.CreateText(strLogFile); string strContext = string.Format("未能找到图元的编码,{0}:{1}", strBM, strName); sw.WriteLine(strContext); sw.Close(); } } catch { } } } MessageBox.Show("入库完毕"); } } catch (SystemException sysEx) { string strErr = sysEx.Message; } }