示例#1
0
        public void TestFeatureClassBag()
        {
            //Arrange
            double            d;
            int               length = (int)1e3;
            List <MyFieldDef> fdefs  = new List <MyFieldDef>();

            fdefs.Add(new MyFieldDef(esriFieldType.esriFieldTypeString, "strFld"));
            fdefs.Add(new MyFieldDef(esriFieldType.esriFieldTypeDouble, "doubleFld"));
            IFieldsEdit      flds = AOUtilities.GetBareMetalFields(esriGeometryType.esriGeometryPoint, 3857, fdefs);
            List <MyFeature> pnts = new List <MyFeature>();

            for (int j = 0; j < length; ++j)
            {
                pnts.Add(new MyFeature(esriFeatureType.esriFTSimple, esriGeometryType.esriGeometryPoint, new PointClass()
                {
                    X = randomDouble(-180, 180), Y = randomDouble(-90, 90)
                }, j, new List <object>()
                {
                    j.ToString(), randomDouble(0, 100)
                }));
            }

            //Act
            using (IFeatureClassBag bag1 = new InMemoryFeatureClassBag("wname1", AOUtilities.GetInMemoryWorkspaceFactory()))
            {
                Assert.IsTrue(bag1.CreateFeatureClass("foo", flds, esriFeatureType.esriFTSimple, "Shape"));
                Assert.IsTrue(bag1.AddFeatures("foo", pnts, fdefs.Count));
                List <IFeature> ftrs = new List <IFeature>();
                foreach (var f in bag1.GetFeatures("foo", false))
                {
                    ftrs.Add(f);
                }
                object o1 = ftrs[0].get_Value(2);
                object o2 = ftrs[0].get_Value(3);

                object o3 = ftrs[length - 1].get_Value(2);
                object o4 = ftrs[length - 1].get_Value(3);

                //Assert
                Assert.IsTrue(ftrs.Count == pnts.Count);
                Assert.IsTrue(null != o1 && o1.ToString() == "0");
                Assert.IsTrue(null != o3 && o3.ToString() == "999");
                Assert.IsTrue(null != o2 && double.TryParse(o2.ToString(), out d));
                Assert.IsTrue(null != o4 && double.TryParse(o4.ToString(), out d));
                //Assert
                //The following should fall through, GetFeatures actually returns nothing instead of an IEnumerable<IFeature>
                foreach (var f in bag1.GetFeatures("bar", true))
                {
                    continue;
                }
            }


            IFeatureClassBag bag2 = new InMemoryFeatureClassBag("wname2", AOUtilities.GetInMemoryWorkspaceFactory());
            IFeatureClassBag bag3 = new InMemoryFeatureClassBag("wname3", AOUtilities.GetInMemoryWorkspaceFactory());

            bag2.Dispose();
            bag3.Dispose();
        }
示例#2
0
        public void ConstrcutStartEdge()
        {
            //Arrange
            NetworkContext ctx = new NetworkContext("Hydro", new List <string>()
            {
                "FlowlineMerge"
            }, new List <string>()
            {
                "Hydro_Net_Junctions", "Barriers"
            });

            ctx.LoadGeometricNetwork(GN_Path, null, null);
            //Flag
            IPoint pnt = new PointClass();

            pnt.X = -86.291;
            pnt.Y = 43.941;
            IFeatureClass fc  = ctx.GetEdgeFeatureClassByAliasName("FlowlineMerge");
            int           idx = AOUtilities.GetFieldIndexByName(fc, "FlowDir");


            //Act
            StartFlagEdge flag = NetworkHelper.GetStartFlagEdge(ctx, -86.291, 43.941, 100, 5, "FlowlineMerge", idx, "0", null);

            //Assert
            Assert.IsNotNull(flag);
            Assert.IsTrue(flag.FeatureID == 1927894);
        }
