Why do it?
To make maps look nicer, you want to prevent tile re-scaling. This article describes guidelines you can follow to prevent tile re-scaling in LuciadRIA.
What are the consequences of tile re-scaling?
When a LuciadRIA map visualizes more than one RasterTileSetModel
, the tiles of one or more raster layers might be re-scaled. Such a tile re-scaling results in a sub-optimal visualization
of those layers, especially when the tiles contain text or thin lines.
The two preceding images show the consequences of tile re-scaling. Both images show USA states. Tile re-scaling occurs in the image on the left. The image on the right displays tiles with their intended resolution. Tile re-scaling makes text less readable and also introduces unwanted aliasing effects in lines. The left image clearly shows that the state labels are smaller in comparison with the labels in the image on the right. The eastern and southern boundaries of the New Mexico state show aliasing effects in the left image. The lines aren’t as sharp as the boundary lines in the right image.
It’s possible to get a much prettier map by carefully preparing your raster data.
Why does this happen?
LuciadRIA renders tiles based on scale levels
LuciadRIA adapts the zoom levels of the map to the scale levels in the tile pyramid of your RasterTileSetLayer
. When a user zooms in or out, the Map selects the most appropriate scale level in the tile structure and snaps the rendering
to that level. That way, it renders the tiles at each level so that they’re not scaled: one pixel in the tile corresponds
with one pixel on the screen.
Things become less straightforward when there is more than one RasterTileSetLayer
in your map. In that case, LuciadRIA picks a single layer and snaps to the scale levels of the selected layer. LuciadRIA
renders at the scale levels of the LayerType.BASE
layer, which is always at the bottom of the map. If there is no BASE
layer in the map, LuciadRIA uses the scale levels of the bottom-most raster layer.
With more than one RasterTileSetLayer
on the map, the scale levels of the different layers may not align. To prevent that the tiles of the other RasterTileSetLayer
layers are re-scaled, you must ensure that the scale levels of each layer align with the scale levels of the BASE
layer.
How to fix it
Determining scale levels and pixel density of the base layer
Aligning the scale levels of two layers means that you must make the pixel densities correspond between both layers. You
can only do that when you’re creating your raster data set. By generating the scale levels of your overlay RasterTileSetLayer
layers at the same pixel densities as your BASE
layer, you guarantee that the LuciadRIA map doesn’t scale text labels and vector data.
The definition of pixel density is "the number of pixels per spatial unit" with the spatial unit typically expressed in meters. Because raster data sets are two-dimensional, there is a pixel density on the X-axis and a pixel density on the Y-axis
For example, if you want to use a Bing Maps layer as your base layer and create a BingTileSetModel
, the pixel densities are as follows:
Scale level | X pixel density (pixels/meter) | Y pixel density (pixels/meter) |
---|---|---|
0 |
0.00001277603959636653 |
0.0016353330683349157 |
1 |
0.00002555207919273306 |
0.00002555207918098738 |
2 |
0.00005110415838546612 |
0.00005110415836197476 |
3 |
0.00010220831677093223 |
0.00010220831672394952 |
4 |
0.00020441663354186447 |
0.00020441663344789905 |
5 |
0.00040883326708372893 |
0.0004088332668957981 |
6 |
0.0008176665341674579 |
0.0008176665337915962 |
7 |
0.0016353330683349157 |
0.0016353330675831924 |
8 |
0.0032706661366698315 |
0.003270666135166385 |
…​ |
…​ |
…​ |
You can query pixel density information from each RasterTileSetModel with the |
Expressed in RasterTileSetModel
parameters, a BingMapTileSet
model has the following characteristics:
-
Bounds: (X, width, Y, height) = (-20037508.34278924, 40075016.68557848, -20037508.352, 40075016.704)
-
Number of tile rows and columns at level 0: 2 by 2
-
Tile dimensions: 256x256 pixels
-
The calculation to arrive at the X-pixel density at level 0 is (2 * 256) / 40075016.68557848 = 0.00001277603959636653.
Level 1 has twice the number of pixels, because tile pyramids are modeled as quad trees. That is why you calculate the X-pixel density as (4 * 256) / 40075016.68557848 = 0.00002555207919273306.
Aligning scale levels with the base layer
Suppose you want to create a raster coverage in a Web Mercator reference that visualizes street data in Belgium. You can use the raster coverage to display street data on top of the Bing Maps raster layer. The properties for the street data set are:
-
Current height and width: 450000m
-
Required number of tile rows and columns at level 0: 1 by 1
-
Required tile dimensions: 512x512 pixels
If you don’t do anything, the X-pixel density of the street coverage at level 0 is 512 / 450000 = 0.00113777777777. That pixel density doesn’t align with any scale level in the Bing Maps layer. The closest scale levels are level 6 (X-pixel density of 0.0008176665341674579) or level 7 (X-pixel density of 0.0016353330683349157). That’s why you could decide to update the bounds of your street data in one of the following ways:
-
Adapt to level 6: extend the coverage bounds to 626172.1357m, which is the result of 512 / 0.0008176665341674579. That means adding some padding to the coverage. The net result is a raster coverage with a level 0 that aligns with level 6 of the Bing Maps layer. LuciadRIA doesn’t scale the tiles.
-
Adapt to level 7: shrink the coverage bounds to 313086.0679m, which is the result of 512 / 0.0016353330683349157. That means removing over 100 kilometers of possibly relevant data, which is probably not what you want. Nonetheless, the net result is a raster coverage with a level 0 that aligns with level 7 of the Bing Maps layer.
If you want to visualize a WMS layer using a |