示例#1
0
        public double[] GetArrayStationOffsetElevationByPoint(Point point)
        {
            Utils.Log(string.Format("Baseline.GetArrayStationOffsetElevationByPoint started...", ""));

            AeccAlignment alignment = this.Alignment.InternalElement as AeccAlignment;

            double station = 0;
            double offset  = 0;

            alignment.StationOffset(point.X, point.Y, out station, out offset);

            //double elevation = point.Z - PointByStationOffsetElevation(station, offset, 0).Z;
            double elevation = point.Z - this._baseline.Profile.ElevationAt(station);

            Utils.Log(string.Format("Baseline.GetArrayStationOffsetElevationByPoint completed.", ""));

            return(new double[] { station, offset, elevation });
        }
示例#2
0
        public Dictionary <string, object> GetStationOffsetElevationByPoint(Point point)
        {
            Utils.Log(string.Format("Baseline.GetStationOffsetElevationByPoint started...", ""));

            AeccAlignment alignment = this.Alignment.InternalElement as AeccAlignment;

            double station = 0;
            double offset  = 0;

            alignment.StationOffset(point.X, point.Y, out station, out offset);

            double elevation = point.Z - PointByStationOffsetElevation(station, offset, 0).Z;

            Utils.Log(string.Format("Baseline.GetStationOffsetElevationByPoint completed.", ""));

            return(new Dictionary <string, object> {
                { "Station", station }, { "Offset", offset }, { "Elevation", elevation }
            });
        }
示例#3
0
        /// <summary>
        /// Returns the closest Baseline CoordinateSystem and uses the point as new origin.
        /// </summary>
        /// <param name="point">The input Point.</param>
        /// <returns>The CoordinateSystem.</returns>
        /// <remarks>if the station falls outside of the corridor it returns the Identity Coordinate System.</remarks>
        public CoordinateSystem GetCoordinateSystemByPoint(Point point)
        {
            Utils.Log(string.Format("Baseline.GetCoordinateSystemByPoint started...", ""));

            CoordinateSystem cs = CoordinateSystem.Identity();

            AeccAlignment alignment = this.Alignment.InternalElement as AeccAlignment;

            double station = 0;
            double offset  = 0;

            alignment.StationOffset(point.X, point.Y, out station, out offset);

            cs = this.CoordinateSystemByStation(station);

            cs = CoordinateSystem.ByOriginVectors(point, cs.XAxis, cs.YAxis, cs.ZAxis);

            Utils.Log(string.Format("Baseline.GetCoordinateSystemByPoint completed.", ""));

            return(cs);
        }
