ThinkGeo.com    |     Documentation    |     Premium Support

Feature.Id or not Feature.Id

Hi,


I've a strange behaviour with feature.id.


I add a single feature in a shapefilefeaturelayer:


Layer.EditTools.Add(pt, columns);

this returns me a very nice Id like pt.Id = "9ab6b709-fab7-48bb-9883-aa8e23fdf7c1"


Then I'm adding the layer to the map (map.add(Layer)) and query the layer to get the Id


Layer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns)[0].Id


At that time, Id = "1"


Why is the Feature.Id different when I add it and when I get it.


How to get the same Id for the same Feature (regardless if form 1 or form 2) ...


Thank you


Regards,

Patrick. 

 



Patrick, 


Thanks for your post!
 
I really understand why you are confused, but unfortunately it is what we are supposed to work now.
 
The id returned from the Add API is used for the Edit system and these ids will be lost after you call the CommitTransaction API. Before this API, you can use the id to query from the layer like this:
 

worldLayer.FeatureSource.IsTransactionLive = true;
Collection<Feature> features = worldLayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns);
string addedId = features[0].Id;

 

When we add a new feature to the shapefile layer via edit system, we will always put it to the end of the shape file. That is to say, originally, shape file contains n records (n>=0), when you added and call the CommitTranstion , the added feature will go to (n+1) records. The reason for this will much simplify the query system via RTree and more consistent with other features in this ShapeFileFeatureLayer.
 
Any more questions just let me know.
 
Thanks.
 
Yale