public Task <LinkedList <News> > FetchAsync(string projectId, System.IProgress <OperationProgress> progress, CancellationToken cancellationToken) { var url = string.Format(CultureInfo.InvariantCulture, @"projects/{0}/news.xml", projectId); progress?.Report(new OperationProgress(Resources.StrsFetchingNews.AddEllipsis())); return(FetchItemsFromAllPagesAsync(url, cancellationToken)); }
public void CreateAllTiles(IRasterDataset dataset, int maxZoom, IOutput output, System.IProgress <int> progress = null) { double xMin, yMin, xMax, yMax; var bytes = 65 * 65 * 2; byte zero = 0; int count = 0; RasterInfo r = dataset.Info; xMin = r.FieldInfo[0].Envelope.XMin; xMax = r.FieldInfo[0].Envelope.XMax; yMin = r.FieldInfo[0].Envelope.YMin; yMax = r.FieldInfo[0].Envelope.YMax; Dictionary <string, string> existingTiles = new Dictionary <string, string>(); for (int zoom = maxZoom; zoom >= 0; zoom--) { //only generate tiles within the extents of the data var southWestTile = PointToTile.LatLonToTile(zoom, yMin, xMin); var northEastTile = PointToTile.LatLonToTile(zoom, yMax, xMax); var dx = northEastTile.X - southWestTile.X; var dy = northEastTile.Y - southWestTile.Y; var boundingBox = PointToTile.TileBounds(zoom, northEastTile.X, northEastTile.Y); var tileSample = (boundingBox.Max.Lon - boundingBox.Min.Lon) / 64; var sourceSample = dataset.Info.FieldInfo[0].CellSizeX.Decimal; ThreadLocal <byte[]> terrainTileLocal = new ThreadLocal <byte[]>(() => new byte[(bytes + 2)]); Console.WriteLine($"{(dx+1)*dy}"); Parallel.For(0, dx + 1, (easterlyOffset) => { Parallel.For(0, dy + 1, (northerlyOffset) => { int tX = southWestTile.X + easterlyOffset; int tY = southWestTile.Y + northerlyOffset; var terrainTile = terrainTileLocal.Value; byte childQuadSwitch = zero; if (zoom != maxZoom) { childQuadSwitch = GetChildQuads(zoom, tX, tY, existingTiles); } //always create tiles with child tiles bool create = childQuadSwitch > 0 || (zoom == maxZoom); if (create) { bool created = false; created = CreateTile(tX, tY, zoom, dataset, terrainTile); if (zoom == maxZoom) { create = created; } } if (create) { terrainTile[bytes] = childQuadSwitch; terrainTile[bytes + 1] = 0; //We'll say it's all land for now output.WriteTile(zoom, tX, tY, terrainTile); existingTiles.Add($"{zoom}/{tX}/{tY}", ""); } progress?.Report(++count); }); }); } }