ThinkGeo.com    |     Documentation    |     Premium Support

Overlay redraw question

Let's back up a little.


Our question is this: Is the overlay drawn time the actual draw time, each time the map is redrawn?


In our example, the draw time for the "Static" overlay never changes even though the "first" draw would have to include fetching data. Each successive redraw (since the GPS overlay has change) does not include the fetch and therefore we think the time should be shorter instead of the same.


In regards to tile caching, etc. Since we will be adding map rotation in some scenerios, we assume the caching would not work. Can you confirm this too?



We created a video screen capture of problem we are experiencing. Hopefully this illustrates our question(s): 
  
 The video (17MB) is at: 
 ironcompass.com/media/Video_2011-01-04_141433.wmv 
  
 This is a live screen capture while using a program we created called “JustGPS” made with Map Suite 4.5x. 
  
 The video shows a moving green arrow that is in the “GPS” overlay. The rest of the map is in the “Static” overlay. The draw times for all the overlays can be viewed in a box at the lower right corner of the app. 
  
 Windows Task Manager is visible and shows 20MB swings in memory usage and CPU usage runs flat at 45% (+/-) for the “JustGPS” app. 
  
 As the “GPS” overlay draws, the draw time is updated along with the draw times of all overlays. We do not understand why the draw time for the “Static” overlay does not decrease after a redraw of the entire map, but while the GPS moves. 
  
 The “unlicensed” label on the “Static” overlay does not change positions when the “GPS” overlay is redrawn (the “unlicensed” label does move on the "GPS overlay as the "GPS overlay is redrawn). We have found this label to be helpful during debugging. 
  
 So, more questions:  
 1. Why is the “Static” overlay time not changing although it appears the layer is not being rendered again? 
 2. Why such memory swings and high CPU usage when we use the translate offset to move one single GPS coordinate on the map? 
  
 We so close to getting our app ready for alpha, this is the last piece and we can’t move forward until this is solved. Any help would be appreciated. 
  
 Thanks. 
  
 John 
  
  


John.  I’m a customer and I want to thank you for carrying the weight of this problematic issue.   Your documentation and description has been excellent.  I also look forward to the resolution. 
  
 In our app, we have 10 to 20 overlays.   Like yours, the “bottom” five to 10 overlays are “static”.  The data never changes.   We will often change the rendering style on something like the 15th overlay.   When we do that, we do an explicit Refresh on just that overlay, thinking that we will not need to render the entire map again.    But in most cases, we find that the lower layers are getting rendered again.    
  
 We are NOT using any tile caches.   When we started building the app, they were not stable, and we haven’t had time to stick our toe back into that water.  We use custom layers for almost all of our layers, though.  So I have an implementation of DrawCore in those layers.   I’ve instrumented that function to write diagnostics of the rendering time, layer name, etc and that displays in the output window.   So, like you, I know that we are rendering overlays that are on the “bottom” of the map as a function of refreshing an overlay that is on the top of the map, w/o changing the map extent. 
  
 I have not seen what the level of detail is on your “static” layer.  But in cases where we are rendering data from the WorldMapKit… road features, etc, it is not uncommon for the renderer to take the amount of time you are describing… without actually going back to the underlying data source for a data refresh. 
  
 My hope was that when refreshing a single overlay, MapSuite would be capable of using overlay-specific cached images to rebuild the “static” layers lying under the dynamic layer.    Seems that this should be possible w/o using the tile caching solution.    If it is the intent that this should happen, then I hope this thread helps track down the reason it is not behaving this way. 
  
 Thanks again for your efforts here. 


John,


Thanks for your post and video.
 
Make sure a few things before going forward:
1)      Does the StaticOverlay means LayerOveraly which contains about 30 shape file feature layer, right?
2)      What does the GPS draw times means, it means the overlay contains the GPS locations?
3)      What does the Scale draw times means?
4)      Could you try to remove all the AdormentOverlays to see if there is a performance boost?
 
