Пример #1
0
            /// <summary>
            /// Server-streaming example. Calls listFeatures with a rectangle of interest. Prints each response feature as it arrives.
            /// </summary>
            public async Task ListFeatures(int lowLat, int lowLon, int hiLat, int hiLon)
            {
                try
                {
                    Log("*** ListFeatures: lowLat={0} lowLon={1} hiLat={2} hiLon={3}", lowLat, lowLon, hiLat,
                        hiLon);

                    Rectangle request =
                        Rectangle.CreateBuilder()
                        .SetLo(Point.CreateBuilder().SetLatitude(lowLat).SetLongitude(lowLon).Build())
                        .SetHi(Point.CreateBuilder().SetLatitude(hiLat).SetLongitude(hiLon).Build()).Build();

                    using (var call = client.ListFeatures(request))
                    {
                        StringBuilder responseLog = new StringBuilder("Result: ");

                        while (await call.ResponseStream.MoveNext())
                        {
                            Feature feature = call.ResponseStream.Current;
                            responseLog.Append(feature.ToString());
                        }
                        Log(responseLog.ToString());
                    }
                }
                catch (RpcException e)
                {
                    Log("RPC failed " + e);
                    throw e;
                }
            }
Пример #2
0
            /// <summary>
            /// Server-streaming example. Calls listFeatures with a rectangle of interest. Prints each response feature as it arrives.
            /// </summary>
            public async Task ListFeatures(int lowLat, int lowLon, int hiLat, int hiLon)
            {
                try
                {
                    Log("*** ListFeatures: lowLat={0} lowLon={1} hiLat={2} hiLon={3}", lowLat, lowLon, hiLat,
                        hiLon);

                    Rectangle request = new Rectangle
                    {
                        Lo = new Point {
                            Latitude = lowLat, Longitude = lowLon
                        },
                        Hi = new Point {
                            Latitude = hiLat, Longitude = hiLon
                        }
                    };

                    using (var call = client.ListFeatures(request))
                    {
                        var           responseStream = call.ResponseStream;
                        StringBuilder responseLog    = new StringBuilder("Result: ");

                        while (await responseStream.MoveNext())
                        {
                            Feature feature = responseStream.Current;
                            responseLog.Append(feature.ToString());
                        }
                        Log(responseLog.ToString());
                    }
                }
                catch (RpcException e)
                {
                    Log("RPC failed " + e);
                    throw;
                }
            }