Exemplo n.º 1
0
        public static IEnumerable <IEnumerable <IPoint> > GetCoordinates(this IGeometry geometry)
        {
            List <IPoint[]> points = new List <IPoint[]>();

            if (geometry is IPolygon)
            {
                IPolygon polygon = (IPolygon)geometry;
                points.AddRange(polygon.Rings.Select(a => a.Select(b => b).Cast <IPoint>().ToArray()));
            }
            else if (geometry is IPoint)
            {
                IPoint point = (IPoint)geometry;
                points.Add(new IPoint[] { point });
            }
            else if (geometry is IMultiPoint)
            {
                IMultiPoint multipoint = (IMultiPoint)geometry;
                points.AddRange(multipoint.Points.Select(a => new IPoint[] { a }));
            }
            else if (geometry is IMultiLine)
            {
                IMultiLine polyline = (IMultiLine)geometry;
                points.AddRange(polyline.Paths.Select(a => a.Select(b => b).Cast <IPoint>().ToArray()));
            }
            else if (geometry is LineString)
            {
                LineString line = (LineString)geometry;
                points.Add(line.Coordinates.ToArray());
            }
            else
            {
                throw new NotSupportedException();
            }
            return(points.AsEnumerable());
        }
Exemplo n.º 2
0
        public static bool ExecuteBoolean(IMultiLine line1, IMultiLine line2)
        {
            IEnumerable <IPoint> intersections = LineIntersect.Execute(line1, line2);

            if (intersections != null && intersections.Count() > 0)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        public static IEnumerable <IPoint> Execute(IMultiLine line1, IMultiLine line2)
        {
            IEnumerable <IPoint> intersections = LineIntersect.Execute(line1, line2);

            if (intersections != null && intersections.Count() > 0)
            {
                return(intersections);
            }
            return(null);
        }
Exemplo n.º 4
0
 public static bool ExecuteBoolean(IMultiLine lines, IPolygon poly)
 {
     foreach (IEnumerable <IPoint> line in lines.GetCoordinates())
     {
         if (ExecuteBoolean(line, poly))
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 5
0
 public static IEnumerable <IPoint> Execute(IMultiLine lines, IPolygon poly)
 {
     foreach (IEnumerable <IPoint> line in lines.GetCoordinates())
     {
         IEnumerable <IPoint> sharedPoints = Execute(line, poly);
         if (sharedPoints != null)
         {
             foreach (IPoint point in sharedPoints)
             {
                 yield return(point);
             }
         }
     }
 }