Any feedbacks would be appreciated.
 
Thanks.
 
Yale

Yale,


My answers are in red:


 
1)      Does the StaticOverlay means LayerOveraly which contains about 30 shape file feature layer, right? The static overlay contains all the base map layers. About 30 MS SQL 2008 feature layers.
2)      What does the GPS draw times means, it means the overlay contains the GPS locations? This Overlay holds one point feature, the GPS position. This feature is updated as the GPS position changes.
3)      What does the Scale draw times means? Lousy name for this Overlay, this overlay contains 2 mapshape layers.
4)      Could you try to remove all the AdormentOverlays to see if there is a performance boost? We'll try this.
 
All data is in the same projection (world mercator). The GPS position is projected from lat/long to mercator before feature is added to memory layer.
Thanks.
 
-John

John,


Thanks for your post and feedback.
 
I reinvestigate into the code and I think the time for drawing the static overlay can never be decreased into zero, but it should be decreased into a very small value(probably less than 0.5 seconds) if the extent is not change when only updating the GPS positions. The reason is that we will keep the overlay bitmap in memory unless the extent is changed, and each time we will only draw this bitmap if the extent is not changed. Hope it make sense to you.
 
Any more questions please feel free to let me know.
 
Thanks.
 
Yale

Yale, 
  
 The big performance problems we have been having were caused by some monitoring software we had in the project. Since we took it out, the performance is much better.  
  
 But we are still curious about one item: 
 We are explicitly refreshing the “GPS Overlay” and the time reported for the “Static Overlay” to redraw for example is 1.3 seconds. 
  
 We have implemented file based caching (and also tried in memory caching). When the caching is used, and the “GPS Overlay” is refreshed, the time reported to redraw the “Static Overlay” is something like 0.05 seconds -very fast. 
  
 Therefore, if when we only refresh the “GPS Overlay”, why does it appear the “Static overlay” is being redrawn every time with a reported time in the 1.3 second range? If the “Static Overlay” is coming from a bitmap in memory, it should always report a very small time even when caching is turned off. 
  
 Why does it appear the “Static” overlay is coming from a bitmap in memory, but the time frame indicates it is being drawn from scratch. Please note the “Static” overlay’s “unlicensed” text does not move, so we assume it is coming from the bitmap in memory. 
  
 Thanks Yale, this is one of the last details for us to solve in our GPS enable app. 
  
 John

 


John,
 
    We are sorry about that we let you misunderstanding the meaning of DrawingTime, this property gets the last drawing time for the Overlay. We didn’t update the value if the Overlay wasn’t redrawn.
 
Thanks for your video, with it, we can find out that, at the beginning the Static overlay drawing time was 0.9210s, and it does not decrease because the overlay didn’t redrawn until the map extent changed and the Static overlay drawing time changed to 1.4070s, this time it keeps until the map extent changed again. Now you can clearly understand the meaning of DrawingTime.
 
Any more questions please feel free to let me know.
 
Thanks,
 
James

James… 
  
 Is this what you’re saying? 
  
 If we want to redraw from the cache, even if just the GPS/memory layer is changed, I should either (1) redraw the whole map or (2) redraw the static and memory overlays (I believe there is a version of Map.Refresh( ) that takes a list of overlays.).  Either one will refresh the static overlay from cache.  We see usually see cache redraw times of well under .1 seconds, so this should not be a performance hit over similarly small numbers just by refreshing the dynamic/GPS overlay. 
  
 Allen

John,


We have fixed DrawingTime problem. Now, if the overlay is not drawn, the drawing time will be 0.


Allen,


I am glad to explan our cache system to you. There are two overloads of Map.Refresh methods:


  Refresh(): It will refresh all overlays, if some of overlay sets TileCache, it will load cache image instead of draw overlay.


  Refresh(overlay), Refresh(overlays): They are pretty much the same, it will redraw specific overlay/overlays, ignore the TileCache.