示例#3
0
        public void FeatureClassBagRAMProfile()
        {
            //more detailed approach is necessary
            //Arrange
            //1,000,000 points will take roughly 500 MB RAM on my desktop

            /*int length = (int)1e6;
             * List<MyFeature> pnts = new List<MyFeature>();
             * for (int i = 0; i < length; ++i)
             *  pnts.Add(new MyFeature(esriFeatureType.esriFTSimple, esriGeometryType.esriGeometryPoint, new PointClass() { X = randomDouble(-180, 180), Y = randomDouble(-90, 90) }));
             */
            //Act
            for (int i = 0; i < 5; ++i)
            {
                int length            = (int)1e6;
                List <MyFeature> pnts = new List <MyFeature>();
                for (int j = 0; j < length; ++j)
                {
                    pnts.Add(new MyFeature(esriFeatureType.esriFTSimple, esriGeometryType.esriGeometryPoint, new PointClass()
                    {
                        X = randomDouble(-180, 180), Y = randomDouble(-90, 90)
                    }, j, null));
                }
                using (InMemoryFeatureClassBag bag1 = new InMemoryFeatureClassBag("wname1", AOUtilities.GetInMemoryWorkspaceFactory()))
                {
                    IFieldsEdit flds = AOUtilities.GetBareMetalFields(esriGeometryType.esriGeometryPoint, 3857, null);
                    Assert.IsTrue(bag1.CreateFeatureClass("foo", flds, esriFeatureType.esriFTSimple, "Shape"));
                    Assert.IsTrue(bag1.AddFeatures("foo", pnts, 0));
                }
            }
        }
示例#4
0
 public static void UnitTest1Cleanup()
 {
     AOUtilities.Dispose();
     //ESRI License Initializer generated code.
     //Do not make any call to ArcObjects after ShutDownApplication()
     m_AOLicenseInitializer.ShutdownApplication();
 }
示例#5
0
        public void TestIdentifyUninitializedStreamSegment()
        {
            //Arrange
            NetworkContext ctx = new NetworkContext("Hydro", new List <string>()
            {
                "FlowlineMerge"
            }, new List <string>()
            {
                "Hydro_Net_Junctions", "Barriers"
            });

            ctx.LoadGeometricNetwork(GN_Path, null, null);

            //Get FlowDir index
            IFeatureClass fc  = ctx.GetEdgeFeatureClassByAliasName("FlowlineMerge");
            int           idx = AOUtilities.GetFieldIndexByName(fc, "FlowDir");
            IPoint        pnt = new PointClass()
            {
                X = -85.04465103149414,
                Y = 43.27143070627271
            };
            IGeometryArray pntArr = new GeometryArrayClass();

            pntArr.Add(pnt);
            IGeometryArray geomArr = AOUtilities.TransfromGeometriesFrom2(4326, 4269, pntArr);
            IPoint         pnt1    = geomArr.get_Element(0) as IPoint;

            //Act
            StartFlagEdge flag = NetworkHelper.GetStartFlagEdge(ctx, pnt1.X, pnt1.Y, 200, 5, "FlowlineMerge", idx, "0", null);

            //Assert
            Assert.IsNull(flag);
        }
 private void LoadNetwork(IPropertySet props)
 {
     if (null != props.GetProperty("NetworkName"))
     {
         m_networkName = props.GetProperty("NetworkName") as string;
     }
     else
     {
         throw new ArgumentNullException("NetworkName is unspecified.");
     }
     if (null == props.GetProperty("MaxFeatureCount") || false == int.TryParse(props.GetProperty("MaxFeatureCount") as string, out this.m_maxFeatureCount))
     {
         this.m_maxFeatureCount = 5000;
     }
     this.m_outputFields = new List <string>()
     {
         "Shape_Length"
     };
     this.m_networkContext = new NetworkContext(m_networkName, new List <string>()
     {
         FlowLineName
     }, new List <string>()
     {
         JunctionName, BarrierJunctionName
     });
     this.m_networkContext.LoadGeometricNetwork(null, this.serverObjectHelper, this.logger);
     this.m_isReady = this.m_networkContext.IsNetworkLoaded;
     if (this.m_isReady)
     {
         this.m_disabledFeatureClassIDs = new List <int>()
         {
             this.m_networkContext.GetJunctionFeatureClassIdByAliasName(BarrierJunctionName).FeatureClassID
         };
         IFeatureClass     flowlineFeatureClass = this.m_networkContext.GetEdgeFeatureClassByAliasName(FlowLineName);
         ISpatialReference srs = AOUtilities.GetFeatureClassSpatialReference(flowlineFeatureClass, false);
         if (null != srs)
         {
             this.m_networkEPSG = srs.FactoryCode;
         }
         else
         {
             this.m_isReady = false;
         }
         this.m_flowDirFieldIndex = AOUtilities.GetFieldIndexByName(flowlineFeatureClass, "FlowDir");
         if (this.m_flowDirFieldIndex < 0)
         {
             this.m_isReady = false;
         }
     }
 }
