Exemplo n.º 1
0
        //����׷�ٵĽ��
        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);

            }
        }
Exemplo n.º 2
0
        public static void ProfileFindPath(AxMapControl ppAxMapControl, IArray pNetFlagArray, IGeometricNetwork pGeoNetwork)
        {
            try
            {

                IEnumNetEID m_ipEnumNetEID_Junctions, m_ipEnumNetEID_Edges;//����������������Junctions��Edges
                IJunctionFlag[] pArrayJFlag = new IJunctionFlag[2];
                pArrayJFlag[0] = pNetFlagArray.get_Element(0) as IJunctionFlag;
                pArrayJFlag[1] = pNetFlagArray.get_Element(1) 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.FindPath(esriFlowMethod.esriFMConnected,
                    esriShortestPathObjFn.esriSPObjFnMinMax,
                    out m_ipEnumNetEID_Junctions,
                    out m_ipEnumNetEID_Edges, 1, ref totalCost);
                //��������еĽ����Ԫ��
                pNetFlagArray.RemoveAll();
                //ma
                //              SpatialHelperFunction.pathToPolyline(pGeoNetwork, ppAxMapControl.ActiveView, m_ipEnumNetEID_Edges);
                //ProfileGetRelatedSewerElevData(ppAxMapControl,pGeoNetwork,m_ipEnumNetEID_Edges, m_ipEnumNetEID_Junctions  );
            }
            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);
        }
		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>
        /// operation solve trace
        /// </summary>
        /// <returns>solve trace</returns>
        public override JsonObject Solve()
        {
            try
            {
                if ((this.edgeFlags.Length == 0) && (this.junctionFlags.Length == 0))
                {
                    string message = "No input valid flags found";
                    if (this.flagNotFound.Count == 0)
                    {
                        throw new GeometricNetworkException(message);
                    }
                    else
                    {
                        JsonObject error = (new ObjectError(message)).ToJsonObject();
                        error.AddArray("flagsNotFound", Helper.GetListJsonObjects(this.flagNotFound));
                        if (this.barrierNotFound.Count > 0)
                        {
                            error.AddArray("barriersNotFound", Helper.GetListJsonObjects(this.barrierNotFound));
                        }

                        return(error);
                    }
                }

                ITraceFlowSolverGEN traceFlowSolver = new TraceFlowSolverClass() as ITraceFlowSolverGEN;
                INetSolver          netSolver       = traceFlowSolver as INetSolver;
                INetwork            network         = this.geometricNetwork.Network;
                netSolver.SourceNetwork = network;

                // flag origin
                this.SetFlagsOrigin(ref traceFlowSolver);

                // barrier
                this.SetBarriers(ref traceFlowSolver);

                // set disabled layers
                foreach (int i in this.DisableLayers)
                {
                    netSolver.DisableElementClass(i);
                }

                // set weight
                this.SetWeights(ref traceFlowSolver);

                if ((this.TraceSolverType != TraceSolverType.FindCircuits) && (this.TraceSolverType != TraceSolverType.FindCommonAncestors))
                {
                    // The TraceIndeterminateFlow property affects the trace results of trace solvers whose FlowMethod parameter is esriFMUpstream or esriFMDownstream
                    if ((this.FlowMethod == esriFlowMethod.esriFMDownstream) || (this.FlowMethod == esriFlowMethod.esriFMUpstream))
                    {
                        traceFlowSolver.TraceIndeterminateFlow = this.TraceIndeterminateFlow;
                    }
                }

                IEnumNetEID junctionEIDs = null;
                IEnumNetEID edgeEIDs     = null;
                object      totalCost;
                int         count;
                object[]    segmentCosts;

                JsonObject objectJson = new JsonObject();
                switch (this.TraceSolverType)
                {
                case TraceSolverType.FindAccumulation:
                    traceFlowSolver.FindAccumulation(this.FlowMethod, this.FlowElements, out junctionEIDs, out edgeEIDs, out totalCost);
                    objectJson.AddDouble("totalCost", (double)totalCost);
                    break;

                case TraceSolverType.FindCircuits:
                    traceFlowSolver.FindCircuits(this.FlowElements, out junctionEIDs, out edgeEIDs);
                    break;

                case TraceSolverType.FindCommonAncestors:
                    traceFlowSolver.FindCommonAncestors(this.FlowElements, out junctionEIDs, out edgeEIDs);
                    break;

                case TraceSolverType.FindFlowElements:
                    traceFlowSolver.FindFlowElements(this.FlowMethod, this.FlowElements, out junctionEIDs, out edgeEIDs);
                    break;

                case TraceSolverType.FindFlowEndElements:
                    traceFlowSolver.FindFlowEndElements(this.FlowMethod, this.FlowElements, out junctionEIDs, out edgeEIDs);
                    break;

                case TraceSolverType.FindFlowUnreachedElements:
                    traceFlowSolver.FindFlowUnreachedElements(this.FlowMethod, this.FlowElements, out junctionEIDs, out edgeEIDs);
                    break;

                case TraceSolverType.FindPath:
                    count = Math.Max(this.junctionFlags.Length, this.edgeFlags.Length);
                    if (count < 2)
                    {
                        throw new GeometricNetworkException("Edge or junction found < 2!");
                    }

                    --count;
                    segmentCosts = new object[count];
                    traceFlowSolver.FindPath(this.FlowMethod, this.ShortestPathObjFn, out junctionEIDs, out edgeEIDs, count, ref segmentCosts);
                    objectJson.AddArray("segmentCosts", segmentCosts);
                    break;

                case TraceSolverType.FindSource:
                    count        = this.junctionFlags.Length + this.edgeFlags.Length;
                    segmentCosts = new object[count];
                    traceFlowSolver.FindSource(this.FlowMethod, this.ShortestPathObjFn, out junctionEIDs, out edgeEIDs, count, ref segmentCosts);
                    objectJson.AddArray("segmentCosts", segmentCosts);
                    break;

                case TraceSolverType.FindLongest:
                    // get end junctions in upstream
                    IEnumNetEID junctionEIDsFindLongest = null;
                    IEnumNetEID edgeEIDsFindLongest     = null;
                    traceFlowSolver.FindFlowEndElements(esriFlowMethod.esriFMUpstream, esriFlowElements.esriFEJunctions, out junctionEIDsFindLongest, out edgeEIDsFindLongest);

                    int?   eidLongest       = null;
                    double eidLongestLenght = double.MinValue;

                    if (junctionEIDsFindLongest.Count > 0)
                    {
                        double eidLongestLenghtCurrent = double.NaN;
                        for (int i = 0; i < junctionEIDsFindLongest.Count; i++)
                        {
                            int         netEIDCurrent       = junctionEIDsFindLongest.Next();
                            object[]    segmentLenghts      = new object[1];
                            IEnumNetEID junctionEIDsLongest = null;
                            IEnumNetEID edgeEIDsLongest     = null;

                            INetFlag     netFlag = new JunctionFlagClass();
                            INetElements netElements = this.geometricNetwork.Network as INetElements;
                            int          featureClassID, featureID, subID;
                            netElements.QueryIDs(netEIDCurrent, esriElementType.esriETJunction, out featureClassID, out featureID, out subID);

                            netFlag.UserClassID = featureClassID;
                            netFlag.UserID      = featureID;
                            netFlag.UserSubID   = subID;

                            IJunctionFlag[] junctionFlags = new IJunctionFlag[] { this.junctionFlags[0], netFlag as IJunctionFlag };
                            traceFlowSolver.PutJunctionOrigins(ref junctionFlags);

                            traceFlowSolver.FindPath(esriFlowMethod.esriFMUpstream, esriShortestPathObjFn.esriSPObjFnMinMax, out junctionEIDsLongest, out edgeEIDsLongest, 1, ref segmentLenghts);
                            if (segmentLenghts[0] != null)
                            {
                                eidLongestLenghtCurrent = Convert.ToDouble(segmentLenghts[0]);
                                if (eidLongestLenghtCurrent > eidLongestLenght)
                                {
                                    eidLongestLenght = eidLongestLenghtCurrent;
                                    eidLongest       = netEIDCurrent;
                                    edgeEIDs         = edgeEIDsLongest;
                                    junctionEIDs     = junctionEIDsLongest;
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new GeometricNetworkException("Junction end not found!");
                    }

                    if (eidLongest.HasValue)
                    {
                        objectJson.AddDouble("totalCost", eidLongestLenght);
                    }
                    else
                    {
                        throw new GeometricNetworkException("EID longest not found!");
                    }

                    break;

                default:
                    throw new GeometricNetworkException("Trace solver type not found");
                }

                this.SetResults(ref objectJson, edgeEIDs, junctionEIDs);
                objectJson.AddArray("flagsNotFound", Helper.GetListJsonObjects(this.flagNotFound));
                objectJson.AddArray("barriersNotFound", Helper.GetListJsonObjects(this.barrierNotFound));
                return(objectJson);
            }
            catch (Exception e)
            {
                return((new ObjectError(e.Message)).ToJsonObject());
            }
        }