deterministic
no-api-key
geo
geodesy
distance

Distance calculator: geodesic distance, bearing and destination point on WGS-84

Distance calculator: distance and direction between WGS-84 coordinates: geodesic distance by Vincenty with a haversine fallback, initial and final bearing, the midpoint, and the destination point reached from a start point on a given bearing and distance. Also computes the cumulative length of a supplied coordinate path. Results in metres, kilometres, nautical miles and miles.

Output (data): op=distance and op=midpoint: distance {m, km, nmi, mi}, bearing_initial, bearing_final (degrees clockwise from north, 4 dp), midpoint {lat, lon} (geodesic midpoint; spherical when method is haversine), method, converged. Vincenty on WGS-84 is used unless method=haversine (R = 6,371,008.8 m); when Vincenty fails to converge (near-antipodal pairs) the response falls back to haversine and reports method:"haversine", converged:false. op=destination: destination {lat, lon} (longitude wrapped to -180..180; Karney's direct algorithm on WGS-84, or spherical with R = 6,371,008.8 m when method=haversine), bearing_final (also for method=haversine, on the sphere), method, converged. op=path: distance {m, km, nmi, mi}, points, legs, method (vincenty, haversine, or vincenty+haversine if any leg fell back), converged. path is a flat comma list lat,lon,lat,lon,... (semicolons or spaces also separate pairs); it needs at least 2 points.

Deterministic: identical input returns identical output, so the response is served with Cache-Control: private, max-age=31536000, immutable (the paying client may cache it indefinitely; shared caches must not, because the response is paid).

Price: $0.05 USDC per call (x402, Base). Route contract version 1.0.0. Docs: https://api.duoleads.com/docs#geo-distance

get/v1/geo/distance

Request

  • Base URL: https://api.duoleads.com
  • URL: https://api.duoleads.com/v1/geo/distance
  • Auth: none declared

Query parameters

op'distance' | 'destination' | 'midpoint' | 'path'

distance (default), destination, midpoint or path. Accepted: distance, destination, midpoint, path.

lat1number

Start latitude. Accepted: a number between -90 and 90.

lon1number

Start longitude. Accepted: a number between -180 and 180.

lat2number

End latitude. Accepted: a number between -90 and 90.

lon2number

End longitude. Accepted: a number between -180 and 180.

bearingnumber

Initial bearing in degrees for op=destination. Accepted: number 0-360.

distance_mnumber

Distance in metres for op=destination, 0 to 1e9 (about 25 Earth circumferences); larger values are 400 INVALID_PARAM. Accepted: a number between 0 and 1e9 (metres).

pathstring

Comma-separated lat,lon pairs for op=path, at most 200 points. Accepted: comma-separated lat,lon pairs, at most 200 points.

method'vincenty' | 'haversine'

vincenty (default, WGS-84) or haversine. Accepted: vincenty, haversine.

Response

Paid and settled. data is route-specific; a route that judges its input returns 200 with data.valid: false for a bad value.

okunknown required
route'/v1/geo/distance' required
version'1.0.0' required

Changes

No recorded changes to this operation across all 1 revision of this API.