示例#7
0
        public void GetFeatureClassEPSG()
        {
            //Arrange
            NetworkContext ctx = new NetworkContext("Hydro", new List <string>()
            {
                "FlowlineMerge"
            }, new List <string>()
            {
                "Hydro_Net_Junctions", "Barriers"
            });

            ctx.LoadGeometricNetwork(GN_Path, null, null);

            //Act
            ISpatialReference srs = AOUtilities.GetFeatureClassSpatialReference(ctx.GetEdgeFeatureClassByAliasName("FlowlineMerge"), false);

            //Assert
            Assert.IsTrue(4269 == srs.FactoryCode);
        }
        private List <IPoint> ParseVirtualBarriers(JsonObject[] barrierJsonArray, uint epsg)//lazy here, just copy epsg from flag and assume barriers having the same one
        {
            List <IPoint> ret = null;

            if (null != barrierJsonArray && barrierJsonArray.Length > 0)
            {
                JsonObject     barrierFeature = null;
                IPoint         pnt            = null;
                IGeometryArray pntArr1        = new GeometryArrayClass();
                for (int i = 0; i < barrierJsonArray.Length; ++i)
                {
                    if (barrierJsonArray[i].TryGetJsonObject("geometry", out barrierFeature))
                    {
                        if (null != barrierFeature)
                        {
                            double?x, y;
                            //int? epsg;
                            if (barrierFeature.TryGetAsDouble("x", out x) && barrierFeature.TryGetAsDouble("y", out y))
                            {
                                pnt   = new PointClass();
                                pnt.X = x.Value;
                                pnt.Y = y.Value;
                                pntArr1.Add(pnt);
                            }
                        }
                    }
                }
                if (pntArr1.Count > 0)
                {
                    IGeometryArray geomArr = AOUtilities.TransfromGeometriesFrom2(epsg, (uint)this.m_networkEPSG, pntArr1);
                    if (null != geomArr && geomArr.Count > 0)
                    {
                        ret = new List <IPoint>();
                        for (int i = 0; i < geomArr.Count; ++i)
                        {
                            ret.Add(geomArr.get_Element(i) as IPoint);
                        }
                    }
                }
            }
            return(ret);
        }
示例#9
0
        public void CopyFeatureClassTemplate()
        {
            //Arrange
            NetworkContext ctx = new NetworkContext("Hydro", new List <string>()
            {
                "FlowlineMerge"
            }, new List <string>()
            {
                "Hydro_Net_Junctions", "Barriers"
            });

            ctx.LoadGeometricNetwork(GN_Path, null, null);
            IFeatureClass fc = ctx.GetJunctionFeatureClassIdByAliasName("Barriers");

            //Act
            AbstractFeatureClassBag fcb = new InMemoryFeatureClassBag("in memory", AOUtilities.GetInMemoryWorkspaceFactory());
            bool ret = fcb.CreateFeatureClass(fc, "clone barrier");

            fcb.Dispose();

            //Assert
            Assert.IsTrue(ret);
        }
示例#10
0
        public void TestGetFieldIndexAndValues()
        {
            //Arrange
            NetworkContext ctx = new NetworkContext("Hydro", new List <string>()
            {
                "FlowlineMerge"
            }, new List <string>()
            {
                "Hydro_Net_Junctions", "Barriers"
            });

            ctx.LoadGeometricNetwork(GN_Path, null, null);
            IFeatureClass fc = ctx.GetEdgeFeatureClassByAliasName("FlowlineMerge");

            //Act
            int idx = AOUtilities.GetFieldIndexByName(fc, "FlowDir");
            Dictionary <string, Tuple <int, esriFieldType> > fldDict = AOUtilities.GetFieldIndexes(fc);

            //Assert
            Assert.IsTrue(idx >= 0);
            Assert.IsNotNull(fldDict);
            Assert.IsTrue(idx == fldDict["FlowDir"].Item1);
        }
