ThinkGeo.com    |     Documentation    |     Premium Support

TileCache with RC2

Hi guys,


I am familiar with the new tilecache system as I had it working correctly in build 397. However, after having upgraded to build 415 with the same code (except for renaming Hybrid to SessionCache) the cache system is not in place. Panning and zooming to previously visited places on the map causes redraws instead of the obvious caching system.


Is there something additional that must be done to enable cache besides setting the overlay.TileCache and overlay.PreviewTileCache?



Nelson, 
  
   It is strange.  Can you verify the cache directory property on the session cache instance and then look in there while you are debugging to see if it is creating tiles?  Another option to try in the short term is the FileBitmapTileCache, this one will cache more permanently but you can always clear it manually by calling clear.  I want to see if it is a problem with the session cache or how it attaches to the overlays.  I am having an issue accessing our source control so I am a bit down right now. 
  
 David

I have tried to use the SessionFileBitmapTileCache, the InMemoryBitmapTileCache, but not strictly the FileBitmapFileCache. 
  
 I am explicitly setting the temp path with System.IO.Path.GetTempPath().  This maps out to "C:\Documents and Settings\nsoto\Local Settings\Temp" on my machine. 
  
 The tiles are being created for the Tile Cache. It does not, however, look like the preview tile cache is being created.  
  
 Perhaps the cache’s visual behavior is different now? Am I supposed to appear to be reloading tiles? Or should it appear as it has in the past which is if the tiles are loaded and you pan back to them, there is nothing visual to notice at all; the tile is already drawn there.  
  
 After trying the FileBitmapCache, I am noticing none of the image cache systems appear to work as it stands. 
  
 It’s still pretty fast, but I am anxious to measure my gains including implementing the TileCache. 
  
 Thanks.

Nelson, 
  
   We may need to do a goto meeting on this.  There is no visual cue to tell you the caching is working.  If your layers render quickly normally without the cache then the cache may not do that much better for you.  In your case I know the features are cached in memory so you might not see much speed gain out of it.  It is more for very complex base layers like the World Map Kit etc.  I would be happy to take a look.  One way you can tell is if you clear the cache and then generate a few tiles in an area and then go to msPaint and mark some of the tiles. 
  
   The preview tiles system has changed and I am not up to speed on how that works.  I will find out and let you know.  I am pretty sure it is only used in the multi threaded mode though. 
  
 David

David, 
  
 I didn’t realize you were on the forums today. I haven’t checked since the morning.  
  
 That is odd that you mentioned the preview tiles cache may only be used in multi-threaded mode. With my previous build it was working and I have been using single-threaded mode for months now. The cache becomes helpful when users are using 10 or so layers and drawing once will save tons of time as opposed to constantly redrawing. Plus it gives a nice effect panning and what not. For one layer, there is not much of a difference but it is still nice to have on. 
  
 If you don’t have the time for this today, maybe we can arrange this tomorrow? It certainly isn’t critical but it is a nice feature we’d like to have back on. 
  
 Thanks.

David, 
  
 I didn’t realize you were on the forums today. I haven’t checked since the morning.  
  
 That is odd that you mentioned the preview tiles cache may only be used in multi-threaded mode. With my previous build it was working and I have been using single-threaded mode for months now. The cache becomes helpful when users are using 10 or so layers and drawing once will save tons of time as opposed to constantly redrawing. Plus it gives a nice effect panning and what not. For one layer, there is not much of a difference but it is still nice to have on. 
  
 If you don’t have the time for this today, maybe we can arrange this tomorrow? It certainly isn’t critical but it is a nice feature we’d like to have back on. 
  
 Thanks.

Nelson, 
  
   Yea I am trying to give some relief to the support guys and the desktop team in general.  I also like the forums and have fun posting on them.  Tomorrow would be fine if it around the end of the day, I have some meeting almost all day until 4pm or 5pm.  I think one thing you can do is set the IsBase Property to true on the overlays you want the nice panning on and I think that will work for you.  I am in the process of creating a new video to go over all of the new caching systems and IsBase, refreshing and locking stuff.  It’s just allot of work and we in the last few weeks have put out a bunch of new stuff I have been involved in.   Anyway e-mail me to let me know your schedule. 
  
 David

Hello, 
  
 Just to say say that I just upgraded to RC2 version, and Automatic TileCache (staticOverlay.LocalCache = LocalCacheMode.AutomaticCaching) don’t seems to work any more for me too. Setting the IsBase property to true did’nt chage anything.  
  
 It would be nive to have a feedback about this problem here when you’ll find the reason ! 
 Thanks, 
 Guillaume.

Hum… 
  
 Ok, sorry, I didn’t read this post properly. 
 Using TileCache (instead of LocalCache) with a FileBitmapTileCache object, and setting IsBase to true works good. 
  
 Thanks,  
 Guillaume.

