/// <summary>
        /// Creates a grpah where each index in the original topology
        /// has 1+n nodes in the graph - one for the initial index
        /// and one for each direction leading out of it.
        /// </summary>
        private static PathConstraintUtils.SimpleGraph CreateEdgedGraph(ITopology topology)
        {
            var nodesPerIndex = topology.DirectionsCount + 1;

            var nodeCount = topology.IndexCount * nodesPerIndex;

            var neighbours = new int[nodeCount][];

            int GetNodeId(int index) => index * nodesPerIndex;

            int GetDirNodeId(int index, Direction direction) => index * nodesPerIndex + 1 + (int)direction;

            foreach (var i in topology.GetIndices())
            {
                var n = new List <int>();
                for (var d = 0; d < topology.DirectionsCount; d++)
                {
                    var direction = (Direction)d;
                    if (topology.TryMove(i, direction, out var dest, out var inverseDir, out var _))
                    {
                        // The central node connects to the direction node
                        n.Add(GetDirNodeId(i, direction));
                        // The diction node connects to the central node
                        // and the opposing direction node
                        neighbours[GetDirNodeId(i, direction)] =
                            new[] { GetNodeId(i), GetDirNodeId(dest, inverseDir) };
                    }
        /// <summary>
        ///   Constructs a new Hidden Markov Model.
        /// </summary>
        /// <param name="topology">
        ///   A <see cref="Topology"/> object specifying the initial values of the matrix of transition
        ///   probabilities <c>A</c> and initial state probabilities <c>pi</c> to be used by this model.
        /// </param>
        /// <param name="emissions">
        ///   The initial emission probability distributions for each state.
        /// </param>
        public ContinuousHiddenMarkovModel(ITopology topology, IDistribution[] emissions)
            : base(topology)
        {
            if (emissions == null)
            {
                throw new ArgumentNullException("emissions");
            }

            if (emissions.GetLength(0) != States)
            {
                throw new ArgumentException(
                          "The emission matrix should have the same number of rows as the number of states in the model.",
                          "emissions");
            }

            B = emissions;

            if (B[0] is IMultivariateDistribution)
            {
                dimension = ((IMultivariateDistribution)B[0]).Dimension;
            }
            else
            {
                dimension = 1;
            }
        }
Exemple #3
0
        /// <summary>
        /// 为要素类添加拓扑规则,针对针对特殊的要素类检查
        /// </summary>
        /// <param name="pTopo">拓扑</param>
        /// <param name="pTopoRuleType">拓扑规则</param>
        /// <param name="outError">异常</param>
        public void AddRuletoTopology(ITopology pTopo, esriTopologyRuleType pTopoRuleType, out Exception outError)
        {
            outError = null;

            try
            {
                ITopologyRuleContainer pRuleContainer   = pTopo as ITopologyRuleContainer;
                IFeatureClassContainer pFeaClsContainer = pTopo as IFeatureClassContainer;
                IEnumFeatureClass      pEnumFeaCls      = pFeaClsContainer.Classes;
                pEnumFeaCls.Reset();
                IFeatureClass pFeaCls = pEnumFeaCls.Next();

                //设置拓扑规则
                while (pFeaCls != null)
                {
                    ITopologyRule pTopoRule = new TopologyRuleClass();
                    pTopoRule.TopologyRuleType  = pTopoRuleType;
                    pTopoRule.Name              = (pFeaCls as IDataset).Name;
                    pTopoRule.OriginClassID     = pFeaCls.FeatureClassID;
                    pTopoRule.AllOriginSubtypes = true;
                    pRuleContainer.AddRule(pTopoRule);
                    pFeaCls = pEnumFeaCls.Next();
                }
            }
            catch (Exception ex)
            {
                ////*********************************************
                ////guozheng 2010-12-24 平安夜  added 系统异常日志
                //if (ModData.SysLog == null) ModData.SysLog = new clsWriteSystemFunctionLog();
                //ModData.SysLog.Write(ex);
                ////**********************************************
                outError = ex;
            }
        }
Exemple #4
0
        public void AddRuleToTopology2(ITopology topology, esriTopologyRuleType ruleType, String ruleName, IFeatureClass originClass, int originSubtype, IFeatureClass destinationClass, int destinationSubtype)
        {
            // Create a topology rule.
            ITopologyRule topologyRule = new TopologyRuleClass();

            topologyRule.TopologyRuleType  = ruleType;
            topologyRule.Name              = ruleName;
            topologyRule.OriginClassID     = originClass.FeatureClassID;
            topologyRule.AllOriginSubtypes = true;
            //topologyRule.OriginSubtype = originSubtype;
            topologyRule.DestinationClassID     = destinationClass.FeatureClassID;
            topologyRule.AllDestinationSubtypes = true;
            //topologyRule.DestinationSubtype = destinationSubtype;

            // Cast the topology to the ITopologyRuleContainer interface and add the rule.
            ITopologyRuleContainer topologyRuleContainer = (ITopologyRuleContainer)topology;

            if (topologyRuleContainer.get_CanAddRule(topologyRule))
            {
                topologyRuleContainer.AddRule(topologyRule);
            }
            else
            {
                throw new ArgumentException("Could not add specified rule to the topology.");
            }
        }
Exemple #5
0
        //topology code
        public ITopology create_topology(IWorkspace myWSp, string[] FCIndex, string TopologyName)
        {
            IEnumDataset myEDS = myWSp.get_Datasets(esriDatasetType.esriDTFeatureDataset);
            IDataset     myDS  = myEDS.Next();

            if (myDS != null)
            {
                DS_Name = myDS.Name;
                IFeatureDataset myFDS = myDS as IFeatureDataset;

                //IWorkspace myWSp = DS as IWorkspace;

                IFeatureClassContainer myFCContainer = myFDS as IFeatureClassContainer;
                //要素类容器
                ITopologyContainer myTopologyContainer = myFDS as ITopologyContainer;
                ITopology          myTopology          = myTopologyContainer.CreateTopology(TopologyName, myTopologyContainer.DefaultClusterTolerance, -1, "");
                int count = 0;
                while (count < FCIndex.Length)
                {
                    myTopology.AddClass(myFCContainer.get_Class(int.Parse(FCIndex[count])), 5, 1, 1, false);
                    count++;
                }
                return(myTopology);
            }
            else
            {
                MessageBox.Show("Error,your Dataset is not a standar DataSet which can be uesed to created topology!");
                return(null);
            }
        }
Exemple #6
0
        /// <summary>
        /// 添加拓扑规则条件
        /// </summary>
        /// <param name="topology">拓扑对象</param>
        /// <param name="ruleType">规则类型</param>
        /// <param name="ruleName">规则名称</param>
        /// <param name="featureClass">要素类</param>
        private void AddRuleToTopology(ITopology topology, esriTopologyRuleType ruleType, String ruleName, IFeatureClass featureClass)
        {
            try
            {
                // Create a topology rule.
                ITopologyRule topologyRule = new TopologyRuleClass();
                topologyRule.TopologyRuleType  = ruleType;
                topologyRule.Name              = ruleName;
                topologyRule.OriginClassID     = featureClass.FeatureClassID;
                topologyRule.AllOriginSubtypes = true;

                // Cast the topology to the ITopologyRuleContainer interface and add the rule.
                ITopologyRuleContainer topologyRuleContainer = (ITopologyRuleContainer)topology;
                if (topologyRuleContainer.get_CanAddRule(topologyRule))
                {
                    topologyRuleContainer.AddRule(topologyRule);
                }
                else
                {
                    throw new ArgumentException("Could not add specified rule to the topology.");
                }
            }
            catch (Exception)
            {
            }
        }
        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)
            {
            }
        }
Exemple #8
0
        private void testToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //打开目标数据库
            IWorkspaceFactory pAccessWorkspaceFactory;

            pAccessWorkspaceFactory = new AccessWorkspaceFactoryClass();
            IWorkspace        fWorkspace    = pAccessWorkspaceFactory.OpenFromFile("E://2018年工作//数据验收平台测试//test.gdb", 0);
            IFeatureWorkspace fW            = fWorkspace as IFeatureWorkspace;
            IEnumDataset      penumDatasets = fWorkspace.get_Datasets(esriDatasetType.esriDTFeatureDataset);

            penumDatasets.Reset();
            IDataset pesriDataset = penumDatasets.Next();

            while (pesriDataset == null)
            {
                IFeatureClass pFeatureClass = fW.OpenFeatureClass("Ⅰ级保护林地范围");
            }
            //启动编辑
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)fWorkspace;

            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();
            //调用创建拓朴的方法
            ITopology topology = Create_Topology(fW, "datset", "Ⅰ级保护林地范围", "Polygon_Topo");

            //停止编辑
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);
            if (topology != null)
            {
                MessageBox.Show("创建拓朴成功!");
            }
        }
