ThinkGeo.com    |     Documentation    |     Premium Support

Questions about 'TestGenerateTilingImages' sample

Hi.


I found 'TestGenerateTilingImages' sample in this forum.


When I ran it to generate tile cache of a jpeg image, two problems were occured.


(The image I've used is at: earth.esa.int/satelliteimage...004_or.jpg )


 


1st problem: An 'InvalidFormatException' occurs at 'winformsMap1.Refresh();' in btnLoadMap_Click() method.


This problem was solved by replacing second parameter of FileBitmapTileCache() constructor with a real string like "worldmap_cache". However, I don't know why the original code doesn't work because I'm sure that you checked it running. I'm using Windows Vista 64bit (Korean version). Please check it.


2nd problem: It fails to generate tile cache for more zoom levels.


I added more zoom levels (6, 7, 8, 9, 10) to resultZoomLevels to generate more detailed tile cache. However, it generated an exception around zoom level 8. It seemed like it's because of the bitmap width/height calculation logic, but I couldn't understand the TileMatrix and GetIntersectingRowColumnRange() things.


 


I need to make a program that generates tile caches from a bunch of images which I only know the Lat/Lon of four corners. I don't even know how many zoom levels should be cached. Please guide me how I can do it.


  Thanks.



Seungwoo,


If I am not making any mistake, the sample is downloaded from following post:

gis.thinkgeo.com/Support/Dis...fault.aspx
 
Attachment is the .jgw file can be used, while this may not be exactly correct, the world file should reflect the world location for the image file, I think this should be known when the image was createdJ.
 
The reason for the second problem is that, in the sample code, our logic is very simple, first draw the whole bitmap and then separate it into tiles, this be applied decently in high zoomlevel(ZoomLevel1 ~ZoomLevel5). When you want to create a lower zoomlevel(ZoomLevel 7 or later) tiles, this logic was very difficult, because when you create the whole bitmap, it was too large to make it.
 
So, if you want to create some lower zoomLevel tiles, 2 possible ways exists:
1)      Set tile cache for it, let it generated when panning or zooming etc, these tiles can only be generated when visited, and when the same location was visited the second time, it will use the tiles. In this way, just forget the “TestGenerateTilingImages” sample.
2)      Create new logic for lower zoomlevel. My logic is , create ZoomLevel6 tiles from ZoomLevel 5 tiles, Create ZoomLevel7 Tiles from ZoomLevel6 tiles etc.
The relationship between ZoomLevel6 tile and ZoomLevel5 tile is each ZoomLevel5 tile can be separated into 4 ZoomLevel6 tiles.
 
Any more questions just feel free to let me know.
 
Thanks.
 
Yale

1732-Jgw.zip (194 Bytes)

Hi, Yale.


Thanks for your help.


I found a strange behavior from cache generation. I'm using a 8000x4000 size world image. It doesn't need to make cache after a certain zoom level because the image's actual resolution is limited. I think an appropriate solution is using the previous level's tile cache instead of regenerate and store a new cache. (It is the way I used in MapSuite 2.x to make cell-based map.) As you know, I can't make tile cache for the entire level set due to time and disk space. But it would be very common to zoom in deeper when a customer use the map, and a lag occurs by dynamic tile cache generation. I hope you can help me with this problem.


I'd like to ask if you have a plan to distribute a tool or module for tile cache generation. I really feel the need for it since we load and unload massive number of satellite images in various size. (the image width often goes over 10000 pixel)


Thanks again.



Seungwoo, 
  
 Thanks for your interests in Map Suite products. 
  
 I think your solution description is very similar to mine, while this logic is a bit complex when implementing. We did not have this plan to build this tool up to now, where I will try to build a prototype somehow when I am free from tons of tasks later. 
  
 Thanks. 
  
 Yale 


Hi, Yale.


I really appreciate your attention.


Would you help me how I can avoid unnecessary tile cache generation for the zoom levels deeper than the original image resolution?


It would be great if there's a property to limit the tile cached zoom levels or flags to enable/disable tile cache generation for certain zoom levels. Currently, even if I set the visible zoom level and the image does not show up in the map, it's generating tile cache behind the map.


Thanks.


 



Seungwoo,


If I do not understand things wrong, what you are trying to do is select out those zoomlevels you want to generate the tiles for and avoid those zoomlevels you do not want to generate the tile cache for.
 
The following codes show how to do it, the return zoomlevels will be those zoomlevels which will generate tile cache for.

 private Collection<ZoomLevel> GetAllZoomLevels()
        {
            // We only add the top 5 ZoomLevels here for example. 
            // If you want to add more scales, you need to optimize the way generating tiles otherwise 
            // the bitmap we generated might be too big to be hold in memory.
            ZoomLevelSet zoomLevelSet = new ZoomLevelSet();
            Collection<ZoomLevel> resultZoomLevels = new Collection<ZoomLevel>();
            //resultZoomLevels.Add(zoomLevelSet.ZoomLevel01);
            //resultZoomLevels.Add(zoomLevelSet.ZoomLevel02);
            //resultZoomLevels.Add(zoomLevelSet.ZoomLevel03);
            //resultZoomLevels.Add(zoomLevelSet.ZoomLevel04);
            //resultZoomLevels.Add(zoomLevelSet.ZoomLevel05);
            //resultZoomLevels.Add(zoomLevelSet.ZoomLevel06);
            //resultZoomLevels.Add(zoomLevelSet.ZoomLevel07);
            //resultZoomLevels.Add(zoomLevelSet.ZoomLevel08);
            //resultZoomLevels.Add(zoomLevelSet.ZoomLevel09);
            return resultZoomLevels;
        }

 
Any more questions just feel free to let me know.
 
Thanks.
 
Yale

I'm sorry, Yale.


I think my question was not sufficient.



"Would you help me how I can avoid unnecessary tile cache generation for the zoom levels deeper than the original image resolution? It generates caches even if I limited the visible layer level of the image layer and it was not shown."



It meant when I use dynamic tile cache generation in time, which you have suggested in the first answer.



1)      Set tile cache for it, let it generated when panning or zooming etc, these tiles can only be generated when visited, and when the same location was visited the second time, it will use the tiles. In this way, just forget the “TestGenerateTilingImages” sample.



Thanks.


 



Seungwoo, 
  
 Sorry for my misunderstanding about your question. 
  
 For the dynamically generating tile cache logic, if you do not want to  generate cache tiles for some area, just set the TileCache for the Overlay to null, and set it to a valid TileCache when you want to cache it. 
  
 Any more questions just feel free to let me know. 
  
 Thanks. 
  
 Yale