AnsweredAssumed Answered

Split polygon and modify its attributes

Question asked by HimBromBeere on Aug 20, 2019
Latest reply on Aug 23, 2019 by nchedzey-esristaff

I´ve edited the CutTool-example from GitHub to also modify the created/changed features. 

 

his is my modified code:

var rowCursor = layer.Search(myGeometry, SpatialRelationship.Crosses);
var fc = layer.GetFeatureClass();
var fkzFieldIndex = fc.GetDefinition().FindField("FSK");
if (fkzFieldIndex == -1)
     return Task.FromResult(false);

int index = 0;

// add the feature IDs into our prepared list
while (rowCursor.MoveNext())
{
     var feature = (Feature) rowCursor.Current;
     var geomTest = feature.GetShape();
     if (geomTest != null)
     {
          // make sure we have the same projection for geomProjected and geomTest
          var geomProjected = GeometryEngine.Instance.Project(geometry, geomTest.SpatialReference);
          // we are looking for polygons are completely intersected by the cut line
          if (GeometryEngine.Instance.Relate(geomProjected, geomTest, "TT*F*****"))
          {
               // add the current feature to the overall list of features to cut
               oids.Add(rowCursor.Current.GetObjectID());
               cutOperation.Modify(rowCursor.Current, fkzFieldIndex, "MyNewFKZ");
          }
     }
}

// add the elements to cut into the edit operation
cutOperation.Split(layer, oids, geometry);
//execute the operation
var operationResult = cutOperation.Execute();

return Task.FromResult(operationResult);

So I have a list of oids of features that I want to assign new attributes and that I want to split afterwards. My feature is split, but it does not get the value "MyNewFKZ" assigned to the FKZ-field. Did I miss anything here? I can´t see how may code differs from the example.

 

Just an asside: I also subscribed to the RowCreatedEvent in order to set the FKZ for the newly created feature as well. The handler is appropriately called and the new feature gets the FKZ-field assigned. Uncommenting that handler however has no effect on the modified feature. 

Outcomes