示例#11
0
        public void CoordinatesReProjection()
        {
            //Arrange
            IPoint pnt1 = new PointClass();

            pnt1.X = -9569447.832126;
            pnt1.Y = 5524225.232441;
            //pnt1.SpatialReference = AOUtilities.GetSpatialReference(3857);
            IGeometryArray pntArr1 = new GeometryArrayClass();

            pntArr1.Add(pnt1);

            //Act
            //The SpatialReference property for all returned geometries will be null.  It is the consumers responsibility to assign the
            //spatial reference to each geometry returned, if desired.  In this case, the spatial reference is assumed to be the output spatial reference defined for the Project operation.
            IGeometryArray geomArr = AOUtilities.TransfromGeometriesFrom2(3857, 4269, pntArr1);
            //It appears IGeometryServer2.Project will NOT throw an error if the coordinates don't match the given epsg
            //instead, it simply returns the input coordinates as output...
            IGeometryArray geomArr1 = AOUtilities.TransfromGeometriesFrom2(4326, 4269, pntArr1);

            //Assert
            Assert.IsNotNull(geomArr);
            Assert.IsNotNull(geomArr1);
            Assert.AreEqual <int>(pntArr1.Count, geomArr.Count);
            Assert.AreEqual <int>(pntArr1.Count, geomArr1.Count);
            IPoint pnt2 = geomArr.get_Element(0) as IPoint;

            Assert.IsNotNull(pnt2);
            pnt2 = geomArr1.get_Element(0) as IPoint;
            Assert.IsNotNull(pnt2);

            //Act
            geomArr1 = AOUtilities.TransfromGeometriesFrom2(4269, 4326, geomArr);
            //Assert
            Assert.IsNotNull(geomArr1);
            Assert.AreEqual <int>(geomArr1.Count, geomArr.Count);
            pnt2 = geomArr1.get_Element(0) as IPoint;
            IPoint pnt3 = geomArr.get_Element(0) as IPoint;

            Assert.IsNotNull(pnt2);
            //Since the output geometry will not have spatial reference assigned, we can't verify if the output are in the desired projection through this shortcut.
            //Assert.IsTrue(4326 == pnt2.SpatialReference.FactoryCode);
            //Assert.IsTrue(4269 == pnt3.SpatialReference.FactoryCode);

            //Arrange
            pntArr1.RemoveAll();
            pntArr1.Add(pnt2);

            //Act
            geomArr = AOUtilities.TransfromGeometriesFrom2(4269, 3857, pntArr1);

            //Assert
            Assert.IsNotNull(geomArr);
            Assert.AreEqual <int>(pntArr1.Count, geomArr.Count);
            pnt2 = geomArr.get_Element(0) as IPoint;
            Assert.IsNotNull(pnt2);
            Assert.IsTrue((Math.Abs(pnt2.X - pnt1.X) < 1e-7) && (Math.Abs(pnt2.Y - pnt1.Y) < 1e-7));

            //Arrange
            pnt1.X = double.MinValue;
            pnt1.Y = double.PositiveInfinity;
            pntArr1.RemoveAll();
            pntArr1.Add(pnt1);

            //Act
            geomArr = AOUtilities.TransfromGeometriesFrom2(3857, 4269, pntArr1);
            pnt2    = geomArr.get_Element(0) as IPoint;

            //Assert
            Assert.IsTrue(pnt2.IsEmpty);
            double x = pnt2.X;
        }
