Beispiel #1
0
        //      Procedure Reverse; Overload; Override;
        //      procedure Reverse(const StartIdx, EndIdx : Integer); Overload; Override;

        // LocateEntityAtStation takes a station value and locates the element
        // within which the station value lies.
        public void LocateEntityAtStation(double Stn, out NFFStationedLineworkEntity Element)
        {
            Element = null;

            for (int I = 0; I < Entities.Count; I++)
            {
                double Eps1;
                if (I == 0)
                {
                    Eps1 = 1E-4;
                }
                else if (Entities[I - 1].EndStation < Entities[I].StartStation)
                {
                    Eps1 = 1E-4;
                }
                else
                {
                    Eps1 = 0;
                }

                double Eps2;
                if (I == Entities.Count - 1)
                {
                    Eps2 = 1E-4;
                }
                else if (Entities[I + 1].StartStation > Entities[I].EndStation)
                {
                    Eps2 = 1E-4;
                }
                else
                {
                    Eps2 = 0;
                }

                if (Range.InRange(Stn, Entities[I].StartStation - Eps1, Entities[I].EndStation + Eps2))
                {
                    Element = Entities[I];
                }
            }
        }
Beispiel #2
0
        public void ComputeStnOfs(double X, double Y, out double Stn, out double Ofs, ref NFFStationedLineworkEntity Element)
        {
            double TestStn, TestOfs;

            Stn = Consts.NullDouble;
            Ofs = Consts.NullDouble;

            // Check the given element to see if it matches. If so then return the answer
            if (Element != null)
            {
                Element.ComputeStnOfs(X, Y, out TestStn, out TestOfs);

                if (TestStn != Consts.NullDouble && TestOfs != Consts.NullDouble)
                {
                    Ofs = TestOfs;
                    Stn = TestStn;
                    return;
                }
            }

            Element = null;
            for (int I = 0; I < Entities.Count; I++)
            {
                Entities[I].ComputeStnOfs(X, Y, out TestStn, out TestOfs);

                if (TestStn != Consts.NullDouble && TestOfs != Consts.NullDouble &&
                    (Ofs == Consts.NullDouble || Math.Abs(TestOfs) < Math.Abs(Ofs)))
                {
                    Ofs     = TestOfs;
                    Stn     = TestStn;
                    Element = Entities[I];
                }
            }
        }
Beispiel #3
0
        // ComputeStnOfs takes a plan position and finds the closest element in the
        // alignment for which the plan position converts to a valid station and offset
        // coordinate. The station and offset value for that station with respect to
        // that element is then returned to the caller.
        public override void ComputeStnOfs(double X, double Y, out double Stn, out double Ofs)
        {
            NFFStationedLineworkEntity element = null;

            ComputeStnOfs(X, Y, out Stn, out Ofs, ref element);
        }