Exemple #9
0
        /// <summary>
        /// 在数据集中构建拓扑(GP方法)
        /// </summary>
        /// <param name="IN_TopoName">要生成拓扑的名称</param>
        /// <param name="IN_Tolerance">拓扑容差,可选,默认0.001</param>
        public void PUB_TopoBuildWithGP(string IN_TopoName, double IN_Tolerance = 0.001)
        {
            TP_topoName = IN_TopoName;
            IWorkspace         FeatureWorkSpace = FeatureDataset_Main.Workspace;
            ITopologyWorkspace TopoWorkSpace    = FeatureWorkSpace as ITopologyWorkspace;

            try//若不存在同名拓扑则添加
            {
                Topology = TopoWorkSpace.OpenTopology(IN_TopoName);
                CommonClass common = new CommonClass();
                common.DeleteTopolgyFromGISDB(Topology);
                DeleteFeature(TP_topoName);
            }
            catch
            {
            }
            CreateTopology Topotool = new CreateTopology();//拓扑GP工具

            Topotool.in_dataset           = FeatureDataset_Main;;
            Topotool.out_name             = IN_TopoName;
            Topotool.in_cluster_tolerance = IN_Tolerance;
            try
            {
                GP_Tool.Execute(Topotool, null);
                Topology = TopoWorkSpace.OpenTopology(IN_TopoName);
            }
            catch (COMException comExc)
            {
                MessageBox.Show(String.Format("拓扑创建出错: {0} 描述: {1}", comExc.ErrorCode, comExc.Message));
            }
        }
 public override void OnMouseUp(int int_0, int int_1, int int_2, int int_3)
 {
     if (this.idisplayFeedback_0 != null)
     {
         IEnvelope spatialReference = (this.idisplayFeedback_0 as INewEnvelopeFeedback).Stop();
         if (!spatialReference.IsEmpty)
         {
             if ((spatialReference.Width == 0 ? false : spatialReference.Height != 0))
             {
                 spatialReference.SpatialReference = this._context.FocusMap.SpatialReference;
                 Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StartEditOperation();
                 try
                 {
                     ITopology          mTopology    = CmdSelectTopology.m_Topology;
                     ISegmentCollection polygonClass = new Polygon() as ISegmentCollection;
                     polygonClass.SetRectangle(spatialReference);
                     IPolygon dirtyArea = mTopology.DirtyArea[polygonClass as IPolygon];
                     mTopology.ValidateTopology(dirtyArea.Envelope);
                     this._context.ActiveView.Refresh();
                 }
                 catch (COMException cOMException)
                 {
                     CErrorLog.writeErrorLog(this, cOMException, "");
                 }
                 catch (Exception exception)
                 {
                     CErrorLog.writeErrorLog(this, exception, "");
                 }
                 Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation();
             }
         }
     }
 }
Exemple #11
0
 public ITopology Create_Topology(IFeatureWorkspace featureWorkspace, string featuredatasetName, string featureClassName, string topologyName)
 {
     try
     {
         //1.---打开拓朴所在的要素数据集,并创建拓朴
         IFeatureDataset featureDataset = featureWorkspace.OpenFeatureDataset(featuredatasetName);
         if (featureDataset != null)
         {
             ITopologyContainer topologyContainer = (ITopologyContainer)featureDataset;
             ITopology          topology          = topologyContainer.CreateTopology("topo", topologyContainer.DefaultClusterTolerance, -1, ""); //在这个地方报错
             //2.---给拓朴加入要素集
             IFeatureClassContainer featureclassContainer = (IFeatureClassContainer)featureDataset;
             IFeatureClass          featureClass          = featureclassContainer.get_ClassByName(featureClassName);
             topology.AddClass(featureClass, 5, 1, 1, false);  // Parameters: AddClass(IClass, double weight, int xyrank, int zrank, Boolean EventNotificationOnValidate).
             //3.---返回拓朴
             return(topology);
         }
     }
     catch (Exception ex)
     {
         //System.Diagnostics.Debug.WriteLine(ex.ToString());
         MessageBox.Show(ex.ToString());
     }
     return(null);
 }
        public WavePropagator(
            PatternModel model,
            ITopology topology,
            int backtrackDepth            = 0,
            IWaveConstraint[] constraints = null,
            Func <double> randomDouble    = null,
            FrequencySet[] frequencySets  = null,
            bool clear = true)
        {
            this.patternCount = model.PatternCount;
            this.frequencies  = model.Frequencies;

            this.indexCount     = topology.IndexCount;
            this.backtrack      = backtrackDepth != 0;
            this.backtrackDepth = backtrackDepth;
            this.constraints    = constraints ?? new IWaveConstraint[0];
            this.topology       = topology;
            this.randomDouble   = randomDouble ?? new Random().NextDouble;
            this.frequencySets  = frequencySets;
            directionsCount     = topology.DirectionsCount;

            patternModelConstraint = new PatternModelConstraint(this, model);

            if (clear)
            {
                Clear();
            }
        }
        public TilePropagator(TileModel tileModel, ITopology topology, TilePropagatorOptions options)
        {
            this.tileModel = tileModel;
            this.topology  = topology;

            var overlapping = tileModel as OverlappingModel;

            tileModelMapping = tileModel.GetTileModelMapping(topology);
            var patternTopology = tileModelMapping.PatternTopology;
            var patternModel    = tileModelMapping.PatternModel;

            var waveConstraints =
                (options.Constraints?.Select(x => new TileConstraintAdaptor(x, this)).ToArray() ?? Enumerable.Empty <IWaveConstraint>())
                .ToArray();

            var waveFrequencySets = options.Weights == null ? null : GetFrequencySets(options.Weights, tileModelMapping);

#pragma warning disable CS0618 // Type or member is obsolete
            this.wavePropagator = new WavePropagator(
                patternModel,
                patternTopology,
                options.BackTrackDepth,
                waveConstraints,
                options.RandomDouble ?? (options.Random == null ? (Func <double>)null : options.Random.NextDouble),
                waveFrequencySets,
                clear: false);
#pragma warning restore CS0618 // Type or member is obsolete
            wavePropagator.Clear();
        }
