Esempio n. 1
0
        public bool Check(IWorkspace workspace)
        {
            IFeatureClass UnionFeatureClass = workspace.GetFeatureClass(UnionLayerName);

            if (UnionFeatureClass != null)
            {
                CheckUnion(UnionFeatureClass);
            }
            else
            {
                Messages.Add(new VillageMessage
                {
                    Description = string.Format("未获取Union图层,无法进行范围核对")
                });
            }
            IFeatureClass CheckFeatureClass  = workspace.GetFeatureClass(CheckLayerName);
            IFeatureClass ExtentFeatureClass = workspace.GetFeatureClass(ExtentLayerName);

            if (CheckFeatureClass == null)
            {
                Messages.Add(new VillageMessage
                {
                    Description = string.Format("无法获取图层【{0}】要素类,未检查面积一致性", CheckLayerName)
                });
                return(false);
            }
            if (ExtentFeatureClass == null)
            {
                Messages.Add(new VillageMessage
                {
                    Description = string.Format("无法获取图层【{0}】要素类,未检查面积一致性", ExtentLayerName)
                });

                return(false);
            }
            var checkArea  = Math.Round(ArcClass.GainArea(CheckFeatureClass), 0);
            var extentArea = Math.Round(ArcClass.GainArea(ExtentFeatureClass), 0);
            var abs        = Math.Abs(checkArea - extentArea);
            var flag       = false;

            if (Absolute.HasValue)
            {
                flag = abs < Absolute.Value;
            }
            if (Relative.HasValue)
            {
                var pp = abs / extentArea;
                flag = pp < Relative.Value;
            }

            if (flag == false)
            {
                Messages.Add(new VillageMessage
                {
                    CheckValue  = abs.ToString(),
                    Description = string.Format("图层【{0}】所在行政区代码【{1}】内面积不一致;", _tableName, _XZQDM)
                });
            }
            return(true);
        }
Esempio n. 2
0
        private void Progarm()
        {
            IWorkspace workspace = ArcClass.GetmdbWorkspace(mdbFilePath);

            if (workspace == null)
            {
                return;
            }
            IFeatureDataset featureDataset = ArcClass.GetFeatureDataset(workspace, "WJL");
            ISchemaLock     schemalock     = featureDataset as ISchemaLock;

            try
            {
                schemalock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
                ITopologyContainer topologyContainer = featureDataset as ITopologyContainer;
                ITopology          topology          = topologyContainer.CreateTopology("ttt", topologyContainer.DefaultClusterTolerance, -1, "");
                IFeatureClass      featureClass      = ArcClass.GetFeatureClass(workspace, "PARK");

                AddRuleToTopology(topology, esriTopologyRuleType.esriTRTAreaNoOverlap, "NO Block OverLap", featureClass);

                IGeoDataset geoDataset = topology as IGeoDataset;
                IEnvelope   envelop    = geoDataset.Extent;
                ValidateTopology(topology, envelop);
            }catch (COMException)
            {
            }
        }
Esempio n. 3
0
        public bool Check(IWorkspace workspace)
        {
            IFeatureClass checkFeatureClass = workspace.GetFeatureClass(CheckFeatureClassName);

            if (checkFeatureClass == null)
            {
                Messages.Add(new VillageMessage
                {
                    Description = string.Format("未获取要素类【{0}】,无法进行核查【{1}】", CheckFeatureClassName, Name)
                });
                return(false);
            }
            IFeatureClass currentFeatureClass = workspace.GetFeatureClass(CurrentFeatureClassName);

            if (currentFeatureClass == null)
            {
                Messages.Add(new VillageMessage
                {
                    Description = string.Format("未获取要素类【{0}】,无法进行核查【{1}】", CurrentFeatureClassName, Name)
                });
                return(false);
            }
            var checkArea   = Math.Round(ArcClass.GainArea(checkFeatureClass, CheckWhereClause), 0);
            var currentArea = Math.Round(ArcClass.GainArea(currentFeatureClass, CurrentWhereClause), 0);
            var abs         = Math.Abs(checkArea - currentArea);
            var flag        = false;

            if (Absolute.HasValue)
            {
                flag = abs < Absolute.Value;
            }
            if (Relative.HasValue)
            {
                var pp = abs / currentArea;
                flag = pp < Relative.Value;
            }
            if (flag == false)
            {
                Messages.Add(new VillageMessage
                {
                    Value       = abs.ToString(),
                    Description = string.Format("【{0}】不符合", Name)
                });
            }
            return(true);
        }
Esempio n. 4
0
        public void Beat()
        {
            IWorkspace      workspace      = ArcClass.GetmdbWorkspace(mdbFilePath);
            IFeatureDataset featureDataset = ArcClass.GetFeatureDataset(workspace, "WJL");

            if (featureDataset != null)
            {
                ITopologyContainer     topologyContainer     = featureDataset as ITopologyContainer;
                ITopology              topology              = topologyContainer.CreateTopology("result", topologyContainer.DefaultClusterTolerance, -1, "");
                IFeatureClassContainer featureClassContainer = featureDataset as IFeatureClassContainer;
                IFeatureClass          featureClass          = featureClassContainer.get_ClassByName("Roads");
                topology.AddClass(featureClass, 5, 1, 1, false);
                ITopologyRuleContainer topologyRuleContainer = topology as ITopologyRuleContainer;
                ITopologyRule          topologyRule          = new TopologyRuleClass();
                topologyRule.TopologyRuleType = esriTopologyRuleType.esriTRTLineNoOverlap;
                topologyRule.OriginClassID    = featureClass.ObjectClassID;
                topologyRule.Name             = "Roads No Overlap";

                if (topologyRuleContainer.get_CanAddRule(topologyRule))
                {
                    topologyRuleContainer.AddRule(topologyRule);
                }

                topologyRule = new TopologyRuleClass();
                topologyRule.TopologyRuleType  = esriTopologyRuleType.esriTRTLineNoDangles;
                topologyRule.OriginClassID     = featureClass.ObjectClassID;
                topologyRule.AllOriginSubtypes = true;
                topologyRule.Name = "Roads No Dangles";

                // Add the rule to the Topology
                if (topologyRuleContainer.get_CanAddRule(topologyRule))
                {
                    topologyRuleContainer.AddRule(topologyRule);
                }
            }
        }