ArcGIS API for Silverlight uses Geometryservice to solve the intersection of lines and lines

Source: Internet
Author: User
Tags polyline silverlight

Draw Line

void Btn_mouseleftbuttondown (object sender, MouseButtonEventArgs e)
{

Button BTN = sender as Button;
var geometry = btn. Tag as ESRI. ArcGIS.Client.Geometry.Polyline;
Collection of storage line features
List<esri. arcgis.client.geometry.polyline> Polylinelistgrid = new List<esri. Arcgis.client.geometry.polyline> ();
List<esri. arcgis.client.geometry.polyline> polylinelistriver = new List<esri. Arcgis.client.geometry.polyline> ();
Polylinelistgrid.add (geometry as ESRI. ArcGIS.Client.Geometry.Polyline);
Geometryservice.trimextendasync (Polylinelistgrid, centergraphic.geometry as ESRI. ArcGIS.Client.Geometry.Polyline, curveextension.defaultcurveextension);
geometryservice.trimextendcompleted + = geometryservice_trimextendcompleted;
}

Perform analysis

void Geometryservice_trimextendcompleted (object sender, Graphicseventargs e)
{
MapPoint point = null;
foreach (Graphic g in E.results)
{
if (g.geometry.extent! = null)
{
Glayer. Graphics.clear ();
Layer. Graphics.clear ();
var pline = G.geometry as ESRI. ArcGIS.Client.Geometry.Polyline;
Graphic GG = new Graphic ()
//{
Geometry = Pline,
Symbol = new Loadmapresource (). Getsymbolbykey ("Drawobjectlinesymbol") as Linesymbol
//};
Glayer. Graphics.add (GG);
var gline = Centergraphic.geometry as ESRI. ArcGIS.Client.Geometry.Polyline;
var len1 = getmindistance (gline. Paths[0][0], Gline. Paths[0][gline. Paths[0]. Count-1], Pline. Paths[0][0]);
var len2 = getmindistance (gline. Paths[0][0], Gline. Paths[0][gline. Paths[0]. Count-1], Pline. Paths[0][pline. Paths[0]. Count-1]);
if (Len1 > Len2)
{
Point = Createmappoint (pline. Paths[0][pline. Paths[0]. COUNT-1]. X, Pline. Paths[0][pline. Paths[0]. COUNT-1]. Y);
}
Else
{
Point = Createmappoint (pline. Paths[0][0]. X, Pline. Paths[0][0]. Y);
}
Addpointgraphic (point);
}
}
}

Constructs a point from X, y
Public MapPoint Createmappoint (double x, double y)
{
return new MapPoint (x, y);
}
Add a point to the layer
public void Addpointgraphic (ESRI. ArcGIS.Client.Geometry.MapPoint point)
{
Graphic g = new Graphic ()
{
Geometry = Point,
Symbol = new Loadmapresource (). Getsymbolbykey ("Drawobjectpointsymbol") as Markersymbol,
};
Glayer. Graphics.add (g);

}

ArcGIS API for Silverlight uses Geometryservice to solve the intersection of lines and lines

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.