示例#1
0
        private void  HighLightClosestPoint(int closestPointSeriesIndex,
                                            int closestPointPointIndex,
                                            PicesGPSDataPoint closestPoint,
                                            PicesSipperDeployment closestDeployment
                                            )
        {
            TimeSpan adjGpsToAct = new TimeSpan(0, 0, 0);

            if (closestDeployment != null)
            {
                adjGpsToAct = closestDeployment.SyncTimeStampActual - closestDeployment.SyncTimeStampGPS;
            }

            DateTime adjDateTime = closestPoint.GpsUtcTime.Add(adjGpsToAct);

            if ((lastClosestSeriesIndex >= 0) && (lastClosestSeriesIndex < ProfileChart.Series.Count))
            {
                if ((lastClosestPointIndex >= 0) && (lastClosestPointIndex < ProfileChart.Series[lastClosestSeriesIndex].Points.Count))
                {
                    Series    s  = ProfileChart.Series[lastClosestSeriesIndex];
                    DataPoint dp = s.Points[lastClosestPointIndex];
                    dp.Label       = "";
                    dp.MarkerSize  = s.MarkerSize;
                    dp.MarkerStyle = s.MarkerStyle;
                }
            }

            lastClosestPoint       = null;
            lastClosestSeriesIndex = -1;
            lastClosestPointIndex  = -1;

            if ((closestPointSeriesIndex >= 0) && (closestPointSeriesIndex < ProfileChart.Series.Count))
            {
                if ((closestPointPointIndex >= 0) && (closestPointPointIndex < ProfileChart.Series[closestPointSeriesIndex].Points.Count))
                {
                    Series    s  = ProfileChart.Series[closestPointSeriesIndex];
                    DataPoint dp = s.Points[closestPointPointIndex];

                    dp.Label               = adjDateTime.ToString("HH:mm");
                    dp.MarkerStyle         = MarkerStyle.Diamond;
                    dp.MarkerSize          = s.MarkerSize * 3;
                    lastClosestPoint       = closestPoint;
                    lastClosestSeriesIndex = closestPointSeriesIndex;
                    lastClosestPointIndex  = closestPointPointIndex;
                }
            }
        } /* HighLightClosestPoint */
示例#2
0
            public PicesGPSDataPoint ClosestPoint(double longitude, double longTh,
                                                  double latitude, double latTh,
                                                  ref int closestPointIndex,
                                                  ref double closestPointSquareDist
                                                  )
            {
                PicesGPSDataPoint closestPoint = null;

                closestPointSquareDist = double.MaxValue;
                closestPointIndex      = -1;

                double longitudeMin = longitude - longTh;
                double longitudeMax = longitude + longTh;
                double latitudeMin  = latitude - longTh;
                double latitudeMax  = latitude + longTh;

                int index = 0;

                foreach (PicesGPSDataPoint dp in data)
                {
                    if ((dp.Longitude >= longitudeMin) && (dp.Longitude <= longitudeMax))
                    {
                        if ((dp.Latitude >= latitudeMin) && (dp.Latitude <= latitudeMax))
                        {
                            double deltaLatitude  = (dp.Latitude - latitude) / latTh;
                            double deltaLongitude = (dp.Longitude - longitude) / longTh;

                            double squareDist = deltaLatitude * deltaLatitude + deltaLongitude * deltaLongitude;
                            if (squareDist < closestPointSquareDist)
                            {
                                closestPoint           = dp;
                                closestPointSquareDist = squareDist;
                                closestPointIndex      = index;
                            }
                        }
                    }
                    index++;
                }
                return(closestPoint);
            } /* ClosestPoint */
示例#3
0
        } /* HighLightClosestPoint */

        private void ProfileChart_MouseClick(object sender, MouseEventArgs e)
        {
            Point p = e.Location;
            //MouseClickLocation.Text = p.X.ToString () + "," + p.Y.ToString ();
            ChartArea ca        = ProfileChart.ChartAreas[0];
            double    longitude = ca.AxisX.PixelPositionToValue((double)p.X);
            double    latitude  = ca.AxisY.PixelPositionToValue((double)p.Y);

            // Determine Threshold.
            int    thInPixels      = 25;
            double x               = ca.AxisX.PixelPositionToValue((double)(p.X + thInPixels));
            double degLongPerPixel = Math.Abs(x - longitude) / thInPixels;

            double y = ca.AxisY.PixelPositionToValue((double)(p.Y + thInPixels));
            double degLatPerPixel = Math.Abs(y - latitude) / thInPixels;

            double longTH = degLongPerPixel * thInPixels;
            double latTH  = degLatPerPixel * thInPixels;

            PicesGPSDataPoint closestPoint          = null;
            int    closestPointIndex                = -1;
            int    closestPointSeriesIndex          = -1;
            double closestPointDistSquare           = double.MaxValue;
            PicesSipperDeployment closestDeployment = null;

            foreach (DataSeriesToPlot dstp in series)
            {
                if (dstp.WithInThreshold(longitude, longTH, latitude, latTH))
                {
                    double            distSquare = double.MaxValue;
                    int               closestPointInSeriesIndex = -1;
                    PicesGPSDataPoint closestPointInSeries      = dstp.ClosestPoint(longitude, longTH, latitude, latTH, ref closestPointInSeriesIndex, ref distSquare);
                    if (closestPointInSeries != null)
                    {
                        if (distSquare < closestPointDistSquare)
                        {
                            closestPointIndex       = closestPointInSeriesIndex;
                            closestPointSeriesIndex = dstp.chartSeriesIndex;
                            closestPointDistSquare  = distSquare;
                            closestPoint            = closestPointInSeries;
                            closestDeployment       = dstp.deployment;
                        }
                    }
                }
            }

            if (closestPoint != null)
            {
                HighLightClosestPoint(closestPointSeriesIndex, closestPointIndex, closestPoint, closestDeployment);
                String gpsStr = PicesMethods.LatitudeLongitudeToString(closestPoint.Latitude, closestPoint.Longitude);
                CurGPSLocation.Text = gpsStr;
                COGField.Text       = closestPoint.CourseOverGround.ToString("##0.0") + " deg's";
                SOGField.Text       = closestPoint.SpeedOverGround.ToString("#0.0") + " kts";

                if (closestDeployment != null)
                {
                    DeploymentHighlighted.Text = closestDeployment.ShortDescription + "(" + closestDeployment.DateTimeStart.ToString("yyyy-MM-dd") + ")";
                }
                else
                {
                    DeploymentHighlighted.Text = "Cruise";
                }
            }
        }