User Tools

Site Tools


boarder_raduis_gpx

Boarder Radius GPX

using BAMCIS.GIS;
using System;
using System.Text;
 
namespace Radius
{
    // NuGet: BAMCIS.GeoCoordinate
    internal class Program
    {
        private const double Radius = 11.0;
 
        static void Main(string[] args)
        {
            GeoCoordinate Source = new GeoCoordinate(-40.166507, 175.470452);
            var output = new StringBuilder();
 
            output.AppendLine(@"<?xml version=""1.0"" encoding=""UTF-8""?>
<gpx xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd"" version=""1.1"" xmlns=""http://www.topografix.com/GPX/1/1"" xmlns:gpxtpx=""http://www.garmin.com/xmlschemas/TrackPointExtension/v1"" xmlns:gpxx=""http://www.garmin.com/xmlschemas/GpxExtensions/v3"">
 <trk>
  <name>10k Boarder</name>
  <type>9</type>
  <trkseg>");
 
            for (int i = 0; i < 361; i += 4)
            {
                var point = Source.FindDestination(i, Radius, DistanceType.KILOMETERS);
 
                output.AppendLine($"   <trkpt lat=\"{point.GetLatitude().DecimalDegrees}\" lon=\"{point.GetLongitude().DecimalDegrees}\"></trkpt>");
            }
 
            output.AppendLine(@"  </trkseg>
 </trk>
</gpx>");
 
 
            Console.WriteLine(output.ToString());
            System.IO.File.WriteAllText("10k Boarder.gpx", output.ToString());
        }
    }
}
boarder_raduis_gpx.txt · Last modified: 2022/07/05 23:53 by stephen