Guillaume, 
  
   The LocalCacheMode doesn’t do anything anymore because we allow you to directly access the cache via the Overlay.TileCache property.  We suggest you create a FileBitmapTimeCache or a SessionFileBitmapTileCache there and that will enable caching.  The IsBase property only determines if that layer is drawn in real-time as you pan.  If none of the overlays have this on then when you are panning it shows white or a background color in the area where you have moved from.  When you stop panning it will draw to fill it all in.  If you set any of the Overlay’s IsBase == true then while you are panning we will try and draw that overlay to fill in the gap casued by your panning action.  This takes resources while you pan and it will not be as crisp or snappy to pan.  We suggest that if you set the IsBase to true then you cal add some kind of caching to that Overlay so we can draw from the cache and not from scratch. 
  
   I am coming out with an education video in the next few days to show this in action. 
  
 David

Guillaume,  
  
 No problem,  I just explained it a different way above, and then I saw your post come in right after I submitted mine.  It can be kinda of tricky so better we go over it twice!  :-) 
  
 David

Sorry David. I didn’t make it into the office yesterday so I am just reading this post now. After reading your further explanation above, I think it’s highly likely that I have been utilizing cache but was looking for the behavior that comes about when using IsBase. Unfortunately when setting this property to true, as you mentioned the panning is a little laggy. Is there any way to tweak this at all? I was using map.DebugParameters(“PanDelay”) = “100” in the past to sort of even this out.  
  
 If there is no way to tweak this, I wouldn’t really consider it a big deal. I was thinking if we were using several layers that the image caching would be saving us some overhead but it seems it’s already in place. I think it’s not a big deal at the moment with low resolutions but when the map control is used at high resolutions then it becomes a concern. Still, they can shut off the layers causing the slow down and turn them back on as necessary for now.  
  
 In regard to the PreviewTileCache not being used in single-threaded mode any longer, I do have a question though. We are in pretty high need of having a visual cue to let us know we are in the process of drawing. We were using a rolling progress bar hooked up to the overlaydrawing event but it doesn’t really work in single-threaded mode even though we are using delegate subs and what not. Is there any means of getting this to work in single-threaded mode? There is a noticable delay when zooming in and out and I think some sort of cue is necessary so our users aren’t zooming in 3 times when they meant to zoom once and what not.  
  
 Thanks again.

Hi Nelson,


For the preview tile cache question, we have done a sample to show you how to add a rolling progress bar by OverlayDrawing and OverlayDrawn events in single threaded mode. We are using a gif image as a rolling progress bar, and you can take a look at the effect (you can test this against a bigger shape file instead of the Countries02.shp). Also you can generate another new gif image as well by the following site:
ajaxload.info/
Hope this can help you and any more questions please let us know.
Thanks,
sun

1228-Post6289Demo.zip (14.2 KB)

This code works ok as long as you add a Catch statement into the Try block. otherwise, there are random errors about the object being in use on dispose or load. 
  
 Thanks.

Nelson,


I think the random errors are caused by the System.Threading.Timer in the sample application above, but I can recreate this problem only when I insert a breakpoint to the DrawGifImage function. I think you could try to add a lock to avoid this problem, because the errors didn’t happen after I added a lock to the DrawGifImage function even when I debug the sample application. Also I made some mistakes when using the System.Threading.Timer in the sample above, so I made some change to the code as well as adding a lock to it. The new sample is in the attachment.


Any questions please let me know.
Thanks,
sun

1229-Post6289Demo.zip (14.4 KB)

This is very good. It takes away some of the other little issues I experienced when drawing track shapes also. Thanks sun.

Actually, the only issue I seem to notice is that the loading bar won’t appear for TrackZoom or anything like that.  
 Is there any way to incorporate all map drawing into the loading bar?

Nelson,


So you mean when you TrackZoomIn or TrackZoomOut on the map the loading bar won’t appear? But in my machine it works when I TrackZoom, you can take a look at this screenshot:
 


I think maybe the map draws too fast in somewhere when the tiles cache exists, so that the loading bar has no time to show on the map when the new map has drawn. The timer starts to run in 100 milliseconds after the overlay drawing event is raised, so if the map’s drawing time is less than 100 milliseconds the loading bar will not appear.
Any more questions please let me know.
Thanks,
sun

Judging by your screenshot and the color of the track box, I am assuming you are trying the TrackZoomIn that takes place when holding shift and clicking when in Pan Mode.  
  
 What I mean to say is that I have created very simple functions for Track Zoom In and Track Zoom Out that basically set my TrackMode to rectangle and handle my own event when the TrackShape has ended.  
  
 So, I guess what I mean to say is that whenever I draw a track shape of any sort and then modify the map during the TrackEnded event, no loading bar ever draws.  
  
 I hope I have clarified what I meant to detail in my previous post. Thanks for the help.

Nelson,


So you mean implement the TrackZoomIn and TrackZoomOut in the TrackEnded event of TrackOverlay when the TrackMode is Rectangle? We have done a sample based on what you said, and the loading bar still can work. You can get the sample from the attachment and take a look.
Any more questions please let me know.
Thanks,
sun

1238-Post6289.zip (22.7 KB)