Let me know if you guys have more questions.


Thanks,


James



 Posted By John on 01-04-2011 02:16 PM 



The video shows a moving green arrow that is in the “GPS” overlay.

John, may I just ask you where you got the green arrow icons? I have been looking for something similar myself. At the moment I am just using a triangle with custom roatation style (and soon custom colour style):


Dim rotatedpointStyle As New RotatedPointStyle(PointStyles.CreateSimpleTriangleStyle(GeoColor.SimpleColors.Red, 15, GeoColor.SimpleColors.Black), “VCMG”, 1)


but the triangle doesn’t really work as it is equalateral and doesn’t properly show the heading of the tracked object. Your icons look a lot better. Are they from the ThinkGeo icon pack?



David, 
  
 I have watched the video again, I can help John answer your question that the green arrow icons are not from our IconLibrary. 
  
 Thanks, 
 James

Ok, I am having trouble finding icons that work well by rotating (with custom style) to show ship heading. The triangle shape I mentioned has no real heading info. I could use Webdings but as reported a while back, some of them have problems where they do not center on the correct point properly. Can we make our own icons for use with Desktop Edition? I did look through your icon library, but as mine is a fairly niche area - ships in plan view, there isn’t really much there suitable for me.

David, 
  
 Maybe I didn’t get you well, but I think it should be easy to make an icon like that green arrow in the video John provided, just by using some simple tools such as MSPaint, and then consume it by Map Suite. Correct me if I missed anything.  
  
 Thanks, 
  
 Ben

If I can’t find anything already done then I guess I will have to attempt that. At the moment trying to get my layer drawing time down from 13 seconds per cycle - I guess 2.8 million ship trails on the screen is a bit ambitious!

Right, 2.8 million trails on the screen is a bit too ambitious. :)  Hope you can find a good way to cut it down. 
  
 Ben

Just a quick one here - I have been testing out displaying drawing times  for overlays but thought I would make it more generic so I don't have  to keep adding code every time a new overlay is added. So, I have this  code: 



For Each Overlay In WinformsMap1.Overlays

Debug.Print(Overlay.Name + " - " + Overlay.DrawingTime.Seconds.ToString + "." + Overlay.DrawingTime.Milliseconds.ToString)

Next




(ignore the break marks in there - can't see how to get rid of them in your forum editor)


The time for each overlay is getting displayed properly but the name is always blank. Why is that? 



Also, is there a way to do a similar loop through all layers instead of overlays?



David,


The reason of the name of Overlay is always blank because you didn't set the name of overlay.


LayerOverlay is one kind of overlay, it contains layers collection, I think you can do the similar loop for them.


BTW, we provide a sample to show how to post the source code that it is always up to the top of forum.


gis.thinkgeo.com/Support/Dis...fault.aspx


I suggest you can start a new thread if you have more questions, that can make your questions easy to be found, if the other users have the same problem, they can find solution immediately.


Thanks,


James



I always thought that the first parameter of the Overlays.add method was the name of the Overlay. Can’t seem to find it in the API to see what that first parameter really is. 
  
 WinformsMap1.Overlays.Add(“S57MapOverlay”, S57MapOverlay) 
  
 I do now see I can use: 
  
 Dim S57MapOverlay As New LayerOverlay() 
 S57MapOverlay.Name = “S57MapOverlay”

David, 
  
 Which version of DesktopEdition are you using? I am using 4.5.0.0 that it has the document for what the API is, "This parameter is the key to find the item." I am not sure if you have ever used Dictionary<key, value> before, they are pretty much the same, you can treat WinformsMap1.Overlays is a Dictionary<string, Overlay>. So that you can get the added overlay by using following code 
 Overlay myOriginalOverlay = WinformsMap1.Overlays["S57MapOverlay"]; 
  
 Thanks, 
 James