ThinkGeo.com    |     Documentation    |     Premium Support

Adding Features to InMemoryFeatureLayer

 Hello,


  Let say that I am getting two copies of the same feature from a  ShapefileFeatureLayer and I want to add those two features to the same InMemoryFeatureLayer.  I know how to do that with InternalFeatures.Add that allows you to set a different key for each copies of the features. But how do I do the same thing using EditTools which is the prefered way?


As you can see below in my code, I have that working with InternalFeatures.Add but how can I do the same thing with EditTools? Thank you.


 


 



       Dim staticOverlay As LayerOverlay = CType(WinformsMap1.Overlays(0), LayerOverlay)
        Dim Layer1 As ShapeFileFeatureLayer = CType(staticOverlay.Layers("Layer1"), ShapeFileFeatureLayer)

        Dim dynamicOverlay As LayerOverlay = CType(WinformsMap1.Overlays(1), LayerOverlay)
        Dim inMemoryFeatureLayer As InMemoryFeatureLayer = CType(dynamicOverlay.Layers("Highlight"), InMemoryFeatureLayer)

        Layer1.Open()
        Dim feature As Feature = Layer1.QueryTools.GetFeatureById("47", ReturningColumnsType.AllColumns)
        Layer1.Close()

        Dim feature2 As Feature = feature.CloneDeep(ReturningColumnsType.AllColumns)

        Dim guid As String = System.Guid.NewGuid.ToString()
        Dim guid2 As String = System.Guid.NewGuid.ToString()

        inMemoryFeatureLayer.InternalFeatures.Add(guid, feature)
        inMemoryFeatureLayer.InternalFeatures.Add(guid2, feature2)


Adolf,


Here is a solution for your requirements below:



Feature feature = new Feature(50, 50, id);
PointShape shp = feature.GetShape() as PointShape;
shp.Id = NewId;
Feature feature2 = shp.GetFeature();
            
inMemoryLayer.EditTools.Add(feature);
inMemoryLayer.EditTools.Add(feature2);

Please take a try and if any problems please let me know again,


Thanks,


Scott,