示例#12
0
        public void TraceStream()
        {
            //Arrange
            NetworkContext ctx = new NetworkContext("Hydro", new List <string>()
            {
                "FlowlineMerge"
            }, new List <string>()
            {
                "Hydro_Net_Junctions", "Barriers"
            });

            ctx.LoadGeometricNetwork(GN_Path, null, null);
            //Flag
            IFeatureClass fc   = ctx.GetEdgeFeatureClassByAliasName("FlowlineMerge");
            int           idx  = AOUtilities.GetFieldIndexByName(fc, "FlowDir");
            StartFlagEdge flag = NetworkHelper.GetStartFlagEdge(ctx, -85.062153, 44.003813, 1000, 5, "FlowlineMerge", idx, "0", null);
            //All Existing Barriers
            List <int> fcid = new List <int>()
            {
                ctx.GetJunctionFeatureClassIdByAliasName("Barriers").FeatureClassID
            };
            //Virtual Barriers
            IPoint pnt = new PointClass();

            pnt.X = -85.021764;
            pnt.Y = 44.122331;
            IPoint pnt1 = new PointClass();

            pnt1.X = -84.974754;
            pnt1.Y = 44.162720;
            IPoint pnt2 = new PointClass();

            pnt2.X = -84.896625;
            pnt2.Y = 44.128;
            List <IPoint> pnts = new List <IPoint>()
            {
                pnt, pnt1, pnt2
            };
            StopperJunctions stoppers1 = NetworkHelper.GetStoppers(ctx, pnts, true, 1000, 5, "FlowlineMerge", "Hydro_Net_Junctions", null);

            //Act
            //Do upstream first
            List <int> ftrList = AOUtilities.StreamTrace(ctx.GeometricNetwork, flag, fcid, stoppers1, true, 1000, null);

            //Assert
            Assert.IsNotNull(ftrList);
            List <string> ids = new List <string>();

            foreach (var ftr in ftrList)
            {
                ids.Add(ftr.ToString());
            }
            //System.Diagnostics.Debug.WriteLine(string.Join(",", ids.ToArray()));

            //Act
            //Do upstream again without stoppers to test if the previous setting is gone
            ftrList = AOUtilities.StreamTrace(ctx.GeometricNetwork, flag, fcid, null, true, 1000, null);

            //Assert
            Assert.IsNotNull(ftrList);
            ids = new List <string>();
            foreach (var ftr in ftrList)
            {
                ids.Add(ftr.ToString());
            }
            //System.Diagnostics.Debug.WriteLine(string.Join(",", ids.ToArray()));

            //Act
            //downstream
            ftrList = AOUtilities.StreamTrace(ctx.GeometricNetwork, flag, fcid, null, false, 1000, null);

            //Assert
            Assert.IsNotNull(ftrList);
            ids = new List <string>();
            foreach (var ftr in ftrList)
            {
                ids.Add(ftr.ToString());
            }
            //System.Diagnostics.Debug.WriteLine(string.Join(",", ids.ToArray()));
            IRecordSet records = AOUtilities.GetRecordSetFromFeatureClass(ctx.GetEdgeFeatureClassByAliasName("FlowlineMerge"), ftrList, new List <string>()
            {
                "Shape_Length"
            }, 3857);

            Assert.IsNotNull(records);
            //How to update a feature
            //http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/d/0001000002rs000000.htm

            /*ICursor ftrCursor = records.get_Cursor(true);
             * try
             * {
             *  IRow row = ftrCursor.NextRow();
             *  IFeature ftr = row as IFeature;
             *  esriFeatureType type = ftr.FeatureType;
             *  esriGeometryType t1 = ftr.Shape.GeometryType;
             *
             *  IRow row1 = ftrCursor.NextRow();
             *  IFeature ftr1 = row as IFeature;
             *
             *  ftr.Shape = ftr1.ShapeCopy;
             * }
             * catch(Exception e)
             * {
             *  string err = e.Message;
             * }
             * finally
             * {
             *  AOUtilities.ReleaseCOMObj(ftrCursor);
             * }*/
            JsonObject json = new JsonObject(System.Text.Encoding.UTF8.GetString(Conversion.ToJson(records)));

            Assert.IsNotNull(json);
            //System.Diagnostics.Debug.WriteLine(json.ToJson());
        }
 public void Shutdown()
 {
     AOUtilities.Dispose();
 }
        private byte[] NetworkTraceHandler(NameValueCollection boundVariables,
                                           JsonObject operationInput,
                                           string outputFormat,
                                           string requestProperties,
                                           out string responseProperties)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            responseProperties = null;

            string traceTypeStr;
            bool   found = operationInput.TryGetString(TracingDirParameterName, out traceTypeStr);

            if (!found || string.IsNullOrEmpty(traceTypeStr))
            {
                throw new ArgumentNullException(TracingDirParameterName + " is required");
            }
            traceTypeStr = traceTypeStr.ToUpper();
            bool?isUpstream = null;

            if ("TRACE_UPSTREAM" == traceTypeStr)
            {
                isUpstream = true;
            }
            else if ("TRACE_DOWNSTREAM" == traceTypeStr)
            {
                isUpstream = false;
            }
            if (false == isUpstream.HasValue)
            {
                throw new ArgumentException("Not valid Trace_Task_type");
            }

            long?outEPSG;

            found = operationInput.TryGetAsLong(OutputEPSGParameterName, out outEPSG);
            if (!found || !outEPSG.HasValue || outEPSG <= 0)
            {
                throw new ArgumentNullException(OutputEPSGParameterName + " is required");
            }
            if (outEPSG < 1)
            {
                throw new ArgumentException(OutputEPSGParameterName + " is not valid");
            }

            JsonObject flagJSON = null;

            object[]     flagArray     = null;
            JsonObject[] flagJsonArray = null;
            if (false == operationInput.TryGetJsonObject(FlagParameterName, out flagJSON) || null == flagJSON)
            {
                throw new ArgumentNullException(FlagParameterName + " is required");
            }
            if (flagJSON.TryGetArray("features", out flagArray))
            {
                try
                {
                    flagJsonArray = flagArray.Cast <JsonObject>().ToArray();
                }
                catch
                {
                    throw new ArgumentException("invalid Flags json format");
                }
            }
            //Found the flag
            List <int> ftrList = null;

            if (null != flagJsonArray && 1 == flagJsonArray.Length)
            {
                JsonObject flagFeature = null;
                if (flagJsonArray[0].TryGetJsonObject("geometry", out flagFeature))
                {
                    if (null == flagFeature)
                    {
                        throw new ArgumentException("invalid Flags json format with geometry");
                    }
                    double?    x, y;
                    long?      epsg;
                    JsonObject srsObj;
                    if (true == flagFeature.TryGetJsonObject("spatialReference", out srsObj))
                    {
                        if (false == srsObj.TryGetAsLong("wkid", out epsg) || epsg <= 0)
                        {
                            throw new ArgumentException("No valid wikd found for flag feature.");
                        }
                    }
                    else
                    {
                        throw new ArgumentException("No spatial reference found for flag feature.");
                    }
                    if (flagFeature.TryGetAsDouble("x", out x) && flagFeature.TryGetAsDouble("y", out y))
                    {
                        if (!x.HasValue || !y.HasValue)
                        {
                            throw new ArgumentException("invalid Flag coordinate");
                        }
                        IPoint pnt1 = new PointClass();
                        pnt1.X = x.Value;
                        pnt1.Y = y.Value;
                        IGeometryArray pntArr1 = new GeometryArrayClass();
                        pntArr1.Add(pnt1);
                        IGeometryArray geomArr = AOUtilities.TransfromGeometriesFrom2((uint)epsg, (uint)this.m_networkEPSG, pntArr1);
                        if (null == geomArr || 1 != geomArr.Count)
                        {
                            throw new ArgumentException("invalid Flag coordinate for reprojection");
                        }
                        pnt1 = geomArr.get_Element(0) as IPoint;
                        StartFlagEdge    flag     = NetworkHelper.GetStartFlagEdge(this.m_networkContext, pnt1.X, pnt1.Y, TracingSOE.m_searchDistance, TracingSOE.m_searchTolerance, FlowLineName, this.m_flowDirFieldIndex, InvalidFlowDirValue, logger);
                        StopperJunctions stoppers = null;
                        if (null != flag)
                        {
                            List <IPoint> barrierPnts      = null;
                            JsonObject    barriersJSON     = null;
                            object[]      barrierArray     = null;
                            JsonObject[]  barrierJsonArray = null;
                            if (true == operationInput.TryGetJsonObject(BarrierParameterName, out barriersJSON) || null != barriersJSON)
                            {
                                if (barriersJSON.TryGetArray("features", out barrierArray))
                                {
                                    try
                                    {
                                        barrierJsonArray = barrierArray.Cast <JsonObject>().ToArray();
                                        barrierPnts      = ParseVirtualBarriers(barrierJsonArray, (uint)epsg);
                                    }
                                    catch
                                    {
                                        throw new ArgumentException("invalid Barriers json format");
                                    }
                                }
                                if (null != barrierPnts && barrierPnts.Count > 0)
                                {
                                    stoppers = NetworkHelper.GetStoppers(this.m_networkContext, barrierPnts, isUpstream.Value, TracingSOE.m_searchDistance, TracingSOE.m_searchTolerance, FlowLineName, JunctionName, logger);
                                }
                            }
                        }
                        ftrList = AOUtilities.StreamTrace(this.m_networkContext.GeometricNetwork, flag, this.m_disabledFeatureClassIDs, stoppers, isUpstream.Value, this.m_maxFeatureCount, logger);
                    }
                }
            }
            IRecordSet records = null;

            if (null != ftrList && ftrList.Count > 0)
            {
                records = AOUtilities.GetRecordSetFromFeatureClass(this.m_networkContext.GetEdgeFeatureClassByAliasName(FlowLineName), ftrList, this.m_outputFields, (uint)outEPSG.Value);
            }
            JsonObject result = new JsonObject();

            if (null != records)
            {
                result.AddJsonObject("value", new JsonObject(System.Text.Encoding.UTF8.GetString(Conversion.ToJson(records))));
            }
            else
            {
                result.AddString("output", "{}");
            }
            watch.Stop();
            this.logger.LogMessage(ServerLogger.msgType.debug, "NetworkTraceHandler", 973, "Tracing taked: " + watch.ElapsedMilliseconds.ToString() + " ms");
            result.AddLong("time(ms)", watch.ElapsedMilliseconds);
            return(Encoding.UTF8.GetBytes(result.ToJson()));
        }