ThinkGeo.com    |     Documentation    |     Premium Support

InMemory vs standard FeatureSource/FeatureLayer

Greetings,


I am creating my own custom FeatureSource/Feature layer which has all objects store in memory, and was just curious if there was any differences between extending from a FeatureSource and an InMemoryFeatureSource as far as performance or anything else that is important.  I also have the question about FeatureLayer and InMemoryFeatureLayer.


Thanks!



Ryan, 
  
   The short answer is that if you have all of your object in memory that I would suggest you use the InMemory flavor of our objects.  The reason is that we have tweaked this and also offer some built in spatial index support using the BuildIndex method.  Once you add all of our items in the InMemoryFeatureLayer you can all the BuildIndex method and it builds an R-Tree spatial index in memory.  This really speeds up finding the items to drawn especially when you get lots of items or the items are very complex such a multi-point polygons.  This is if you add the items through the InternalItems property.  If you use the EditTools then the spatial index is built automatically. 
  
   Having said that you can also inherit from FeatureSource and FeatureLayer to create your own specialized class.  This is exactly what we did to create the InMemeoryFeatureLayer and source.  If you go this route you need to be aware that you need to make your own speed enhancements.  For example if you have all of your items backed in memory, and you have lots of them, you will need some sort of spatial index to at least cache the bounding boxes.  You need to consider how to load the items etc.  We have a great video on how to extend the FeatureSource etc online at the address below.  You will be responsible for knowing what you need to override and what to do.  The video does a good job on going over this but there are some advanced things that it may not cover. 
  
   If you are loading data from some other source and want to integrate that in then I suggest you to inherit from the InMemory type classes and create your own that does the front end loading.  Things just really depend on what your goals are, how experience you are at extending classes, and if there is some case we don’t seems to support with the classes we have.  If you give me some more detail I would be happy to give you a more detailed suggestion or even a full solution as a code community project.   
  
 Look at items below: 
  
 Extending Map Suite: Integrating Custom Data Formats - 10/29/2008 
 Extending Map Suite: Exploring Layers - 5/13/2009 
  
 gis.thinkgeo.com/Products/GISComponentsforNETDevelopers/MapSuiteDesktopEdition/Videos/tabid/679/Default.aspx 
  
 David