Beispiel #1
0
        public async Task GetSearchAlongRoute()
        {
            var am = new AzureMapsToolkit.AzureMapsServices(_KEY);

            var req = new SearchAlongRouteRequest
            {
                Limit         = 2,
                MaxDetourTime = 1000,
                Query         = "burger"
            };

            List <GeoPosition> coordinates = new()
            {
                new GeoPosition(-122.143035, 47.653536),
                new GeoPosition(-122.187164, 47.617556),
                new GeoPosition(-122.114981, 47.570599),
                new GeoPosition(-122.132756, 47.654009)
            };

            GeoLineString lineString = new(coordinates);

            var result = await am.GetSearchAlongRoute(req, lineString);

            Assert.Null(result.Error);

            Assert.Equal("NON_NEAR", result.Result.Summary.QueryType);
        }
Beispiel #2
0
        public void GetSearchAlongRoute()
        {
            var am = new AzureMapsToolkit.AzureMapsServices(_KEY);

            var req = new SearchAlongRouteRequest
            {
                Limit         = 2,
                MaxDetourTime = 1000,
                Query         = "burger"
            };

            var lineString = new AzureMapsToolkit.GeoJson.LineString
            {
                Coordinates = new double[, ] {
                    { -122.143035, 47.653536 },
                    { -122.187164, 47.617556 },
                    { -122.114981, 47.570599 },
                    { -122.132756, 47.654009 }
                }
            };

            var result = am.GetSearchAlongRoute(req, lineString).Result;

            Assert.Null(result.Error);

            Assert.Equal("NON_NEAR", result.Result.Summary.QueryType);
        }
Beispiel #3
0
        /// <summary>
        /// The Search Along Route endpoint allows you to perform a fuzzy search for POIs along a specified route. This search is constrained by specifying the maxDetourTime limiting measure.
        /// To send the route-points you will use a POST request where the request body will contain the route object represented as a GeoJSON LineString type and the Content-Type header will be set to application/json. Each route-point in route is represented as a GeoJSON Position type i.e. an array where the longitude value is followed by the latitude value and the altitude value is ignored. The route should contain at least 2 route-points.
        /// It is possible that original route will be altered, some of it's points may be skipped. If the route that passes through the found point is faster than the original one, the detourTime value in the response is negative.
        /// </summary>
        /// <param name="req"></param>
        /// <param name="lineString"></param>
        /// <returns></returns>
        public virtual async Task <Response <SearchAlongRouteResponse> > GetSearchAlongRoute(SearchAlongRouteRequest req, LineString lineString)
        {
            try
            {
                var bodyContent = new { route = lineString };

                var queryContent = Newtonsoft.Json.JsonConvert.SerializeObject(bodyContent);

                var args = GetQuery <SearchAlongRouteRequest>(req, true);

                var url = $"https://atlas.microsoft.com/search/alongRoute/json?subscription-key={Key}&api-version=1.0{args}";

                using (var responseMsg = await GetHttpResponseMessage(url, queryContent))
                {
                    using (var data = responseMsg.Content)
                    {
                        var content = await data.ReadAsStringAsync();

                        var response = Newtonsoft.Json.JsonConvert.DeserializeObject <SearchAlongRouteResponse>(content);
                        return(Response <SearchAlongRouteResponse> .CreateResponse(response));
                    }
                }
            }
            catch (AzureMapsException ex)
            {
                return(Response <SearchAlongRouteResponse> .CreateErrorResponse(ex));
            }
        }