示例#1
0
        private bool InsertTopoError(IFeatureClass destFClass)
        {
            try
            {
                string strSQL = @"SELECT
                            b.CheckType,
                            IIF(b.TargetFeatClass1 is Null,'',b.TargetFeatClass1) as YSTC,
                            IIF(a.SourceBSM is Null,'',a.SourceBSM) as SourceBSM,
                            IIF(a.MBTC is Null,'',a.MBTC) as MBTC,
                            IIF(a.TargetBSM is Null,'',a.TargetBSM) as BSM2,
                            a.TPTC as TopoLayerName,
                            a.Reason as Description,
                            a.IsException as IsException,
                            IIf(a.Remark is Null,'',a.Remark) as Remark,
                            b.GZBM ,
                            a.ArcGisRule as ArcGisRule,
                            a.JHLX as JHLX,
                            a.SourceLayerID,
                            a.TargetLayerID,
                            a.SourceOID as OID,
                            a.TargetOID as OID2
                            from LR_ResAutoTopo as a, LR_ResultEntryRule as b where a.RuleInstID=b.RuleInstID
                            ";


                DataTable dtError = Hy.Common.Utility.Data.AdoDbHelper.GetDataTable(this.ResultConnection, strSQL);

                IFeatureCursor        fCusorInsert   = destFClass.Insert(false);
                Dictionary <int, int> dictFieldIndex = new Dictionary <int, int>();
                for (int i = 0; i < m_FieldCaptions.Count; i++)
                {
                    dictFieldIndex.Add(i, destFClass.FindField(m_FieldCaptions[i]));
                }
                int xFieldIndex = destFClass.FindField("X坐标");
                int yFieldIndex = destFClass.FindField("Y坐标");

                IErrorFeatureContainer errFeatureContainer = this.Topology as IErrorFeatureContainer;
                ISpatialReference      spatialRef          = (this.Topology as IGeoDataset).SpatialReference;
                for (int i = 0; i < dtError.Rows.Count; i++)
                {
                    DataRow              rowError  = dtError.Rows[i];
                    int                  fClassID  = Convert.ToInt32(rowError["SourceLayerID"]);
                    int                  fClassID2 = Convert.ToInt32(rowError["TargetLayerID"]);
                    int                  oid       = Convert.ToInt32(rowError["OID"]);
                    int                  oid2      = Convert.ToInt32(rowError["OID2"]);
                    esriGeometryType     geoType   = (esriGeometryType)Convert.ToInt32(rowError["JHLX"]);
                    esriTopologyRuleType ruleType  = (esriTopologyRuleType)Convert.ToInt32(rowError["ArcGISRule"]);

                    IFeature srcFeature = errFeatureContainer.get_ErrorFeature(spatialRef, ruleType, geoType, fClassID, fClassID2, oid, oid2) as IFeature;

                    IFeatureBuffer fNew = destFClass.CreateFeatureBuffer();
                    for (int j = 0; j < m_FieldCaptions.Count; j++)
                    {
                        int fIndex = dictFieldIndex[j];
                        if (fIndex < 0)
                        {
                            continue;
                        }

                        fNew.set_Value(fIndex, rowError[j]);
                    }
                    fNew.Shape = GetErrorGeometry(srcFeature);
                    IPoint point = fNew.Shape as IPoint;
                    fNew.set_Value(xFieldIndex, point.X);
                    fNew.set_Value(yFieldIndex, point.Y);

                    fCusorInsert.InsertFeature(fNew);

                    if (i % 2000 == 0)
                    {
                        fCusorInsert.Flush();
                    }
                }

                fCusorInsert.Flush();

                return(true);
            }
            catch (Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());
                return(false);
            }
        }
示例#2
0
文件: UCResult.cs 项目: zj8487/HyDM
        private IFeature GetFeature(DataRow rowError, string strLayerName)
        {
            IMap theMap = this.m_HookHelper.FocusMap;
            MapLayersController mapController = new MapLayersController(theMap);
            enumErrorType       errType       = (enumErrorType)Convert.ToInt32(rowError["ErrorType"]);

            switch (errType)
            {
            case enumErrorType.Topology:
            {
                ITopologyLayer topoLayerTarget = mapController.GetLayer(strLayerName) as ITopologyLayer;
                if (topoLayerTarget == null)
                {
                    return(null);
                }

                ITopology topology = topoLayerTarget.Topology;
                IErrorFeatureContainer errFeatureContainer = topology as IErrorFeatureContainer;
                esriTopologyRuleType   ruleType            = (esriTopologyRuleType)Convert.ToInt32(rowError[Field_Name_TopologyRuleType]);
                //string strGeoType = rowError[Field_Name_TopologyGeometryType] as string;
                //esriGeometryType geoType = (strGeoType == "点" ? esriGeometryType.esriGeometryPoint : (strGeoType == "线" ? esriGeometryType.esriGeometryLine : esriGeometryType.esriGeometryPolygon));
                esriGeometryType geoType = (esriGeometryType)Convert.ToInt32(rowError[Field_Name_TopologyGeometryType]);
                int sourceClassID        = (int)rowError["SourceLayerID"];
                int sourceOID            = (int)rowError["OID"];
                int targetClassID        = (int)rowError["TargetLayerID"];
                int targetOID            = Convert.ToInt32(rowError["OID2"]);

                return(errFeatureContainer.get_ErrorFeature((topology as IGeoDataset).SpatialReference, ruleType, geoType, sourceClassID, sourceOID, targetClassID, targetOID) as IFeature);
            }
            break;

            case enumErrorType.Normal:
            {
                IFeatureLayer flyrTarget = mapController.GetLayer(strLayerName) as IFeatureLayer;
                if (flyrTarget == null)
                {
                    return(null);
                }

                // 改为优先从OID查找定位
                if (rowError.Table.Columns.Contains(Field_Name_TargetOID) && rowError[Field_Name_TargetOID] != DBNull.Value)
                {
                    return(flyrTarget.FeatureClass.GetFeature((int)rowError[Field_Name_TargetOID]));
                }
                else if (rowError.Table.Columns.Contains(Field_Name_TargetBSM) && !string.IsNullOrEmpty(rowError[Field_Name_TargetBSM] as string))
                {
                    IQueryFilter qFilter    = new QueryFilterClass();
                    IFields      fields     = flyrTarget.FeatureClass.Fields;
                    int          fieldIndex = fields.FindField("BSM");
                    if (fieldIndex < 0)
                    {
                        return(null);
                    }

                    IField bsmField = fields.get_Field(fieldIndex);
                    if (bsmField.Type == esriFieldType.esriFieldTypeInteger)
                    {
                        qFilter.WhereClause = string.Format("BSM={0}", rowError[Field_Name_TargetBSM]);
                    }
                    else
                    {
                        qFilter.WhereClause = string.Format("BSM='{0}'", rowError[Field_Name_TargetBSM]);
                    }
                    IFeatureCursor fCursor = flyrTarget.FeatureClass.Search(qFilter, false);

                    return(fCursor.NextFeature());
                }
                else
                {
                    return(null);
                }
            }

            default: return(null);
            }
        }