Exemple #14
0
        internal override TileModelMapping GetTileModelMapping(ITopology topology)
        {
            var gridTopology = topology.AsGridTopology();

            RequireDirections();
            SetDirections(gridTopology.Directions);

            if (frequencies.Sum() == 0.0)
            {
                throw new Exception("No tiles have assigned frequences.");
            }

            var patternModel = new PatternModel
            {
                Propagator  = propagator.Select(x => x.Select(y => y.ToArray()).ToArray()).ToArray(),
                Frequencies = frequencies.ToArray(),
            };
            var tilesToPatternsByOffset = new Dictionary <int, IReadOnlyDictionary <Tile, ISet <int> > >()
            {
                { 0, tilesToPatterns.ToLookup(x => x.Key, x => x.Value).ToDictionary(g => g.Key, g => (ISet <int>) new HashSet <int>(g)) }
            };
            var patternsToTilesByOffset = new Dictionary <int, IReadOnlyDictionary <int, Tile> >
            {
                { 0, tilesToPatterns.ToDictionary(x => x.Value, x => x.Key) },
            };

            return(new TileModelMapping
            {
                PatternTopology = gridTopology,
                PatternModel = patternModel,
                PatternsToTilesByOffset = patternsToTilesByOffset,
                TilesToPatternsByOffset = tilesToPatternsByOffset,
                TileCoordToPatternCoordIndexAndOffset = null,
            });
        }
Exemple #15
0
        /// <summary>
        /// 在数据集中构建拓扑(GP方法)
        /// </summary>
        /// <param name="IN_TopoName">要生成拓扑的名称</param>
        /// <param name="IN_Tolerance">拓扑容差,可选,默认0.001</param>
        public void PUB_TopoBuildWithGP(string IN_TopoName, double IN_Tolerance = 0.001)
        {
            IWorkspace         FeatureWorkSpace = FeatureDataset_Main.Workspace;
            ITopologyWorkspace TopoWorkSpace    = FeatureWorkSpace as ITopologyWorkspace;

            try//若不存在同名拓扑则添加
            {
                Topology = TopoWorkSpace.OpenTopology(IN_TopoName);
                MessageBox.Show("已存在该拓扑,无法添加!");
            }
            catch
            {
                CreateTopology Topotool = new CreateTopology();//拓扑GP工具
                Topotool.in_dataset           = FeatureDataset_Main;;
                Topotool.out_name             = IN_TopoName;
                Topotool.in_cluster_tolerance = IN_Tolerance;
                try
                {
                    GP_Tool.Execute(Topotool, null);
                    Topology = TopoWorkSpace.OpenTopology(IN_TopoName);
                }
                catch (COMException comExc)
                {
                    MessageBox.Show(String.Format("拓扑创建出错: {0} 描述: {1}", comExc.ErrorCode, comExc.Message));
                }
            }
        }
Exemple #16
0
        /// <summary>
        /// 添加单要素拓扑规则
        /// </summary>
        /// <param name="topology">建立的拓扑</param>
        /// <param name="FeatureClassName1">要素的名称</param>
        /// <param name="TopoRule">拓扑规则中文描述</param>
        private void AddTopoRules(ITopology topology, string FeatureClassName1, string TopoRule)
        {
            IFeatureClass        pFeatureClass1 = getFeatureClassByName(FeatureClassName1, pFeatureClassList);
            esriTopologyRuleType RuleType       = getTopoRuleByDescription(TopoRule);

            //创建拓扑规则
            ITopologyRule pTopoRule = new TopologyRuleClass();

            pTopoRule.OriginClassID    = pFeatureClass1.FeatureClassID;
            pTopoRule.TopologyRuleType = RuleType;

            //这两个参数应该设置为true,否则生成的拓扑没有东西
            pTopoRule.AllDestinationSubtypes = true;
            pTopoRule.AllOriginSubtypes      = true;

            ITopologyRuleContainer pTopologyRuleContainer = topology as ITopologyRuleContainer;

            if (pTopologyRuleContainer.CanAddRule[pTopoRule])
            {
                pTopologyRuleContainer.AddRule(pTopoRule);
            }
            else
            {
                throw new ArgumentException("无法添加" + pFeatureClass1.AliasName + "-" + pTopoRule.Name + "!");
            }
        }
        /// <summary>
        ///   Constructs a new Hidden Markov Model with discrete state probabilities.
        /// </summary>
        /// <param name="topology">
        ///   A <see cref="Topology"/> object specifying the initial values of the matrix of transition
        ///   probabilities <c>A</c> and initial state probabilities <c>pi</c> to be used by this model.
        /// </param>
        /// <param name="emissions">
        ///   The initial emission probability distribution to be used by each of the states.
        /// </param>
        public ContinuousHiddenMarkovModel(ITopology topology, IDistribution emissions)
            : base(topology)
        {
            if (emissions == null)
            {
                throw new ArgumentNullException("emissions");
            }

            // Initialize B using the initial distribution
            B = new IDistribution[States];

            for (int i = 0; i < B.Length; i++)
            {
                B[i] = (IDistribution)emissions.Clone();
            }

            if (B[0] is IMultivariateDistribution)
            {
                dimension = ((IMultivariateDistribution)B[0]).Dimension;
            }
            else
            {
                dimension = 1;
            }
        }
        public static SimpleGraph CreateGraph(ITopology topology)
        {
            var nodeCount  = topology.IndexCount;
            var neighbours = new int[nodeCount][];

            for (int i = 0; i < nodeCount; i++)
            {
                if (!topology.ContainsIndex(i))
                {
                    neighbours[i] = Emtpy;
                }

                var n = new List <int>();
                for (var d = 0; d < topology.DirectionsCount; d++)
                {
                    if (topology.TryMove(i, (Direction)d, out var dest))
                    {
                        n.Add(dest);
                    }
                }
                neighbours[i] = n.ToArray();
            }

            return(new SimpleGraph
            {
                NodeCount = nodeCount,
                Neighbours = neighbours,
            });
        }
