Hi,
I have one problem trying to create points in the middle of all sides of polygons, creating points is not a problem in itself, but the subsequent assignment of the name to which polygon belongs.
Here is an example of where I create points:
private async Task ListFilter(CancelableProgressorSource cps, uint steps, FeatureClass fc, FeatureLayer lyrList, QueryFilter queryFilter, string text, FeatureLayer points, string field)
{
await QueuedTask.Run(() =>
{
FeatureClass listFc = lyrList.GetTable() as FeatureClass;
var polyCursor = fc.Search(queryFilter);
cps.Progressor.Max = (uint)steps;
cps.Progressor.Message = "Probíhá ";
var createOperation = new EditOperation();
createOperation.Name = "Generovani bodu";
createOperation.SelectNewFeatures = false;
while (polyCursor.MoveNext() && !cps.Progressor.CancellationToken.IsCancellationRequested)
{
cps.Progressor.Value += 1;
cps.Progressor.Status = cps.Progressor.Value + @" z " + cps.Progressor.Max + @" hotovo.";
var polyFeature1 = polyCursor.Current as Feature;
var polygonGeometry1 = polyFeature1.GetShape() as Polygon;
TableDefinition tableDefinition = listFc.GetDefinition();
int nameIndex = tableDefinition.FindField(text);
Row row = polyCursor.Current;
string nameNom = row.GetOriginalValue(nameIndex) as String;
var polylineBorder = new PolylineBuilder(polygonGeometry1).ToGeometry();
ReadOnlyPointCollection pts = polylineBorder.Points;
int quarterPts = polylineBorder.PointCount / 4;
int halfPts = polylineBorder.PointCount / 2;
List<MapPoint> pointList = new List<MapPoint>()
{
pts[0], pts[quarterPts], pts[halfPts], pts[quarterPts * 3]
};
foreach (var aMapPoint in pointList)
{
createOperation.Create(points, aMapPoint);
}
createOperation.Execute();
var spatialQueryInter = new SpatialQueryFilter()
{
FilterGeometry = polygonGeometry1,
SpatialRelationship = SpatialRelationship.Touches,
};
var polyCursor2 = points.Search(spatialQueryInter);
while (polyCursor2.MoveNext())
{
Row row1 = polyCursor2.Current;
row1[field] = nameNom.ToString();
row1.Store();// here it throws an error:ArcGIS.Core.Data.GeodatabaseRowException: 'Cannot call Store on a recycled row while editing.'
}
}
}, cps.Progressor);
}So it occurred to me before naming the edit itself, but I don't know how or I don't know if it's a good solution.
I will be happy for any help or advice.
Thank you David