Raster Pyramids II
We looked at raster pyramids briefly in tutorial 8.2. We'll go into more detail here. The map with pyramided data example shows how to use both OpenStreetMap pyramids and BlueSpray pyramids.
Steps
The key to a good raster pyramid is matching the number of "steps" in the pyramid to the data. BlueSpray creates a pyramid that starts with just a few tiles to represent the top step in the pyramid and then creates additional steps until the tiles are the same resolution as the raster data or better. You can limit the number of steps by simply specifying the maximum number of steps when you create the pyramid.
Issues with Pyramids and Tiles
There are a number of problems that are created with typical sets of pyramided data or "slippy tiles". The OpenStreetMap format, originally pioneered by TopoZone, assumes that you have a pyramid that contains a complete set of the data. In other words, it assumes that you have about 20 steps of tiles, representing the entire earth. This leads to huge data sets. BlueSpray's pyramids are currently unique because they provide an "info" file that defines the bounds of the pyramid, the number of rows and columns of data and other information. Then, each tile has a "VTile" file that describes the contents of the tile. The NumChildTiles parameter defines if there are any tiles below the current tile. This allows BlueSpray's tiles to stop when a tile is empty or the resolution of the current raster has been reached. There is also a "TheColor" value. If this parameter is not null, then the tile is just a solid color. This reduces the amount of time and painting that is required for the browsers.
Raster Pyramids
Large rasters need to be turned into "pyramids" of "tiles" to keep the performance fast. This can be done in BlueSpray by right clicking on a raster layer and selecting "Transforms (other) -> To Pyramid Layer ". This will create a pyramid of tiles in BlueSpray. Then, right-click and select "Export to File". Navigate to a folder for the pyramid files and select "Canvas Map Folder" as the file type. Don't worry about the file name as BlueSpray will put a large number of files in the folder including "pngs" that represent the files, an "info.js" file with information on the raster, and a series of "tile" files with information on each tile.
var ThePyramidLayer=new CMLayerDataset(); ThePyramidLayer.SetSetting("Item","Name","Pyramid2/BlueMarble"); TheMainContainer.AddLayer(ThePyramidLayer); ThePyramidLayer.SetSetting("Dataset","Format",CMDataset.PYRAMID);
ThePyramidLayer.SetSetting("Dataset","URL","GISData/GoogleMercator/Pyramids/BlueMarble/");
ThePyramidLayer.RequestData();
Note that you do not need to provide the bounds as this is already defined by the tiling "info.js" file. You do need to call "AddBackground()" to add a tiled layer as a background but call "AddLayer()" if you want it to appear in the layer list.
Also note that the layer should be convered into the desired spatial reference before converting it to a pyramid.