public static List <Place> CreateNiceRoute2(WayPoint from, WayPoint to, int radius, List <string> types) { HashSet <Place> places = new HashSet <Place>(); double dist = GeoController.Distance(from, to); double ds = dist / 10.0; double cur = ds; for (int i = 0; i < 10; i++) { WayPoint mid = GeoController.OffsetPoint(from, to, cur); List <Place> midPlaces = GoogleController.GetAttractions(mid, radius, types); foreach (Place place in midPlaces) { if (!places.Contains(place)) { places.Add(place); break; } } cur += ds; } List <Place> lstPlaces = places.ToList(); return(lstPlaces); }
public HttpResponseMessage Get(string from, string to, int radius, string types) { WayPoint fromWp = GoogleController.GetAddress(from); WayPoint toWp = GoogleController.GetAddress(to); List <Place> waypoints = RouteController.CreateNiceRoute(fromWp, toWp, radius, types.Split(',').ToList()); var resp = new HttpResponseMessage() { Content = new StringContent(JsonConvert.SerializeObject(waypoints)) }; resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); return(resp); }