Connection
Base URL, credentials and a reachable server.
Review coordinate units with the angular calculation and keep any physical distance conversion in the calling application.
Base URL, credentials and a reachable server.
A model available through the configured endpoint.
Context limits and tool support are determined by the model and server.
from math import asin, cos, isfinite, radians, sin, sqrt
def central_angle(lat1, lon1, lat2, lon2):
values = (lat1, lon1, lat2, lon2)
if any(type(x) not in (int, float) or not -limit <= x <= limit
or not isfinite(x) for x, limit in zip(values, (90, 180, 90, 180))):
raise ValueError("bounded finite coordinates")
p, q = radians(lat1), radians(lat2)
a = sin((q-p)/2)**2 + cos(p)*cos(q)*sin(radians(lon2-lon1)/2)**2
return 2 * asin(sqrt(min(1.0, max(0.0, a))))