The
IlvManagerTiler class is a utility class that renders a map, saved
to a specified location on the disk at different scale levels, as
tiled images. These images can be used to fill the cache of a thin-client
server application. Offline tile generation speeds up the initial
response time of the server, as it does not need to create and cache
the images when clients request them. It increases the server scalability
for the same reason.
The first step to generate tiled images for a map is
to ensure that the Thin Client Parameters have been set in the map,
see
Setting Thin Client Parameters in
JViews Maps Using
the Map Builder. What
the map builder does is that is to add two
IlvNamedProperty
instances
to the map. The names of these properties are defined in the IlvMapTileGen
IlvMapTileGeneratorConstants class as constants:
TILE_SIZE_PROPERTY is the name of the
property that holds the size of the tiles that will be generated.
The size is measure in pixels. An example value is 256 pixels.
SCALE_LEVELS_PROPERTY PROPERTY is the
name of the property that holds an array of double
values
representing the different scales at which the map should be rendered
using tiles.
If these parameters are not set in the map, you must
specify them explicitly in the
createTiles()
method
call. Then, you must create an
IlvManagerTiler
instance and call the
createTiles method with the appropriate parameters using the
following code:
IlvManagerTiler tiler = new IlvManagerTiler();
long maximumDiskSpace = 10000000; // 10 Mbytes
String mapFilename = "MyMap.ivl";
File outputFolder = new File("output");
tiler.createTiles(mapFilename,null, outputFolder, maximumDiskSpace);
// Null is passed as the region so as not to limit the tiling process.
Remember that generating tiles for a map covering a large
region, with several scale levels, and without specifying an area
of interest, can easily lead to millions of tiles being created. This
may require several Gigabytes of memory and in some cases may take
a long time to complete.
To avoid this:
Note
Only map layers with the thin client background
property
set to true
in their style will be rendered
as tiled images. Dynamic layers such as labeling layers should not
be marked as background layers, as they are dynamically generated
by the servlet.