Guest User

Untitled

a guest
Jan 22nd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. ISet features = feature.Split(splitLine);
  2.  
  3. //let's say the original feature had surrogate id 1,
  4. //so both split features have surrogate id 1 at the moment
  5.  
  6. //let the next available surrogate id be 6
  7. IFeature splitFeature = (IFeature)(features.Next());
  8. splitFeature.set_Value(surrogateIdOrdinal, 6);
  9. splitFeature.Store();
  10. splitFeature = (IFeature)(features.Next());
  11. splitFeature.set_Value(surrogateIdOrdinal, 7);
  12. splitFeature.Store();
  13.  
  14. IQueryFilter filter = new QueryFilterClass();
  15. filter.WhereClause = surrogateIdField + " = " + surrogateId;
  16. return fClass.FeatureCount(filter) > 0;
  17.  
  18. IDataChangesEx changes = workspace.get_EditDataChanges(esriEditDataChangesType.esriEditDataChangesWithinSession);
  19. IDifferenceCursorEx = changes.ExtractEx("fclass", esriDifferenceType.esriDifferenceTypeInsert);
  20. IRow sourceRow, differenceRow;
  21. ILongArray differenceIndices;
  22. int oid;
  23. differenceCursor.Next(out oid, out sourceRow, our differenceRow, out differenceIndices);
  24. //sourceRow has OID 100 and surrogate id 6
  25.  
  26. public bool existsBySubsId(int subsId, out bool foundInAllRows)
  27. {
  28. foundInAllRows = false;
  29. IFeatureClass fClass = featureWorkspace.OpenFeatureClass("fclass");
  30. int subsIdOrd = fClass.FindField("SUBSID");
  31. IFeatureCursor cursor = fClass.Search(null, true);
  32. IFeature feat;
  33. while ((feat = cursor.NextFeature()) != null)
  34. {
  35. int foundSubsId = (int)feat.get_Value(subsIdOrd);
  36. if(foundSubsId == subsId)
  37. {
  38. foundInAllRows = true;
  39. break;
  40. }
  41. }
  42.  
  43. IQueryFilter filter = new QueryFilterClass();
  44. queryFilter.WhereClause = "SUBSID = " + subsId;
  45. return fClass.FeatureCount(filter) > 0;
  46. }
  47.  
  48. //feature has SUBSID = 5
  49. public ISet SplitFeature(IFeature feature, IPolyLine splitLine)
  50. {
  51. ISet splitFeatures;
  52. bool subsIdExists, subsIdFoundInAllRows;
  53. subsIdExists = existsBySubsId(5, out subsIdFoundInAllRows);
  54. //both subsIdExists and subsIdFoundInAllRows are true
  55. splitFeatures = feature.Split(splitLine);
  56. subsIdExists = existsBySubsId(5, out subsIdFoundInAllRows);
  57. //subsIdExists is false, subsIdFoundInAllRows is true
  58. return splitFeatures;
  59. }
  60.  
  61. IQueryFilter filter = new QueryFilterClass();
  62. filter.WhereClause = "SUBSID = 1";
  63. IFeatureCursor cursor = featureClass.Search(filter, true);
  64. IFeature feat = cursor.NextFeature();
  65. //feat is not null even though there are no features with SUBSID == 1
  66. int subsId = (int)feat.get_Value(feat.Fields.FindField("SUBSID"));
  67. //subsId is 2
Add Comment
Please, Sign In to add comment