示例#4
0
        public Dictionary <string, object> GetStationOffsetElevationByPoint(Point point)
        {
            Utils.Log(string.Format("Featureline.GetStationOffsetElevationByPoint started...", ""));

            Utils.Log(string.Format("Point: X: {0} Y: {1} Z: {2}", point.X, point.Y, point.Z));

            Point flatPt = Point.ByCoordinates(point.X, point.Y);

            Curve flatPC = this.Curve.PullOntoPlane(Plane.XY());

            AeccAlignment alignment = this._baseline.Alignment.InternalElement as AeccAlignment;

            double station   = 0;
            double offset    = 0;
            double elevation = 0;

            double alStation = 0;
            double alOffset  = 0;

            //Point start = null; //  c.PointAtParameter(0);
            //Point end = null; // c.PointAtParameter(1);

            //Vector dir = null; // Vector.ByTwoPoints(start, end).Normalized();

            //Vector test = null;

            Point ortho = null;

            //Line l = null;

            CoordinateSystem cs = null;

            Point result = null;

            alignment.StationOffset(point.X, point.Y, out alStation, out alOffset);

            Utils.Log(string.Format("The point is at station {0}", alStation));

            // 20190414 -- START

            if (Math.Abs(alStation - this.Start) <= 0.00001)
            {
                alStation = this.Start;
                Utils.Log(string.Format("Station rounded to {0}", alStation));
            }

            if (Math.Abs(alStation - this.End) <= 0.00001)
            {
                alStation = this.End;
                Utils.Log(string.Format("Station rounded to {0}", alStation));
            }

            // 20190414 -- END

            if (this.Start <= Math.Round(alStation, 5) && Math.Round(alStation, 5) <= this.End ||
                Math.Abs(this.Start - alStation) < 0.0001 ||
                Math.Abs(this.End - alStation) < 0.0001)
            {
                // the point is in the featureline range

                Utils.Log(string.Format("The point is inside the featureline station range.", ""));

                // 20190205 -- START

                ortho = flatPC.ClosestPointTo(flatPt);

                Utils.Log(string.Format("Orthogonal Point at Z = 0: {0}", ortho));

                double orStation = 0;
                double orOffset  = 0;
                double error     = 0;

                alignment.StationOffset(ortho.X, ortho.Y, out orStation, out orOffset);

                cs = this.CoordinateSystemByStation(orStation, false).Inverse();

                Utils.Log(string.Format("CoordinateSystem: {0}", cs));

                result = point.Transform(cs) as Point;

                Utils.Log(string.Format("Result: {0}", result));

                station   = orStation;
                offset    = result.X;
                elevation = result.Z;
                error     = result.Y;

                // 20190205 -- END

                #region UNDER REVIEW
                //Dictionary<double, Point> cpts = new Dictionary<double, Point>();

                //foreach (Curve c in this._polycurve.Curves())
                //{
                //    start = c.PointAtParameter(0);
                //    end = c.PointAtParameter(1);

                //    start = Point.ByCoordinates(start.X, start.Y, 0);
                //    end = Point.ByCoordinates(end.X, end.Y, 0);

                //    Point q = Point.ByCoordinates(point.X, point.Y, 0);

                //    // Utils.Log(string.Format("Curve Start: {0} End: {1}", start, end));

                //    dir = Vector.ByTwoPoints(start, end).Normalized();

                //    test = null;

                //    ortho = null;

                //    if (start.DistanceTo(q) > 0)
                //    {
                //        test = Vector.ByTwoPoints(start, q);

                //        ortho = start.Translate(dir, test.Dot(dir)) as Point;
                //    }
                //    else
                //    {
                //        test = Vector.ByTwoPoints(end, q);

                //        ortho = end.Translate(dir.Reverse(), test.Dot(dir)) as Point;
                //    }

                //    if (ortho != null)
                //    {
                //        l = Line.ByStartPointEndPoint(start, end);

                //        double par = l.ParameterAtPoint(ortho);

                //        if (par >= 0 && par <= 1)
                //        {
                //            double orStation = 0;
                //            double orOffset = 0;

                //            alignment.StationOffset(ortho.X, ortho.Y, out orStation, out orOffset);

                //            CoordinateSystem cs = this.CoordinateSystemByStation(orStation, false).Inverse();

                //            Point result = point.Transform(cs) as Point;

                //            //Utils.Log(string.Format("OrStation: {0}", orStation));

                //            cpts[orStation] = result;
                //        }
                //    }
                //    else
                //    {
                //        Utils.Log(string.Format("No projection was found", ""));
                //    }
                //}

                //double error = double.MaxValue;

                //foreach (double s in cpts.Keys)
                //{
                //    double margin = cpts[s].Y;

                //    if (margin < error)
                //    {
                //        station = s;
                //        offset = cpts[s].X;
                //        elevation = cpts[s].Z;
                //        error = margin;
                //    }
                //}
                #endregion

                Utils.Log(string.Format("Final Margin: {0}", error));

                #region TEST CODE
                //Point projection = this._polycurve.ClosestPointTo(point);

                //int count = 0;

                ////while (true)
                ////{
                //    // The station and offset from the alignment of the point sitting on the featureline
                //double flStation = 0;
                //double flOffset = 0;

                //    // The X and Y from the alignment of the point on the featureline at station and offset
                //    double x = 0;
                //    double y = 0;

                //alignment.StationOffset(projection.X, projection.Y, out flStation, out flOffset);

                //    alignment.PointLocation(flStation, flOffset, out x, out y);

                //CoordinateSystem cs = this.CoordinateSystemByStation(flStation).Inverse();

                //Point result = point.Transform(cs) as Point;

                //station = flStation;
                //offset = result.X;
                //elevation = result.Z;

                //    Utils.Log(string.Format("Station: {0}", station));

                //    Utils.Log(string.Format("Margin: {0}", result.Y));

                //    Utils.Log(string.Format("X: {0} Y: {1}", x, y));

                //    // tolerance
                //    if (Math.Abs(result.Y) > 0.0001 && count < 10)
                //    {
                //        projection = projection.Translate(cs.YAxis, -result.Y) as Point;
                //    }
                //    else
                //    {
                //        cs.Dispose();
                //        result.Dispose();

                //        //break;
                //    }

                //    ++count;
                ////}
                #endregion
            }
            else
            {
                Utils.Log(string.Format("The point is outside the featureline station range.", ""));

                station   = alStation;
                offset    = alOffset;                                                                  // offset from alignment
                elevation = point.Z - this._baseline.PointByStationOffsetElevation(alStation, 0, 0).Z; // Absolute elevation
            }

            Utils.Log(string.Format("Station: {0} Offset: {1} Elevation: {2}", station, offset, elevation));

            //start.Dispose();
            //end.Dispose();
            //dir.Dispose();
            //test.Dispose();
            ortho.Dispose();
            //l.Dispose();
            cs.Dispose();
            result.Dispose();
            flatPt.Dispose();
            flatPC.Dispose();

            #region OLD CODE
            //double[] soe = this._baseline.GetStationOffsetElevationByPoint(point);

            //double station = soe[0];
            //double offset = soe[1] - this._baseline.GetStationOffsetElevationByPoint(PointAtStation(station))[1];
            //double elevation = point.Z - PointAtStation(station).Z;
            #endregion
            Utils.Log(string.Format("Featureline.GetStationOffsetElevationByPoint completed.", ""));

            return(new Dictionary <string, object>
            {
                { "Station", Math.Round(station, 5) },
                { "Offset", Math.Round(offset, 5) },
                { "Elevation", Math.Round(elevation, 5) }
            });
        }
