ThinkGeo.com    |     Documentation    |     Premium Support

RC1 - ReDraw(Overlay)

Hi Guys,


If RefreshDynamic, RefreshEditOverlay etc.  are now obsolete it would have helped if you had actually implemented it's replacement ReDraw(Overlay).  To declare something obsolete without providing the replacement is a strange thing to do.


John



Likely this wasn’t intentional or we are not looking for the method in the right place. I too am trying to find it but have instead decided to just wait until tomorrow. For the most part, the API changes look pretty nice though…

John,



  You are absolutely right!  Nelson, thanks for the defense but I am am afraid we screwed it up.  We should have given instructions on how this works now.  We tried to do that on every obsolete member but this one slipped through.  In the RC1 we have re-introduced multi-threading however there is a little bit more you need to do.  Since we could be using an Overlay at the same time you are adding or modifying it we added an Overlay lock system.  

Whenever you want to modify an overlay, outside of the form load, you need to use the EnterWriteLock method on the Overlay.Lock property.  When you are finished you call the Overlay.Lock.ExitWriteLock.  I suggest you put the ExitWriteLock in the finally part of a try statement.  When you exit the write lock that is our cue that the Overlay is now dirty and we need to redraw it.  At the end just call Refresh() and we will handle the rest.  

  

  We updated our samples with this pattern and a good example is our RefreshPointsRandomly sample under the Dynamic Shapes branch.

  

  In the next day or two we will release a video to go over the new features and talk about this a little more in depth.  I am really sorry about the Redraw method not having an intuitive description on it.  We really did strive to make sure they all did.



David

 



// Lock the overlay while we add the points   
            pointsOverlay.Lock.EnterWriteLock();   
            try  
            {   
                pointsLayer.InternalFeatures.Clear();   
                for (int i = 0; i < pointsCount; i++)   
                {   
                    PointShape pointShape = GetRandomPoint(pointsBoundary);   
                    string id = GetRandomDirection().ToString();   
                    Feature feature = new Feature(pointShape.X, pointShape.Y, id);   
                    pointsLayer.InternalFeatures.Add(feature);   
                }   
            }   
            finally  
            {   
                // Release the lock on the overlay   
                pointsOverlay.Lock.ExitWriteLock();   
            }   
  
            winformsMap1.Refresh();   


David, 
  
 Thanks for the explanation that helps a little. 
  
 I did download RC1 but missed the stuff about locking.  I saw the RefreshPointsRandomly example but as the source is missing and the help does not contain any explanation of what EnterWriteLock/ExitWriteLock do or their significance, I missed the point.  
  
 We did try to port our application over; finally after some 4 hours we did manage to get it running partially but decided to give up as we could not get the threading going, probably related to locking.  
  
 We, like some others, have refresh problems where STATIC overlays do not paint correctly, bizarrely enough our dynamic overlays do work as expected, slowly, but they do work.  It’s the ones that don’t change that appear and disappear randomly. 
  
 There seem to be some other changes in the way that overlays work with many exceptions about needing to ‘Open’ things before adding columns, querying and a whole bunch of other simple functions that did not require opening in the previous release. 
  
 As our application is too slow to use when compiled with RC1 as opposed to the previous beta and we have delivery schedules to meet, we have reverted to version 2. 
  
 We will, when time permits and more information about the changes leaks out, have another go. 
  
 Incidentally, we probably have different ideas about what constitutes a release candidate, the definition we use here is:- 
  
 A release candidate (RC) refers to a version with potential to be a final product, ready to release unless fatal bugs emerge. In this stage of product stabilization (read QA cycle), all product features have been designed, coded and tested through one or more Beta cycles with no known showstopper-class bugs. 
  
 Regards 
  
 John 


John, 
  
   I have a couple of questions for you on your changes. 
  
 1.Did you take your layers out of the StaticOverlay and put them in a new Overlay and place them in the Overlays collection?  We marked the StaticOverlay and DynamicOverlay as obsolete.  I am curious to see if this is related to you missing layers.  What we did was to make this so you cannot use them anymore. This was put in for some temporary backward compatibility but it is better you do not use it and create your own LayersOverlay and place your layers in there.  Create one for your static stuff and another for the dynamic stuff and place them in the Overllays collection. 
  
 2.You mentioned that the source was missing for the RefreshPointsRandomly.  I installed the eval and verified that it is there on all versions (VS 2008).  What version of the samples did you open? VS 2005 or VB 2008 VB or C#?  This seems strange. 
  
 3.The ‘Open’ issue is a bug, we have already caught this.  We will have another update in about 2 hours.  Our samples did not catch this but you are correct.  This will also really slow things down since opening and closing on every draw has lots o overhead.  Fixing this will speed things back up. 
  
 4.Are you still calling RefreshDynamic?  This was deprecated as well and I am not sure if it is going to work correctly.  We went ahead and deprecated this and made it a compile error so people have to change it.  We also added a much better message to tell people how to use the locking stuff.  We are recording a video to walk people through the changes. 
  
  
 David 


I may have missed something, but has any of this pointed us how to use the ReDraw method or under what object it is even under?


Or am I supposed to engage a writelock and then exit it to do so?



Nelson, 
  
  There is no Redraw method.  There used to be however it was marked internal.  The obsolete message never got updated as this change was made just a few days ago.  We have updated the obsolete message now and also fixed some performance bugs and will have a new version posted in about 3-4 hours.  The  replacement to RefreshDynanic is to use the new locking system.  This is like I posted above.  Whenever you modify anything on an overlay you need to call the Overlay.Lock.EnterWriteLock and when you are finished call a Overlay.Lock.ExitWriteLock and then call Refresh.  The locking prevents you changing something while we are drawing on another thread.  It also marks the overlay as dirty so when you refresh we will redraw and dump the temporary cache for that overlay. 
  
   I am recording a video on how this works to try an easy people who already have code in the previous beta.  
  
 David

Sure, thanks David.

Nelson, 
  
   Sorry about this.  As this was changed last minute and the obsolete messages had already passed their review it kinda slipped in.  The good news is that we are hard at work fixing these items and I think we will stabilize soon. 
  
 David

No problem. All new things come with learning curves.  
  
 Thanks again.

Nelson, 
  
  The new edition is out, but you may already know that.  Also the video is out as well.  I think you can find it in the developers blog area and also as a sticky in the Desktop Edition forum. 
  
 David