Exemple #19
0
        //验证拓扑
        private void VaildateTopo(ITopology pTopology, IEnvelope pEnvelope)
        {
            double      x      = pEnvelope.LowerLeft.X;
            double      y      = pEnvelope.LowerLeft.Y;
            IGeoDataset pGeoDS = pTopology as IGeoDataset;

            pTopology.ValidateTopology(pEnvelope);
        }
Exemple #20
0
        private void btnCreateTopo_Click(object sender, EventArgs e)
        {
            SpatialDBMS.Classes.Topology second = new SpatialDBMS.Classes.Topology();
            ITopology myTempTopology            = second.create_topology(myWorkSpace, CB_FCIndex, textBoxTopoName.Text);

            myTopology = myTempTopology;
            MessageBox.Show("创建拓扑成功 !");
        }
Exemple #21
0
 /// <summary>
 ///   Creates a new Sequence Classifier with the given number of classes.
 /// </summary>
 ///
 /// <param name="classes">The number of classes in the classifier.</param>
 /// <param name="topology">The topology of the hidden states. A forward-only topology
 /// is indicated to sequence classification problems, such as speech recognition.</param>
 /// <param name="initial">The initial probability distributions for the hidden states.
 /// For multivariate continuous density distributions, such as Normal mixtures, the
 /// choice of initial values is crucial for a good performance.</param>
 ///
 public HiddenMarkovClassifier(int classes, ITopology topology, Func <int, int, TDistribution> initial)
     : base(classes)
 {
     for (int i = 0; i < classes; i++)
     {
         Models[i] = new HiddenMarkovModel <TDistribution, TObservation>(topology, (stateIndex) => initial(i, stateIndex));
     }
 }
Exemple #22
0
 /// <summary>
 ///   Creates a new Sequence Classifier with the given number of classes.
 /// </summary>
 public SequenceClassifier(int classes, ITopology topology, TDistribution initial)
     : base(classes)
 {
     for (int i = 0; i < classes; i++)
     {
         Models[i] = new HiddenMarkovModel <TDistribution>(topology, initial);
     }
 }
Exemple #23
0
 /// <summary>
 ///   Creates a new Sequence Classifier with the given number of classes.
 /// </summary>
 ///
 public HiddenMarkovClassifier(int classes, ITopology topology, int symbols)
     : base(classes)
 {
     for (int i = 0; i < classes; i++)
     {
         Models[i] = new HiddenMarkovModel(topology, symbols);
     }
 }
        /// <summary>
        ///   Constructs a new Hidden Markov Model.
        /// </summary>
        ///
        protected HiddenMarkovModel(ITopology topology)
        {
            double[,] a;
            this.states = topology.Create(true, out a, out logPi);
            logA        = a.ToJagged();

            NumberOfInputs = 1;
        }
 /// <summary>
 ///   Creates a new Sequence Classifier with the given number of classes.
 /// </summary>
 public ContinuousSequenceClassifier(int classes, ITopology topology, IDistribution initial)
     : base(classes)
 {
     for (int i = 0; i < classes; i++)
     {
         Models[i] = new ContinuousHiddenMarkovModel(topology, initial);
     }
 }
 /// <summary>
 ///   Creates a new Sequence Classifier with the given number of classes.
 /// </summary>
 ///
 /// <param name="classes">The number of classes in the classifier.</param>
 /// <param name="topology">The topology of the hidden states. A forward-only topology
 /// is indicated to sequence classification problems, such as speech recognition.</param>
 /// <param name="initial">The initial probability distributions for the hidden states.
 /// For multivariate continuous density distributions, such as Normal mixtures, the
 /// choice of initial values is crucial for a good performance.</param>
 ///
 public HiddenMarkovClassifier(int classes, ITopology topology, TDistribution[] initial)
     : base(classes)
 {
     for (int i = 0; i < classes; i++)
     {
         Models[i] = new HiddenMarkovModel <TDistribution, TObservation>(topology, initial[i]);
     }
 }
 public Configuration(ITopology topology)
 {
     IsMaster = !topology.Replicas.Any();
     if (!IsMaster)
     {
         MasterEndpoint = topology.Replicas.First();
     }
 }
Exemple #28
0
        protected void Publish(string exchange, string routingKey, ITopology topology, MessageProperties properties,
                               byte[] messageBody, Action <IPublishConfiguration> configure)
        {
            if (disposed)
            {
                throw new Exception("PublishChannel is already disposed");
            }
            if (!_rabbitMessageBus.PersistentConnection.IsConnected)
            {
                throw new Exception("Publish failed. No rabbit server connected.");
            }

            try
            {
                var configuration = new AdvancedPublishConfiguration();
                if (configure != null)
                {
                    configure(configuration);
                }

                if (_publisherConfirms != null)
                {
                    //if (configuration.SuccessCallback == null || configuration.FailureCallback == null)
                    //{
                    //    throw new Exception("When pulisher confirms are on, you must supply success and failure callbacks in the publish configuration");
                    //}

                    _publisherConfirms.RegisterCallbacks(_channel,
                                                         configuration.SuccessCallback != null ? configuration.SuccessCallback : () => { },
                                                         configuration.FailureCallback != null ? configuration.FailureCallback : () => { });
                }

                var defaultProperties = _channel.CreateBasicProperties();
                properties.CopyTo(defaultProperties);

                if (topology != null)
                {
                    topology.Visit(new TopologyBuilder(_channel));
                }

                _channel.BasicPublish(
                    exchange,          // exchange
                    routingKey,        // routingKey
                    defaultProperties, // basicProperties
                    messageBody);      // body

                _rabbitMessageBus.Logger.Debug(string.Format("Published to exchange: '{0}', routing key: '{1}', correlationId: '{2}'",
                                                             exchange, routingKey, defaultProperties.CorrelationId));
            }
            catch (OperationInterruptedException exception)
            {
                throw new Exception(string.Format("Publish Failed: '{0}'", exception.Message));
            }
            catch (IOException exception)
            {
                throw new Exception(string.Format("Publish Failed: '{0}'", exception.Message));
            }
        }
 /// <summary>
 /// Instancia um objeto do tipo HiddenMarkovModel.
 /// </summary>
 /// <param name="states">número de estados</param>
 /// <param name="observations">número de observações</param>
 /// <param name="topology">topologia do modelo</param>
 public HiddenMarkovModel(int states, int observations, ITopology topology)
 {
     States       = states;
     Observations = observations;
     A            = new double[states, states];
     B            = new double[states, observations];
     Pi           = new double[states];
     topology.Init(this);
 }
