Distance between two points
Point-to-point distance uses the great-circle distance on a sphere of radius 6,371 km — the mean radius of the Earth:R = 6371. The result is rounded to
two decimal places and expressed in kilometres.
The argument to arccos is clamped to the interval [−1, 1] before it is evaluated. Floating-point
rounding can push it a fraction beyond either end for two points that are nearly identical or
nearly antipodal, and an unclamped arccos is undefined there. Clamping makes the distance
between a point and itself resolve to exactly zero rather than an error.
This is a straight-line distance over the ground. It does not follow roads, so a road journey is
always at least as long. It is used where a consistent, cheap, symmetric measure is what matters —
ranking candidates, computing an on-demand fare, checking a delivery radius — not for turn-by-turn
estimates.
Distance from a point to an area is a different calculation. A zone boundary is a polygon, and
the distance from a destination to that boundary is measured to the nearest edge of the shape.
That is the distance the door-delivery overage in Pricing is billed on.
Finding the nearest pickup point
A shipment can be routed to a pickup point instead of a door. Given the customer’s coordinates, the platform ranks every active pickup point belonging to an active courier by distance and returns the closest, each annotated with its owndistance_km. The search can be narrowed to a
single courier when the courier has already been chosen.
The ranking is exhaustive rather than clever: distance is computed for every candidate and the
list is sorted. Pickup points number in the tens per city, so the direct comparison is both exact
and immediate — an index that only approximates proximity would add failure modes without saving
measurable time at this size. Delivery stations, which serve the same purpose on the inbound leg,
are ranked identically.

