public async Task <List <Feature> > GetByBoundingBox(Coordinate sourthWest, Coordinate northEast, string language) { for (int retryIndex = 0; retryIndex < 3; retryIndex++) { try { var geoSearchGenerator = new GeoSearchGenerator(_wikiSites[language]) { BoundingRectangle = GeoCoordinateRectangle.FromBoundingCoordinates(sourthWest.X, sourthWest.Y, northEast.X, northEast.Y), PaginationSize = 500 }; var results = await geoSearchGenerator.EnumItemsAsync().ToListAsync(); var features = new List <Feature>(); foreach (var geoSearchResultItem in results) { var coordinate = new CoordinateZ(geoSearchResultItem.Coordinate.Longitude, geoSearchResultItem.Coordinate.Latitude); var attributes = GetAttributes(coordinate, geoSearchResultItem.Page.Title, geoSearchResultItem.Page.Id.ToString(), language); features.Add(new Feature(new Point(coordinate), attributes)); } return(features); } catch { // this is used since this function throws an unrelated timeout error... } } _logger.LogError($"All Retries failed while trying to get data from {language}.wikipedia"); return(new List <Feature>()); }
public void GeoCoordinateRectangleTest() { var rect = new GeoCoordinateRectangle(365, 50, 20, 30); Assert.Equal(385, rect.Right, 8); Assert.Equal(20, rect.Bottom, 8); Assert.False(rect.IsNormalized); Assert.True(rect.IsNormalizable); rect.Normalize(); Assert.Equal(new GeoCoordinateRectangle(5, 50, 20, 30), rect); Assert.True(rect.Contains(new GeoCoordinate(25, 370))); }