Esempio n. 1
0
 public CircularArcGeometry(ICircleGeometry circle, IPosition bc, IPosition ec, bool isClockwise)
 {
     m_Circle      = circle;
     m_BC          = PositionGeometry.Create(bc);
     m_EC          = PositionGeometry.Create(ec);
     m_IsClockwise = isClockwise;
 }
Esempio n. 2
0
        /// <summary>
        /// Generates an approximation of a circular arc.
        /// </summary>
        /// <param name="tol">The maximum chord-to-circumference distance.</param>
        /// <returns></returns>
        public static IPointGeometry[] GetApproximation(ICircularArcGeometry g, ILength tol)
        {
            // Get info about the circle the curve lies on.
            IPosition center = g.Circle.Center;
            double    radius = g.Circle.Radius;

            // Determine the change in bearing which will satisfy the specified tolerance
            // (if no tolerance has been specified, arbitrarily use a tolerance of 1mm on the ground).
            double tolm  = (tol.Meters > Double.Epsilon ? tol.Meters : 0.001);
            double dbear = Math.Acos((radius - tolm) / radius);

            IPointGeometry start = g.BC;
            IPointGeometry end   = g.EC;
            bool           iscw  = g.IsClockwise;

            // Get the total angle subtended by the curve.
            Turn   reft   = new Turn(center, start);
            double totang = reft.GetAngleInRadians(end); // clockwise

            if (!iscw)
            {
                totang = MathConstants.PIMUL2 - totang;
            }

            // Figure out how many positions we'll generate
            int nv = (int)(totang / dbear); // truncate

            Debug.Assert(nv >= 0);

            // Handle special case of very short arc.
            if (nv == 0)
            {
                return new IPointGeometry[] { start, end }
            }
            ;

            // Sign the delta-bearing the right way.
            if (!iscw)
            {
                dbear = -dbear;
            }

            // Get the initial bearing to the first position along the curve.
            double curbear = reft.BearingInRadians + dbear;

            // Append positions along the length of the curve.
            List <IPointGeometry> result = new List <IPointGeometry>(nv);

            result.Add(start);

            for (int i = 0; i < nv; i++, curbear += dbear)
            {
                IPosition p = BasicGeom.Polar(center, curbear, radius);
                result.Add(PositionGeometry.Create(p));
            }

            result.Add(end);
            return(result.ToArray());
        }
Esempio n. 3
0
        /// <summary>
        /// Creates new <c>LineStringGeometry</c> that corresponds to the supplied positions (rounded
        /// off to the nearest micron).
        /// </summary>
        /// <param name="data">The positions defining the line.</param>
        public LineStringGeometry(IPosition[] data)
        {
            if (data == null || data.Length < 2)
            {
                throw new ArgumentException();
            }

            m_Data = new IPointGeometry[data.Length];
            for (int i = 0; i < data.Length; i++)
            {
                m_Data[i] = PositionGeometry.Create(data[i]);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Creates new <c>SegmentGeometry</c> that corresponds to the supplied positions.
 /// </summary>
 /// <param name="start">The position of the start of the line.</param>
 /// <param name="end">The position of the end of the line.</param>
 public LineSegmentGeometry(IPosition start, IPosition end)
 {
     m_Start = PositionGeometry.Create(start);
     m_End   = PositionGeometry.Create(end);
 }