AnsweredAssumed Answered

Move Arc graphic

Question asked by kireandreev on Feb 13, 2019

Hello,

 

I have Arc graphic and i like to move.I am using next code:

 

Esri.ArcGISRuntime.Geometry.PointCollection points_Move_Arc = new Esri.ArcGISRuntime.Geometry.PointCollection(new SpatialReference(WKID));
Esri.ArcGISRuntime.Geometry.PointCollection points_End_Arc = new Esri.ArcGISRuntime.Geometry.PointCollection(new SpatialReference(WKID));

Polyline coords = GlobalVar.Overlay_Graphic.Graphics[g].Geometry as Polyline;
var countCoord = coords.Parts.First().Points;
for (int i = 0; i < countCoord.Count; i++)
{
points_Move_Arc.Add(new MapPoint(Convert.ToDouble(coords.Parts.First().StartPoint.X), Convert.ToDouble(coords.Parts.First().StartPoint.Y), Convert.ToDouble(coords.Parts.First().StartPoint.Z), new SpatialReference(WKID)));
var second_Start = GeometryEngine.MoveGeodetic(points_Move_Arc, distance, LinearUnits.Meters, angle, AngularUnits.Degrees, GeodeticCurveType.Geodesic).First();
points_End_Arc.Add(new MapPoint(second_Start.X, second_Start.Y, second_Start.Z, new SpatialReference(WKID)));
points_Move_Arc.Clear();
points_Move_Arc.Add(new MapPoint(Convert.ToDouble(coords.Parts.First().EndPoint.X), Convert.ToDouble(coords.Parts.First().EndPoint.Y), Convert.ToDouble(coords.Parts.First().EndPoint.Z), new SpatialReference(WKID)));
var second_End = GeometryEngine.MoveGeodetic(points_Move_Arc, distance, LinearUnits.Meters, angle, AngularUnits.Degrees, GeodeticCurveType.Geodesic).First();
points_End_Arc.Add(new MapPoint(second_End.X, second_End.Y, second_End.Z, new SpatialReference(WKID)));
points_Move_Arc.Clear();
}
Arc arc = new Arc(GlobalVar.Overlay_Graphic, points_End_Arc, ClickPoint, myItemList);
arc.CreateArcMove();

 

Code for create Arc graphic is:

 

Esri.ArcGISRuntime.Geometry.PointCollection pcol = new Esri.ArcGISRuntime.Geometry.PointCollection(new SpatialReference(WKID));

if (points_Line.Count ==2)
{
//Create point collections
MapPoint point=new MapPoint(x, y,z, new SpatialReference(WKID));
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;

//double radius = Math.Sqrt((p1x * p1x) + (p1y * p1y));
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, new SpatialReference(WKID)));
}
}
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, new SpatialReference(WKID)));
}
}
//Put first point on arc
////Graphic _pointStart = new Graphic(new MapPoint(pcol[0].X, pcol[0].Y, new SpatialReference(WKID)), redCircleSymbol);
////_overlay_Polyline.Graphics.Add(_pointStart);
//////Put second point on arc
////Graphic _pointEnd = new Graphic(new MapPoint(pcol[pcol.Count - 1].X, pcol[pcol.Count - 1].Y, new SpatialReference(WKID)), redCircleSymbol);
////_overlay_Polyline.Graphics.Add(_pointEnd);
Polyline p = new Polyline(pcol);
// Create the graphic with polyline and symbol
Graphic graphicPoly = new Graphic(p, lineSymbol);
// Add graphic to the graphics overlay
//_overlay_Graphic.Graphics.Add(graphicPoly);
Random r = new Random();
// string id = "Arc." + r.Next(1, 100);
//Add atribute
string id = GlobalVar.CountGraphic.ToString();
graphicPoly.Attributes.Add("UID", id);
graphicPoly.Attributes.Add("Label", " ");
graphicPoly.Attributes.Add("Type", "arc");
graphicPoly.Attributes.Add("Xcenter", GlobalVar.Points_Arc[0].X.ToString());
graphicPoly.Attributes.Add("Ycenter", GlobalVar.Points_Arc[0].Y.ToString());
_overlay_Polyline.Graphics.Add(graphicPoly);
if (GlobalVar.CountA3P == 0)
{
//Add layer
// Legend constLeg = new Legend(myItemList, Form.lstItem, _overlay_Polyline, "Construction", true, 0);
Legend constLeg = new Legend(myItemList, Form.lstItem, _overlay_Polyline, GlobalVar.Overlay_Graphic_Label, "Construction", "ConstructionGraphic", "ConstructionLabel", true, 0);

constLeg.CreatConstruction();
}
}

 

Before move Arc graph look like:

 

  

 

After move look like:

 

 

How to solved this problem?

 

Best Regard

Outcomes