private static void NearestSuburbs(IGeoMap map) { while (true) { Console.WriteLine("Input latitude, longitude and distance in kilometers:"); var line = Console.ReadLine(); if (string.IsNullOrEmpty(line)) { break; } var arr = line.Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries); var latitude = double.Parse(arr[0]); var longitude = double.Parse(arr[1]); var km = double.Parse(arr[2]); var sw = Stopwatch.StartNew(); var suburbs = map.GetNearestSuburbs(new GeoPoint(latitude, longitude), Distance.FromKilometres(km)).ToList(); sw.Stop(); foreach (var suburb in suburbs.OrderBy(x => x.Name)) { Console.WriteLine(suburb); } Console.WriteLine($"Time taken: {sw.Elapsed.TotalMilliseconds:F3}ms"); PrintMemoryUsage(); } }
private static void NearestSuburbs(IGeoMap map) { Console.WriteLine("Input latitude, longitude and distance in kilometers:"); while (true) { var line = Console.ReadLine(); if (string.IsNullOrEmpty(line)) { break; } var arr = line.Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries); var latitude = double.Parse(arr[0]); var longitude = double.Parse(arr[1]); var km = double.Parse(arr[2]); var suburbs = map.GetNearestSuburbs(new GeoPoint(latitude, longitude), Distance.FromKilometres(km)).OrderBy(x => x.Name); foreach (var suburb in suburbs) { Console.WriteLine(suburb); } } }