Exemple #30
0
 /// <summary>
 /// Constructs a TilePropagator.
 /// </summary>
 /// <param name="tileModel">The model to guide the generation.</param>
 /// <param name="topology">The dimensions of the output to generate</param>
 /// <param name="backtrack">If true, store additional information to allow rolling back choices that lead to a contradiction.</param>
 /// <param name="constraints">Extra constraints to control the generation process.</param>
 public TilePropagator(TileModel tileModel, ITopology topology, bool backtrack = false,
                       ITileConstraint[] constraints = null)
     : this(tileModel, topology, new TilePropagatorOptions
 {
     BackTrackDepth = backtrack ? -1 : 0,
     Constraints = constraints,
 })
 {
 }
        public static HiddenMarkovModel<GeneralDiscreteDistribution, int> CreateDiscrete(ITopology topology, int symbols, bool random)
        {
            if (symbols <= 0)
            {
                throw new ArgumentOutOfRangeException("symbols",
                    "Number of symbols should be higher than zero.");
            }

            double[,] A;
            double[] pi;
            topology.Create(true, out A, out pi);

            // Initialize B with a uniform discrete distribution
            var B = new GeneralDiscreteDistribution[topology.States];

            if (random)
            {
                for (int i = 0; i < B.Length; i++)
                {
                    double[] probabilities = new double[symbols];

                    double sum = 0;
                    for (int j = 0; j < probabilities.Length; j++)
                        sum += probabilities[j] = Accord.Math.Random.Generator.Random.NextDouble();

                    for (int j = 0; j < probabilities.Length; j++)
                        probabilities[j] /= sum;

                    B[i] = new GeneralDiscreteDistribution(true, probabilities.Log());
                }
            }
            else
            {
                for (int i = 0; i < B.Length; i++)
                    B[i] = new GeneralDiscreteDistribution(logarithm: true, symbols: symbols);
            }


            return new HiddenMarkovModel<GeneralDiscreteDistribution, int>(A, B, pi, logarithm: true);
        }
Exemple #32
0
        //---------------------------------------------


        #region Constructors
        /// <summary>
        ///   Constructs a new Hidden Markov Model.
        /// </summary>
        /// 
        /// <param name="topology">
        ///   A <see cref="Topology"/> object specifying the initial values of the matrix of transition 
        ///   probabilities <c>A</c> and initial state probabilities <c>pi</c> to be used by this model.
        /// </param>
        /// <param name="emissions">The emissions matrix B for this model.</param>
        /// <param name="logarithm">Set to true if the matrices are given with logarithms of the
        /// intended probabilities; set to false otherwise. Default is false.</param>
        /// 
        public HiddenMarkovModel(ITopology topology, double[,] emissions, bool logarithm = false)
            : base(topology)
        {
            if (logarithm)
                logB = emissions;
            else logB = Matrix.Log(emissions);

            symbols = logB.GetLength(1);
        }
Exemple #33
0
        public void Release()
        {
            if (m_NormalRuleList != null)
            {
                for (int i = 0; i < m_NormalRuleList.Count; i++)
                {
                    m_NormalRuleList[i] = null;
                }
            }
            if (m_TopoRuleList != null)
            {
                for (int i = 0; i < m_TopoRuleList.Count; i++)
                {
                    m_TopoRuleList[i] = null;
                }
            }

            this.BaseWorkspace = null;
            this.QueryConnection = null;
            this.QueryWorkspace = null;
            this.RuleInfos = null;
            this.SchemaID = null;
            this.TopoDBPath = null;
            this.TopoTolerance = -1;
            //this.Messager = null;

            if (this.m_ResultConnection != null)
            {
                if (this.m_ResultConnection.State != ConnectionState.Closed)
                    this.m_ResultConnection.Close();
            }
            if (this.m_Topology != null)
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(this.m_Topology);
                this.m_Topology = null;
            }
            if (this.m_TopoWorkspace != null)
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(this.m_TopoWorkspace);
                this.m_TopoWorkspace = null;
            }
        }
Exemple #34
0
        /// <summary>
        ///   Constructs a new Hidden Markov Model.
        /// </summary>
        /// <param name="topology">
        ///   A <see cref="Topology"/> object specifying the initial values of the matrix of transition 
        ///   probabilities <c>A</c> and initial state probabilities <c>pi</c> to be used by this model.
        /// </param>
        /// <param name="symbols">The number of output symbols used for this model.</param>
        public HiddenMarkovModel(ITopology topology, int symbols)
            : base(topology)
        {
            this.symbols = symbols;

            // Initialize B with uniform probabilities
            logB = new double[States, symbols];
            for (int i = 0; i < States; i++)
                for (int j = 0; j < symbols; j++)
                    logB[i, j] = 1.0 / symbols;

            logB = Matrix.Log(logB);
        }
        /// <summary>
        ///   Constructs a new Hidden Markov Model.
        /// </summary>
        /// <param name="topology">
        ///   A <see cref="Topology"/> object specifying the initial values of the matrix of transition 
        ///   probabilities <c>A</c> and initial state probabilities <c>pi</c> to be used by this model.
        /// </param>
        /// <param name="emissions">
        ///   The initial emission probability distributions for each state.
        /// </param>
        public ContinuousHiddenMarkovModel(ITopology topology, IDistribution[] emissions)
            : base(topology)
        {
            if (emissions == null)
            {
                throw new ArgumentNullException("emissions");
            }

            if (emissions.GetLength(0) != States)
            {
                throw new ArgumentException(
                    "The emission matrix should have the same number of rows as the number of states in the model.",
                    "emissions");
            }

            B = emissions;

            if (B[0] is IMultivariateDistribution)
                dimension = ((IMultivariateDistribution) B[0]).Dimension;
            else dimension = 1;
        }
Exemple #36
0
        public bool ValidateTopology(ITopology t)
        {
            bool theReturn = false;

            if (t != null)
            {
                try
                {
                    IWorkspaceEdit theWSEdit = t.FeatureDataset.Workspace as IWorkspaceEdit;
                    if (theWSEdit != null)
                    {
                        IGeoDataset theGeoDS = (IGeoDataset)t;
                        ISegmentCollection theSegColl = new PolygonClass();
                        theSegColl.SetRectangle(theGeoDS.Extent);

                        IPolygon theDirtyArea = t.get_DirtyArea((IPolygon)theSegColl);

                        if (theDirtyArea.IsEmpty == false)
                        {
                            bool bNeedStopEdit = false;
                            if (theWSEdit.IsBeingEdited() == false)
                            {
                                theWSEdit.StartEditing(false);
                                bNeedStopEdit = true;
                            }

                            try
                            {
                                theWSEdit.StartEditOperation();
                                t.ValidateTopology(theDirtyArea.Envelope);
                                theWSEdit.StopEditOperation();

                                if (bNeedStopEdit)
                                {
                                    theWSEdit.StopEditing(true);
                                }
                            }
                            catch (Exception ex)
                            {
                                theWSEdit.StopEditing(false);
                                throw ex;
                            }
                        }

                        theReturn = true;
                    }
                }
                catch (Exception ex)
                {
                    this.LogMessage("Exception raised validating topology for " + this.Name + Environment.NewLine
                        + ex.Message + Environment.NewLine + ex.StackTrace);
                }
            }

            return theReturn;
        }
