I’m trying to setup a tilecache using the generator from the Wiki. My higher ups think the 256x256 png images aren’t sharp enough. I’m trying to work out how to increase the resolution for higher quality, but all I seem to get it higher res pngs with higher map scales applied, so the area-to-pixel ratio stays the same.
How do I modify the Tilecache generator and my project code to use higher resolution images with the same map scale it has with the default 256x256 resolution?
Tilecache image resolution
Hi Jonci,
Thank for your post and Welcome to Thinkgeo Forums!
We can change the resolution for each tiles by following the below codes in TileCacheGenerator.class file:
public Bitmap GetCellFromBitmap(Bitmap sourceBitmap, RectangleShape sourceExtent, RectangleShape cellExtent, int tileWidth, int tileHeight)
{
Bitmap cellBitmap = null;
if (sourceBitmap != null)
{
Graphics graphics = null;
try
{
ScreenPointF upperLeftPoint = ExtentHelper.ToScreenCoordinate(sourceExtent, cellExtent.UpperLeftPoint, Convert.ToSingle(sourceBitmap.Width), Convert.ToSingle(sourceBitmap.Height));
cellBitmap = new Bitmap(tileWidth, tileHeight);
cellBitmap.SetResolution(120.0f, 120.0f);
graphics = Graphics.FromImage(cellBitmap);
graphics.DrawImageUnscaled(sourceBitmap, -(int)Math.Round(upperLeftPoint.X), -(int)Math.Round(upperLeftPoint.Y));
}
finally
{
if (graphics != null) { graphics.Dispose(); }
}
}
return cellBitmap;
}
Please try it and let us know if it is fit for you.
Regards,
Johnny
Adding that SetResolution line just gave me 256x256 blank pngs.
Hi Jonci,
Seems you don’t want to get the high resolution image but big size tile image, you can just assign the original tile size 256 to the size you want like 512:
class TileCacheGenerator
{
private int tileWidth = 256*2;
private int tileHeight = 256*2;
…
}
Please let us know if this is what you want.
Regards,
Johnny
That was my original approach, but the larger tiles sample more of the map, so the area-to-pixel ratio stays the same. The end result looks the same. The tool is just dividing up the scale between the larger tiles.
I want the larger size, but with the same sampling that the default size has. I want the same city block in a tile I would have had before. The scale per tile would stay the same, but rendered on a higher resolution image.
The reason for this is our original map image, a single file with a resolution around 7000x8000, is what was previously used. At the scale to view the whole city, the image is very sharp due to how long the image is. Of course it blurs out as you zoom closer, which is the reason for the switch to vector maps. But they still want some of that sharpness at the higher scale, which requires me to generate our cache with better resolution.
Hi Jonci,
I think that you want to get a
high resolution tile cache but the tile cache image is smaller than original
image, such as the original image is 1024*768, the end result tile cache image
is 256*128, but it’s resolution change to 400dpi. I make a simple sample for
this case in attachment, please check it, and let me know if it is your needs
or not.
Regards,
Casper
ConsoleApplication51.zip (735 KB)