AnsweredAssumed Answered

Sequence contains no elements

Question asked by kireandreev on Nov 28, 2018
Latest reply on Nov 30, 2018 by JNery-esristaff

I developed custom arc with center, start and end point (code of arc) is:

 

Esri.ArcGISRuntime.Geometry.PointCollection pcol = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.WebMercator);
SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.FromRgb(0x00, 0x00, 0x00), 1);
SimpleMarkerSymbol redCircleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.FromRgb(0xFF, 0x00, 0x00), 5);
if (points_Line.Count ==2)
{
//Create point collections
MapPoint point=new MapPoint(x, y,z, SpatialReferences.WebMercator);
double p1x = points_Line[1].X - points_Line[0].X;
double p1y = points_Line[1].Y - points_Line[0].Y;
double p2x = point.X - points_Line[0].X;
double p2y = point.Y - points_Line[0].Y;
double slice = 2 * Math.PI / 360;
CalculateAngle calculateAngle1 = new CalculateAngle(p1x, p1y);
CalculateAngle calculateAngle2 = new CalculateAngle(p2x, p2y);
double angle1 = calculateAngle1.Azimute();
double angle2 = calculateAngle2.Azimute();
double startAngle, endAngle, viewAngle;
Polyline polyline = new Polyline(points_Line);
double radius = Math.Round(GeometryEngine.LengthGeodetic(polyline, LinearUnits.Meters, GeodeticCurveType.Geodesic), 2);
Graphic graphicRad = new Graphic(polyline, lineSymbol);
_overlay_PolylineRevers.Graphics.Add(graphicRad);

if (angle1 >= angle2)
{
startAngle = angle2;
endAngle = angle1;
viewAngle = angle2;
for (double i = endAngle; i >= startAngle; i--)
{
double rad = slice * i;
double px = points_Line[0].X + radius * Math.Sin(rad);
double py = points_Line[0].Y + radius * Math.Cos(rad);
pcol.Add(new MapPoint(px, py, SpatialReferences.WebMercator));
}
}
else
{
startAngle = angle1;
endAngle = angle2;
viewAngle = angle2;
for (double i = startAngle; i <= endAngle; i++)
{
double rad = slice * i;
double px = points_Line[0].X + radius * Math.Sin(rad);
double py = points_Line[0].Y + radius * Math.Cos(rad);
pcol.Add(new MapPoint(px, py, SpatialReferences.WebMercator));
}
}

Polyline p = new Polyline(pcol);
// Create the graphic with polyline and symbol
Graphic graphicPoly = new Graphic(p, lineSymbol);

//Add atribute
string id = GlobalVar.CountGraphic.ToString();
graphicPoly.Attributes.Add("UID", id);
graphicPoly.Attributes.Add("Label", " ");
graphicPoly.Attributes.Add("Type", "arc");
_overlay_Polyline.Graphics.Add(graphicPoly);

 

When intersect this arc with rectangle (code of rectangle) is:

 

var rectangle = await MyMapView.SketchEditor.StartAsync(SketchCreationMode.Rectangle, false);

 

appear next message:

 

 

How to solved this problem?

Outcomes