Extract the coordinates of polyline (wpf)

138
2
Jump to solution
06-20-2021 06:24 PM
SungHyunKim
New Contributor

 I would like to extract the coordinates of polyline one by one later.

Is there a way?

here is my Code

foreach (CableGPSInfo gpsinfo in StaticCommon.CableGPSInfoList)
{
string[] gps = gpsinfo.GPS.Split(';');
double[] mappoint = new double[2];
Dictionary<double, double> posdic = new Dictionary<double, double>();
foreach (string point in gps)
{
string[] text = point.Split(',');
//if(gpsinfo.Fiberstart==)
if (text.Length > 1)
{
mappoint[0] = Convert.ToDouble(text[0]);
mappoint[1] = Convert.ToDouble(text[1]);
points.Add(mappoint[1], mappoint[0]);
posdic.Add(mappoint[1], mappoint[0]);
}
}
polyline = new Esri.ArcGISRuntime.Geometry.Polyline(points);
points.Clear();

overlay.Graphics.Add(graphic);
}

What I'm saying is that I want to extract the coordinate value of polyline drawn in overlay graphic.

SungHyunKim_1-1624238299867.png

 

0 Kudos
1 Solution

Accepted Solutions
ZackAllen
Esri Contributor

Hi Sung Hyun Kim. Every polyline has a parts property that contains a collection of read only parts . Each of these parts has a collection of points. You can project these points to Wgs84 to get latitude and longitude values for each point. This code snippet demonstrates getting coordinates from all of the points in the parts of a polyline.

 

 

foreach (ReadOnlyPart part in polyline.Parts)
{
    foreach (MapPoint point in part.Points)
    {
        MapPoint projectedPoint = GeometryEngine.Project(point, SpatialReferences.Wgs84) as MapPoint;
        double longitude = projectedPoint.X;
        double latitude = projectedPoint.Y;

        // Use the longitude / latitude values.
    }
}

 

 

I hope this helps, please let me know if you have any more questions.

Zack

View solution in original post

2 Replies
ZackAllen
Esri Contributor

Hi Sung Hyun Kim. Every polyline has a parts property that contains a collection of read only parts . Each of these parts has a collection of points. You can project these points to Wgs84 to get latitude and longitude values for each point. This code snippet demonstrates getting coordinates from all of the points in the parts of a polyline.

 

 

foreach (ReadOnlyPart part in polyline.Parts)
{
    foreach (MapPoint point in part.Points)
    {
        MapPoint projectedPoint = GeometryEngine.Project(point, SpatialReferences.Wgs84) as MapPoint;
        double longitude = projectedPoint.X;
        double latitude = projectedPoint.Y;

        // Use the longitude / latitude values.
    }
}

 

 

I hope this helps, please let me know if you have any more questions.

Zack

View solution in original post

SungHyunKim
New Contributor

Thank you. That's the information I wanted.

0 Kudos