private static bool OverlapsExistingFeature(Graphic n, GraphicsLayer l) { var area = Geodesic.Area(n.Geometry as Polygon); foreach (var g in l.Graphics) { if (g != n) { if (g.Geometry.Extent.Intersects(n.Geometry.Extent)) { var intersection = GetIntersection(n, g); var intersectionArea = Geodesic.Area(intersection); var target = Geodesic.Area(g.Geometry as Polygon); var coverage = (intersectionArea / target * 100); if (coverage >= 100) return true; } } } return false; } private static Polygon GetIntersection(Graphic n, Graphic g) { var env = n.Geometry.Extent.Intersection(g.Geometry.Extent); var intersection = new Polygon(); PointCollection ring = new PointCollection(); ring.Add(new MapPoint(env.XMin, env.YMin)); ring.Add(new MapPoint(env.XMin, env.YMax)); ring.Add(new MapPoint(env.XMax, env.YMax)); ring.Add(new MapPoint(env.XMax, env.YMin)); ring.Add(new MapPoint(env.XMin, env.YMin)); intersection.Rings.Add(ring); return intersection; }
var l = MyMap.Layers["MyFeatureLayer"] as FeatureLayer; if (l != null) { var graphic = l.Graphics.FirstOrDefault(g => g.Geometry != null && g.Geometry.Equals(someGeometry)); if (graphic != null) l.Graphics.Remove(graphic); //check if this returns true/false. }
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.