ThinkGeo.com    |     Documentation    |     Premium Support

FeatureSource.AddFeature(new Feature(x, y, id)); make wrong ID

 feat = new Feature(x, y, id, new string[] { "TITLE:" + new_title, "LOCATION:Test"


 }); 


 



 


TransactionResult tr = shapeFileLayer.FeatureSource.CommitTransaction();


 shapeFileLayer.FeatureSource.Close();


shapeFileLayer.Close();


And my ID is "3333"  for example!


But realy it make entity wiyh ID near 208(the nearest free ID in my point shape file.)


 what to do? 


 



 string id2 = shapeFileLayer.FeatureSource.AddFeature(feat); 


 



TransactionResult tr = shapeFileLayer.FeatureSource.CommitTransaction(); 

CurrentID = shapeFileLayer.FeatureSource.GetCount(); 



Thet return the real id, but thet seems me wrong)


How can i get id of the feature I Adding?



And some new question 



string test2 = shapeFileLayer.QueryTools.ExecuteQuery("Select max(cast(CODEOBJ as int)) From O71TRE_P").Rows[0].ItemArray[0] as string; 



cast does not work. What is you analog of cast in your interpritation of SQL? 



Without cast all works but return "99" not 285 

so I need cast or convert. What is your analog? 



 



Artem, 
  
 At least from some aspects, shapefile feature source is special. It does not require a column for feature’s id, however it uses its index. In other word, you cannot set a shape file feature’s id to “abc” or a random number, the 30th feature must have the id of 30, that cannot be changed. 
  
 As a result, in our system, after a new feature is added and commented to the shape file feature source, its original feature id will be updated  to match the shape file specification. Like in your example, the original id “3333” will be updated to “208” as it’s the one it should be.  The original id (“3333” in your case) only works before the commenting, as that time we have no idea what the right ID should be and setting an Id can help us access the feature from the transaction buffer. 
  
 I didn’t have time for your 3rd post today, I’ll have a look at that tomorrow. 
  
 Thanks, 
  
 Ben

May be you have some method thet can return the real id of the feature thet i am inserting(insert). 



Thenks for you help.


 


PS: If you know answer for thet, then the answer for 3-rd question is not needed.



And 
 shapeFileLayer.FeatureSource.GetCount() 
 Do not work when delit records(beacose they unpacked and stored as deleted records) 
  
 BUT! 
 After packing with help of speshial tools its return wrong(old) cout! 
 Are you pushing count in your index files? 
 Or some cache?

And 
 featureSource.GetDataFromDbf("23","KINDTREE") return 27  
 featureSource.GetFeaturesByColumnValue("KINDTREE", "27") throw "Your input index is out of bound" 
  
 the KINDTREE is numeric. 
 What can it be.

Thet happend often after deleting some record from dbf file("not safe" or "lite" deleting, but real deleting) 



ps: safe deleting it is when file not realy deleting from dbf but just marks as deleted. 



Your deleting is "not real" it is "safe" 



shapeFileLayer.FeatureSource.DeleteFeature(id); -not delete record just marks it as deleted. 



but if realy delete them, then northing work in your funcshionality of shapeFile 



Is it true? And what type of Layer to use if i need working of all thet?




How can i get id of the feature I Adding?







 


I just need a method to get the real id of feature i am inserting, it will resolve practicaly all my problems.



Artem, 
  
 There is a property FeatureSource.IsTransactionLive, if we set it to true, the GetCount() method should work fine even before you comment transaction. I also met the problem that GetFeaturesByColumnValue throws an exception, I think there is an issue and we will have a look at that.  
  
 There is no API which returns the “real” id during the transaction, but you can  get it yourself with the help of method GetCount(). You might think of adding an “id” column to store the id, that’s not so great for shape file as GetFeaturesByColumnValue has lower performance than getting record by index, so get the index ourselves is not a bad idea.  
  
 BTW: To improve the performance, the changes you applied to the shape file is not stored in a “standard” way, we can handle that “unstandard” shape file well but if you want, you can call the static method ShapeFileFeatureSource.Rebuild(string shapePathFileName) to convert it to a “standard” format. 
  
 Hope that solves your problem. 
  
 Thanks, 
  
 Ben

Artem, 
  
 For your 3nd question, can you try "select max(CLng([CODEOBJ])) from O71TRE_P"? 
  
 Thanks, 
  
 Ben