Need to calculate where you'll end up after traveling a certain distance in a specific direction? This guide covers everything about destination point calculation via API, including the underlying mathematics, practical applications, and code examples.
What is Destination Point Calculation?
Destination point calculation determines the geographic coordinates you'll reach after traveling a specified distance along a given bearing from a starting point. This is also known as "direct geodetic problem" in surveying.
Given a starting point (latitude, longitude), an initial bearing (direction in degrees), and a distance, the API calculates the exact destination coordinates.
How It Works
The calculation uses spherical trigonometry to account for Earth's curvature:
The Haversine Formula (Inverse)
The destination point formula is the inverse of the Haversine distance formula. It uses the initial bearing and angular distance to compute the destination latitude and longitude.
Understanding Bearings
Bearings are measured in degrees from true north, clockwise:
- 0° / 360° = North
- 90° = East
- 180° = South
- 270° = West
Using the Destination Point API
TinyFn provides a simple endpoint to calculate destination points:
POST https://api.tinyfn.io/v1/geo/destination
Headers: X-API-Key: your-api-key
Content-Type: application/json
{
"start": {"lat": 51.5074, "lng": -0.1278},
"bearing": 45,
"distance": 1000
}
{
"destination": {
"lat": 51.5139,
"lng": -0.1168
},
"final_bearing": 45.01,
"distance_km": 1
}
Parameters
| Parameter | Type | Description |
|---|---|---|
start |
object | Starting coordinates with lat/lng properties (required) |
bearing |
number | Initial bearing in degrees (0-360, required) |
distance |
number | Distance to travel in kilometers (required) |
unit |
string | Distance unit: "km", "mi", "m", "nm" (default: "km") |
Code Examples
JavaScript / Node.js
const response = await fetch(
'https://api.tinyfn.io/v1/geo/destination',
{
method: 'POST',
headers: {
'X-API-Key': 'your-api-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
start: { lat: 51.5074, lng: -0.1278 }, // London
bearing: 45, // Northeast
distance: 100 // 100 km
})
}
);
const { destination } = await response.json();
console.log(destination); // { lat: 52.1234, lng: 0.5678 }
Python
import requests
response = requests.post(
'https://api.tinyfn.io/v1/geo/destination',
headers={'X-API-Key': 'your-api-key'},
json={
'start': {'lat': 51.5074, 'lng': -0.1278}, # London
'bearing': 45, # Northeast
'distance': 100 # 100 km
}
)
destination = response.json()['destination']
print(destination) # {'lat': 52.1234, 'lng': 0.5678}
cURL
curl -X POST "https://api.tinyfn.io/v1/geo/destination" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"start": {"lat": 51.5074, "lng": -0.1278},
"bearing": 45,
"distance": 100
}'
Common Use Cases
- Navigation Systems: Calculate waypoints along a route
- Geofencing: Determine boundary points for circular geofences
- Surveying: Plot survey points from a known reference
- Aviation/Maritime: Calculate flight paths and shipping routes
- Game Development: Position game objects based on direction and distance
Best Practices
- Choose correct units: Ensure your distance unit matches your input data
- Normalize bearings: Convert bearings to 0-360 range before sending
- Consider Earth models: For very precise calculations, consider WGS84 ellipsoid vs. sphere
- Handle edge cases: Test behavior near poles and the antimeridian (180° longitude)
Use via MCP
Your AI agent can call this tool directly via Model Context Protocol — no HTTP code needed. Add TinyFn to Claude Desktop, Cursor, or any MCP client:
{
"mcpServers": {
"tinyfn-geo": {
"url": "https://api.tinyfn.io/mcp/geo/",
"headers": {
"X-API-Key": "your-api-key"
}
}
}
}
See all geolocation tools available via MCP in our Geolocation MCP Tools for AI Agents guide.
Try the Destination Point API
Get your free API key and start calculating destination coordinates in seconds.
Get Free API Key