当前位置: 首页>>代码示例>>C#>>正文


C# GeoCoord.bearing方法代码示例

本文整理汇总了C#中LibGeo.GeoCoord.bearing方法的典型用法代码示例。如果您正苦于以下问题:C# GeoCoord.bearing方法的具体用法?C# GeoCoord.bearing怎么用?C# GeoCoord.bearing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LibGeo.GeoCoord的用法示例。


在下文中一共展示了GeoCoord.bearing方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: realtimeCallback

        private void realtimeCallback( GpsRealTimeData rtData )
        {
            if(!closing)
            {
                this.timeLabel.Text = rtData.time.Equals(DateTime.MinValue) ? "" : ("" + Project.zuluToLocal(rtData.time));
                this.fixLabel.Text = rtData.fixStr;
                this.statusLabel.Text = "PC: " + DateTime.Now.ToLongTimeString() + " - " + rtData.comment;
                switch (rtData.fix)
                {
                    case 0:
                    case 1:
                    case -1:
                        this.positionLabel.Text = "No GPS fix";
                        this.altLabel.Text = "";
                        this.accuracyLabel.Text = "";
                        this.speedLabel.Text = "";
                        this.magnHeadingLabel.Text = "";
                        this.trueHeadingLabel.Text = "";
                        this.slopeLabel.Text = "";
                        lastFixLoc = null;
                        gpsBasicsGroupBox.BackColor = Color.Pink;
                        gpsBasicsGroupBox.Text = "";
                        break;
                    default:
                        if(rtData.location != null)
                        {
                            string sLoc = rtData.location.ToString();		// alt not included
                            this.positionLabel.Text = sLoc.Replace(" ", "   ");
                            //LibSys.StatusBar.Trace2(sLoc);
                            Distance dAlt = new Distance(rtData.location.Elev);
                            this.altLabel.Text = "" + dAlt.ToString(Distance.UNITS_DISTANCE_FEET);
                        }
                        else
                        {
                            this.positionLabel.Text = "";
                            this.altLabel.Text = "";
                            //LibSys.StatusBar.Trace2("GPS: no fix");
                        }
                        Distance dAccH = new Distance(rtData.posErrorH);
                        Distance dAccV = new Distance(rtData.posErrorV);
                        this.accuracyLabel.Text =
                            (rtData.posErrorH > 0 ? (dAccH.ToString(Distance.UNITS_DISTANCE_FEET) + "(Horiz)") : "") + "   "
                            + (rtData.posErrorV > 0 ? (dAccV.ToString(Distance.UNITS_DISTANCE_FEET) + "(Vert)") : "");

                        double variation = Math.Round(rtData.location.magneticVariation());
                        string variationDir = variation > 0.0d ? "W" : "E";

                        bool hasHeading = false;
                        double headingTrue = 0.0d;
                        double headingMagn = 0.0d;
                        string slopeInfo = "";

                        if(lastFixLoc != null)
                        {
                            headingTrue = Math.Round(lastFixLoc.bearing(rtData.location) * 180.0d / Math.PI, 1);
                            headingMagn = (headingTrue + variation + 360.0d) % 360.0d;
                            hasHeading = true;

                            double dAlt = rtData.location.Elev - lastFixLoc.Elev;	// meters
                            double dDist = rtData.location.distanceFrom(lastFixLoc).Meters;
                            double dSlope = Math.Atan(dAlt / dDist) * 180.0d / Math.PI;
                            double dTimeMs = (DateTime.Now - lastFixDateTime).TotalMilliseconds + 1.0d;		// 1.0d to avoid 0
                            double fpm = dAlt / dTimeMs / Distance.METERS_PER_FOOT * 1000.0d * 60.0d;
                            string fpmFormat = Math.Abs(fpm) > 20.0d ? "1:F0" : "1:F1";

                            if(fpm > 1.0d || dSlope >= 0.1d)
                            {
                                slopeInfo = String.Format("slope: {0:F1}° (up) - climbing at {" + fpmFormat + "} fpm", dSlope, fpm);
                            }
                            else if(fpm < -1.0d || dSlope <= -0.1d)
                            {
                                slopeInfo = String.Format("slope: {0:F1}° (down) - descending at {" + fpmFormat + "} fpm", -dSlope, -fpm);
                            }
                        }

                        Speed dSpeed = new Speed(rtData.velocity * 3600.0d);		// rtData.velocity is in meters/sec, Speed requires meters/hr
                        if(dSpeed.Meters < 300)
                        {
                            this.speedLabel.Text = "0";
                            this.magnHeadingLabel.Text = "";
                            this.trueHeadingLabel.Text = "";
                        }
                        else
                        {
                            this.speedLabel.Text = dSpeed.ToString();
                        }

                        this.magnHeadingLabel.Text = (hasHeading ? String.Format("{0:000}°", Math.Round(headingMagn)) : "");
                        this.trueHeadingLabel.Text = (hasHeading ? String.Format("true heading: {0:000}°", Math.Round(headingTrue)) : "") + String.Format("  variation {0:F0}{1}", Math.Abs(variation), variationDir);

                        this.slopeLabel.Text = slopeInfo;

                        lastFixLoc = new GeoCoord(rtData.location);
                        lastFixDateTime = DateTime.Now;
                        gpsBasicsGroupBox.BackColor = Color.LightGreen;
                        gpsBasicsGroupBox.Text = "";
                        break;
                }
            }
        }
开发者ID:slgrobotics,项目名称:QuakeMap,代码行数:100,代码来源:DlgGpsManager.cs

