//����׷�ٵĽ��
        public static void FindStreamTraceResult(AxMapControl ppAxMapControl, INetFlag ipNetFlag, IGeometricNetwork pGeoNetwork)
        {
            try
            {

                IEnumNetEID m_ipEnumNetEID_Junctions, m_ipEnumNetEID_Edges;//����������������Junctions��Edges
                IJunctionFlag[] pArrayJFlag = new IJunctionFlag[1];
                pArrayJFlag[0] = ipNetFlag as IJunctionFlag;
                ITraceFlowSolverGEN ipTraceFlowSolver = new TraceFlowSolverClass() as ITraceFlowSolverGEN;

                //get the inetsolver interface
                INetSolver ipNetSolver = ipTraceFlowSolver as INetSolver;
                ipNetSolver.SourceNetwork = pGeoNetwork.Network;

                ipTraceFlowSolver.PutJunctionOrigins(ref pArrayJFlag);

                ipTraceFlowSolver.TraceIndeterminateFlow = false;

                object[] totalCost = new object[1];

                //ipTraceFlowSolver.FindSource(esriFlowMethod.esriFMUpstream,esriShortestPathObjFn.esriSPObjFnMinSum,out m_ipEnumNetEID_Junctions,out m_ipEnumNetEID_Edges,1,ref totalCost);

                ipTraceFlowSolver.FindFlowElements(esriFlowMethod.esriFMUpstream,
                    esriFlowElements.esriFEEdges,
                    out m_ipEnumNetEID_Junctions,
                    out m_ipEnumNetEID_Edges);

                //ma
                //SpatialHelperFunction.pathToPolyline(pGeoNetwork, ppAxMapControl.ActiveView, m_ipEnumNetEID_Edges);
                //UpStreamFindParcels(ppAxMapControl, m_ipEnumNetEID_Edges,pGeoNetwork);
            }
            catch (Exception eX)
            {
                MessageBox.Show(eX.Message);

            }
        }
        public ITraceFlowSolverGEN UTIL_coreTraceSetup()
        {
            // get the current network's logical network
            INetworkAnalysisExt nax = m_utilNetExt as INetworkAnalysisExt;
            INetwork            net = nax.CurrentNetwork.Network;

            // create a new TraceFlowSolver object and
            // set the source network for the solve
            ITraceFlowSolverGEN tfs       = new TraceFlowSolverClass() as ITraceFlowSolverGEN;
            INetSolver          netSolver = tfs as INetSolver;

            netSolver.SourceNetwork = net;

            // get the barriers for the network, using the element barriers and
            // selection barriers that have been added using the user interface
            INetworkAnalysisExtBarriers naxBarriers = m_utilNetExt as INetworkAnalysisExtBarriers;
            INetElementBarriers         juncElemBarriers, edgeElemBarriers;

            naxBarriers.CreateElementBarriers(out juncElemBarriers, out edgeElemBarriers);
            ISelectionSetBarriers selSetBarriers;

            naxBarriers.CreateSelectionBarriers(out selSetBarriers);
            netSolver.set_ElementBarriers(esriElementType.esriETJunction, juncElemBarriers);
            netSolver.set_ElementBarriers(esriElementType.esriETEdge, edgeElemBarriers);
            netSolver.SelectionSetBarriers = selSetBarriers;

            // set up the disabled layers for the network solver
            // for each feature layer belonging to this network, determine if it is
            // enabled or disabled; if it's disabled, then notify the network solver
            for (int i = 0; i < nax.FeatureLayerCount; i++)
            {
                IFeatureLayer featureLayer = nax.get_FeatureLayer(i);
                if (naxBarriers.GetDisabledLayer(featureLayer))
                {
                    netSolver.DisableElementClass(featureLayer.FeatureClass.FeatureClassID);
                }
            }

            INetworkAnalysisExtWeightFilter naxWeightFilter  = m_utilNetExt as INetworkAnalysisExtWeightFilter;
            INetSolverWeightsGEN            netSolverWeights = netSolver as INetSolverWeightsGEN;
            INetSchema netSchema = net as INetSchema;

            // create the junction weight filter
            int juncFilterRangeCount = naxWeightFilter.get_FilterRangeCount(esriElementType.esriETJunction);

            if (juncFilterRangeCount > 0)
            {
                INetWeight netWeight = netSchema.get_WeightByName(naxWeightFilter.JunctionWeightFilterName);
                netSolverWeights.JunctionFilterWeight = netWeight;

                esriWeightFilterType juncWeightFilterType;
                bool juncApplyNotOperator;
                naxWeightFilter.GetFilterType(esriElementType.esriETJunction,
                                              out juncWeightFilterType, out juncApplyNotOperator);
                netSolverWeights.SetFilterType(esriElementType.esriETJunction,
                                               juncWeightFilterType, juncApplyNotOperator);

                object[] juncFromValues = new object[juncFilterRangeCount];
                object[] juncToValues   = new object[juncFilterRangeCount];
                for (int i = 0; i < juncFilterRangeCount; i++)
                {
                    naxWeightFilter.GetFilterRange(esriElementType.esriETJunction, i,
                                                   out juncFromValues[i], out juncToValues[i]);
                }
                netSolverWeights.SetFilterRanges(esriElementType.esriETJunction,
                                                 ref juncFromValues, ref juncToValues);
            }

            // create the edge weight filters
            int edgeFilterRangeCount = naxWeightFilter.get_FilterRangeCount(esriElementType.esriETEdge);

            if (edgeFilterRangeCount > 0)
            {
                INetWeight fromToNetWeight = netSchema.get_WeightByName(naxWeightFilter.FromToEdgeWeightFilterName);
                netSolverWeights.FromToEdgeFilterWeight = fromToNetWeight;
                INetWeight toFromNetWeight = netSchema.get_WeightByName(naxWeightFilter.ToFromEdgeWeightFilterName);
                netSolverWeights.ToFromEdgeFilterWeight = toFromNetWeight;

                esriWeightFilterType edgeWeightFilterType;
                bool edgeApplyNotOperator;
                naxWeightFilter.GetFilterType(esriElementType.esriETEdge,
                                              out edgeWeightFilterType, out edgeApplyNotOperator);
                netSolverWeights.SetFilterType(esriElementType.esriETEdge,
                                               edgeWeightFilterType, edgeApplyNotOperator);

                object[] edgeFromValues = new object[edgeFilterRangeCount];
                object[] edgeToValues   = new object[edgeFilterRangeCount];
                for (int i = 0; i < edgeFilterRangeCount; i++)
                {
                    naxWeightFilter.GetFilterRange(esriElementType.esriETEdge, i,
                                                   out edgeFromValues[i], out edgeToValues[i]);
                }
                netSolverWeights.SetFilterRanges(esriElementType.esriETEdge,
                                                 ref edgeFromValues, ref edgeToValues);
            }

            INetworkAnalysisExtFlags naxFlags = m_utilNetExt as INetworkAnalysisExtFlags;

            // assign the edge flags to the network solver
            int edgeFlagCount = naxFlags.EdgeFlagCount;

            if (edgeFlagCount > 0)
            {
                IEdgeFlag[] edgeFlags = new IEdgeFlag[edgeFlagCount];
                for (int i = 0; i < edgeFlagCount; i++)
                {
                    IEdgeFlagDisplay edgeFlagDisplay = naxFlags.get_EdgeFlag(i);
                    IFlagDisplay     flagDisplay     = edgeFlagDisplay as IFlagDisplay;
                    IEdgeFlag        edgeFlag        = new EdgeFlagClass();
                    edgeFlag.Position = Convert.ToSingle(edgeFlagDisplay.Percentage);
                    INetFlag netFlag = edgeFlag as INetFlag;
                    netFlag.UserClassID = flagDisplay.FeatureClassID;
                    netFlag.UserID      = flagDisplay.FID;
                    netFlag.UserSubID   = flagDisplay.SubID;
                    edgeFlags[i]        = edgeFlag;
                }
                tfs.PutEdgeOrigins(ref edgeFlags);
            }

            // assign the junction flags to the network solver
            int juncFlagCount = naxFlags.JunctionFlagCount;

            if (juncFlagCount > 0)
            {
                IJunctionFlag[] juncFlags = new IJunctionFlag[juncFlagCount];
                for (int i = 0; i < juncFlagCount; i++)
                {
                    IJunctionFlagDisplay juncFlagDisplay = naxFlags.get_JunctionFlag(i);
                    IFlagDisplay         flagDisplay     = juncFlagDisplay as IFlagDisplay;
                    IJunctionFlag        juncFlag        = new JunctionFlagClass();
                    INetFlag             netFlag         = juncFlag as INetFlag;
                    netFlag.UserClassID = flagDisplay.FeatureClassID;
                    netFlag.UserID      = flagDisplay.FID;
                    netFlag.UserSubID   = flagDisplay.SubID;
                    juncFlags[i]        = juncFlag;
                }
                tfs.PutJunctionOrigins(ref juncFlags);
            }

            // set the option for tracing on indeterminate flow
            ITraceTasks traceTasks = m_utilNetExt as ITraceTasks;

            tfs.TraceIndeterminateFlow = traceTasks.TraceIndeterminateFlow;

            return(tfs);
        }
        /// <summary>
        /// Add two junction flags to TraceSolver
        /// </summary>
        /// <param name="traceFlowSolver">object TraceSolver</param>
        /// <param name="netflag1">1° junction flag</param>
        /// <param name="netflag2">2° junction flag</param>
        internal static void AddTwoJunctionFlagsToTraceSolver(ref ITraceFlowSolverGEN traceFlowSolver, INetFlag netflag1, INetFlag netflag2)
        {
            IJunctionFlag junctionflag1 = netflag1 as IJunctionFlag;
            IJunctionFlag junctionflag2 = netflag2 as IJunctionFlag;

            if (junctionflag1 != null && junctionflag2 != null)
            {
                IJunctionFlag[] junctionflags = new IJunctionFlag[2];
                junctionflags[0] = junctionflag1 as IJunctionFlag;
                junctionflags[1] = junctionflag2 as IJunctionFlag;
                traceFlowSolver.PutJunctionOrigins(ref junctionflags);
            }
        }
Exemple #4
0
 public NetFlagWrap(INetFlag NetFlag, IPoint pt)
 {
     this.m_NetFlag = NetFlag;
     this.m_pt      = pt;
 }