public async Task <Feature> GetById(string id) { var splitId = id.Split('_'); var language = splitId.First(); var pageId = splitId.Last(); var site = _wikiSites[language]; var stub = await WikiPageStub.FromPageIds(site, new[] { int.Parse(pageId) }).FirstAsync(); var page = new WikiPage(site, stub.Title); return(await ConvertPageToFeature(page, language)); }
public async Task <FeatureCollection> GetById(string id) { var language = id.Split('_').First(); var pageId = id.Split('_').Last(); var site = _wikiSites[language]; var stub = await WikiPageStub.FromPageIds(site, new[] { int.Parse(pageId) }).First(); var page = new WikiPage(site, stub.Title); await page.RefreshAsync(new WikiPageQueryProvider { Properties = { new ExtractsPropertyProvider { AsPlainText = true, IntroductionOnly = true, MaxSentences = 1 }, new PageImagesPropertyProvider { QueryOriginalImage = true }, new GeoCoordinatesPropertyProvider { QueryPrimaryCoordinate = true } } }); var geoCoordinate = page.GetPropertyGroup <GeoCoordinatesPropertyGroup>().PrimaryCoordinate; var coordinate = new Coordinate(geoCoordinate.Longitude, geoCoordinate.Latitude); var attributes = GetAttributes(coordinate, page.Title, id, language); attributes.Add(FeatureAttributes.DESCRIPTION, page.GetPropertyGroup <ExtractsPropertyGroup>().Extract ?? string.Empty); attributes.Add(FeatureAttributes.IMAGE_URL, page.GetPropertyGroup <PageImagesPropertyGroup>().OriginalImage.Url); attributes.Add(FeatureAttributes.WEBSITE, $"https://{language}.wikipedia.org/?curid={page.Id}"); return(new FeatureCollection(new Collection <IFeature> { new Feature(new Point(coordinate), attributes) })); }