示例2: adjustTimeShiftByPhotopoint

        private void adjustTimeShiftByPhotopoint()
        {
            try
            {
                Waypoint wptToAdjust = PhotoWaypoints.getWaypointById(Project.photoSelectedWptId);
                long trackId = wptToAdjust.TrackId;
                Track track = WaypointsCache.getTrackById(trackId);
                GeoCoord photoDesiredLocation = new GeoCoord(Project.photoSelectedCoord.X, Project.photoSelectedCoord.Y);
                this.traceLabel.Text = "Adjusting photopoint " + wptToAdjust.Name + " track: " + trackId + " to: " + photoDesiredLocation + "\r\n";

                // compute the closest trackpoint (to the click):
                Waypoint closestTrackpoint1 = null;
                int closestTrackpointIndex = -1;
                double closestDistance1 = 100000000.0;
                double bearing1 = 0.0d;
                for(int j=0; j < track.Trackpoints.Count ;j++)
                {
                    Waypoint trkpt = (Waypoint)track.Trackpoints.GetByIndex(j);
                    Distance dst = trkpt.Location.distanceFrom(photoDesiredLocation);
                    if(dst.Meters < closestDistance1)
                    {
                        closestDistance1 = dst.Meters;
                        closestTrackpoint1 = trkpt;
                        closestTrackpointIndex = j;
                        bearing1 = photoDesiredLocation.bearing(closestTrackpoint1.Location);
                    }
                }
            //				this.traceLabel.Text += "point1: " + closestTrackpoint1.Name + " (" + closestDistance1 + ")";

                // measure the previous and next trackpoints, choose the closest of them to the click:
                Waypoint closestTrackpoint2 = null;
                double closestDistance2 =  10000000000.0d;
                double bearing2 = 0.0d;

                if(closestTrackpointIndex > 0)
                {
                    // previous:
                    closestTrackpoint2 = (Waypoint)track.Trackpoints.GetByIndex(closestTrackpointIndex - 1);
                    closestDistance2 = closestTrackpoint2.Location.distanceFrom(photoDesiredLocation).Meters;
                    bearing2 = photoDesiredLocation.bearing(closestTrackpoint2.Location);
                }

                Waypoint closestTrackpoint3 = null;
                double closestDistance3 =  10000000000.0d;
                double bearing3 = 0.0d;

                if(closestTrackpointIndex < track.Trackpoints.Count - 1)
                {
                    // next:
                    closestTrackpoint3 = (Waypoint)track.Trackpoints.GetByIndex(closestTrackpointIndex + 1);
                    closestDistance3 = closestTrackpoint3.Location.distanceFrom(photoDesiredLocation).Meters;
                    bearing3 = photoDesiredLocation.bearing(closestTrackpoint3.Location);
                }

                bool useNext = closestTrackpoint2 == null
                            || closestTrackpoint3 != null && (Math.Abs(bearing3 - bearing1) > Math.Abs(bearing2 - bearing1));

                if(useNext)
                {
                    // using the next - it's leg is turned more towards the desired point:
                    closestTrackpoint2 = closestTrackpoint3;
                    closestDistance2 = closestDistance3;
                }

                // at this point closestTrackpoint3 is irrelevant, all is defined by the 1 and 2 and the ratio:

            //				this.traceLabel.Text += "  point2: " + closestTrackpoint2.Name + " (" + closestDistance2 + ")";

                Graphics g = PictureManager.This.Graphics;
                Point p0 = CameraManager.This.toPixelLocation(photoDesiredLocation, null);

            //				Point p1 = CameraManager.This.toPixelLocation(closestTrackpoint1.Location, null);
            //				Point p2 = CameraManager.This.toPixelLocation(closestTrackpoint2.Location, null);
            //				g.DrawLine(Pens.Yellow, p0, p1);
            //				g.DrawLine(Pens.Yellow, p1, p2);
            //				g.DrawLine(Pens.Yellow, p2, p0);

                // The main point is closestTrackpoint1, the other point is always closestTrackpoint2.
                // positive ratio means go forward towards the next point, negative - go back towards the previous:
                double ratio = closestDistance1 / (closestDistance1 + closestDistance2);

            //				this.traceLabel.Text += "\r\nratio: " + ratio;

                double lat = closestTrackpoint1.Location.Lat + (closestTrackpoint2.Location.Lat - closestTrackpoint1.Location.Lat) * ratio;
                double lng = closestTrackpoint1.Location.Lng + (closestTrackpoint2.Location.Lng - closestTrackpoint1.Location.Lng) * ratio;

                long midTicks = (long)Math.Round(closestTrackpoint1.DateTime.Ticks + (closestTrackpoint2.DateTime.Ticks - closestTrackpoint1.DateTime.Ticks) * ratio);

                GeoCoord midpoint = new GeoCoord(lng, lat);
                Point pMid = CameraManager.This.toPixelLocation(midpoint, null);
                g.DrawLine(Pens.Red, pMid, p0);

                long ticksToAdjust = midTicks - wptToAdjust.DateTime.Ticks;
                TimeSpan toAdjust = new TimeSpan(ticksToAdjust);

                this.traceLabel.Text += "   midpoint: " + midpoint + "  toAdjust=" + toAdjust;

            //				//CameraManager.This.MarkLocation(midpoint, 0);
            //				Waypoint wpt = new Waypoint(wptToAdjust);
            //				wpt.TrackId = -1L;
//.........这里部分代码省略.........
开发者ID:slgrobotics,项目名称:QuakeMap,代码行数:101,代码来源:DlgPhotoManager.cs


注:本文中的LibGeo.GeoCoord.bearing方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。