Exemple #37
0
        /// <summary>
        /// 添加拓扑规则条件 
        /// </summary>
        /// <param name="topology">拓扑对象</param>
        /// <param name="ruleType">规则类型</param>
        /// <param name="ruleName">规则名称</param>
        /// <param name="featureClass">要素类</param>
        private void AddRuleToTopology(ITopology topology, esriTopologyRuleType ruleType, String ruleName, IFeatureClass featureClass)
        {
            try
            {
                // Create a topology rule.
                ITopologyRule topologyRule = new TopologyRuleClass();
                topologyRule.TopologyRuleType = ruleType;
                topologyRule.Name = ruleName;
                topologyRule.OriginClassID = featureClass.FeatureClassID;
                topologyRule.AllOriginSubtypes = true;

                // Cast the topology to the ITopologyRuleContainer interface and add the rule.
                ITopologyRuleContainer topologyRuleContainer = (ITopologyRuleContainer)topology;
                if (topologyRuleContainer.get_CanAddRule(topologyRule))
                {
                    topologyRuleContainer.AddRule(topologyRule);
                }
                else
                {
                    throw new ArgumentException("Could not add specified rule to the topology.");
                }
            }
            catch (Exception)
            {

            }
        }
Exemple #38
0
        private ArrayList ProcessPotentialGapErrors(ArrayList pointPairs, ITopology topology, IFeatureClass sourceFC,
			double limitRadians, bool allowPinches)
        {
            ArrayList theReturn = new ArrayList();

            // We have a list of pairs of points on opposite sides of a gap which are
            // within the tolerance distances. We need to calculate the angles
            /*
             * Format of the "pair" is IndexPoint[6]
             * [0] - thePoint
             * [1] - theOtherPoint
             * [2] - point preceding thePoint in source feature shape
             * [3] - point following thePoint in source feature shape
             * [4] - point preceding theOtherPoint in source feature shape
             * [5] - point following theOtherPoint in source feature shape
             */
            int count = 0;
            IScratchWorkspaceFactory theFactory = new ScratchWorkspaceFactoryClass();

            for (int i = 0; i < pointPairs.Count; i++)
            {
                IndexPoint[] thePair = (IndexPoint[])pointPairs[i];

                // Construct line segments and compare angles
                ILine[] theLines = new ILine[2];
                ILine[] theOtherLines = new ILine[2];
                if (thePair[2] != null) theLines[0] = this.ConstructLine(thePair[2].X, thePair[2].Y, thePair[0].X, thePair[0].Y);
                if (thePair[3] != null) theLines[1] = this.ConstructLine(thePair[0].X, thePair[0].Y, thePair[3].X, thePair[3].Y);
                if (thePair[4] != null) theOtherLines[0] = this.ConstructLine(thePair[4].X, thePair[4].Y, thePair[1].X, thePair[1].Y);
                if (thePair[5] != null) theOtherLines[1] = this.ConstructLine(thePair[1].X, thePair[1].Y, thePair[5].X, thePair[5].Y);

                bool bFoundError = false;

                for (int j = 0; j < theLines.Length; j++)
                {
                    for (int k = 0; k < theOtherLines.Length; k++)
                    {
                        // Eval angle. If it is less than the limit, Create an error and add it to the collection
                        double angleRadians = this.EvalAngle(theLines[j], theOtherLines[k]);
                        if (double.IsNaN(angleRadians) == false)
                        {
                            if (angleRadians >= 0 && angleRadians < limitRadians)
                            {
                                // Error point will be 1/2 way between points
                                ILine theGap = this.ConstructLine(thePair[0].X, thePair[0].Y, thePair[1].X, thePair[1].Y);
                                double theGapSize = theGap.Length;

                                IPolyline theGapPolyline = new PolylineClass();
                                theGapPolyline.Project(SpatialReferenceHelper.BCAlbersSpatialReference);
                                ((ISegmentCollection)theGapPolyline).AddSegment((ISegment)theGap, ref this._missing, ref this._missing);
                                theGapPolyline.Project(SpatialReferenceHelper.GeographicReference);

                                IPoint theErrorPoint = new PointClass();
                                theGapPolyline.QueryPoint(esriSegmentExtension.esriNoExtension, 0.5, true, theErrorPoint);

                                if (allowPinches || this.IsPinch(
                                    theErrorPoint,
                                    theGapPolyline,
                                    sourceFC,
                                    theFactory.DefaultScratchWorkspace
                                    ) == false)
                                {
                                    IDataset theDataset = (IDataset)sourceFC;

                                    PotentialError thePError = new PotentialError();
                                    thePError.AngleDegrees = angleRadians * 180 / Math.PI;
                                    thePError.ErrorPoint = theErrorPoint;
                                    thePError.FeatureClassName = theDataset.Name;
                                    thePError.FromPoint = theGapPolyline.FromPoint;
                                    thePError.GapSize = theGapSize;
                                    thePError.OtherOID = thePair[1].SourceFeatureID;
                                    thePError.OtherPointIndex = thePair[1].SourcePointIndex;
                                    thePError.SourceOID = thePair[0].SourceFeatureID;
                                    thePError.SourcePointIndex = thePair[0].SourcePointIndex;
                                    thePError.ToPoint = theGapPolyline.ToPoint;

                                    theReturn.Add(thePError);
                                }

                                bFoundError = true;
                            }
                        }
                        if (bFoundError)
                            break;
                    }
                    if (bFoundError)
                        break;
                }

                if (++count % 500 == 0)
                    this.LogMessage("Processed gap " + count + " of " + pointPairs.Count);
            }

            return theReturn;
        }
        /// <summary>
        ///   Constructs a new Hidden Markov Model with discrete state probabilities.
        /// </summary>
        /// <param name="topology">
        ///   A <see cref="Topology"/> object specifying the initial values of the matrix of transition 
        ///   probabilities <c>A</c> and initial state probabilities <c>pi</c> to be used by this model.
        /// </param>
        /// <param name="symbols">The number of output symbols used for this model.</param>
        public ContinuousHiddenMarkovModel(ITopology topology, int symbols)
            : base(topology)
        {
            if (symbols <= 0)
            {
                throw new ArgumentOutOfRangeException("symbols",
                                                      "Number of symbols should be higher than zero.");
            }

            // Initialize B with a uniform discrete distribution
            B = new IDistribution[States];
            for (int i = 0; i < B.Length; i++)
                B[i] = new GeneralDiscreteDistribution(symbols);

            dimension = 1;
        }
 public AzureServiceBusSender(ITopology topology, Configure config)
 {
     this.topology = topology;
     this.config = config;
 }
        private double[] logPi; // Initial state probabilities



        /// <summary>
        ///   Constructs a new Hidden Markov Model.
        /// </summary>
        /// 
        protected BaseHiddenMarkovModel(ITopology topology)
        {
            double[,] a;
            this.states = topology.Create(true, out a, out logPi);
            this.logA = a.ToJagged();
        }
 public AzureServiceBusTopologyCreator(ITopology topology)
 {
     this.topology = topology;
 }
 public AzureServiceBusPublisher(Configure config, ITopology topology)
 {
     this.config = config;
     this.topology = topology;
 }
 public AzureServiceBusTopicSubscriptionManager(Configure config, ITopology topology)
 {
     this.config = config;
     this.topology = topology;
 }
        private double[] logPi; // Initial state probabilities



        /// <summary>
        ///   Constructs a new Hidden Markov Model.
        /// </summary>
        /// 
        protected BaseHiddenMarkovModel(ITopology topology)
        {
            this.states = topology.Create(true, out logA, out logPi);
        }
