Esempio n. 1
0
        public PointF[] GenerateTrackGraphic(GPXAnalyzer frm, int Trackidx, int width, int height, int borderWidth)
        {
            PointF[] Points = new PointF[0];
            if (!ValidTrack(Trackidx)) return Points;

            if (gpxInfo != null)
            {
                // Compute scale factor
                double dlat = (double)(trackBounds.maxlat - trackBounds.minlat);
                double dlon = (double)(trackBounds.maxlon - trackBounds.minlon);
                double xScale = (width - 2 * borderWidth) / dlon;
                double yScale = (height - 2 * borderWidth) / dlat;
                xScale = Math.Min(xScale, yScale);
                yScale = xScale;

                trkType track = gpxInfo.trk[Trackidx];
                trksegType seg = track.trkseg[0];
                Points = new PointF[seg.trkpt.Length];
                wptType wpt;
                for (int iPoint = 0; iPoint < seg.trkpt.Length; iPoint++)
                {
                    wpt = seg.trkpt[iPoint];
                    PointF pt = frm.LatLonToScreen((double)wpt.lat, (double)wpt.lon,
                        (double)trackBounds.minlat, (double)trackBounds.minlon, xScale, yScale);
                    Points[iPoint] = pt;
                }

            }
            return Points;
        }