//延长线函数 public static void ExpandLine(mcRecordSet LineSet, IVectorCls vcls) { IGeometry l_geoLine = null; LineSet.GetGeometry(out l_geoLine); IGeoVarLine l_Line = null; l_Line = l_geoLine as IGeoVarLine; mcDots l_dots = null; l_Line.Get2Dots(out l_dots); mcDot dot_1 = l_dots.get_item(0); mcDot dot_2 = l_dots.get_item(l_dots.count - 1); //垂直(因为数据不标准,所以设置为< 1) if (Math.Abs(dot_1.x - dot_2.x) < 1) { mcDot NewDot1 = new mcDot(); mcDot NewDot2 = new mcDot(); NewDot1.x = dot_1.x; NewDot1.y = dot_1.y + l_Line.CalLength(null) / 10; NewDot2.x = dot_2.x; NewDot2.y = dot_2.y - l_Line.CalLength(null) / 10; mcGeoVarLine NewLine = new mcGeoVarLine(); NewLine.Append2D(NewDot1); NewLine.Append2D(NewDot2); vcls.Append(NewLine, null, null); mcObjectID delID = null; LineSet.GetID(out delID); vcls.Del(delID); } else { //计算直线的斜率 double slope = Math.Abs(dot_2.y - dot_1.y) / Math.Abs(dot_2.x - dot_1.x); mcDot NewDot1 = new mcDot(); mcDot NewDot2 = new mcDot(); NewDot1.x = dot_1.x - l_Line.CalLength(null) / 10; NewDot1.y = slope * (NewDot1.x - dot_1.x) + dot_1.y; NewDot2.x = dot_2.x + l_Line.CalLength(null) / 10; NewDot2.y = slope * (NewDot2.x - dot_2.x) + dot_2.y; mcGeoVarLine NewLine = new mcGeoVarLine(); NewLine.Append2D(NewDot1); NewLine.Append2D(NewDot2); vcls.Append(NewLine, null, null); mcObjectID delID = null; LineSet.GetID(out delID); vcls.Del(delID); } }
private static void SpatialDataAutoUpdate(mcGDBServer GDBSvr, mcGDataBase GDB, mcGDataBase GDB_source, mcQueryDef QueryDef, mcQueryDef QueryDef_source, string data, string data_source, string field, string field_source) { //变量定义 mcRecordSet RecordSet = null; mcRecordSet RecordSet_source = null; IVectorCls VecCls_data = null; IVectorCls VecCls_source_data = null; try { //打开待分析数据 VecCls_data = GDB.get_XClass(meXClsType.meXSFCls) as IVectorCls; VecCls_data.Open(data, 0); VecCls_source_data = GDB_source.get_XClass(meXClsType.meXSFCls) as IVectorCls; VecCls_source_data.Open(data_source, 0); VecCls_data.Select(QueryDef, out RecordSet); VecCls_source_data.Select(QueryDef_source, out RecordSet_source); int SfcID = 0; SfcID = RecordSet.MoveFirst(); while (!RecordSet.IsEOF()) { mcRecord record = null; mcFields Fields = null; IGeometry geo = null; IGeomInfo geoInfo = null; object val = null; mcObjectID mID = new mcObjectID(); RecordSet.Get(out geo, out record, out geoInfo); record.GetFields(out Fields); record.GetFldVal(field, out val); int SfcID_source = 0; bool flag = true; SfcID_source = RecordSet_source.MoveFirst(); while (!RecordSet_source.IsEOF()) { mcObjectID id_source = new mcObjectID(); mcRecord record_source = null; mcFields Fields_source = null; IGeometry geo_source = null; IGeomInfo geoInfo_source = null; object val_source = null; RecordSet_source.Get(out geo_source, out record_source, out geoInfo_source); RecordSet_source.GetID(out id_source); record_source.GetFields(out Fields_source); record_source.GetFldVal(field_source, out val_source); //找到新旧数据中对应的矿体 if (val.ToString().Equals(val_source.ToString())) { flag = false; VecCls_source_data.Del(id_source); VecCls_source_data.Append(geo, record, geoInfo); //更新原始数据结果集 要不会报空指针错误 VecCls_source_data.Select(QueryDef, out RecordSet_source); break; } SfcID_source = RecordSet_source.MoveNext(); } //判断是否是新增矿体 新增矿体直接添加 if (flag) { VecCls_source_data.Append(geo, record, geoInfo); //更新原始数据结果集 要不会报空指针错误 VecCls_source_data.Select(QueryDef, out RecordSet_source); } SfcID = RecordSet.MoveNext(); } } catch (Exception ex) { throw new Exception("更新出错啦!"); } finally { //关闭类、数据库、断开数据源 VecCls_data.Close(); VecCls_source_data.Close(); } }