Skip to content

Critical Logic Error: Incorrect Distance Calculation #16

@2403717674422018-hue

Description

@2403717674422018-hue

The Flaw:
The function calculates the distance between coordinates, but the arguments are passed to haversine_distance in the wrong order, causing nonsensical calculations.

Function definition expects: (lat1, lon1, lat2, lon2)

def haversine_distance(lat1, lon1, lat2, lon2): ...

Function call inside create_order:

distance_km = haversine_distance(
order.source_lat,
order.dest_lat, # <--- Should be dest_lon
order.source_lon, # <--- Should be source_lon (if 2nd arg was correct)
order.dest_lon
)

Why it breaks the system:

It is passing Dest Latitude as the second argument where Source Longitude is expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions