Exemplo n.º 1
0
        public ActionResult <Geojson> Get(
            float fromLat,
            float fromLon,
            float toLat,
            float toLon,
            string profileName = "pedestrian",
            uint maxSearch     = 2500
            )
        {
            try
            {
                var coordinates = RouteBuilder.Get(fromLat, fromLon, toLat, toLon, profileName, maxSearch);
                if (coordinates == null || !coordinates.Any())
                {
                    return(BadRequest(
                               "Could not calculate a route. Check that departure and arrival points are close to a road, and that the maxSearch is not too low"));
                }

                var geometry = new Geometry(coordinates);

                return(new Geojson(new List <Feature> {
                    new Feature(geometry, new Properties("#000000"))
                }));
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }
        }