14,607,954 members

# Code for Determining Navigation Paths on Maps

Rate this:
4 Jul 2020CPOL
Use this method for setting path on a map given [current position, heading, and distance]

## Introduction

Do you have a need for calculating Lat and Long of Next position given [current position, heading, and distance travelled]? If so, this code will do the trick.

## Background

It worked for me. I guess it will work for you! Let me know in the comments.

## The Code

```using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;

namespace MobileIE.Classes
{
public class GeoMath
{
(double fmLat, double fmLon, double heading, double distanceKm)
{

double newLatR = Math.Asin(Math.Sin(latR) *

double newLonR = lonR + Math.Atan2(
Math.Sin(bearingR) *
Math.Sin(newLatR)
);

return  new Tuple<double, double="">(newLatR.ToDegrees(), newLonR.ToDegrees());
}
}

public static class NumericExtensions
{
public static double ToRadians(this double degrees)
{
return (Math.PI / 180) * degrees;
}
public static double ToDegrees(this double radians)
{
return (180 / Math.PI) * radians;
}
}
}```

Also available at https://gist.github.com/BicycleMark/3e1a2152febaa2935e4c8cfcea7e061b.

## History

• 4th July, 2020: Original publication

## Share

 United States
No Biography provided

 First Prev Next
 Latitude calculation is incorrect Member 1471815822-Jul-20 5:01 Member 14718158 22-Jul-20 5:01
 Title is misleading Andreas Saurwein6-Jul-20 1:34 Andreas Saurwein 6-Jul-20 1:34
 Re: Title is misleading MarkWardell6-Jul-20 11:31 MarkWardell 6-Jul-20 11:31
 Earth is not a sphere Mircea Neacsu5-Jul-20 11:29 Mircea Neacsu 5-Jul-20 11:29
 Re: Earth is not a sphere MarkWardell6-Jul-20 11:27 MarkWardell 6-Jul-20 11:27
 Last Visit: 14-Aug-20 11:02     Last Update: 14-Aug-20 11:02 Refresh 1