/// <summary> /// Convert to edge point from string. /// </summary> /// <param name="culture"></param> /// <param name="value"></param> /// <returns></returns> internal static EdgePoint ConvertFromString(CultureInfo culture, string value) { double d1, d2; value = value.Trim(); if (culture == null) { culture = CultureInfo.InvariantCulture; } if (value.StartsWith("(", false, culture) && value.EndsWith(")", false, culture)) { value = value.Substring(1, value.Length - 2); char[] chArr = new char[] { ':' }; string[] sArr = value.Split(chArr, System.StringSplitOptions.None); if ((sArr.Length < 2) || (sArr.Length > 3) || !Double.TryParse(sArr[0].Trim(), NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowExponent, culture, out d1) || !Double.TryParse(sArr[1].Trim(), NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowExponent, culture, out d2)) { throw new System.InvalidCastException(); } if (sArr.Length == 3) { EdgePointType pointType = (EdgePointType)System.Enum.Parse(typeof(EdgePointType), sArr[2].Trim(), true); return(new EdgePoint(d1, d2, pointType)); } return(new EdgePoint(d1, d2)); } throw new System.InvalidCastException(); }
/// <summary> /// /更改边界点的坐标,使其位于边界上 /// </summary> /// <param name="pt"></param> /// <param name="otherTysonGeoPoint"></param> /// <param name="type"></param> void ChangePtPosToEdge(GeoPoint pt, GeoPoint otherTysonGeoPoint, EdgePointType type) { GeoPoint intersection = null; switch (type) { case EdgePointType.MinX: { intersection = MathUtil.GetIntersection (_lbPt, _ltPt, pt, otherTysonGeoPoint); break; } case EdgePointType.MinY: { intersection = MathUtil.GetIntersection (_lbPt, _rbPt, pt, otherTysonGeoPoint); break; } case EdgePointType.MaxX: { intersection = MathUtil.GetIntersection (_rtPt, _rbPt, pt, otherTysonGeoPoint); break; } case EdgePointType.MaxY: { intersection = MathUtil.GetIntersection (_ltPt, _rtPt, pt, otherTysonGeoPoint); break; } default: break; } if (intersection != null) { pt.X = intersection.X; pt.Y = intersection.Y; } }
/// <summary> /// Constructor. /// </summary> /// <param name="pt">Point.</param> /// <param name="pointType">Point type-</param> public EdgePoint(PointD pt, EdgePointType pointType) { this.point = new PointD(pt.X, pt.Y); this.pointType = pointType; this.Id = Guid.NewGuid(); }
/// <summary> /// Constructor. /// </summary> /// <param name="x">X coordinate.</param> /// <param name="y">Y coordinate.</param> /// <param name="pointType">Point type.</param> public EdgePoint(double x, double y, EdgePointType pointType) : this(new PointD(x, y), pointType) { }
/// <summary> /// Constructor. /// </summary> /// <param name="x">X coordinate.</param> /// <param name="y">Y coordinate.</param> /// <param name="pointType">Point type.</param> public EdgePoint(double x, double y, EdgePointType pointType) : this(new PointD(x,y), pointType) { }