Describe how you would compute the distance between two points in Python and explain what assumptions you make about the coordinate system.
Write a PostgreSQL query that applies the same reasoning to distance requests. A distance is valid only when both points and coordinates exist, both points use the same known coordinate system, and that system is Euclidean. Rows with missing or incompatible inputs must remain in the output with a status and a NULL distance.
Output
- One row per request, ordered by
request_id ascending.
- Return
request_id, point_a_id, point_b_id, coordinate_system_a, coordinate_system_b, distance_status, and distance.
- Round valid distances to 6 decimal places. Rows with missing coordinates or coordinate systems are included with a NULL distance.