Represents the polyline geometry.
Inheritance: Geometry
示例#1
0
        internal static void LoadWkt(this Polyline polyline, string wkt)
        {
            var json = wkt.ToJson("MULTILINESTRING");

            polyline.paths = json == null ? new double[][][] { } : json.Deserialize <double[][][]>();
        }
示例#2
0
        /// <summary>
        /// Creates a new polyline from well-known text (WKT).
        /// </summary>
        /// <param name="wkt"></param>
        /// <returns></returns>
        public static Polyline FromWkt(string wkt)
        {
            if (wkt == null)
                return null;

            var polyline = new Polyline();
            polyline.LoadWkt(wkt);
            return polyline;
        }
示例#3
0
 /// <summary>
 /// Determines if the polygon intersects the polyline.
 /// </summary>
 /// <param name="polygon"></param>
 /// <param name="polyline"></param>
 /// <returns></returns>
 public static bool Intersects(this Polygon polygon, Polyline polyline)
 {
     return new Polyline { paths = polygon.rings }.Intersects(polyline);
 }
示例#4
0
        /// <summary>
        /// Determines if the multipoint is within the specified distance from the polyline.
        /// </summary>
        /// <param name="multipoint"></param>
        /// <param name="polyline"></param>
        /// <param name="distance"></param>
        /// <returns></returns>
        public static bool WithinDistance(this Multipoint multipoint, Polyline polyline, double distance)
        {
            if (Null(multipoint, polyline))
                return false;

            return multipoint.Extent().Buffer(distance).Intersects(polyline.Extent()) && multipoint.Distance(polyline) < distance;
        }
示例#5
0
        /// <summary>
        /// Returns intersection points between the two polylines.
        /// </summary>
        /// <param name="polyline1"></param>
        /// <param name="polyline2"></param>
        /// <returns></returns>
        public static Point[] Intersect(this Polyline polyline1, Polyline polyline2)
        {
            if (Null(polyline1, polyline2))
                return new Point[] { };

            return !polyline1.Extent().Intersects(polyline2.Extent())
                ? new Point[] { }
                : Intersect(polyline1.paths, polyline2.paths);
        }
示例#6
0
 /// <summary>
 /// Determines if the polyline intersects the other polyline.
 /// </summary>
 /// <param name="polyline1"></param>
 /// <param name="polyline2"></param>
 /// <returns></returns>
 public static bool Intersects(this Polyline polyline1, Polyline polyline2)
 {
     return polyline1.Intersect(polyline2).Any();
 }
示例#7
0
        /// <summary>
        /// Calculates the distance to the other polyline.
        /// </summary>
        /// <param name="polyline1"></param>
        /// <param name="polyline2"></param>
        /// <returns></returns>
        public static double Distance(this Polyline polyline1, Polyline polyline2)
        {
            AssertNotNull(polyline1, polyline2);

            if (polyline1.Equals(polyline2))
                return 0;

            if (polyline1.Intersects(polyline2))
                return 0;

            return Math.Min(polyline1.paths.Distance(polyline2.paths), polyline2.paths.Distance(polyline1.paths));
        }
示例#8
0
        /// <summary>
        /// Calculates the shortest distance to the polyline.
        /// </summary>
        /// <param name="polygon"></param>
        /// <param name="polyline"></param>
        /// <returns></returns>
        public static double Distance(this Polygon polygon, Polyline polyline)
        {
            AssertNotNull(polygon, polyline);

            return polyline.Distance(polygon);
        }
示例#9
0
        /// <summary>
        /// Calculates the shortest distance to the polyline.
        /// </summary>
        /// <param name="multipoint"></param>
        /// <param name="polyline"></param>
        /// <returns></returns>
        public static double Distance(this Multipoint multipoint, Polyline polyline)
        {
            AssertNotNull(multipoint, polyline);

            return multipoint.points.Min(p => new Point(p[0], p[1]).Distance(polyline));
        }
示例#10
0
        /// <summary>
        /// Calculates the shortest distance to the polyline.
        /// </summary>
        /// <param name="point"></param>
        /// <param name="polyline"></param>
        /// <returns></returns>
        public static double Distance(this Point point, Polyline polyline)
        {
            AssertNotNull(point, polyline);

            return point.Distance(polyline.paths);
        }
示例#11
0
        /// <summary>
        /// Determines if the polygon is within the specified distance from the polyline.
        /// </summary>
        /// <param name="polygon"></param>
        /// <param name="polyline"></param>
        /// <param name="distance"></param>
        /// <returns></returns>
        public static bool WithinDistance(this Polygon polygon, Polyline polyline, double distance)
        {
            if (Null(polygon, polyline))
                return false;

            return polyline.Distance(polygon) < distance;
        }
示例#12
0
        /// <summary>
        /// Determines if the polygon completely contains the polyline.
        /// </summary>
        /// <param name="polygon"></param>
        /// <param name="polyline"></param>
        /// <returns></returns>
        public static bool Contains(this Polygon polygon, Polyline polyline)
        {
            if (Null(polygon, polyline))
                return false;

            return !polygon.Intersects(polyline) && polyline.paths.All(polygon.Contains);
        }
示例#13
0
        /// <summary>
        /// Determines if the polyline is within the specified distance from the other polyline.
        /// </summary>
        /// <param name="polyline1"></param>
        /// <param name="polyline2"></param>
        /// <param name="distance"></param>
        /// <returns></returns>
        public static bool WithinDistance(this Polyline polyline1, Polyline polyline2, double distance)
        {
            if (Null(polyline1, polyline2))
                return false;

            return polyline1.Extent().Buffer(distance).Intersects(polyline2.Extent()) && polyline1.Distance(polyline2) < distance;
        }