Exemple #46
0
        /// <summary>
        /// 验证拓扑
        /// </summary>
        /// <param name="topology">拓扑对象</param>
        /// <param name="envelope">验证范围</param>
        private void ValidateTopology(ITopology topology, ESRI.ArcGIS.Geometry.IEnvelope envelope)
        {
            try
            {
                // Get the dirty area within the provided envelope.
                ESRI.ArcGIS.Geometry.IPolygon locationPolygon = new ESRI.ArcGIS.Geometry.PolygonClass();
                ESRI.ArcGIS.Geometry.ISegmentCollection segmentCollection = (ESRI.ArcGIS.Geometry.ISegmentCollection)locationPolygon;
                segmentCollection.SetRectangle(envelope);
                ESRI.ArcGIS.Geometry.IPolygon polygon = topology.get_DirtyArea(locationPolygon);

                // If a dirty area exists, validate the topology.if (!polygon.IsEmpty)
                {
                    // Define the area to validate and validate the topology.
                    ESRI.ArcGIS.Geometry.IEnvelope areaToValidate = polygon.Envelope;
                    ESRI.ArcGIS.Geometry.IEnvelope areaValidated = topology.ValidateTopology(areaToValidate);

                }
            }
            catch (Exception)
            {

            }
        }
Exemple #47
0
        private void ReOpenTopo()
        {
            if (this.m_Topology == null)
                return;

            System.Runtime.InteropServices.Marshal.ReleaseComObject(this.m_Topology);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(this.m_TopoWorkspace);

            Hy.Common.Utility.Esri.AEAccessFactory.OpenFGDB(ref this.m_TopoWorkspace,this.m_TopoDBPath+"\\"+ COMMONCONST.DB_Name_Topo);
            this.m_Topology= (this.m_TopoWorkspace as ITopologyWorkspace).OpenTopology(COMMONCONST.Topology_Name);

            for (int i = 0; i < m_NormalRuleList.Count; i++)
            {
                m_NormalRuleList[i].TopoWorkspace = this.m_TopoWorkspace;
            }

            for (int i = 0; i < m_TopoRuleList.Count; i++)
            {
                m_TopoRuleList[i].TopoWorkspace = this.m_TopoWorkspace;
                (m_TopoRuleList[i] as ITopologicalRule).Topology = this.m_Topology;
            }
        }
 /// <summary>
 ///   Constructs a new Hidden Markov Model.
 /// </summary>
 /// <param name="topology">
 ///   A <see cref="Topology"/> object specifying the initial values of the matrix of transition 
 ///   probabilities <c>A</c> and initial state probabilities <c>pi</c> to be used by this model.
 /// </param>
 /// <param name="emissions">The emissions matrix B for this model.</param>
 public HiddenMarkovModel(ITopology topology, double[,] emissions)
     : base(topology)
 {
     B = emissions;
     symbols = B.GetLength(1);
 }
        /// <summary>
        ///   Constructs a new Hidden Markov Model with discrete state probabilities.
        /// </summary>
        /// <param name="topology">
        ///   A <see cref="Topology"/> object specifying the initial values of the matrix of transition 
        ///   probabilities <c>A</c> and initial state probabilities <c>pi</c> to be used by this model.
        /// </param>
        /// <param name="emissions">
        ///   The initial emission probability distribution to be used by each of the states.
        /// </param>
        public ContinuousHiddenMarkovModel(ITopology topology, IDistribution emissions)
            : base(topology)
        {
            if (emissions == null)
            {
                throw new ArgumentNullException("emissions");
            }

            // Initialize B using the initial distribution
            B = new IDistribution[States];

            for (int i = 0; i < B.Length; i++)
                B[i] = (IDistribution) emissions.Clone();

            if (B[0] is IMultivariateDistribution)
                dimension = ((IMultivariateDistribution) B[0]).Dimension;
            else dimension = 1;
        }
 public AzureServiceBusDequeueStrategy(ITopology topology, CriticalError criticalError)
 {
     this.topology = topology;
     this.criticalError = criticalError;
     circuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker("AzureServiceBusDequeueStrategy", TimeSpan.FromSeconds(30), ex => criticalError.Raise("Failed to receive message from Azure ServiceBus.", ex));
 }
 public static HiddenMarkovModel<GeneralDiscreteDistribution, int> CreateDiscrete(ITopology topology, int symbols)
 {
     return CreateDiscrete(topology, symbols, false);
 }
 /// <summary>
 ///   Constructs a new Hidden Markov Model.
 /// </summary>
 protected HiddenMarkovModelBase(ITopology topology)
 {
     states = topology.Create(out A, out pi);
 }
Exemple #53
0
        /// <summary>
        ///   Constructs a new Hidden Markov Model with discrete state probabilities.
        /// </summary>
        /// 
        /// <param name="topology">
        ///   A <see cref="Topology"/> object specifying the initial values of the matrix of transition 
        ///   probabilities <c>A</c> and initial state probabilities <c>pi</c> to be used by this model.
        /// </param>
        /// <param name="symbols">The number of output symbols used for this model.</param>
        /// 
        public static HiddenMarkovModel<GeneralDiscreteDistribution> CreateGeneric(ITopology topology, int symbols)
        {
            if (symbols <= 0)
            {
                throw new ArgumentOutOfRangeException("symbols",
                    "Number of symbols should be higher than zero.");
            }

            // Initialize B with a uniform discrete distribution
            GeneralDiscreteDistribution[] B = new GeneralDiscreteDistribution[topology.States];

            for (int i = 0; i < B.Length; i++)
                B[i] = new GeneralDiscreteDistribution(symbols);

            return new HiddenMarkovModel<GeneralDiscreteDistribution>(topology, B);
        }
 /// <summary>
 ///   Constructs a new Hidden Markov Model.
 /// </summary>
 /// <param name="topology">
 ///   A <see cref="Topology"/> object specifying the initial values of the matrix of transition 
 ///   probabilities <c>A</c> and initial state probabilities <c>pi</c> to be used by this model.
 /// </param>
 /// <param name="emissions">The emissions matrix B for this model.</param>
 public HiddenMarkovModel(ITopology topology, double[,] emissions)
     : base(topology)
 {
     B = emissions;
 }
