Ejemplo n.º 1
0
        private Dictionary <string, object> TestCorridorInfo_Old(string code)
        {
            IList <string[]>             corridorCodes        = new List <string[]>();
            IList <IList <Featureline> > corridorFeaturelines = new List <IList <Featureline> >();

            foreach (Baseline bl in this.Baselines)
            {
                IList <Featureline> blFeaturelines = new List <Featureline>();

                var b = bl._baseline;

                foreach (AeccFeatureLines coll in b.MainBaselineFeatureLines.FeatureLinesCol)
                {
                    foreach (AeccFeatureLine f in coll)
                    {
                        if (f.CodeName == code)
                        {
                            IList <Point> featureline = new List <Point>();

                            foreach (AeccFeatureLinePoint p in f.FeatureLinePoints)
                            {
                                Point point = Point.ByCoordinates(p.XYZ[0], p.XYZ[1], p.XYZ[2]);

                                featureline.Add(point);
                            }

                            featureline = Point.PruneDuplicates(featureline);

                            PolyCurve pc = PolyCurve.ByPoints(featureline);

                            var offset = bl.GetArrayStationOffsetElevationByPoint(pc.PointAtParameter(0.5))[1];

                            Featureline.SideType side = Featureline.SideType.Right;

                            if (offset < 0)
                            {
                                side = Featureline.SideType.Left;
                            }

                            blFeaturelines.Add(new Featureline(bl, pc, f.CodeName, side));
                        }
                    }
                }

                corridorFeaturelines.Add(blFeaturelines);
            }

            return(new Dictionary <string, object>()
            {
                { "Featurelines", corridorFeaturelines }
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the featurelines by code
        /// </summary>
        /// <param name="code">the Featurelines code.</param>
        /// <returns></returns>
        private IList <IList <Featureline> > GetFeaturelinesByCode_(string code)  // 1.1.0
        {
            Utils.Log(string.Format("Baseline.GetFeaturelinesByCode({0}) Started...", code));

            IList <IList <Featureline> > blFeaturelines = new List <IList <Featureline> >();

            var b = this._baseline;

            // 20190121 -- Start

            AeccFeatureLines fs = null;

            try
            {
                fs = b.MainBaselineFeatureLines.FeatureLinesCol.Item(code);
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR: {0}", ex.Message));
            }

            Dictionary <int, Dictionary <double, Point> > cFLs = new Dictionary <int, Dictionary <double, Point> >();

            int i = 0;

            if (fs != null)
            {
                Utils.Log(string.Format("Featurelines in region: {0}", fs.Count));

                foreach (var fl in fs.Cast <AeccFeatureLine>())
                {
                    Dictionary <double, Point> points = new Dictionary <double, Point>();

                    foreach (var pt in fl.FeatureLinePoints.Cast <AeccFeatureLinePoint>())
                    {
                        var p = pt.XYZ;

                        try
                        {
                            points.Add(Math.Round(pt.Station, 5), Point.ByCoordinates(p[0], p[1], p[2]));
                        }
                        catch (Exception ex)
                        {
                            Utils.Log(string.Format("ERROR: {0}", ex.Message));
                        }
                    }

                    cFLs.Add(i, points);

                    ++i;
                }
            }


            if (cFLs.Count > 0)
            {
                int regionIndex = 0;

                foreach (AeccBaselineRegion region in b.BaselineRegions)
                {
                    Utils.Log(string.Format("Processing region {0}...", regionIndex));

                    IList <Featureline> regFeaturelines = new List <Featureline>();

                    foreach (var k in cFLs.Keys)
                    {
                        IList <Point> points = new List <Point>();

                        var pts = cFLs[k];

                        if (pts.Keys.Count == 0)
                        {
                            continue;
                        }

                        foreach (double s in region.GetSortedStations())
                        {
                            var st = Math.Round(s, 5);

                            Point p = null;

                            if (pts.TryGetValue(st, out p))
                            {
                                points.Add(p);
                            }
                        }

                        points = Point.PruneDuplicates(points);

                        if (points.Count > 1)
                        {
                            PolyCurve pc = PolyCurve.ByPoints(points);

                            double offset = this.GetArrayStationOffsetElevationByPoint(pc.StartPoint)[1];  // 1.1.0

                            Featureline.SideType side = Featureline.SideType.Right;

                            if (offset < 0)
                            {
                                side = Featureline.SideType.Left;
                            }

                            regFeaturelines.Add(new Featureline(this, pc, code, side, regionIndex));

                            Utils.Log(string.Format("Featureline added", ""));
                        }

                        foreach (var pt in points)
                        {
                            pt.Dispose();
                        }
                    }

                    blFeaturelines.Add(regFeaturelines);

                    Utils.Log(string.Format("Region {0} completed.", regionIndex));

                    regionIndex++;
                }
            }

            // 20190121 -- End

            #region OLDCODE

            //int regionIndex = 0;

            //foreach (AeccBaselineRegion region in b.BaselineRegions)
            //{
            //    IList<Featureline> regFeaturelines = new List<Featureline>();

            //    foreach (AeccFeatureLines coll in b.MainBaselineFeatureLines.FeatureLinesCol.Cast<AeccFeatureLines>().Where(fl => fl.FeatureLineCodeInfo.CodeName == code))  // 1.1.0
            //    {
            //        foreach (AeccFeatureLine f in coll.Cast<AeccFeatureLine>().Where(x => x.CodeName == code))  // maybe redundant?
            //        {
            //            double start = f.FeatureLinePoints.Item(0).Station;  // 1.1.0
            //            double end = f.FeatureLinePoints.Item(f.FeatureLinePoints.Count - 1).Station;  // 1.1.0

            //            bool reverse = start < end ? false : true;  // 1.1.0

            //            IList<Point> points = new List<Point>();

            //            foreach (AeccFeatureLinePoint p in f.FeatureLinePoints)
            //            {
            //                Point point = Point.ByCoordinates(p.XYZ[0], p.XYZ[1], p.XYZ[2]);

            //                double s = Math.Round(p.Station, 5);  // 1.1.0

            //                if (s >= region.StartStation || Math.Abs(s - region.StartStation) < 0.001)
            //                {
            //                    if (s <= region.EndStation || Math.Abs(s - region.EndStation) < 0.001)
            //                    {
            //                        points.Add(point);
            //                    }
            //                }
            //            }

            //            points = Point.PruneDuplicates(points);

            //            if (points.Count > 1)
            //            {
            //                PolyCurve pc = PolyCurve.ByPoints(points);

            //                if (reverse)  // 1.1.0
            //                {
            //                    pc = pc.Reverse() as PolyCurve;
            //                }

            //                double offset = this.GetArrayStationOffsetElevationByPoint(pc.StartPoint)[1];  // 1.1.0

            //                Featureline.SideType side = Featureline.SideType.Right;

            //                if (offset < 0)
            //                {
            //                    side = Featureline.SideType.Left;
            //                }

            //                regFeaturelines.Add(new Featureline(this, pc, f.CodeName, side, regionIndex));
            //            }
            //        }
            //    }

            //    blFeaturelines.Add(regFeaturelines);

            //    regionIndex++;
            //}
            #endregion

            Utils.Log(string.Format("Baseline.GetFeaturelinesByCode() Completed.", code));

            return(blFeaturelines);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the featurelines by code and station
        /// </summary>
        /// <param name="code">the Featurelines code.</param>
        /// <param name="station">the station used to select the featurelines.</param>
        /// <returns></returns>
        public IList <Featureline> GetFeaturelinesByCodeStation(string code, double station)  // 1.1.0
        {
            Utils.Log(string.Format("Baseline.GetFeaturelinesByCodeStation({0}, {1}) Started...", code, station));

            IList <Featureline> blFeaturelines = new List <Featureline>();

            var b = this._baseline;

            // 20190122 -- Start

            AeccFeatureLines fs = null;

            try
            {
                fs = b.MainBaselineFeatureLines.FeatureLinesCol.Item(code);
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR 1: {0}", ex.Message));
            }

            if (fs != null)
            {
                AeccBaselineRegion reg = null;

                int regionIndex = 0;

                foreach (AeccBaselineRegion region in b.BaselineRegions)
                {
                    if (region.StartStation < station && region.EndStation > station || Math.Abs(station - region.StartStation) < 0.001 || Math.Abs(station - region.EndStation) < 0.001)
                    {
                        reg = region;
                        break;
                    }

                    ++regionIndex;
                }

                if (reg != null)
                {
                    foreach (var fl in fs.Cast <AeccFeatureLine>())
                    {
                        var pts = new List <Point>();

                        foreach (var pt in fl.FeatureLinePoints.Cast <AeccFeatureLinePoint>())
                        {
                            if (reg.StartStation < Math.Round(pt.Station, 5) && reg.EndStation > Math.Round(pt.Station, 5) ||
                                Math.Abs(Math.Round(pt.Station, 5) - reg.StartStation) < 0.001 ||
                                Math.Abs(Math.Round(pt.Station, 5) - reg.EndStation) < 0.001)
                            {
                                var p = pt.XYZ;

                                //try
                                //{
                                //    pts.Add(Point.ByCoordinates(p[0], p[1], p[2]));
                                //}
                                //catch { }

                                try
                                {
                                    pts.Add(Point.ByCoordinates(p[0], p[1], p[2]));
                                }
                                catch (Exception ex)
                                {
                                    // 'System.Collections.Generic.IList<Autodesk.DesignScript.Geometry.Point>' does not contain a definition for 'Add'
                                    Utils.Log(string.Format("ERROR 2: {0}", ex.Message));
                                }
                            }
                        }

                        var points = Point.PruneDuplicates(pts);

                        if (points.Count() > 1)
                        {
                            PolyCurve pc = PolyCurve.ByPoints(points);

                            double offset = this.GetArrayStationOffsetElevationByPoint(pc.StartPoint)[1];  // 1.1.0

                            Featureline.SideType side = Featureline.SideType.Right;

                            if (offset < 0)
                            {
                                side = Featureline.SideType.Left;
                            }

                            blFeaturelines.Add(new Featureline(this, pc, code, side, regionIndex));

                            Utils.Log(string.Format("Featureline added", ""));
                        }

                        foreach (var pt in points)
                        {
                            pt.Dispose();
                        }
                    }
                }
            }

            // 20190122 -- End

            #region OLD CODE
            //int regionIndex = 0;

            //foreach (AeccBaselineRegion region in b.BaselineRegions)
            //{
            //    if (region.StartStation < station && region.EndStation > station || Math.Abs(station - region.StartStation) < 0.001 || Math.Abs(station - region.EndStation) < 0.001)  // 1.1.0
            //    {
            //        foreach (AeccFeatureLines coll in b.MainBaselineFeatureLines.FeatureLinesCol.Cast<AeccFeatureLines>().Where(fl => fl.FeatureLineCodeInfo.CodeName == code))  // 1.1.0
            //        {
            //            foreach (AeccFeatureLine f in coll.Cast<AeccFeatureLine>().Where(x => x.CodeName == code))  // maybe redundant?
            //            {
            //                double start = f.FeatureLinePoints.Item(0).Station;  // 1.1.0
            //                double end = f.FeatureLinePoints.Item(f.FeatureLinePoints.Count - 1).Station;  // 1.1.0

            //                bool reverse = start < end ? false : true;  // 1.1.0

            //                IList<Point> points = new List<Point>();

            //                foreach (AeccFeatureLinePoint p in f.FeatureLinePoints)
            //                {
            //                    Point point = Point.ByCoordinates(p.XYZ[0], p.XYZ[1], p.XYZ[2]);

            //                    double s = Math.Round(p.Station, 3);  // 1.1.0

            //                    if (s >= region.StartStation || Math.Abs(s - region.StartStation) < 0.001)
            //                    {
            //                        if (s <= region.EndStation || Math.Abs(s - region.EndStation) < 0.001)
            //                        {
            //                            points.Add(point);
            //                        }
            //                    }
            //                }

            //                points = Point.PruneDuplicates(points);

            //                if (points.Count > 1)
            //                {
            //                    PolyCurve pc = PolyCurve.ByPoints(points);

            //                    if (reverse)  // 1.1.0
            //                    {
            //                        pc = pc.Reverse() as PolyCurve;
            //                    }

            //                    double offset = this.GetArrayStationOffsetElevationByPoint(pc.StartPoint)[1];  // 1.1.0

            //                    Featureline.SideType side = Featureline.SideType.Right;

            //                    if (offset < 0)
            //                    {
            //                        side = Featureline.SideType.Left;
            //                    }

            //                    blFeaturelines.Add(new Featureline(this, pc, f.CodeName, side, regionIndex));
            //                }
            //            }
            //        }
            //    }

            //    regionIndex++;
            //}
            #endregion

            Utils.Log(string.Format("Baseline.GetFeaturelinesByCodeStation() Completed.", code));

            return(blFeaturelines);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the featurelines by code
        /// </summary>
        /// <param name="code">the Featurelines code.</param>
        /// <returns></returns>
        private IList <IList <Featureline> > GetFeaturelinesByCode_(string code)  // 1.1.0
        {
            Utils.Log(string.Format("Baseline.GetFeaturelinesByCode({0}) Started...", code));

            IList <IList <Featureline> > blFeaturelines = new List <IList <Featureline> >();

            var b = this._baseline;

            // 20190121 -- Start

            AeccFeatureLines fs = null;

            try
            {
                fs = b.MainBaselineFeatureLines.FeatureLinesCol.Item(code);
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR: {0}", ex.Message));
            }

            Dictionary <int, Dictionary <double, Point> > cFLs = new Dictionary <int, Dictionary <double, Point> >();

            int i = 0;

            if (fs != null)
            {
                Utils.Log(string.Format("Featurelines in region: {0}", fs.Count));

                foreach (var fl in fs.Cast <AeccFeatureLine>())
                {
                    Dictionary <double, Point> points = new Dictionary <double, Point>();

                    foreach (var pt in fl.FeatureLinePoints.Cast <AeccFeatureLinePoint>())
                    {
                        var p = pt.XYZ;

                        try
                        {
                            points.Add(Math.Round(pt.Station, 5), Point.ByCoordinates(p[0], p[1], p[2]));
                        }
                        catch (Exception ex)
                        {
                            Utils.Log(string.Format("ERROR: {0}", ex.Message));
                        }
                    }

                    cFLs.Add(i, points);

                    ++i;
                }
            }


            if (cFLs.Count > 0)
            {
                int regionIndex = 0;

                foreach (AeccBaselineRegion region in b.BaselineRegions)
                {
                    Utils.Log(string.Format("Processing region {0}...", regionIndex));

                    IList <Featureline> regFeaturelines = new List <Featureline>();

                    foreach (var k in cFLs.Keys)
                    {
                        IList <Point> points = new List <Point>();

                        var pts = cFLs[k];

                        if (pts.Keys.Count == 0)
                        {
                            continue;
                        }

                        foreach (double s in region.GetSortedStations())
                        {
                            var st = Math.Round(s, 5);

                            Point p = null;

                            if (pts.TryGetValue(st, out p))
                            {
                                points.Add(p);
                            }
                        }

                        points = Point.PruneDuplicates(points);

                        if (points.Count > 1)
                        {
                            PolyCurve pc = PolyCurve.ByPoints(points);

                            double offset = this.GetArrayStationOffsetElevationByPoint(pc.StartPoint)[1];  // 1.1.0

                            Featureline.SideType side = Featureline.SideType.Right;

                            if (offset < 0)
                            {
                                side = Featureline.SideType.Left;
                            }

                            regFeaturelines.Add(new Featureline(this, pc, code, side, regionIndex));

                            Utils.Log(string.Format("Featureline added", ""));
                        }

                        foreach (var pt in points)
                        {
                            pt.Dispose();
                        }
                    }

                    blFeaturelines.Add(regFeaturelines);

                    Utils.Log(string.Format("Region {0} completed.", regionIndex));

                    regionIndex++;
                }
            }

            // 20190121 -- End

            Utils.Log(string.Format("Baseline.GetFeaturelinesByCode() Completed.", code));

            return(blFeaturelines);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the featurelines by code and station
        /// </summary>
        /// <param name="code">the Featurelines code.</param>
        /// <param name="station">the station used to select the featurelines.</param>
        /// <returns></returns>
        public IList <Featureline> GetFeaturelinesByCodeStation(string code, double station)  // 1.1.0
        {
            Utils.Log(string.Format("Baseline.GetFeaturelinesByCodeStation({0}, {1}) Started...", code, station));

            IList <Featureline> blFeaturelines = new List <Featureline>();

            var b = this._baseline;

            // 20190122 -- Start

            AeccFeatureLines fs = null;

            try
            {
                fs = b.MainBaselineFeatureLines.FeatureLinesCol.Item(code);
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR 1: {0}", ex.Message));
            }

            if (fs != null)
            {
                AeccBaselineRegion reg = null;

                int regionIndex = 0;

                foreach (AeccBaselineRegion region in b.BaselineRegions)
                {
                    if (region.StartStation < station && region.EndStation > station || Math.Abs(station - region.StartStation) < 0.001 || Math.Abs(station - region.EndStation) < 0.001)
                    {
                        reg = region;
                        break;
                    }

                    ++regionIndex;
                }

                if (reg != null)
                {
                    foreach (var fl in fs.Cast <AeccFeatureLine>())
                    {
                        var pts = new List <Point>();

                        foreach (var pt in fl.FeatureLinePoints.Cast <AeccFeatureLinePoint>())
                        {
                            if (reg.StartStation < Math.Round(pt.Station, 5) && reg.EndStation > Math.Round(pt.Station, 5) ||
                                Math.Abs(Math.Round(pt.Station, 5) - reg.StartStation) < 0.001 ||
                                Math.Abs(Math.Round(pt.Station, 5) - reg.EndStation) < 0.001)
                            {
                                var p = pt.XYZ;

                                try
                                {
                                    pts.Add(Point.ByCoordinates(p[0], p[1], p[2]));
                                }
                                catch (Exception ex)
                                {
                                    Utils.Log(string.Format("ERROR 2: {0}", ex.Message));
                                }
                            }
                        }

                        var points = Point.PruneDuplicates(pts);

                        if (points.Count() > 1)
                        {
                            PolyCurve pc = PolyCurve.ByPoints(points);

                            double offset = this.GetArrayStationOffsetElevationByPoint(pc.StartPoint)[1];  // 1.1.0

                            Featureline.SideType side = Featureline.SideType.Right;

                            if (offset < 0)
                            {
                                side = Featureline.SideType.Left;
                            }

                            blFeaturelines.Add(new Featureline(this, pc, code, side, regionIndex));

                            Utils.Log(string.Format("Featureline added", ""));
                        }

                        foreach (var pt in points)
                        {
                            pt.Dispose();
                        }
                    }
                }
            }

            // 20190122 -- End

            Utils.Log(string.Format("Baseline.GetFeaturelinesByCodeStation() Completed.", code));

            return(blFeaturelines);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets the featurelines by Code &gt; Baseline &gt; Region.
        /// </summary>
        /// <param name="code">The code.</param>
        /// <returns></returns>
        private IList <IList <IList <Featureline> > > GetFeaturelinesByCode_Old1(string code)
        {
            IList <string[]> corridorCodes = new List <string[]>();
            IList <IList <IList <Featureline> > > corridorFeaturelines = new List <IList <IList <Featureline> > >();

            foreach (Baseline bl in this.Baselines)
            {
                IList <IList <Featureline> > blFeaturelines = new List <IList <Featureline> >();

                var b = bl._baseline;

                int regionIndex = 0;

                foreach (AeccBaselineRegion region in b.BaselineRegions)
                {
                    IList <Featureline> regFeaturelines = new List <Featureline>();

                    foreach (AeccFeatureLines coll in b.MainBaselineFeatureLines.FeatureLinesCol)
                    {
                        foreach (AeccFeatureLine f in coll)
                        {
                            if (f.CodeName == code)
                            {
                                IList <Point> points = new List <Point>();

                                foreach (AeccFeatureLinePoint p in f.FeatureLinePoints)
                                {
                                    Point point = Point.ByCoordinates(p.XYZ[0], p.XYZ[1], p.XYZ[2]);

                                    double s = Math.Round(bl.GetArrayStationOffsetElevationByPoint(point)[0], 5);

                                    if (s >= region.StartStation || Math.Abs(s - region.StartStation) < 0.001)
                                    {
                                        if (s <= region.EndStation || Math.Abs(s - region.EndStation) < 0.001)
                                        {
                                            points.Add(point);
                                        }
                                    }
                                }

                                points = Point.PruneDuplicates(points);

                                if (points.Count > 1)
                                {
                                    PolyCurve pc = PolyCurve.ByPoints(points);

                                    var    soeStart = bl.GetArrayStationOffsetElevationByPoint(pc.PointAtParameter(0));
                                    var    soeEnd   = bl.GetArrayStationOffsetElevationByPoint(pc.PointAtParameter(1));
                                    double offset   = soeStart[1];

                                    if (soeStart[0] > soeEnd[0])
                                    {
                                        pc     = pc.Reverse() as PolyCurve;
                                        offset = bl.GetArrayStationOffsetElevationByPoint(pc.PointAtParameter(0))[1];
                                    }

                                    Featureline.SideType side = Featureline.SideType.Right;

                                    if (offset < 0)
                                    {
                                        side = Featureline.SideType.Left;
                                    }

                                    regFeaturelines.Add(new Featureline(bl, pc, f.CodeName, side, regionIndex));
                                }
                            }
                        }
                    }

                    blFeaturelines.Add(regFeaturelines);

                    regionIndex++;
                }

                corridorFeaturelines.Add(blFeaturelines);
            }

            return(corridorFeaturelines);
        }