示例#5
0
        public Dictionary <string, object> GetStationOffsetElevationByPoint(Point point)
        {
            Utils.Log(string.Format("Featureline.GetStationOffsetElevationByPoint started...", ""));

            Utils.Log(string.Format("Point: X: {0} Y: {1} Z: {2}", point.X, point.Y, point.Z));

            Point flatPt = Point.ByCoordinates(point.X, point.Y);

            Curve flatPC = this.Curve.PullOntoPlane(Plane.XY());

            AeccAlignment alignment = this._baseline.Alignment.InternalElement as AeccAlignment;

            double station   = 0;
            double offset    = 0;
            double elevation = 0;

            double alStation = 0;
            double alOffset  = 0;

            Point ortho = null;

            CoordinateSystem cs = null;

            Point result = null;

            alignment.StationOffset(point.X, point.Y, out alStation, out alOffset);

            Utils.Log(string.Format("The point is at station {0}", alStation));

            // 20190414 -- START

            if (Math.Abs(alStation - this.Start) <= 0.00001)
            {
                alStation = this.Start;
                Utils.Log(string.Format("Station rounded to {0}", alStation));
            }

            if (Math.Abs(alStation - this.End) <= 0.00001)
            {
                alStation = this.End;
                Utils.Log(string.Format("Station rounded to {0}", alStation));
            }

            // 20190414 -- END

            if (this.Start <= Math.Round(alStation, 5) && Math.Round(alStation, 5) <= this.End ||
                Math.Abs(this.Start - alStation) < 0.0001 ||
                Math.Abs(this.End - alStation) < 0.0001)
            {
                // the point is in the featureline range

                Utils.Log(string.Format("The point is inside the featureline station range.", ""));

                // 20190205 -- START

                ortho = flatPC.ClosestPointTo(flatPt);

                Utils.Log(string.Format("Orthogonal Point at Z = 0: {0}", ortho));

                double orStation = 0;
                double orOffset  = 0;
                double error     = 0;

                alignment.StationOffset(ortho.X, ortho.Y, out orStation, out orOffset);

                cs = this.CoordinateSystemByStation(orStation, true).Inverse();  // 20191117

                Utils.Log(string.Format("CoordinateSystem: {0}", cs));

                if (cs == null)
                {
                    var message = "The Point is not compatible with the Featureline and its Baseline.";

                    Utils.Log(string.Format("ERROR: {0}", message));
                    return(null);
                }

                result = point.Transform(cs) as Point;

                Utils.Log(string.Format("Result: {0}", result));

                station   = orStation;
                offset    = result.X;
                elevation = result.Z;
                error     = result.Y;

                // 20190205 -- END


                Utils.Log(string.Format("Final Margin: {0}", error));
            }
            else
            {
                Utils.Log(string.Format("The point is outside the featureline station range.", ""));

                try
                {
                    station   = alStation;
                    offset    = alOffset;                                                                  // offset from alignment
                    elevation = point.Z - this._baseline.PointByStationOffsetElevation(alStation, 0, 0).Z; // Absolute elevation
                }
                catch (Exception ex)
                {
                    var message = "The Point is not compatible with the Alignment.";

                    Utils.Log(string.Format("ERROR: {0} {1}", message, ex.Message));
                    return(null);
                }
            }

            Utils.Log(string.Format("Station: {0} Offset: {1} Elevation: {2}", station, offset, elevation));

            if (ortho != null)
            {
                ortho.Dispose();
            }
            if (cs != null)
            {
                cs.Dispose();
            }
            if (result != null)
            {
                result.Dispose();
            }
            if (flatPt != null)
            {
                flatPt.Dispose();
            }
            if (flatPC != null)
            {
                flatPC.Dispose();
            }

            Utils.Log(string.Format("Featureline.GetStationOffsetElevationByPoint completed.", ""));

            return(new Dictionary <string, object>
            {
                { "Station", Math.Round(station, 5) },
                { "Offset", Math.Round(offset, 5) },
                { "Elevation", Math.Round(elevation, 5) }
            });
        }