Exemple #55
0
        private void Init()
        {
            this.m_ErrorCount = 0;
            this.m_SucceedCount = 0;

            // 验证
            if (this.m_BaseWorkspace == null)
            {
                SendMessage(enumMessageType.Exception, "检查驱动的Base库没有设置,无法继续检查");
                return;
            }
            if (this.m_QueryWorkspace == null || this.m_QueryConnection == null)
            {
                SendMessage(enumMessageType.Exception, "检查驱动的Query库没有设置,无法继续检查");
                return;
            }

            // 结果库
            try
            {
                string strResultDBFile = this.m_ResultPath + "\\" + COMMONCONST.DB_Name_Result;
                System.IO.File.Copy(System.Windows.Forms.Application.StartupPath + "\\template\\report\\result_AutoTmpl.mdb", strResultDBFile, true);
                this.m_ResultConnection = Hy.Common.Utility.Data.AdoDbHelper.GetDbConnection(strResultDBFile);

            }
            catch (Exception exp)
            {
                SendMessage(enumMessageType.Exception, string.Format("创建结果库出错,信息:{0}", exp.Message));
                return;
            }

            // 创建规则实例,赋值,分类

            if (RuleInfos == null || RuleInfos.Count == 0)
                return;

            int count = RuleInfos.Count;
            m_NormalRuleList = new List<ICheckRule>();
            m_TopoRuleList = new List<ICheckRule>();
            m_DictRuleAndInfo = new Dictionary<ICheckRule, SchemaRule>();
            for (int i = 0; i < count; i++)
            {
                if (this.RuleInfos[i] == null || this.RuleInfos[i].ruleDllInfo == null)
                    continue;

                RuleInfo ruleInfo = new RuleInfo();// this.RuleInfos[i].ruleDllInfo;
                ruleInfo.ID = this.RuleInfos[i].arrayRuleParas[0].strInstID;
                ruleInfo.Name = this.RuleInfos[i].arrayRuleParas[0].strName;
                ruleInfo.Paramters = this.RuleInfos[i].arrayRuleParas[0].pParas;
                ruleInfo.RuleClassInfo = this.RuleInfos[i].ruleDllInfo;
                ruleInfo.Description = this.RuleInfos[i].strRemark;

                //if (ruleClassInfo == null)
                //    continue;

                if (ruleInfo.RuleClassInfo == null)
                {
                    SendMessage(enumMessageType.OperationalLog, string.Format("规则“{0}”无类信息,跳过检查", ruleInfo.Name));
                    continue;
                }

                ICheckRule checkRule = RuleFactory.CreateRuleInstance(ruleInfo.RuleClassInfo.DllName, ruleInfo.RuleClassInfo.ClassName);
                if (checkRule == null)
                {
                    SendMessage(enumMessageType.OperationalLog, string.Format("规则“{0}”反射未成功,跳过检查", ruleInfo.Name));
                    continue;

                }

                try
                {
                    // 参数设置
                    checkRule.BaseWorkspace = this.m_BaseWorkspace;
                    checkRule.InstanceName = ruleInfo.Name;
                    checkRule.InstanceID = ruleInfo.ID;
                    checkRule.DefectLevel = DefectHelper.GetRuleDefectLevel(ruleInfo.ID);
                    checkRule.MessageHandler = this.m_Messager;
                    checkRule.QueryConnection = this.m_QueryConnection;
                    checkRule.QueryWorkspace = this.m_QueryWorkspace;
                    checkRule.TopoWorkspace = this.m_TopoWorkspace;
                    checkRule.ResultConnection = this.m_ResultConnection;
                    checkRule.SchemaID = this.m_SchemaID;
                    checkRule.SetParamters(ruleInfo.Paramters);

                    if (checkRule.ErrorType == enumErrorType.Topology)
                    {
                        if (m_Topology == null)
                        {
                            try
                            {
                                // 先创建Topo库(空库)和结果库
                                if (System.IO.Directory.Exists(this.m_TopoDBPath + "\\" + COMMONCONST.DB_Name_Topo))
                                {
                                    System.IO.Directory.Delete(this.m_TopoDBPath + "\\" + COMMONCONST.DB_Name_Topo, true);
                                }
                                Hy.Common.Utility.Esri.AEAccessFactory.CreateFGDB(this.m_TopoDBPath, COMMONCONST.DB_Name_Topo, ref this.m_TopoWorkspace);
                                if (this.m_TopoWorkspace == null)
                                {
                                    SendMessage(enumMessageType.Exception, "创建拓扑库失败");
                                }

                                // 根据Base库找第一个Geodataset的空间参考,用来创建拓扑库
                                ISpatialReference topoSptatialRef = null;
                                IEnumDataset enDataset = this.m_BaseWorkspace.get_Datasets(esriDatasetType.esriDTAny);
                                IDataset ds = enDataset.Next();
                                while (ds != null)
                                {
                                    if (ds is IGeoDataset)
                                    {
                                        topoSptatialRef = (ds as IGeoDataset).SpatialReference;
                                        break;
                                    }
                                    ds = enDataset.Next();
                                }
                                IFeatureDataset fDataset = (this.m_TopoWorkspace as IFeatureWorkspace).CreateFeatureDataset(COMMONCONST.Dataset_Name, topoSptatialRef);
                                if (fDataset == null)
                                {
                                    SendMessage(enumMessageType.Exception, "创建拓扑库Dataset失败");
                                }

                                ITopologyContainer topoContainer = fDataset as ITopologyContainer;
                                //m_Topology = topoContainer.get_TopologyByName(COMMONCONST.Topology_Name);    // 若已有Topology,则不再创建

                                //if (m_Topology == null)
                                    m_Topology = topoContainer.CreateTopology(COMMONCONST.Topology_Name, this.m_TopoTolerance, COMMONCONST.TopoError_MaxCount, "esriConfigurationKeywordTopology");
                            }
                            catch (Exception exp)
                            {
                                SendMessage(enumMessageType.Exception, "创建Topology出错,信息:" + exp.ToString());
                            }
                        }
                        (checkRule as ITopologicalRule).Topology = m_Topology;

                        m_TopoRuleList.Add(checkRule);
                    }
                    else
                    {
                        m_NormalRuleList.Add(checkRule);
                    }
                    //m_RuleList.Add(checkRule);
                    m_DictRuleAndInfo.Add(checkRule, this.RuleInfos[i]);

                }
                catch (Exception ex)
                {
                    SendMessage(enumMessageType.Exception, "初始化规则失败,信息:" + ex.ToString());
                    continue;
                }
            }
        }