Skip to content

Displacement has lon and lat the wrong way around #913

@jc-harrison

Description

@jc-harrison

Describe the bug
In Displacement._make_query, the SQL string to calculate distance is created as

dist_string = get_dist_string("lat_home_loc", "lon_home_loc", "lat", "lon")

However, the calling signature of get_dist_string (as defined in utils.py) is

get_dist_string(lo1, la1, lo2, la2)

Displacement is passing lat and lon values the wrong way around, so distances will be incorrect.

Product
FlowMachine

Additional context
There is some inconsistency more generally around the ordering of "lat" and "lon" in FlowMachine (e.g. "versioned-site" level has columns ["site_id", "version", "lon", "lat"], but "lat-lon" level has columns ["lat", "lon"]). This is mostly not a problem, since the values are usually in columns referenced by name, but more consistency around this would reduce the chance of these bugs popping up. I'm attempting to make this consistent as part of my spatial unit refactoring, choosing ["lon", "lat"] ordering for consistency with the order required by ST_Point().

Metadata

Metadata

Assignees

No one assigned

    Labels

    FlowMachineIssues related to FlowMachinebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions