public virtual async Task FetchMapImages(MooiDocument document, string tempPath, IResourceFetchingProgress progress) { var clusters = document.Sections.SelectMany(x => x.Clusters).ToList(); var placemarks = document.Sections.SelectMany(x => x.Clusters).SelectMany(x => x.Placemarks).ToList(); progress.ReportFetchImagesCount(clusters.Count + placemarks.Count); _logger.Info("Downloading overviews"); foreach (var cluster in clusters) { await FetchClusterMapImage(cluster, tempPath); progress.ReportFetchImageProcessed(); } _logger.Info("Downloading sections"); foreach (var placemark in placemarks) { await FetchPlacemarkMapImage(placemark, tempPath); progress.ReportFetchImageProcessed(); } }
public async Task <(string tempPath, MooiDocument document)> Generate([NotNull] KmlDocument document , [NotNull] List <DiscoveredPlace> discoveredPlaces, string language, IResourceFetchingProgress progress) { // TODO: Add cancellationtoken approach var tempPath = CreateAndGetTempPath(); foreach (var resource in document.Resources) { await _file.WriteBytesAsync(Path.Combine(tempPath, resource.FileName), resource.Blob); } progress.ReportResourceEntriesProcessed(); await _foursquare.PopulateWithDetailedInfo(discoveredPlaces.Where(x => !x.IsForPlacemark), language, CancellationToken.None); var mooiDocument = _mooiDocumentFactory.Create(document, discoveredPlaces, tempPath); await FetchMapImages(mooiDocument, tempPath, progress); progress.ReportDone(); return(tempPath, mooiDocument); }