public void TestQueryAround() { var simbadClient = new SimbadClient(); var objects = simbadClient.QueryAround( new Objects.RaDecCoordinate(rightAscension: 20, declination: 10), radiusInDegrees: 1.5f); }
private static async Task SearchForObjectsAroundRaDecAsync(ReceivedMessage receivedMessage, Match regexMatch, SimbadClient simbadClient) { RaDecCoordinate centerCoordinates = null; const float radiusInDegrees = 0.5f; try { if (regexMatch.Groups["CenterOfSearchRA"].Success) { centerCoordinates = new RaDecCoordinate( double.Parse(regexMatch.Groups["CenterOfSearchRA"].Value, CultureInfo.InvariantCulture), double.Parse(regexMatch.Groups["CenterOfSearchDEC"].Value, CultureInfo.InvariantCulture)); } else if (regexMatch.Groups["CenterOfSearchName"].Success) { var name = regexMatch.Groups["CenterOfSearchName"].Value; var queryAroundObject = simbadClient.FindObjectByName(name); if (queryAroundObject == null) { await receivedMessage.Channel.SendMessageAsync($"No object with name {name} found in the SIMBAD databse!").ConfigureAwait(false); return; } centerCoordinates = queryAroundObject.RaDecCoordinate; } } finally { if (centerCoordinates == null) { await receivedMessage.Channel.SendMessageAsync("Could not parse RA/DEC coordinates").ConfigureAwait(false); } } var objectsAroundTarget = simbadClient.QueryAround(centerCoordinates, radiusInDegrees); var csvString = CsvExporter.AstronomicalObjectsToCsv(objectsAroundTarget); await receivedMessage.Channel.SendMessageAsync($"Found {objectsAroundTarget.Count} objects around {centerCoordinates} within a radius of {radiusInDegrees}°:").ConfigureAwait(false); await receivedMessage.Channel.SendMessageAsync( new SendMessage( content : null, new List <Attachment> { new SendAttachment { Name = "queryResult.csv", Content = Encoding.ASCII.GetBytes(csvString) } })).ConfigureAwait(false); }