ThinkGeo.com    |     Documentation    |     Premium Support

Most effcient way to Paint multiple features

The saga continues although this is more of a best practices. I have multiple vehicles. Each vehicle is made up of several shapes. I need to position and rotate these vehicles over an image map overtime. So in my paint function I get the overlays get the shapes from the overlays move them then the LAST THING I DO is refresh. But this seems wasteful.  I am repainting the entire screen to handle some moving vehicles. Is there a way to minimize the redraw or is this the best way? This is just part of making this very efficent.


Thanks Bob


 


void Paint()


{  ........ skip some business logic .



 



InMemoryFeatureLayer VehicleOverlay = (InMemoryFeatureLayer)staticOverlay.Layers[index]; int cnt = VehicleOverlay.InternalFeatures.Count;String desiredId;""; false;// loop through the shapes to get the center 

 


// point used for rotation. 

 


{


 


for(int zz = 0; zz < cnt; zz++)BaseShape bs = VehicleOverlay.InternalFeatures[zz].GetShape(); 

 ......


....



bs.Rotate(CenterPoint, rotate );



bs.TranslateByOffset(VP.deltax, -VP.deltay);



VehicleOverlay.EditTools.Update(bs);


}



VehicleOverlay.EditTools.CommitTransaction();


VehicleOverlay.Close();



winformsMap1.Refresh(winformsMap1.Overlays[


 }"VehicleOverlay"]);

 



 


VehicleOverlay.Open();


VehicleOverlay.EditTools.BeginTransaction();


 


desiredId =


used =


 



Yesterday, we published a project in the Code Community that shows a case very similar to yours where there is a vehicle being refreshed every seconds or so in an efficiently way. We refresh the Overlay with the vehicles only, not refreshing the entire map. From looking at your code, you are doing the right way by refreshing only the relevant Overlay. I don’t think there is a more efficient way to do that. 
  I suggest you take a look at the Code Community  project and see how we efficiently refresh the map with a moving vehicle, with rotating icon and changing label. 
  
 code.thinkgeo.com/projects/show/movingvehiclelabel 


Thanks Val. I will take a look

Seems very similar to me. To try and speed things up I went to a single InMemoryFeatureLayer overlay.  
 I was wondering if there wasnt a way that you could invalidate a rectangle based on a group of features (one vehicle) so you could minimize the repaint impact. But maybe that kind of intelligence is already in there? I will do some timing measurements in the next day or so to see what kind of performance I am seeing.  
  


Bob, thanks for your post and questions.


I agree with Val that only refreshing the specified Overlay is a very efficient way when only one overlay was changing, and the sample in the Code Community shows how to achieve this.
 
When you mentioned the solution to invalidate a rectangle, I am not very sure about the relationship with Refreshing only one overlay, while we provide a simple sample for this, if I am misunderstanding anything wrong for this, just feel free to let me know.
HowDoI samples\Moving Around The Map\ Create A Restriction Layer.
 
Any more questions just feel free to let me know.
 
Thanks.
 
Yale