Navigation Log
POST/api/v1/navlog/bearing-and-distanceCommercial Pilot

Calculate Bearing And Distance

Calculates the great-circle bearing and distance between two geographic points.

Code Examples

curl \
  -X POST \
  -H "Ocp-Apim-Subscription-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "startLatitude": 35.214,
  "startLongitude": -80.9431,
  "endLatitude": 36.1245,
  "endLongitude": -86.6782
}' \
  "https://api.preflightapi.io/api/v1/navlog/bearing-and-distance"

Description

Provide a start and end point as latitude/longitude in decimal degrees. The service computes:

  • True Course — The initial bearing from start to end referenced to True North (0-360 degrees), computed using WGS84 geodesic (great-circle) geometry.
  • Magnetic Course — The true course adjusted for local magnetic variation at the start point. This is the course you would read on a magnetic compass (0-360 degrees).
  • Distance — The great-circle distance between the two points in nautical miles.

This endpoint is useful for quick point-to-point calculations without building a full navigation log. Note that this returns *course* (direction of the route), not *heading* (direction the aircraft nose points). For wind-corrected headings, use the full navigation log endpoint.

Request BodyBearingAndDistanceRequestDto

startLatitudenumber

Starting point latitude in decimal degrees.

startLongitudenumber

Starting point longitude in decimal degrees.

endLatitudenumber

Ending point latitude in decimal degrees.

endLongitudenumber

Ending point longitude in decimal degrees.

Response Schema

200Returns the bearing and distance calculationBearingAndDistanceResponseDto
trueCoursenumber

True course in degrees.

magneticCoursenumber

Magnetic course in degrees (adjusted for magnetic variation).

distancenumber

Great-circle distance in nautical miles.

400The coordinates are invalid (e.g., latitude outside -90 to 90 range)ApiErrorResponse
codestring

Machine-readable error code (e.g., "AIRCRAFT_NOT_FOUND").

messagestring

Human-readable error message suitable for display.

detailsstringnullable

Additional error details (only included in development environment).

servicestringnullable

Name of the external service that failed (only included for 503 errors).

validationErrorsRecord<string, string[]>nullable

Field-level validation errors (only for validation failures).

timestampstring

UTC timestamp when the error occurred.

traceIdstringnullable

Correlation ID for tracing the request.

pathstringnullable

Request path that generated the error.

503The NOAA magnetic variation service is temporarily unavailableApiErrorResponse
codestring

Machine-readable error code (e.g., "AIRCRAFT_NOT_FOUND").

messagestring

Human-readable error message suitable for display.

detailsstringnullable

Additional error details (only included in development environment).

servicestringnullable

Name of the external service that failed (only included for 503 errors).

validationErrorsRecord<string, string[]>nullable

Field-level validation errors (only for validation failures).

timestampstring

UTC timestamp when the error occurred.

traceIdstringnullable

Correlation ID for tracing the request.

pathstringnullable

Request path that generated the error.

Search Documentation

Search docs, endpoints, and schemas